Skip to content

Commit 3e8abac

Browse files
committed
sync
1 parent 65e99fc commit 3e8abac

File tree

1 file changed

+3
-18
lines changed

1 file changed

+3
-18
lines changed

packages/console/app/src/routes/api/enterprise.ts

Lines changed: 3 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -27,22 +27,7 @@ function splitFullName(fullName: string) {
2727
return { firstName: parts[0], lastName: parts.slice(1).join(" ") }
2828
}
2929

30-
function getEmailOctopusApiKey() {
31-
if (process.env.EMAILOCTOPUS_API_KEY) return process.env.EMAILOCTOPUS_API_KEY
32-
try {
33-
return Resource.EMAILOCTOPUS_API_KEY.value
34-
} catch {
35-
return
36-
}
37-
}
38-
3930
function subscribe(email: string, fullName: string) {
40-
const apiKey = getEmailOctopusApiKey()
41-
if (!apiKey) {
42-
console.warn("Skipping EmailOctopus subscribe: missing API key")
43-
return Promise.resolve(false)
44-
}
45-
4631
const name = splitFullName(fullName)
4732
const fields: Record<string, string> = {}
4833
if (name.firstName) fields.FirstName = name.firstName
@@ -54,14 +39,14 @@ function subscribe(email: string, fullName: string) {
5439
return fetch(`https://api.emailoctopus.com/lists/${EMAIL_OCTOPUS_LIST_ID}/contacts`, {
5540
method: "PUT",
5641
headers: {
57-
Authorization: `Bearer ${apiKey}`,
42+
Authorization: `Bearer ${Resource.EMAILOCTOPUS_API_KEY.value}`,
5843
"Content-Type": "application/json",
5944
},
6045
body: JSON.stringify(payload),
6146
}).then(
62-
(res) => {
47+
async (res) => {
6348
if (!res.ok) {
64-
console.error("EmailOctopus subscribe failed:", res.status, res.statusText)
49+
console.error("EmailOctopus subscribe failed:", res.status, res.statusText, await res.text())
6550
return false
6651
}
6752
return true

0 commit comments

Comments
 (0)