Skip to content

feat: Pass $NoTargeting as User Attribute value when passed to launch…#1247

Open
rmi22186 wants to merge 12 commits intodevelopmentfrom
feat/set-notargeting-user-attribute
Open

feat: Pass $NoTargeting as User Attribute value when passed to launch…#1247
rmi22186 wants to merge 12 commits intodevelopmentfrom
feat/set-notargeting-user-attribute

Conversation

@rmi22186
Copy link
Copy Markdown
Member

Background

This feature enables customers who elect noTargeting to be filtered out of audiences for retargeting. Server expects this to now be set as a value for the user attribute as $NoTargeting with a boolean true.

What Has Changed

Add setUserAttribute in parseIdentityResponse.

Screenshots/Video

image

Checklist

  • I have performed a self-review of my own code.
  • I have made corresponding changes to the documentation.
  • I have added tests that prove my fix is effective or that my feature works.
  • I have tested this locally.

@rmi22186 rmi22186 requested a review from a team as a code owner April 10, 2026 20:39
@cursor
Copy link
Copy Markdown

cursor bot commented Apr 10, 2026

PR Summary

Medium Risk
Touches identity/init sequencing and user-attribute persistence, which can affect event batching/queue draining and what user data is sent. Behavior is gated by launcherOptions.noTargeting and is covered by unit/integration tests.

Overview
Propagates the launcherOptions.noTargeting privacy flag into a persisted user attribute ($NoTargeting: true) so it is included on event/batch payloads and can be used for audience exclusion.

Adds CookieConsentManager.syncNoTargetingAttribute() (set/remove) and calls it during identity response parsing (before UIC events drain the queue) and during init/re-init paths where no identity call occurs. Updates tests to cover attribute set/remove behavior and verifies the attribute appears in uploaded and sendBeacon batches.

Reviewed by Cursor Bugbot for commit 11611dc. Bugbot is set up for automated code reviews on this repo. Configure here.

Comment thread src/identity.js Outdated
Comment thread src/identity.js Outdated
rmi22186 and others added 3 commits April 13, 2026 13:24
…becomes false

Extract $NoTargeting string to NO_TARGETING_ATTRIBUTE constant. Add removal
logic in both identity response and re-init paths so the attribute doesn't
persist when noTargeting is no longer true.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Copy link
Copy Markdown

@cursor cursor bot left a comment

Choose a reason for hiding this comment

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

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, have a team admin enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit e316717. Configure here.

Comment thread src/identity.js Outdated
rmi22186 and others added 2 commits April 14, 2026 10:20
Move duplicated set/remove logic from identity.js and mp-instance.ts
into syncNoTargetingAttribute() on CookieConsentManager. Add unit tests.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@rmi22186 rmi22186 requested a review from mattbodle April 14, 2026 15:02
rmi22186 and others added 4 commits April 14, 2026 11:08
Move syncNoTargetingAttribute call above processReadyQueue in identity.js.
Add test verifying session_start batch includes $NoTargeting in user_attributes.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Address SonarCloud preference for avoiding direct window references.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
…sponse

Move syncNoTargetingAttribute call before processQueuedEvents so that
events queued before the identity response (e.g. session_start) pick up
the $NoTargeting user attribute via appendUserInfo.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
…vent race

Move syncNoTargetingAttribute inside the HTTP_OK block before
sendUserIdentityChangeEvent. UIC events call sendEventToServer which
triggers processQueuedEvents, draining the event queue before
$NoTargeting was set — causing flaky test failures depending on
whether prior tests left identity state that produced UIC events.

Also update the test to verify $NoTargeting on a post-init event
batch instead of the session_start batch, avoiding async upload
timing issues from test pollution.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Copy link
Copy Markdown
Contributor

@khushi1033 khushi1033 left a comment

Choose a reason for hiding this comment

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

LGTM!

Add test verifying $NoTargeting is included in beacon batch
user_attributes when user leaves the page. Uses triggerVisibilityHidden
with a resetHistory flush to clear stale beacon calls from prior tests'
BatchUploader instances whose event listeners persist across resets.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Comment thread src/constants.ts
@sonarqubecloud
Copy link
Copy Markdown

Quality Gate Failed Quality Gate failed

Failed conditions
19.7% Duplication on New Code (required ≤ 3%)

See analysis details on SonarQube Cloud

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants