Skip to content

fix: honor OpenAI Ads device-mode hash config - #3295

Merged
ItsSudip merged 5 commits into
developfrom
harness/INT-7435-fix-honor-openai-ads-device-mod-d7121d3d
Oct 26, 2026
Merged

ItsSudip merged 5 commits into
developfrom
harness/INT-7435-fix-honor-openai-ads-device-mod-d7121d3d

Conversation

@rudder-devbox

@rudder-devbox rudder-devbox Bot commented Oct 23, 2026 •

Copy link
Copy Markdown
Contributor

PR Description

Honor isHashRequired in the OpenAI Ads Measurement Pixel integration while keeping hashing enabled by default. When hashing is disabled, only SHA-256-looking customer identifiers are accepted and forwarded lowercase; plaintext identifiers are logged and dropped. Anonymous ID fallbacks continue to be hashed when non-hex and passed through lowercase when already hashed.

Coverage includes restored-user seeding, identify calls, default and explicit modes, uppercase hashes, plaintext rejection, anonymous ID behavior, real user ID gating, absent identifiers, and unchanged location fields.

Linear task (optional)

INT-7435

Cross Browser Tests

  • Chrome
  • Firefox
  • IE11

Sanity Suite

  • All sanity suite test cases pass locally

Security

  • The code changed/added as part of this pull request won't create any security issues with how the software is being used.

The strict SHA-256 gate remains active in hashing-disabled mode, preventing plaintext PII from being sent to the third-party pixel.

Security dependency refresh

The package-lock.json update raises follow-redirects from 1.16.0 to 1.16.1 because GHSA-q3jh-wrc6-jgq8 and GHSA-8r9p-f939-6h3c (high severity, published 2026-10-20) affect versions >= 1.16.0, < 1.16.1. Without this refresh, npm audit --audit-level=high --omit=dev fails the Security checks job for every PR based on develop.

This is a lockfile-only patch update within [email protected]'s existing ^1.16.0 range; package.json is unchanged. The nested Nx copy remains at 1.15.11, is dev-only, and is outside the affected range.

Dependabot group PR #3290 also carries this refresh, so whichever PR merges second will need its lockfile regenerated against the updated base.

Validation

  • Targeted OpenAI Ads Jest suite: 49 tests passed locally.
  • Targeted ESLint, JavaScript syntax checks, and git diff --check: passed locally.
  • CI Unit Tests and Lint: passed.
  • CI Bundle size checks: passed.
  • CI Security checks: passed.

Copilot AI balanced review requested due to automatic review settings October 23, 2026 09:45
@rudder-devbox

rudder-devbox Bot commented Oct 23, 2026

Copy link
Copy Markdown
Contributor Author

👋 I'm rudder-devbox. I opened this PR from a Linear ticket.

Mention @devbox or @rudder-devbox and I'll act on it — on a top-level PR comment,
in a review summary, or on an inline comment on the diff. Without a mention I won't see it.

@coderabbitai

coderabbitai Bot commented Oct 23, 2026 •

Copy link
Copy Markdown
Contributor

Important

Review skipped

Bot user detected.

To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration
  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Repository UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: cc9b6f1a-d4cc-449b-bd43-ec42213c3a22

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
  • 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

Comment @coderabbitai help to get the list of available commands.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🔵 Needs a closer look

Static review found no blocking defects, but privacy-sensitive identifier changes still need regression-test execution with the required toolchain.

No open issues 🎉

What changed in this PR

This PR makes the OpenAI Ads device-mode integration honor isHashRequired while keeping hashing enabled by default.

Changes:

  • Applies the hashing configuration to restored-user initialization and identify calls.
  • Accepts only SHA-256-shaped customer identifiers when hashing is disabled, lowercases accepted hashes, and preserves anonymous-ID fallback handling.
  • Adds regression coverage and documents the hashing behavior.
File Description
packages/​analytics-js-integrations/​src/​integrations/​OpenAIAds/​utils.js Implements configurable hashing and anonymous-ID handling.
packages/​analytics-js-integrations/​src/​integrations/​OpenAIAds/​constants.js Adds a rejection message for unhashed identifiers.
packages/​analytics-js-integrations/​src/​integrations/​OpenAIAds/​browser.js Passes hashing configuration into user-data processing.
packages/​analytics-js-integrations/​__tests__/​integrations/​OpenAIAds/​browser.test.js Covers hashing modes, identifier validation, and restored users.
.agents/​knowledge/​patterns.md Documents the identifier hashing rules.

Review effort: Balanced

@github-actions

github-actions Bot commented Oct 23, 2026 •

Copy link
Copy Markdown

size-limit report 📦

Name Size Delta Limit check
Common - No bundling 5.8 KB 0 B (0% 🟢) 6.5 KB (✅)
Legacy Utils - No bundling 11.16 KB 0 B (0% 🟢) 12.5 KB (✅)
Cookies Utils - Legacy - NPM (ESM) 1.54 KB 0 B (0% 🟢) 2 KB (✅)
Cookies Utils - Legacy - NPM (CJS) 1.74 KB 0 B (0% 🟢) 2 KB (✅)
Cookies Utils - Legacy - NPM (UMD) 1.52 KB 0 B (0% 🟢) 2 KB (✅)
Cookies Utils - Modern - NPM (ESM) 1.16 KB 0 B (0% 🟢) 1.5 KB (✅)
Cookies Utils - Modern - NPM (CJS) 1.39 KB 0 B (0% 🟢) 2 KB (✅)
Cookies Utils - Modern - NPM (UMD) 1.15 KB 0 B (0% 🟢) 1.5 KB (✅)
Plugins Module Federation Mapping - Legacy - CDN 330 B 0 B (0% 🟢) 512 B (✅)
Plugins Module Federation Mapping - Modern - CDN 330 B 0 B (0% 🟢) 512 B (✅)
Plugins - Legacy - CDN 13.86 KB 0 B (0% 🟢) 15.5 KB (✅)
Plugins - Modern - CDN 5.76 KB 0 B (0% 🟢) 6.5 KB (✅)
Core (v1.1) - NPM (ESM) 29.78 KB 0 B (0% 🟢) 33 KB (✅)
Core (v1.1) - NPM (CJS) 29.99 KB 0 B (0% 🟢) 33.5 KB (✅)
Core (v1.1) - NPM (UMD) 29.82 KB 0 B (0% 🟢) 33 KB (✅)
Core (Content Script - v1.1) - NPM (ESM) 29.39 KB 0 B (0% 🟢) 32.5 KB (✅)
Core (Content Script - v1.1) - NPM (CJS) 29.54 KB 0 B (0% 🟢) 32.5 KB (✅)
Core (Content Script - v1.1) - NPM (UMD) 29.4 KB 0 B (0% 🟢) 32.5 KB (✅)
Core (v1.1) - Legacy - CDN 31.26 KB 0 B (0% 🟢) 34.5 KB (✅)
Core (v1.1) - Modern - CDN 29.73 KB 0 B (0% 🟢) 33 KB (✅)
Service Worker - Legacy - NPM (ESM) 34.14 KB 0 B (0% 🟢) 38 KB (✅)
Service Worker - Legacy - NPM (CJS) 34.3 KB 0 B (0% 🟢) 38 KB (✅)
Service Worker - Legacy - NPM (UMD) 34.15 KB 0 B (0% 🟢) 38 KB (✅)
Service Worker - Modern - NPM (ESM) 29.96 KB 0 B (0% 🟢) 33 KB (✅)
Service Worker - Modern - NPM (CJS) 30.13 KB 0 B (0% 🟢) 33.5 KB (✅)
Service Worker - Modern - NPM (UMD) 29.96 KB 0 B (0% 🟢) 33 KB (✅)
All Integrations - Legacy - CDN 101.47 KB 163 B (+0.16% 🔺) 111 KB (✅)
All Integrations - Modern - CDN 93.81 KB 16 B (+0.02% 🔺) 102.5 KB (✅)
SDK Loader 876 B 0 B (0% 🟢) 1 KB (✅)
SDK Loader (GTM) 829 B 0 B (0% 🟢) 1 KB (✅)
Core - Legacy - NPM (ESM) 50.36 KB 0 B (0% 🟢) 55 KB (✅)
Core - Legacy - NPM (CJS) 50.57 KB 0 B (0% 🟢) 55.5 KB (✅)
Core - Legacy - NPM (UMD) 50.46 KB 0 B (0% 🟢) 55 KB (✅)
Core - Legacy - CDN 50.46 KB 0 B (0% 🟢) 55 KB (✅)
Core - Modern - NPM (ESM) 30.22 KB 0 B (0% 🟢) 32 KB (✅)
Core - Modern - NPM (CJS) 30.38 KB 0 B (0% 🟢) 32 KB (✅)
Core - Modern - NPM (UMD) 30.25 KB 0 B (0% 🟢) 32 KB (✅)
Core - Modern - CDN 29.05 KB 0 B (0% 🟢) 32.5 KB (✅)
Core (Bundled) - Legacy - NPM (ESM) 50.42 KB 0 B (0% 🟢) 55 KB (✅)
Core (Bundled) - Legacy - NPM (CJS) 50.59 KB 0 B (0% 🟢) 55.5 KB (✅)
Core (Bundled) - Legacy - NPM (UMD) 50.43 KB 0 B (0% 🟢) 55 KB (✅)
Core (Bundled) - Modern - NPM (ESM) 44.18 KB 0 B (0% 🟢) 46.5 KB (✅)
Core (Bundled) - Modern - NPM (CJS) 44.38 KB 0 B (0% 🟢) 47 KB (✅)
Core (Bundled) - Modern - NPM (UMD) 44.2 KB 0 B (0% 🟢) 46.5 KB (✅)
Core (Content Script) - Legacy - NPM (ESM) 50.34 KB 0 B (0% 🟢) 55 KB (✅)
Core (Content Script) - Legacy - NPM (CJS) 50.49 KB 0 B (0% 🟢) 55.5 KB (✅)
Core (Content Script) - Legacy - NPM (UMD) 50.35 KB 0 B (0% 🟢) 55 KB (✅)
Core (Content Script) - Modern - NPM (ESM) 44.2 KB 0 B (0% 🟢) 46.5 KB (✅)
Core (Content Script) - Modern - NPM (CJS) 44.39 KB 0 B (0% 🟢) 47 KB (✅)
Core (Content Script) - Modern - NPM (UMD) 44.24 KB 0 B (0% 🟢) 46.5 KB (✅)
Core (Lite) - Legacy - NPM (ESM) 39.1 KB 0 B (0% 🟢) 42.5 KB (✅)
Core (Lite) - Legacy - NPM (CJS) 39.26 KB 0 B (0% 🟢) 43 KB (✅)
Core (Lite) - Legacy - NPM (UMD) 39.12 KB 0 B (0% 🟢) 42.5 KB (✅)
Core (Lite) - Modern - NPM (ESM) 35.39 KB 0 B (0% 🟢) 37.5 KB (✅)
Core (Lite) - Modern - NPM (CJS) 35.64 KB 0 B (0% 🟢) 37.5 KB (✅)
Core (Lite) - Modern - NPM (UMD) 35.47 KB 0 B (0% 🟢) 37.5 KB (✅)

Copilot AI balanced review requested due to automatic review settings October 23, 2026 09:58
@rudder-devbox

rudder-devbox Bot commented Oct 23, 2026

Copy link
Copy Markdown
Contributor Author

The Security checks job failed because npm audit --audit-level=high --omit=dev found [email protected] vulnerable to GHSA-q3jh-wrc6-jgq8 and GHSA-8r9p-f939-6h3c, reporting one high-severity vulnerability and exiting with code 1.

I updated the production lockfile resolution to [email protected] and pushed it. A clean npm ci succeeds, the installed production tree resolves Axios to 1.16.1, and all 49 targeted OpenAI Ads tests pass. The local npm audit service returned HTTP 403 before scanning, so the pushed commit will provide the authoritative CI rerun.

f46c62f

@rudder-devbox

rudder-devbox Bot commented Oct 23, 2026

Copy link
Copy Markdown
Contributor Author

Recorded knowledge from this round:

  • mistakes: Captured the vulnerable follow-redirects lockfile resolution and minimum safe version guidance for mistakes.md.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🔵 Needs a closer look

Privacy-sensitive identifier handling still needs human validation because targeted tests and the integration build remain unexecuted.

No open issues 🎉

Review effort: Balanced

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🔵 Needs a closer look

Privacy-sensitive hashing changes need human sign-off because targeted tests and build validation remain blocked by unavailable tooling.

No open issues 🎉

Review effort: Balanced

@ItsSudip

Copy link
Copy Markdown
Member

@rudder-devbox please address the following review feedback on this PR:

  1. Document the follow-redirects lockfile bump in the PR description
    Keep the package-lock.json bump (follow-redirects 1.16.0 → 1.16.1). Add a short section to the PR description explaining it:

  2. Resolve isHashRequired once
    The ?? true default currently lives in three places: both browser.js call sites (seedUserData() and identify()) plus the default parameters of buildUserData and hashUserValue. Resolve it once — e.g. this.isHashRequired = this.config.isHashRequired ?? true in the constructor/init — and pass this.isHashRequired explicitly from both call sites. Remove the = true default parameters from buildUserData and hashUserValue so callers must pass the flag. No behavior change; existing tests should pass unchanged.

  3. Update the PR description's Validation section
    It says Jest, Nx, and Rollup were blocked locally, but CI ran and passed (Unit Tests and Lint, Bundle size checks, Security checks). Update it to reflect the CI results.

Copilot AI balanced review requested due to automatic review settings October 23, 2026 12:02
@rudder-devbox

rudder-devbox Bot commented Oct 23, 2026

Copy link
Copy Markdown
Contributor Author

Resolved isHashRequired once in the OpenAI Ads constructor and now pass the resolved value explicitly from both buildUserData call sites; the helper defaults were removed. I also updated the PR description with the follow-redirects advisory rationale, lockfile-only scope, Nx/Dependabot notes, and the passing local/CI validation results. All 49 targeted OpenAI Ads tests passed, along with targeted ESLint, syntax, and diff checks. Commit 603439d

@rudder-devbox

rudder-devbox Bot commented Oct 23, 2026

Copy link
Copy Markdown
Contributor Author

Recorded knowledge from this round:

  • feedback: Captured the reviewer requirement to resolve OpenAI Ads isHashRequired once at the browser integration boundary and keep helper parameters explicit for feedback.md.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟢 Approval recommended

The focused changes preserve identifier validation, include regression coverage, and have no identified blocking issues.

No open issues 🎉

Review effort: Balanced

Copilot AI balanced review requested due to automatic review settings October 23, 2026 12:03

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Copilot encountered an error and was unable to review this pull request. You can try again by re-requesting a review.

@sonarqubecloud

Copy link
Copy Markdown

@ItsSudip
ItsSudip marked this pull request as ready for review October 23, 2026 13:09
@ItsSudip
ItsSudip requested review from a team as code owners October 23, 2026 13:09
@ItsSudip
ItsSudip requested a review from saikumarrs October 26, 2026 03:45
ItsSudip pushed a commit to rudderlabs/rudder-transformer that referenced this pull request Oct 26, 2026
## What are the changes introduced in this PR?

OpenAI Ads cloud transformations now honor destination-level
`isHashRequired`. Hashing remains enabled when the setting is absent,
while disabling it accepts valid pre-hashed customer identifiers and
lowercases them before delivery.

When hashing is disabled and `userId` is absent, the SDK-generated
`anonymousId` fallback is handled separately: an existing SHA-256 digest
passes through lowercased, while a plain value is normalized and hashed
through the existing external-ID path. Audience hashing consistency
metrics also carry the real workspace and destination identifiers.

The transformer passes only plain destination metadata through the
OpenAI Ads builder. The descriptor required by `processAudienceRecord`
is constructed at the utility call boundary, and hash-format recognition
is shared with audience consistency validation.

Focused unit and component coverage verifies enabled, disabled, and
default behavior, all supported hashed identifiers, anonymous-ID
fallback handling, mixed/plain input rejection, metric attribution, and
the shared hash-format predicate.

## What is the related Linear task?

Resolves INT-7432

## Please explain the objectives of your changes below

Allow customers that hash OpenAI Ads identifiers upstream to disable
transformer hashing without changing the existing default behavior. The
matching destination configuration is provided by
[rudder-integrations-config#2864](rudderlabs/rudder-integrations-config#2864).

### Any changes to existing capabilities/behaviour, mention the reason &
what are the changes ?

When `isHashRequired` is `false`, email, phone number, first name, last
name, and `userId` must already be normalized and SHA-256 hashed; plain
values remain rejected. Pre-hashed values are emitted as lowercase
hexadecimal strings. If `userId` is absent, RudderStack automatically
normalizes and hashes a plain `anonymousId` fallback, or lowercases and
passes through an already-hashed fallback. An absent or `true` setting
retains the existing normalization and hashing behavior.

### Any new dependencies introduced with this change?

N/A

### Any new generic utility introduced or modified. Please explain the
changes.

Exposes `isAlreadyHashed(value, hashingType)` from the shared audience
utility and uses it in both hashing-consistency validation and the
OpenAI Ads anonymous-ID fallback decision. The shared digest regex
remains the single definition of an already-hashed value.

### Any technical or performance related pointers to consider with the
change?

OpenAI Ads passes `workspaceId` and `destinationId` as plain metadata
through its builder. `processHashedUserPayload` constructs the
destination descriptor only where `processAudienceRecord` is called,
preserving the uppercase `OPENAI_ADS` metric series without leaking the
audience utility input shape through the transformer.

## Validation

- `npm run lint` - passed
- `npm test --
--testPathPattern="src/v0/(destinations/openai_ads/routerTransform|util/audienceUtils).test.ts"
--no-coverage --runInBand` - passed, 120 tests
- `npm run test:ts -- component --destination=openai_ads` - passed, 14
tests
- `./node_modules/.bin/tsc --noEmit -p tsconfig.test.json` - passed
- Full secret-path regeneration passed; OpenAI Ads still derives only
`headers.Authorization`, and the aggregate artifact remains unchanged
- `git diff --check` - passed
- Simplification pass reused the existing plaintext and SHA-256 fixtures
across the new helper cases and consistency tests

## ⚠️ Known Issues

- End-to-end runtime verification was skipped because the local stack
uses a SHA-pinned transformer image and cannot source-exercise this
change.
- Web device-mode support for `isHashRequired` will follow in
[rudder-sdk-js#3295](rudderlabs/rudder-sdk-js#3295).
- Release remains dependent on the matching integrations-config rollout
and required `rudder-hugo` documentation covering pre-hashed customer
identifiers, automatic anonymous-ID fallback hashing, normalization
responsibilities, and both cloud and web device-mode behavior.

<hr>

### Developer checklist

- [x] My code follows the style guidelines of this project
- [x] **No breaking changes are being introduced.**
- [ ] All related docs linked with the PR?
- [ ] All changes manually tested?
- [x] Any documentation changes needed with this change? Required
`rudder-hugo` dependency described above.
- [x] Is the PR limited to 10 file changes?
- [x] Is the PR limited to one linear task?
- [x] Are relevant unit and component test-cases added in **new
readability format**?

### Reviewer checklist

- [ ] Is the type of change in the PR title appropriate as per the
changes?
- [ ] Verified that there are no credentials or confidential data
exposed with the changes.

---------

Co-authored-by: tech-infra-rudderstack <[email protected]>
@ItsSudip
ItsSudip merged commit 79e6526 into develop Oct 26, 2026
14 checks passed
@ItsSudip
ItsSudip deleted the harness/INT-7435-fix-honor-openai-ads-device-mod-d7121d3d branch October 26, 2026 04:53
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