Skip to content

[MKT-737]:feat/integrate Klaviyo subscription when creating Send links#945

Open
jaaaaavier wants to merge 3 commits intomasterfrom
feat/tracking-service-for-send
Open

[MKT-737]:feat/integrate Klaviyo subscription when creating Send links#945
jaaaaavier wants to merge 3 commits intomasterfrom
feat/tracking-service-for-send

Conversation

@jaaaaavier
Copy link
Contributor

This PR introduces the integration with Klaviyo for the Send feature. It ensures that whenever a user creates a Send link, the sender's email is automatically subscribed to a specific Klaviyo list.

Key Changes:

  • NewsletterService: Modified the subscribe method to accept an optional listId parameter, making it reusable to subscribe users to different Klaviyo lists using the newly assigned resolvedListId.

  • Configuration updates: Added klaviyo.sendListId to the configuration, retrieving the list ID dynamically from the .env
    (using the variable KLAVIYO_SEND_LIST_ID).

  • SendUseCases tracking integration: Integrated the NewsletterService into the createSendLinks use case. The subscription call is executed as a fire-and-forget background task (with .catch), ensuring it does not block the link creation process or affect performance if Klaviyo is unreachable.

@jaaaaavier jaaaaavier self-assigned this Feb 25, 2026
@jaaaaavier jaaaaavier added the enhancement New feature or request label Feb 25, 2026
@sonarqubecloud
Copy link

sonarqubecloud bot commented Feb 25, 2026

@jaaaaavier jaaaaavier marked this pull request as ready for review February 25, 2026 12:25
@github-actions
Copy link

This PR is stale because it has been open for more than 15 days with no activity.

@jaaaaavier jaaaaavier requested review from apsantiso and jzunigax2 and removed request for apsantiso and jzunigax2 March 24, 2026 09:36
@apsantiso apsantiso requested a review from sg-gs March 26, 2026 10:45
Comment on lines +79 to +101
it('should subscribe user using provided listId', async () => {
const email = 'test@example.com';
const providedListId = 'providedListId';
jest.spyOn(httpClient, 'post').mockResolvedValueOnce({
data: { data: { id: 'prof_123' } },
} as any);
jest.spyOn(httpClient, 'post').mockResolvedValueOnce({} as any);

await service.subscribe(email, providedListId);

expect(httpClient.post).toHaveBeenNthCalledWith(
1,
'https://a.klaviyo.com/api/profiles/',
expect.any(Object),
expect.any(Object),
);

expect(httpClient.post).toHaveBeenNthCalledWith(
2,
'https://a.klaviyo.com/api/lists/providedListId/relationships/profiles/',
{ data: [{ type: 'profile', id: 'prof_123' }] },
expect.any(Object),
);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use the format it(When... then....) so this is aligned with the other spec files please

@apsantiso
Copy link
Collaborator

@jaaaaavier added @sg-gs as this seems to require env variables

@sg-gs
Copy link
Member

sg-gs commented Mar 26, 2026

No need to add me as a reviewer @apsantiso, just ping me via comment as you did haha

@sg-gs
Copy link
Member

sg-gs commented Mar 26, 2026

Environment variable set in production @jaaaaavier

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request ready-for-preview

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants