Skip to content

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

Merged
apsantiso merged 5 commits intomasterfrom
feat/tracking-service-for-send
Apr 2, 2026
Merged

[MKT-737]:feat/integrate Klaviyo subscription when creating Send links#945
apsantiso merged 5 commits intomasterfrom
feat/tracking-service-for-send

Conversation

@jaaaaavier
Copy link
Copy Markdown
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
Comment thread src/modules/send/send.usecase.spec.ts Fixed
@jaaaaavier jaaaaavier marked this pull request as ready for review February 25, 2026 12:25
@github-actions
Copy link
Copy Markdown

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 thread src/externals/newsletter/index.spec.ts Outdated
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
Copy Markdown
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

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Updated

@apsantiso
Copy link
Copy Markdown
Collaborator

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

sg-gs
sg-gs previously approved these changes Mar 26, 2026
@sg-gs
Copy link
Copy Markdown
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
Copy Markdown
Member

sg-gs commented Mar 26, 2026

Environment variable set in production @jaaaaavier

apsantiso
apsantiso previously approved these changes Mar 30, 2026
@sonarqubecloud
Copy link
Copy Markdown

sonarqubecloud Bot commented Apr 1, 2026

@jaaaaavier
Copy link
Copy Markdown
Contributor Author

@apsantiso made a new push to remove the sonarcloud issue

@jaaaaavier jaaaaavier requested a review from apsantiso April 1, 2026 08:19
@apsantiso apsantiso merged commit 7f37d7b into master Apr 2, 2026
13 checks passed
@apsantiso apsantiso deleted the feat/tracking-service-for-send branch April 2, 2026 15:51
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.

4 participants