Skip to content

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

Open
bkbooth wants to merge 2 commits into
mainfrom
claude/upbeat-black-9f5655
Open

feat(audience): remove sandbox env routing, add testMode (SDK-357)#2872
bkbooth wants to merge 2 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 where events are sent by default (always https://api.immutable.com unless baseUrl is overridden) and updates the event schema to optionally include test: true, which could affect ingestion/analytics if backend handling or consumers aren’t aligned.

Overview
Removes getBaseUrl()/test-key prefix routing and standardizes core networking to use BASE_URL = https://api.immutable.com for both ingest and consent sync (tests updated; config.test.ts deleted), while still supporting explicit baseUrl overrides.

Adds testMode?: boolean to both Pixel and Web SDK init configs; when enabled, all emitted messages include a top-level test: true field (type updated in @imtbl/audience-core).

Reviewed by Cursor Bugbot for commit 484a5fd. 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 484a5fd

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

☁️ Nx Cloud last updated this comment at 2026-05-13 05:52:45 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>
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.

1 participant