Skip to content

Commit 40425bd

Browse files
authored
Merge pull request #736 from immutable/feat/sdk-314-remove-page-button
chore(audience-sample): remove page() button from sample app (SDK-314)
2 parents f2fb455 + 9f283d4 commit 40425bd

5 files changed

Lines changed: 19 additions & 39 deletions

File tree

examples/audience/Assets/SampleApp/Resources/AudienceSample.uxml

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -125,11 +125,6 @@
125125
<ui:VisualElement class="actions last">
126126
<ui:Button name="btn-init" text="Init" />
127127

128-
<ui:Button name="btn-page" class="with-sig">
129-
<ui:Label class="btn-label" text="Page" />
130-
<ui:Label class="btn-sig" text="page()" />
131-
</ui:Button>
132-
133128
<ui:Button name="btn-flush" class="with-sig">
134129
<ui:Label class="btn-label" text="Flush" />
135130
<ui:Label class="btn-sig" text="flush()" />

examples/audience/Assets/SampleApp/Scripts/AudienceSample.UI.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ private static readonly (string TabId, string PanelId)[] Tabs =
5353
private TextField _publishableKey, _baseUrl, _flushInterval, _flushSize;
5454
private DropdownField _initialConsent;
5555
private Toggle _debug;
56-
private Button _btnInit, _btnPage, _btnFlush, _btnReset, _btnShutdown, _btnDeleteData;
56+
private Button _btnInit, _btnFlush, _btnReset, _btnShutdown, _btnDeleteData;
5757

5858
// ---- UXML element fields (Consent tab) ----
5959

@@ -195,7 +195,7 @@ private void BindElements()
195195
_flushInterval = Require<TextField>("flush-interval");
196196
_flushSize = Require<TextField>("flush-size");
197197
_btnInit = Require<Button>("btn-init");
198-
_btnPage = Require<Button>("btn-page");
198+
199199
_btnFlush = Require<Button>("btn-flush");
200200
_btnReset = Require<Button>("btn-reset");
201201
_btnShutdown = Require<Button>("btn-shutdown");
@@ -304,7 +304,7 @@ private void RegisterHandlers()
304304
_baseUrl.RegisterValueChangedCallback(_ => RefreshStatusBar());
305305

306306
_btnInit.clicked += OnInit;
307-
_btnPage.clicked += OnPage;
307+
308308
_btnFlush.clicked += async () => await OnFlushAsync();
309309
_btnReset.clicked += OnReset;
310310
_btnShutdown.clicked += OnShutdown;
@@ -614,7 +614,7 @@ private void RefreshConsentPills()
614614

615615
private void RefreshInitState()
616616
{
617-
foreach (var b in new[] { _btnPage, _btnFlush, _btnReset, _btnShutdown, _btnDeleteData, _btnCustomEvent, _btnIdentify, _btnIdentifyTraits })
617+
foreach (var b in new[] { _btnFlush, _btnReset, _btnShutdown, _btnDeleteData, _btnCustomEvent, _btnIdentify, _btnIdentifyTraits })
618618
b.SetEnabled(_initialised);
619619
foreach (var p in _consentPills.Values) p.SetEnabled(_initialised);
620620
foreach (var btn in _typedEventsHost.Query<Button>().ToList()) btn.SetEnabled(_initialised);

examples/audience/Assets/SampleApp/Scripts/AudienceSample.cs

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
using System.Collections.Generic;
55
using System.Threading.Tasks;
66
using UnityEngine;
7-
using UnityEngine.SceneManagement;
87
using UnityEngine.UIElements;
98

109
namespace Immutable.Audience.Samples.SampleApp
@@ -104,17 +103,6 @@ private async Task OnDeleteDataAsync()
104103

105104
// ---- SDK action handlers: telemetry ----
106105

107-
// v1 has no typed Screen API; Plan §10 specifies a custom Track call
108-
// as the studio-facing pattern for scene coverage. Demo follows that.
109-
private void OnPage() => RunAndLog("page()", () =>
110-
{
111-
GuardConsentForTrack();
112-
var screen = SceneManager.GetActiveScene().name;
113-
var props = new Dictionary<string, object> { ["path"] = screen };
114-
ImmutableAudience.Track("screen_viewed", props);
115-
return Json.Serialize(props, 2);
116-
});
117-
118106
// Prefers the typed overload for the four events with public C#
119107
// classes (Progression, Resource, Purchase, MilestoneReached); the
120108
// rest stay on the string overload. Typed validation errors are

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

Lines changed: 15 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -133,8 +133,7 @@ public IEnumerator InitTrackFlush_AgainstSandbox_FlushReportsOk()
133133
{
134134
yield return LoadAndInit();
135135

136-
// Page-view track via btn-page; the test doesn't wait on its row.
137-
_root!.Q<Button>(SampleAppUi.Buttons.Page).Click();
136+
_root!.Q<Button>(SampleAppUi.Buttons.TypedEvent("progression")).Click();
138137
yield return null;
139138

140139
yield return FlushAndAssertNoErrors();
@@ -228,7 +227,7 @@ public IEnumerator SetConsent_None_PurgesQueueAndPersists()
228227
// Init at default Anonymous; enqueue an event; revoke; flush — no errors.
229228
yield return LoadAndInit();
230229

231-
_root!.Q<Button>(SampleAppUi.Buttons.Page).Click();
230+
_root!.Q<Button>(SampleAppUi.Buttons.TypedEvent("progression")).Click();
232231
yield return null;
233232

234233
yield return SetConsentVia(SampleAppUi.Buttons.ConsentNone);
@@ -281,7 +280,7 @@ public IEnumerator Shutdown_AfterTrack_NoErrors()
281280
// those if their types/methods aren't reachable from a root assembly.
282281
yield return LoadAndInit();
283282

284-
_root!.Q<Button>(SampleAppUi.Buttons.Page).Click();
283+
_root!.Q<Button>(SampleAppUi.Buttons.TypedEvent("progression")).Click();
285284
yield return null;
286285

287286
_root.Q<Button>(SampleAppUi.Buttons.Shutdown).Click();
@@ -298,13 +297,13 @@ public IEnumerator Reset_RegeneratesAnonymousIdAndAcceptsTrack()
298297
// round-trip to sandbox without errors.
299298
yield return LoadAndInit();
300299

301-
_root!.Q<Button>(SampleAppUi.Buttons.Page).Click();
300+
_root!.Q<Button>(SampleAppUi.Buttons.TypedEvent("progression")).Click();
302301
yield return null;
303302

304303
_root.Q<Button>(SampleAppUi.Buttons.Reset).Click();
305304
yield return SampleAppTestHelpers.WaitForLogEntry(_root, SampleAppUi.LogLabels.Reset, LogLevels.Ok, 5f);
306305

307-
_root.Q<Button>(SampleAppUi.Buttons.Page).Click();
306+
_root.Q<Button>(SampleAppUi.Buttons.TypedEvent("progression")).Click();
308307
yield return null;
309308

310309
yield return FlushAndAssertNoErrors();
@@ -347,7 +346,7 @@ public IEnumerator ReInit_AfterShutdown_AcceptsTrack()
347346
Assert.Greater(SampleAppTestHelpers.CountLogEntriesAtLevel(_root, LogLevels.Ok), 1,
348347
"expected a second INIT@Ok row after re-init");
349348

350-
_root.Q<Button>(SampleAppUi.Buttons.Page).Click();
349+
_root.Q<Button>(SampleAppUi.Buttons.TypedEvent("progression")).Click();
351350
yield return null;
352351

353352
yield return FlushAndAssertNoErrors();
@@ -368,7 +367,7 @@ public IEnumerator SetConsent_AnonymousFromFull_StripsUserIdFromTrack()
368367

369368
yield return SetConsentVia(SampleAppUi.Buttons.ConsentAnon);
370369

371-
_root.Q<Button>(SampleAppUi.Buttons.Page).Click();
370+
_root.Q<Button>(SampleAppUi.Buttons.TypedEvent("progression")).Click();
372371
yield return null;
373372

374373
yield return FlushAndAssertNoErrors();
@@ -467,7 +466,7 @@ public IEnumerator Init_WithBaseUrlOverride_FlushReportsOk()
467466
root.Q<TextField>(SampleAppUi.Setup.BaseUrl).value = SampleAppUi.SandboxBaseUrl;
468467
});
469468

470-
_root!.Q<Button>(SampleAppUi.Buttons.Page).Click();
469+
_root!.Q<Button>(SampleAppUi.Buttons.TypedEvent("progression")).Click();
471470
yield return null;
472471

473472
yield return FlushAndAssertNoErrors();
@@ -499,7 +498,7 @@ public IEnumerator Init_WithCustomFlushSize_FlushReportsOk()
499498
root.Q<TextField>(SampleAppUi.Setup.FlushSize).value = "5";
500499
});
501500

502-
_root!.Q<Button>(SampleAppUi.Buttons.Page).Click();
501+
_root!.Q<Button>(SampleAppUi.Buttons.TypedEvent("progression")).Click();
503502
yield return null;
504503

505504
yield return FlushAndAssertNoErrors();
@@ -515,7 +514,7 @@ public IEnumerator Init_WithDebugDisabled_FlushReportsOk()
515514
root.Q<Toggle>(SampleAppUi.Setup.Debug).value = false;
516515
});
517516

518-
_root!.Q<Button>(SampleAppUi.Buttons.Page).Click();
517+
_root!.Q<Button>(SampleAppUi.Buttons.TypedEvent("progression")).Click();
519518
yield return null;
520519

521520
yield return FlushAndAssertNoErrors();
@@ -524,13 +523,13 @@ public IEnumerator Init_WithDebugDisabled_FlushReportsOk()
524523
[UnityTest]
525524
public IEnumerator MultiEvent_SingleFlush_NoErrors()
526525
{
527-
// Five page Tracks queued up, single Flush. Exercises queue
526+
// Five Tracks queued up, single Flush. Exercises queue
528527
// batching + gzip + multi-event payload serialisation under IL2CPP.
529528
yield return LoadAndInit();
530529

531530
for (var i = 0; i < 5; i++)
532531
{
533-
_root!.Q<Button>(SampleAppUi.Buttons.Page).Click();
532+
_root!.Q<Button>(SampleAppUi.Buttons.TypedEvent("progression")).Click();
534533
yield return null;
535534
}
536535

@@ -609,14 +608,14 @@ public IEnumerator StatusBar_QueueSizeIncrementsAfterTrack()
609608
{
610609
// Init auto-fires session_start + game_launch so the queue is
611610
// already non-zero by the time the status label paints. Capture
612-
// the baseline and assert btn-page bumps it by at least one.
611+
// the baseline and assert a progression Track bumps it by at least one.
613612
yield return LoadAndInit();
614613
yield return null;
615614

616615
var queueLabel = _root!.Q<Label>(SampleAppUi.StatusBar.Queue);
617616
int.TryParse(queueLabel.text, out var baseline);
618617

619-
_root.Q<Button>(SampleAppUi.Buttons.Page).Click();
618+
_root.Q<Button>(SampleAppUi.Buttons.TypedEvent("progression")).Click();
620619
yield return null;
621620
var deadline = Time.realtimeSinceStartup + 2f;
622621
while (Time.realtimeSinceStartup < deadline)
@@ -628,7 +627,7 @@ public IEnumerator StatusBar_QueueSizeIncrementsAfterTrack()
628627

629628
int.TryParse(queueLabel.text, out var finalCount);
630629
Assert.Greater(finalCount, baseline,
631-
$"queue should grow past baseline {baseline} after btn-page Track; got {finalCount}");
630+
$"queue should grow past baseline {baseline} after progression Track; got {finalCount}");
632631
}
633632

634633
[UnityTest]

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

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,6 @@ internal static class Setup
4848
internal static class Buttons
4949
{
5050
internal const string Init = "btn-init";
51-
internal const string Page = "btn-page";
5251
internal const string Flush = "btn-flush";
5352
internal const string Reset = "btn-reset";
5453
internal const string Shutdown = "btn-shutdown";
@@ -152,7 +151,6 @@ internal static string TypedEventField(string specName, string fieldKey) =>
152151
internal static class LogLabels
153152
{
154153
internal const string Init = "INIT";
155-
internal const string Page = "page()";
156154
internal const string Flush = "flush()";
157155
internal const string Reset = "reset()";
158156
internal const string Shutdown = "shutdown()";

0 commit comments

Comments
 (0)