[MKT-737]:feat/integrate Klaviyo subscription when creating Send links#945
Merged
[MKT-737]:feat/integrate Klaviyo subscription when creating Send links#945
Conversation
|
This PR is stale because it has been open for more than 15 days with no activity. |
apsantiso
reviewed
Mar 26, 2026
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), | ||
| ); |
Collaborator
There was a problem hiding this comment.
Use the format it(When... then....) so this is aligned with the other spec files please
Collaborator
|
@jaaaaavier added @sg-gs as this seems to require env variables |
sg-gs
previously approved these changes
Mar 26, 2026
Member
|
No need to add me as a reviewer @apsantiso, just ping me via comment as you did haha |
Member
|
Environment variable set in production @jaaaaavier |
apsantiso
previously approved these changes
Mar 30, 2026
|
Contributor
Author
|
@apsantiso made a new push to remove the sonarcloud issue |
apsantiso
approved these changes
Apr 2, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.



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.