Skip to content

feat(audience): remove sandbox env routing, add testMode (SDK-357)#2872

Merged
bkbooth merged 8 commits into
mainfrom
claude/upbeat-black-9f5655
May 15, 2026
Merged

feat(audience): remove sandbox env routing, add testMode (SDK-357)#2872
bkbooth merged 8 commits into
mainfrom
claude/upbeat-black-9f5655

Conversation

@bkbooth
Copy link
Copy Markdown
Contributor

@bkbooth bkbooth commented May 13, 2026

Summary

  • Removes getBaseUrl() and the pk_imapik-test- key prefix check that routed events to api.sandbox.immutable.com (being decommissioned). Default base URL is now always https://api.immutable.com; dev routing continues via the existing baseUrl override.
  • Adds testMode?: boolean to PixelInitOptions and AudienceConfig. When true, all outbound events carry a top-level test: true field so the backend can filter test traffic from production analytics.
  • Updates both READMEs with a Test Mode section and removes sandbox references.

Closes SDK-357. Sub-issue of SDK-351 (Sandbox Removal).

Changed files

File Change
core/src/config.ts Removed TEST_KEY_PREFIX, getBaseUrl(). Added BASE_URL constant.
core/src/config.test.ts Deleted (tested removed function).
core/src/types.ts Added test?: true to BaseMessage.
core/src/queue.ts Uses BASE_URL instead of getBaseUrl(publishableKey).
core/src/consent.ts Uses BASE_URL instead of getBaseUrl(publishableKey).
pixel/src/pixel.ts Added testMode to PixelInitOptions, instance property, and buildBase().
sdk/src/types.ts Added testMode to AudienceConfig with JSDoc.
sdk/src/sdk.ts Added testMode instance property, wired into baseMessage().
pixel/README.md Added Test Mode section.
sdk/README.md Added Test Mode section.

Test plan

  • All 155 @imtbl/audience-core unit tests pass
  • All 96 @imtbl/pixel unit tests pass
  • All 60 @imtbl/audience unit tests pass
  • eslint passes on all changed files (lint-staged ran at commit)
  • Verify with backend that test: true top-level field is handled correctly on ingest

🤖 Generated with Claude Code


Note

Medium Risk
Changes the default ingest/consent endpoints to always use production and removes key-based sandbox routing, which could redirect real traffic if callers relied on the old behavior. Adds an optional testMode flag that alters outbound event payloads by tagging messages with test: true.

Overview
Removes sandbox environment routing by deleting getBaseUrl()/test-key prefix logic and standardizing the default API base to BASE_URL = https://api.immutable.com for both ingest (MessageQueue) and consent sync (createConsentManager), with baseUrl remaining as the only override.

Adds test event tagging via a new testMode?: boolean option in both the web SDK and pixel; when enabled, all emitted messages include a top-level test: true field (type updates in audience-core), and docs/sample app UI are updated accordingly.

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

Removes getBaseUrl() and the pk_imapik-test- prefix check that routed
events to api.sandbox.immutable.com, which is being decommissioned.
Adds testMode init option to both the pixel and SDK — when true, every
outbound event carries a top-level test: true field so the backend can
filter test data from production analytics.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@bkbooth bkbooth requested a review from a team as a code owner May 13, 2026 04:34
@nx-cloud
Copy link
Copy Markdown

nx-cloud Bot commented May 13, 2026

View your CI Pipeline Execution ↗ for commit ad0f604

Command Status Duration Result
nx affected -t build,lint,test ✅ Succeeded 8s View ↗
nx run-many -p @imtbl/sdk,@imtbl/checkout-widge... ✅ Succeeded 1s View ↗

☁️ Nx Cloud last updated this comment at 2026-05-15 03:36:28 UTC

@github-actions
Copy link
Copy Markdown

github-actions Bot commented May 13, 2026

✅ Audience Bundle Size — @imtbl/audience

Metric Size Delta vs main (f0f4f43)
Gzipped 18232 bytes (17.80 KB) -17 bytes
Raw (minified) 53047 bytes +6 bytes

Budget: 24.00 KB gzipped (warn at 20.00 KB)

@github-actions
Copy link
Copy Markdown

github-actions Bot commented May 13, 2026

✅ Pixel Bundle Size — @imtbl/pixel

Metric Size Delta vs main
Gzipped 5872 bytes (5.73 KB) -12 bytes
Raw (minified) 15856 bytes -8 bytes

Budget: 10.00 KB gzipped (warn at 8.00 KB)

Copy link
Copy Markdown
Contributor

@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, enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit 13e8cf5. Configure here.

Comment thread packages/audience/core/src/consent.ts
…EADMEs

Updates the 8 stale sandbox URL assertions in consent.test.ts and
queue.test.ts that bugbot flagged — they referenced api.sandbox URLs
that no longer get produced after the getBaseUrl removal.

Drops the Test Mode README sections. The option is for internal/non-prod
use, similar to baseUrl which is also undocumented. Still discoverable
via TypeScript IntelliSense.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
nattb8
nattb8 previously approved these changes May 13, 2026
Copy link
Copy Markdown
Contributor

@nattb8 nattb8 left a comment

Choose a reason for hiding this comment

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

Need another PR to update the sample app?

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
bkbooth and others added 4 commits May 15, 2026 12:55
- Remove api.sandbox.immutable.com from CSP and environment dropdown
- Add testMode checkbox in Advanced section, wired into Audience.init()
- Update package.json description

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
…ptions

Group it with the other configuration sections (Consent Modes,
Auto-Tracked Events) instead of orphaning it after the operational
details (Cookies, CSP, Browser Support).

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
The Web SDK README documents zero init options inline — everything is
shown in the quickstart snippet and otherwise deferred to the docs site.
Singling out testMode violated that pattern.

Pixel README keeps its Test mode section, matching its existing
convention of documenting consent / autocapture options inline.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
@bkbooth bkbooth requested a review from nattb8 May 15, 2026 03:13
Comment thread packages/audience/pixel/README.md Outdated
nattb8
nattb8 previously approved these changes May 15, 2026
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
@bkbooth bkbooth enabled auto-merge May 15, 2026 03:42
@bkbooth bkbooth added this pull request to the merge queue May 15, 2026
Merged via the queue into main with commit fc8b5e3 May 15, 2026
12 checks passed
@bkbooth bkbooth deleted the claude/upbeat-black-9f5655 branch May 15, 2026 04:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

2 participants