feat(audience): wire onError callback from AudienceConfig through to core#2857
Merged
ImmutableJeffrey merged 2 commits intomainfrom Apr 16, 2026
Merged
feat(audience): wire onError callback from AudienceConfig through to core#2857ImmutableJeffrey merged 2 commits intomainfrom
ImmutableJeffrey merged 2 commits intomainfrom
Conversation
|
View your CI Pipeline Execution ↗ for commit 4165586
☁️ Nx Cloud last updated this comment at |
|
View your CI Pipeline Execution ↗ for commit 6706e2e
☁️ Nx Cloud last updated this comment at |
66f5f36 to
7160fbe
Compare
90add33 to
42565f8
Compare
7160fbe to
0f3193a
Compare
3 tasks
nattb8
previously approved these changes
Apr 15, 2026
nattb8
previously approved these changes
Apr 15, 2026
…core Exposes AudienceError to web SDK consumers. The core queue and consent manager already accept an onError callback and map TransportError to a public AudienceError via toAudienceError; this commit just forwards AudienceConfig.onError into both positional slots in the Audience constructor, which were previously hard-coded to undefined. Also re-exports AudienceError (runtime) and AudienceErrorCode (type) from the @imtbl/audience package index so ESM consumers can import the error type they need for their onError handler. CDN consumers already have it via window.ImmutableAudience.AudienceError from the CDN bundle work in #2853. Two new sdk.test.ts tests cover the wire-through end-to-end: a flush failure against a mocked backend, and a consent sync failure against a mocked backend. Both verify the AudienceError shape (name, code, status, endpoint) rather than just that the callback fires. Refs SDK-49 Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
0f3193a to
5085b69
Compare
Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
nattb8
approved these changes
Apr 16, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Adds
onError?: (err: AudienceError) => voidtoAudienceConfigand forwards it to the two places in theAudienceconstructor that already accept it downstream.What changes
packages/audience/sdk/src/types.tsgains theonError?field onAudienceConfig.packages/audience/sdk/src/sdk.tspassesconfig.onErrorinto theMessageQueueoptions object (previously hadonFlushbut notonError) and into the 7th positional slot ofcreateConsentManager(previously hard-coded toundefined).packages/audience/sdk/src/index.tsre-exportsAudienceError(runtime) andAudienceErrorCode(type) from@imtbl/audience-coreso ESM consumers can import the error type. CDN consumers already haveAudienceErrorviawindow.ImmutableAudience.AudienceErrorfrom feat(audience): CDN bundle entry point and tsup build (SDK-115) #2853.packages/audience/sdk/src/sdk.test.tsadds two tests verifying the full wire-through against a mocked backend.Why this exists
AudienceErroris exported from@imtbl/audience-coreand attached towindow.ImmutableAudienceby PR #2853, but the publicAudienceConfighas noonErrorfield and theAudienceconstructor passesundefinedwhere the wire-through would go. Net result: studios using@imtbl/audiencetoday have no way to receiveAudienceError. This PR closes that gap with the smallest possible change — all the error mapping logic already exists in core.Test plan
pnpm --filter @imtbl/audience run lintpnpm --filter @imtbl/audience run typecheckpnpm --filter @imtbl/audience run test— 58/58 passing (56 baseline + 2 new)pnpm --filter @imtbl/audience-core run test— 150/150, no regressionRefs SDK-49