You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
We were storing the partnerPostback cookie for 30 days and we do not erase it when a user purchase, when user is purchasing with another link and with another account, since the cookie is not erased, it will send again to the same affiliate, and this caused several sales to be attributed to who weren't actually involved. We've now deleted the cookie and added the check for the coupon so this won't happen again.
And updated the list of CPAs for the plans that the affiliate push the traffic.
Related Issues
Related Pull Requests
Checklist
Changes have been tested locally.
Unit tests have been written or updated as necessary.
The code adheres to the repository's coding standards.
Relevant documentation has been added or updated.
No new warnings or errors have been introduced.
SonarCloud issues have been reviewed and addressed.
QA Passed
Testing Process
the testing process was done in local environment with the following changes:
partnerPostback.service.ts: Added test mode price_id price_1RQYb8FAOdcgaBMQZuRVPT4F: 180 and price_1UH2G1FAOdcgaBMQNNUWbiJF: 80 in the CPA_AMOUNT_BY_PLAN list. Commented the fetch call and added the console.log to show the event sent or not, because the fetch is already working and the affiliate is counting all the registers.
analytics.service.ts: Added await sendPurchasePostback(); in line 56, in the if (!envService.isProduction()) condition. So it sends the event in development environment.
TFAChanged.webm
In the video:
The price_1RQYb8FAOdcgaBMQZuRVPT4F is sending 180 in value of CPA.
The price_1UH2G1FAOdcgaBMQNNUWbiJF is sending 80 in value of CPA.
The CPA are corresponding to the value set in the list, and when the send the event it clears the cookie of TFA.
Enter with the TFA link, leaves the cookie and enter other page to purchase, in this case MAXOFFER, and we see without the TFA coupon the partnerPostback is not sent.
Additional Notes
Summary by CodeRabbit
Bug Fixes
Coupon codes from previous purchases are no longer retained when a new purchase has no discount code.
Collaborator purchase postbacks are sent only when the purchase coupon matches the partner’s configured coupon, regardless of letter case.
Attribution cookies are cleared after a partner purchase is processed or an eligible partner’s postback cannot be completed. They remain unchanged when no partner attribution is present.
Added support for additional campaign plans and their associated CPA amounts.
No actionable comments were generated in the recent review.
Walkthrough
The change stores or removes purchase coupon codes, gates partner postbacks on a matching coupon, adds plan-to-CPA mappings, and clears attribution cookies after partner processing. Tests cover coupon handling, postback eligibility, cookie cleanup, and Impact tracking.
Changes: Purchase Attribution
Layer / File(s)
Summary
Store purchase coupon codes src/app/analytics/impact.service.ts, src/app/analytics/impact.service.test.ts
When no coupon code name is provided, payment data removes the stored coupon code. Tests cover cases with and without coupon data.
Gate partner postbacks and clear attribution cookies src/app/analytics/partnerPostback.service.ts, src/app/analytics/partnerPostback.service.test.ts, src/app/analytics/analytics.service.test.ts
The S42MF2 partner uses coupon TFA, and postbacks require a case-insensitive coupon match. Six plan IDs gain CPA amounts. Partner and click-ID cookies are cleared after processing. Tests cover postback eligibility, cleanup, plan amounts, and Impact tracking.
sequenceDiagram
participant sendPurchasePostback
participant localStorage
participant PostbackEndpoint
participant AttributionCookies
sendPurchasePostback->>localStorage: Read stored coupon code
alt Coupon matches partner coupon
sendPurchasePostback->>PostbackEndpoint: Send purchase postback
else Coupon does not match
sendPurchasePostback-->>sendPurchasePostback: Skip postback
end
sendPurchasePostback->>AttributionCookies: Expire partner and click-ID cookies
Loading
Suggested reviewers:internxt-yu, xabg2
Merge Risk: Minimal · up to a7c63
Partner postbacks are now sent only when the purchase used the partner's coupon, and the attribution cookies are cleared after processing. No concrete defect was found. A very unlikely edge case where a new referral could overlap an in-flight postback remains unconfirmed and does not block the merge.
Pre-merge checks: 4
Check name
Status
Explanation
Title check
The title "[-]:fix/postback sevice cookie delete" names the main change: deleting the postback cookie after a purchase. It has a non-standard "[-]:" prefix and a typo ("sevice"), and it omits the coup…
Description check
The description explains the problem (partnerPostback cookie kept for 30 days and not erased after purchase, causing misattributed sales), the fix (cookie deletion and coupon check), and the CPA list …
Linked Issues check
Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check
Check skipped because no linked issues were found for this pull request.
Full details: Title check
Explanation
The title "[-]:fix/postback sevice cookie delete" names the main change: deleting the postback cookie after a purchase. It has a non-standard "[-]:" prefix and a typo ("sevice"), and it omits the coupon check and CPA update. The core intent is still clear, so the title is partially related but not polished.
Full details: Description check
Explanation
The description explains the problem (partnerPostback cookie kept for 30 days and not erased after purchase, causing misattributed sales), the fix (cookie deletion and coupon check), and the CPA list update. It includes a testing process and a video. However, the template's Related Issues and Related Pull Requests sections are left as placeholder comments, and the Additional Notes section is empty. The testing section also describes temporary local-only changes (commented-out fetch, dev-only send call, and a list entry numbering that skips step 2) without saying whether those are reverted before merge.
Resolution
Add a related issue or state that none exists. Fill in or remove the Related Pull Requests placeholder. Confirm that the temporary development changes (commented-out fetch, console.log, dev-only sendPurchasePostback call) are reverted before merge. Correct the step numbering in the testing process. Complete the Additional Notes section if there are reviewer-relevant impacts.
Finishing Touches
Generate unit tests (beta)
Commit to this branch
Create a new PR
Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.
File: No configuration file from this repository applied
Commit: Unavailable
Layers: defaults
Review profile: CHILL
Plan: Advanced
Run ID: 5ed0b753-0a41-40a6-8ecb-f80e7991b94a
Commits
Reviewing files that changed from the base of the PR and between 983d4fd and a7c636f.
Files selected for processing: 5
src/app/analytics/analytics.service.test.ts
src/app/analytics/impact.service.test.ts
src/app/analytics/impact.service.ts
src/app/analytics/partnerPostback.service.test.ts
src/app/analytics/partnerPostback.service.ts
Included review availability: This review used your included allowance. Your plan provides up to 2 included reviews per hour; 1 remain after this review.
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
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.
Description
We were storing the partnerPostback cookie for 30 days and we do not erase it when a user purchase, when user is purchasing with another link and with another account, since the cookie is not erased, it will send again to the same affiliate, and this caused several sales to be attributed to who weren't actually involved. We've now deleted the cookie and added the check for the coupon so this won't happen again.
And updated the list of CPAs for the plans that the affiliate push the traffic.
Related Issues
Related Pull Requests
Checklist
Testing Process
the testing process was done in local environment with the following changes:
TFAChanged.webm
In the video:
The price_1RQYb8FAOdcgaBMQZuRVPT4F is sending 180 in value of CPA.
The price_1UH2G1FAOdcgaBMQNNUWbiJF is sending 80 in value of CPA.
The CPA are corresponding to the value set in the list, and when the send the event it clears the cookie of TFA.
Enter with the TFA link, leaves the cookie and enter other page to purchase, in this case MAXOFFER, and we see without the TFA coupon the partnerPostback is not sent.
Additional Notes
Summary by CodeRabbit