Add Compare with Resend panel to Subscribers; stop resubscribing opted-out contacts; v2.6.1
Publish Container / build (push) Successful in 16m27s
Publish Container / build (push) Successful in 16m27s
- Subscribers: compare in-app list with Resend audience/segment, with one-click fixes - syncContactToResend no longer resets unsubscribed on existing contacts Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
e74bd1df5d
commit
af967d0049
5 files changed
+273
-6
No files matched your search
+10
-5
@@ -89,17 +89,22 @@ export async function syncContactToResend(name, email) {
|
||||
const { firstName, lastName } = splitName(name)
|
||||
const contactResend = new Resend(process.env.RESEND_CONTACTS_API_KEY ?? process.env.RESEND_API_KEY)
|
||||
try {
|
||||
const { error: contactError } = await contactResend.contacts.create({
|
||||
// Never touch `unsubscribed` for a contact that already exists — otherwise a form submission
|
||||
// would silently resubscribe someone who opted out in Resend.
|
||||
const { data: existing } = await contactResend.contacts.get({ email })
|
||||
if (existing) {
|
||||
const { error: updateError } = await contactResend.contacts.update({ email, firstName, lastName })
|
||||
if (updateError) console.error('[resend] contact sync error:', updateError)
|
||||
return
|
||||
}
|
||||
const { error: createError } = await contactResend.contacts.create({
|
||||
email,
|
||||
firstName,
|
||||
lastName,
|
||||
unsubscribed: false,
|
||||
...(process.env.RESEND_SEGMENT_ID ? { segments: [{ id: process.env.RESEND_SEGMENT_ID }] } : {}),
|
||||
})
|
||||
if (contactError) {
|
||||
const { error: updateError } = await contactResend.contacts.update({ email, firstName, lastName, unsubscribed: false })
|
||||
if (updateError) console.error('[resend] contact sync error:', updateError)
|
||||
}
|
||||
if (createError) console.error('[resend] contact sync error:', createError)
|
||||
} catch (err) {
|
||||
console.error('[resend] contact sync exception:', err)
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user