feat(audience-env): explicit dev/sandbox/production selection#709
Merged
ImmutableJeffrey merged 1 commit intofeat/sdk-146-unityfrom Apr 26, 2026
Merged
feat(audience-env): explicit dev/sandbox/production selection#709ImmutableJeffrey merged 1 commit intofeat/sdk-146-unityfrom
ImmutableJeffrey merged 1 commit intofeat/sdk-146-unityfrom
Conversation
nattb8
reviewed
Apr 24, 2026
nattb8
reviewed
Apr 24, 2026
Base automatically changed from
feat/audience-diagnostics
to
feat/sdk-146-unity
April 24, 2026 04:49
0767fb0 to
ae6780f
Compare
7dacbf1 to
dbe483a
Compare
ImmutableJeffrey
added a commit
that referenced
this pull request
Apr 24, 2026
Addresses review feedback on #709 from @nattb8: avoid exposing a public enum of environments and match the Web/Pixel SDK pattern. Problems with the enum: - Makes Dev a first-class, permanently-supported public choice that cannot be removed later without a breaking change. - Forces every future backend addition onto the public enum surface. - Diverges from @imtbl/audience, which has no enum. This commit undoes the enum wiring and restores the key-prefix URL derivation that existed before the PR. A follow-up commit adds an optional BaseUrl override on AudienceConfig (Web SDK parity) so devs who need Dev can point the SDK there directly. - Delete AudienceEnvironment.cs. - Constants: restore TestKeyPrefix and the MessagesUrl/ConsentUrl/DataUrl(string?) signatures. - AudienceConfig: drop the Environment field. - HttpTransport: drop the AudienceEnvironment ctor parameter; URL derives from publishableKey prefix. - ImmutableAudience: remove the CurrentEnvironment getter and its cached backing field; revert DeleteData, SyncConsentToBackend, and Init to pass publishableKey into the URL helpers. - Tests: remove the CurrentEnvironment_* cases and the per-env URL cases; restore the pre-PR test-key / prod-key URL assertions. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
ImmutableJeffrey
added a commit
that referenced
this pull request
Apr 24, 2026
Addresses review feedback on #709 from @nattb8: match the Web/Pixel SDK pattern of letting callers override the API base URL. BaseUrl is null by default. A null override keeps the existing key-prefix derivation — "pk_imapik-test-" keys resolve to Sandbox and every other key resolves to Production — so there is no behaviour change for studios that never set this field. Integrations that need a different backend (for example the Immutable-internal Dev API at https://api.dev.immutable.com) pass the URL directly; no public env token is surfaced. - AudienceConfig: new BaseUrl string? property. - Constants: BaseUrl / MessagesUrl / ConsentUrl / DataUrl accept an optional baseUrlOverride; override wins when non-empty, falls back to key-prefix derivation when null or empty. - HttpTransport: ctor accepts baseUrlOverride and threads it into MessagesUrl. - ImmutableAudience.Init passes config.BaseUrl into HttpTransport; DeleteData and SyncConsentToBackend pass it into DataUrl / ConsentUrl. - Tests: BaseUrl resolution cases (test key, non-test key, null key, override wins, empty-string override falls back) and an end-to-end HttpTransport test confirming the override wins over a sandbox- derived key. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
nattb8
reviewed
Apr 24, 2026
nattb8
reviewed
Apr 24, 2026
ImmutableJeffrey
added a commit
that referenced
this pull request
Apr 25, 2026
- `Initialized`: true once Init() finishes; false before Init / after Shutdown. - `UserId`: cleared by Reset and any consent downgrade out of Full. - `SessionId`: new ID at Init, Reset, on resume from a long-enough background pause, and on granting consent from None. Plain-language style matches the audience-diagnostics docs follow-up. Addresses PR #709 review: three getters lacked the per-member docs that the other public diagnostics getters already carry. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
ImmutableJeffrey
added a commit
that referenced
this pull request
Apr 25, 2026
- `Initialized`: true once Init() finishes; false before Init / after Shutdown. - `UserId`: cleared by Reset and any consent downgrade out of Full. - `SessionId`: new ID at Init, Reset, on resume from a long-enough background pause, and on granting consent from None. - Drops the shared "diagnostic getters" block header; per-getter docs now cover each member's behaviour directly. Plain-language style matches the audience-diagnostics docs follow-up. Addresses PR #709 review: three getters lacked the per-member docs that the other public diagnostics getters already carry. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
29b9f2e to
ab0433d
Compare
ae6780f to
e03d3c9
Compare
ImmutableJeffrey
added a commit
that referenced
this pull request
Apr 25, 2026
- `Initialized`: true once Init() finishes; false before Init / after Shutdown. - `UserId`: cleared by Reset and any consent downgrade out of Full. - `SessionId`: new ID at Init, Reset, on resume from a long-enough background pause, and on granting consent from None. - Drops the shared "diagnostic getters" block header; per-getter docs now cover each member's behaviour directly. Plain-language style matches the audience-diagnostics docs follow-up. Addresses PR #709 review: three getters lacked the per-member docs that the other public diagnostics getters already carry. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
ab0433d to
89059b0
Compare
ImmutableJeffrey
added a commit
that referenced
this pull request
Apr 25, 2026
Addresses review feedback on #709 from @nattb8: match the Web/Pixel SDK pattern of letting callers override the API base URL. BaseUrl is null by default. A null override keeps the existing key-prefix derivation — "pk_imapik-test-" keys resolve to Sandbox and every other key resolves to Production — so there is no behaviour change for studios that never set this field. Integrations that need a different backend (for example the Immutable-internal Dev API at https://api.dev.immutable.com) pass the URL directly; no public env token is surfaced. - AudienceConfig: new BaseUrl string? property. - Constants: BaseUrl / MessagesUrl / ConsentUrl / DataUrl accept an optional baseUrlOverride; override wins when non-empty, falls back to key-prefix derivation when null or empty. - HttpTransport: ctor accepts baseUrlOverride and threads it into MessagesUrl. - ImmutableAudience.Init passes config.BaseUrl into HttpTransport; DeleteData and SyncConsentToBackend pass it into DataUrl / ConsentUrl. - Tests: BaseUrl resolution cases (test key, non-test key, null key, override wins, empty-string override falls back) and an end-to-end HttpTransport test confirming the override wins over a sandbox- derived key. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
89059b0 to
032f05c
Compare
Adds six public diagnostic getters on ImmutableAudience: - Initialized: true between Init and Shutdown. - CurrentConsent: live consent level. - UserId: last Identify value; null below Full consent. - AnonymousId: anonymous, persistent ID. - SessionId: current session id; rotates on Init / Reset / timeout. - QueueSize: number of unsent events (memory + disk). Each getter is safe from any thread and returns a safe default when the SDK cannot answer. EventQueue gains an internal InMemoryCount property so QueueSize can sum without locking. Adds optional AudienceConfig.BaseUrl override (matches Web/Pixel SDK pattern; addresses #709 review). Null preserves the key-prefix derivation; integrations needing a different backend pass the URL directly. Tests cover diagnostics lifecycle and BaseUrl resolution. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
032f05c to
b0b9646
Compare
nattb8
approved these changes
Apr 26, 2026
ImmutableJeffrey
added a commit
that referenced
this pull request
Apr 27, 2026
Adds six public diagnostic getters on ImmutableAudience: - Initialized: true between Init and Shutdown. - CurrentConsent: live consent level. - UserId: last Identify value; null below Full consent. - AnonymousId: anonymous, persistent ID. - SessionId: current session id; rotates on Init / Reset / timeout. - QueueSize: number of unsent events (memory + disk). Each getter is safe from any thread and returns a safe default when the SDK cannot answer. EventQueue gains an internal InMemoryCount property so QueueSize can sum without locking. Adds optional AudienceConfig.BaseUrl override (matches Web/Pixel SDK pattern; addresses #709 review). Null preserves the key-prefix derivation; integrations needing a different backend pass the URL directly. Tests cover diagnostics lifecycle and BaseUrl resolution. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
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.
Summary
AudienceEnvironmentenum:Dev,Sandbox,Production.AudienceConfig.Environmentfield, defaultSandbox.Constants.BaseUrl/MessagesUrl/ConsentUrl/DataUrltake anAudienceEnvironment; the publishable-key parameter on these helpers is removed.Constants.DevBaseUrl; removesConstants.ResolveEnvironmentandConstants.TestKeyPrefix.HttpTransportconstructor takes anAudienceEnvironment(defaultSandbox); key-prefix URL derivation removed.ImmutableAudience.Initwiresconfig.EnvironmentintoHttpTransport;DeleteDataandSetConsentthread it into their control-plane URLs.ImmutableAudience.CurrentEnvironmentpublic getter; caches the last Init's env so the value survives Shutdown;ResetStaterestores the Sandbox default.Behaviour change: integrations using a production-prefixed key that left
Environmentunset previously hit production via key-prefix detection. They now hit Sandbox untilEnvironment = Productionis set explicitly. Test-key integrations already hit Sandbox and are unaffected.Linear: SDK-244.