fix: Do not unsubscribe existing contacts

This commit is contained in:
Dries Augustyns
2026-02-20 16:58:17 +01:00
parent 64bd094b47
commit 2c4d95e604
2 changed files with 8 additions and 4 deletions
+6 -3
View File
@@ -72,12 +72,13 @@ export class Actions {
// Create or update contact with persistent data only
// ContactService.upsert will filter out non-persistent fields
// Event tracking should subscribe contacts by default
// Event tracking should subscribe new contacts by default (subscribed=true in ContactService)
// but preserve existing subscription state for existing contacts
const contact = await ContactService.upsert(
auth.projectId,
email,
data as Record<string, unknown> | undefined,
subscribed ?? true,
subscribed,
);
// Track the event with ALL data (persistent + non-persistent)
@@ -268,7 +269,9 @@ export class Actions {
// Create or update contact with metadata
// Transactional emails should not subscribe contacts by default
const contact = await ContactService.upsert(auth.projectId, recipient.email, recipientData, subscribed ?? false);
// New contacts default to unsubscribed unless explicitly opted in
// Existing contacts preserve their subscription state unless explicitly changed
const contact = await ContactService.upsert(auth.projectId, recipient.email, recipientData, subscribed, false);
// Get merged data including non-persistent fields for template rendering
const mergedData = ContactService.getMergedData(contact, data as Record<string, unknown> | undefined);