feat(phase-16.3): light up anonId unique-listener layer

Mint a first-party localStorage anonId, thread it onto play/share beacons,
persist it via EventController, and add all-time distinct-listener counts
(site/track/release). Storage columns + indexes already existed from 16.1.
This commit is contained in:
daniel-c-harvey
2026-06-19 14:37:55 -04:00
parent ebbaa3f84f
commit c084efa78e
16 changed files with 680 additions and 12 deletions
@@ -30,6 +30,7 @@ public partial class SharePopover : ComponentBase, IDisposable
[Inject] public required NavigationManager Navigation { get; set; }
[Inject] public required IJSRuntime JS { get; set; }
[Inject] public required ShareTracker ShareTracker { get; set; }
[Inject] public required IAnonIdProvider AnonId { get; set; }
private bool IsReleaseMode => ReleaseEntryKey is not null;
@@ -65,7 +66,15 @@ public partial class SharePopover : ComponentBase, IDisposable
? EmbedSnippetBuilder.ForRelease(Navigation.BaseUri, ReleaseEntryKey!)
: EmbedSnippetBuilder.ForTrack(Navigation.BaseUri, EntryKey!);
private void Toggle() => _open = !_open;
private async Task Toggle()
{
_open = !_open;
// Warm the anon-id cache when the popover opens (wave 16.3) so a copy-share fired moments later
// reads a populated AnonId.Current. Idempotent and best-effort — if it fails the share simply
// carries no anonId. Opening is interactive, so the localStorage interop is available here.
if (_open)
await AnonId.EnsureLoadedAsync();
}
private void Close() => _open = false;