Skip to content

Papermark is the open-source DocSend alternative and secure data rooms with built-in analytics and custom domains.

feat: add user to segment

Marc Seitzd9fd74598fa5
diff --git a/lib/resend.ts b/lib/resend.ts
index 6201d4a6..a69887fb 100644
--- a/lib/resend.ts
+++ b/lib/resend.ts
@@ -110,6 +110,16 @@ export const subscribe = async (email: string): Promise<void> => {
console.error("Failed to create contact:", error);
return;
}
+
+ if (
+ process.env.NODE_ENV === "production" &&
+ process.env.RESEND_MARKETING_SEGMENT_ID
+ ) {
+ await resend.contacts.segments.add({
+ contactId: data.id,
+ segmentId: process.env.RESEND_MARKETING_SEGMENT_ID as string,
+ });
+ }
};
export const unsubscribe = async (email: string): Promise<void> => {