Skip to content

Commit 356d18d

Browse files
test(audience): add ci marker test that stamps run metadata on CDP (SDK-317)
- New [UnityTest] AudienceCiTestMarker_EmitsRunMetadata. Skips outside CI (AUDIENCE_TEST_RUN_ID and AUDIENCE_TEST_CELL_ID both unset). Inside CI, calls LoadAndInit then emits one ImmutableAudience.Track("audience_ci_test_marker", { source: "ci", ciRunId, ciCellId }). - Lets dashboards filter test traffic in / out: - select event_name = "audience_ci_test_marker" lists every CI run that hit CDP, with run / cell metadata directly on the row. - properties.buildGuid on the marker matches the buildGuid the SDK auto-emits on every game_launch event from the same cell binary, so a follow-up filter pulls the rest of the cell's events. - Standalone test rather than a hook in LoadAndInit so the marker stays explicit and opt-in. Other tests do not silently emit a side-event; the SampleApp and SDK carry no CI / QA-specific knowledge. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
1 parent 5c2a9c5 commit 356d18d

1 file changed

Lines changed: 24 additions & 0 deletions

File tree

examples/audience/Assets/SampleApp/Tests/Runtime/SampleAppLiveFireTests.cs

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,30 @@ private IEnumerator SetConsentVia(string consentButtonName)
128128

129129
// ---- Tests ----
130130

131+
// Marks this as coming from CI.
132+
[UnityTest]
133+
public IEnumerator AudienceCiTestMarker_EmitsRunMetadata()
134+
{
135+
var runId = Environment.GetEnvironmentVariable("AUDIENCE_TEST_RUN_ID");
136+
var cellId = Environment.GetEnvironmentVariable("AUDIENCE_TEST_CELL_ID");
137+
if (string.IsNullOrEmpty(runId) && string.IsNullOrEmpty(cellId))
138+
{
139+
Assert.Ignore("Not running in CI.");
140+
yield break;
141+
}
142+
143+
yield return LoadAndInit();
144+
145+
ImmutableAudience.Track("audience_ci_test_marker", new System.Collections.Generic.Dictionary<string, object>
146+
{
147+
["source"] = "ci",
148+
["ciRunId"] = runId ?? string.Empty,
149+
["ciCellId"] = cellId ?? string.Empty,
150+
});
151+
152+
yield return null;
153+
}
154+
131155
[UnityTest]
132156
public IEnumerator InitTrackFlush_AgainstSandbox_FlushReportsOk()
133157
{

0 commit comments

Comments
 (0)