refactor(audience): catalogues, identity helpers, sample-app strings, and test infrastructure (SDK-277)#726
Open
ImmutableJeffrey wants to merge 9 commits intochore/sdk-272-pr-1-sdk-runtime-constantsfrom
Conversation
fba80b5 to
34d4050
Compare
9c7496b to
91f1783
Compare
Names the message strings routed through AudienceConfig.OnError so a wording tweak touches one file and runtime emit / test assert read from the same constants. - Log.cs: adds AudienceErrorMessages with the LocalStorageReadFailed / BatchPartiallyRejected formatters and the BatchRejectedPrefix / ServerErrorWillRetryPrefix / ConsentSyncFailedWithStatus / ConsentSyncThrew entries. - HttpTransport.cs: flush onError messages route through AudienceErrorMessages. - ImmutableAudience.cs: consent-sync onError messages route through AudienceErrorMessages.
Names the ArgumentException strings thrown from public SDK surfaces so user-code that reads .Message stays in sync if a wording is tweaked in one site but not another. - Log.cs: adds AudienceArgumentMessages with the Init / config validation entries (PublishableKeyRequired, PersistentDataPathRequired) and the typed-event ToProperties entries (ProgressionStatusRequired, ResourceFlow / Currency / AmountRequired, PurchaseValue / CurrencyInvalid, MilestoneReachedNameRequired). - TypedEvents.cs: Progression / Resource / Purchase / MilestoneReached ArgumentException messages route through AudienceArgumentMessages. - ImmutableAudience.cs: Init validation ArgumentException messages route through AudienceArgumentMessages.
…rnPrefix
Hoists the SDK stamp into named constants so the sample-app log adapter can strip it back off
without hardcoding the same string.
- Log.cs: promotes Prefix from private to internal and adds WarnPrefix following the "{Prefix}
WARN:" shape Log.Warn emits.
- Log.cs: Warn now reads its prefix from WarnPrefix instead of inlining the format.
…seString Adds the inverse of ToLowercaseString so callers reading user-supplied or wire-format identity strings can round-trip back into the enum without hand-rolling another switch. - IdentityType.cs: adds IdentityTypeExtensions.ParseLowercaseString, the case-insensitive inverse of ToLowercaseString. Falls back to Custom for unknown / empty values; never throws. - AudienceSample.cs: ParseIdentityType reverse mapper delegates to IdentityTypeExtensions.ParseLowercaseString instead of hand-rolling its own switch.
…to SampleAppUi
Moves the SampleAppUi catalogue from Tests/Runtime to Scripts so non-test code can reference it, and
expands it to cover every UXML element name, CSS class, button caption, resource path, and side
string the sample manipulates.
- Moves SampleAppUi.cs from Tests/Runtime to Scripts so AudienceSample.cs / .UI.cs / .Events.cs can
reference it.
- SampleAppUi gains AliasFromType / AliasToType identity-field names.
- SampleAppUi.Layout names the layout-internal elements (sdk-version, tab-bar, typed-events-host,
log-resize-handle, page-scroll, controls-column, log-column, sample-app-grid, log-count,
accordion-{item, title, content}).
- SampleAppUi.Css names every CSS class the sample manipulates (state-*, accordion-*, log-*,
badge-*, status-value, field-*, etc.).
- SampleAppUi.ButtonText (Send / Copy / Copied) names dynamically-built button captions.
- SampleAppUi.Resources names the four Resources.Load asset paths.
- SampleAppUi.Messages holds six human-readable side strings used in consent / identity flows.
- SampleAppUi.LogLabels gains Ready / Sdk / OnError / Init / Shutdown / Reset / Flush / DeleteData /
Page / Track / SetConsent.
- SampleAppUi.LogBadgeText names the two-letter SDK / APP pill text.
- SampleAppUi.StatusBar.EmptyText replaces six hardcoded em-dash placeholder glyphs.
- AudienceSample.cs / .UI.cs / .Events.cs read UXML element names, CSS classes, dynamic button
captions, resource paths, and log labels from SampleAppUi.
- SampleAppLiveFireTests.cs reads UXML element names, log labels, and the env-var key from
SampleAppUi.
Names the sandbox-shaped publishable-key fixture so the same string doesn't have to live in 28
separate test files.
- TestDefaults.cs: new internal helper with PublishableKey ("pk_imapik-test-key1") plus the
FlushIntervalSeconds and FlushSize defaults shared across the test fixture.
- HttpTransportTests, ImmutableAudienceTests, ConsentSyncTests, DeleteDataTests, SessionTests: 28
inline copies of the publishable-key string read from TestDefaults.PublishableKey.
…ures
Names a small builder for wire-format envelope JSON so tests stop hand-rolling escape-laden strings,
and a rename on MessageFields lights up runtime emit and test fixtures together.
- WireFixture.cs: new internal helper with Track / Identify / Alias overloads that build envelopes
from MessageFields and MessageTypes constants.
- DiskStoreTests.cs, GzipTests.cs, HttpTransportTests.cs, EventQueueTests.cs: hand-rolled
"{type:track,...}" mock-store fixtures read from WireFixture; envelope key access uses
MessageFields.
…rcaseString Final test sweep: tests asserting on enum-derived wire strings stop hardcoding the lowercase forms and read them from the matching ToLowercaseString extension instead, so a wire-rename on an enum member touches one place. - MessageBuilderTests, ImmutableAudienceTests, JsonReaderTests, JsonTests, TypedEventTests, ConsentSyncTests, SessionTests, OfflineResilienceTests: ConsentLevel / IdentityType / ProgressionStatus / ResourceFlow assertions read via ToLowercaseString. - SessionTests pause-rollover thresholds derive from Session.PauseTimeoutMs. - DeleteDataTests query-string asserts use the constants introduced in earlier slices.
…ts.cs
The previous SSOT pass left twelve timing / retry constants co-located
with their owning module: HttpTransport.RequestTimeoutSeconds and
five Backoff*Ms constants, Session.HeartbeatIntervalMs / PauseTimeoutMs
/ HeartbeatDrainTimeoutMs / StartDrainTimeoutMs, and ImmutableAudience.
ConsentSyncMaxAttempts / ConsentSyncBaseRetryMs. Constants.cs already
held analogous timing / sizing knobs (DefaultFlushIntervalSeconds,
MaxBatchSize, ControlPlaneRequestTimeoutSeconds), so the split was
inconsistent.
Move all twelve into Constants.cs with module-prefixed names
(MessagesRequestTimeoutSeconds, HttpBackoff{1st,2nd,3rd,4th,Cap}Ms,
SessionHeartbeatIntervalMs, SessionPauseTimeoutMs,
SessionHeartbeatDrainTimeoutMs, SessionStartDrainTimeoutMs,
ConsentSyncMaxAttempts, ConsentSyncBaseRetryMs). Migrate runtime call
sites in HttpTransport, Session, and ImmutableAudience plus the one
test reference in SessionTests. Behaviour unchanged.
Follow-up to SDK-272 (centralisation of duplicated literals).
34d4050 to
994279f
Compare
91f1783 to
427f963
Compare
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
AudienceErrorMessagescatalogue for runtime error messages.AudienceArgumentMessagescatalogue for argument-validation messages.Log.Prefixtointernaland addsLog.WarnPrefix.IdentityTypeExtensions.ParseLowercaseStringfor case-insensitive wire-string parsing withCustomfallback for unknown / null / empty inputs.SampleAppUi.TestDefaults.PublishableKeyfor the test publishable-key default.WireFixtureand migrates mock-store JSON fixtures so test envelopes are built fromMessageFieldsandMessageTypes.IdentityType.ToLowercaseString()/ConsentLevel.ToLowercaseString().Constants.cswith module-prefixed names:MessagesRequestTimeoutSeconds,HttpBackoff{1st,2nd,3rd,4th,Cap}Ms,SessionHeartbeatIntervalMs,SessionPauseTimeoutMs,SessionHeartbeatDrainTimeoutMs,SessionStartDrainTimeoutMs,ConsentSyncMaxAttempts,ConsentSyncBaseRetryMs. Migrates runtime call sites inHttpTransport,Session,ImmutableAudience, plusSessionTests.OnErrorcallback contract unchanged.Linear: SDK-277