Skip to content

[-]:fix/postback sevice cookie delete - #2345

Merged
internxt-yu merged 6 commits into
masterfrom
fix/postback-services
Nov 20, 2026
Merged

internxt-yu merged 6 commits into
masterfrom
fix/postback-services

Conversation

@jaaaaavier

@jaaaaavier jaaaaavier commented Nov 19, 2026 •

Copy link
Copy Markdown
Contributor

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

  • 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:

  1. 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.
  2. 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:

  1. The price_1RQYb8FAOdcgaBMQZuRVPT4F is sending 180 in value of CPA.

  2. 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.

  3. 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.

@jaaaaavier jaaaaavier self-assigned this Nov 19, 2026
@coderabbitai

coderabbitai Bot commented Nov 19, 2026 •

Copy link
Copy Markdown

Explain Change →

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.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Change: Bug fix

Sequence Diagram(s)

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: Passed 4

Check name Status Explanation
Title check Passed 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 Passed 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 Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed 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.

Share

Recent review info

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • 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.

@cloudflare-workers-and-pages

cloudflare-workers-and-pages Bot commented Nov 20, 2026 •

Copy link
Copy Markdown

Deploying drive-web with  Cloudflare Pages  Cloudflare Pages

Latest commit: a7c636f
Status: ✅  Deploy successful!
Preview URL: https://e3ed01bb.drive-web.pages.dev
Branch Preview URL: https://fix-postback-services.drive-web.pages.dev

View logs

@internxt-yu internxt-yu self-assigned this Nov 20, 2026
@internxt-yu internxt-yu added the bug Something isn't working label Nov 20, 2026
@internxt-yu
internxt-yu marked this pull request as ready for review November 20, 2026 13:09
@internxt-yu
internxt-yu requested a review from a team as a code owner November 20, 2026 13:09
@sonarqubecloud

Copy link
Copy Markdown

@internxt-yu
internxt-yu merged commit e360f41 into master Nov 20, 2026
12 checks passed
@internxt-yu
internxt-yu deleted the fix/postback-services branch November 20, 2026 13:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants