Skip to content

feat(widget): instrument event surfaces + evaluate TelemetryDeck #51

Description

@Ardnived

Summary

Analytics companion to the event-surfaces redesign (companion redesign ticket — linked in a follow-up comment). Spec §9 ("Analytics — instrument from day one — no behavioral data exists yet", Event Display & Registration Surfaces Redesign, 2026-07-14 v2) requires named product events with per-event parameters and a registration funnel segmented by event type and origin. The widget currently ships Fathom pageviews only (src/App.tsx:106-128, fathom-client@^3.7.2, gated on VITE_FATHOM_ID + a non-localhost primary domain from the client record's allowedDomains), and Fathom events are name-only — so §9 as written is unimplementable on the current stack. This ticket owns two phases: (1) the analytics-stack decision — explicitly deferred into this ticket, with migrating to TelemetryDeck as the requested exploration — and (2) the §9 instrumentation behind a vendor-agnostic track() seam.

(Note: spec §12.4 says to reconcile event names with "the existing GA4/Firebase schema conventions" — that is wrong for this repo. There is no GA4/Firebase; only Fathom pageviews.)

Phase 1 — stack decision (blocks Phase 2 implementation)

Why a decision is needed

§9 requires common params on every event — event_id, event_type (derived), is_online, status_state, origin — and the core funnel event_panel_view → register_start → register_complete segmented by event_type and origin. Fathom's event API is trackEvent(name, { _value }): an event name plus one optional monetary value in cents — no custom properties (verified 2026-07-14: https://usefathom.com/docs/events/overview). Meeting §9 on Fathom would mean encoding params into event names (register_complete__course__embed_example_org__…) — a cardinality explosion that makes funnels and segmentation unusable.

Hard constraints (any choice must satisfy all)

  • The widget runs embedded in third-party host pages: the tool must be cookieless and must not require a consent banner. GDPR posture is a hard requirement, not a preference.
  • No secrets in the client bundle — public app IDs only, via VITE_* env vars (the bundle is public).
  • Bundle-size impact acceptable for an embeddable widget.
  • Embed vs native conversions must be separable (§9 MUST).

Candidate (a) — migrate to TelemetryDeck (stakeholder-requested exploration)

Findings, verified 2026-07-14:

  • SDK: @telemetrydeck/sdk v2.0.4 — zero dependencies, ~2.4 KB minified / ~1.1 KB gzipped — negligible for the widget. Browser-native (uses SubtleCrypto). Initialized with a public appID (fits a VITE_TELEMETRYDECK_APP_ID; no secret involved).
  • Custom params: signals take an arbitrary payload object — td.signal('register_complete', { event_type: 'course', origin: 'embed:example.org', … }); values are stringified (floatValue for numerics). Payload keys become filterable dimensions in the dashboard. Covers §9's param set 1:1.
  • Funnels/segmentation: native Funnel insight type with a per-step filter editor (each step filters on signal type and/or any payload key), so the §9 funnel segmented by event_type/origin is directly expressible. Caveat: funnels count unique users (each step intersects the previous ones), so a consistent per-session clientUser is needed for funnel integrity — see Phase 2.
  • Privacy/GDPR: cookieless (no cookies at all — vendor states no cookie banner is needed); user identifiers are salted + hashed on-device, then re-salted + re-hashed server-side (double hashing); the vendor's stated position is that only non-personal data is processed, placing the service outside GDPR/CCPA scope. Our side of that contract: never feed PII into clientUser or payloads.
  • Hosting/residency: usage data stored exclusively within the EU (Hetzner, Nuremberg).
  • Pricing (July 2026 update): free tier is now 50,000 signals/month for accounts created after 2026-07-01 (older accounts keep 100k); first paid plan ~9 EUR/month, with more granular tiers and auto-upgrade after two consecutive months at 100% usage. Estimate expected volume (pageviews + ~10 event types) against the 50k tier before committing.
  • Existing Fathom history: no import path for third-party historical data is documented — pageview history stays in Fathom. Keep the Fathom dashboard (or an export) as the historical baseline; TelemetryDeck starts from zero.

Candidate (b) — stay on Fathom, minimal name-only events

Define a small set of global event names (register_start, register_complete, directions_click, …) with no params. §9 coverage lost (must be documented if chosen): no event_id/event_type/is_online/status_state/origin on any event → embed-vs-native separation fails (violates a §9 MUST unless every name is doubled per origin), no funnel segmentation, no per-event drill-down; Fathom has no funnel report, so conversion analysis is manual ratio math between event totals.

Candidate (c) — run both during a transition

Both SDKs behind the seam: Fathom keeps pageview continuity, TelemetryDeck takes §9 events (+ its own pageview signal); decommission Fathom after a few weeks of volume sanity-checking. Combined bundle impact stays negligible (fathom-client is also tiny); the cost is two dashboards + two env vars for the interim.

Recommendation

Adopt (a) TelemetryDeck for events and pageviews — optionally via a short (c) parallel run to validate volumes before removing fathom-client. It is the only candidate that fully satisfies §9 within the hard constraints. The acceptance criterion is that the final decision is recorded on this issue before Phase 2 implementation starts.

Phase 2 — instrumentation (after the decision)

§9 inventory (verbatim from the spec)

Events: event_panel_view, register_start, register_complete, directions_click, calendar_add, contact_click (channel param), share_click, card_click, nearby_events_click, drawer-expansion depth.

Common params: event_id, event_type (derived, §3.2), is_online, status_state (§4.1), and origin: atlas_panel | atlas_list | embed:<domain> — embed conversions must be separable from native (MUST). card_click SHOULD carry the displayed distance bucket.

Core funnel: event_panel_view → register_start → register_complete, segmented by event_type and origin.

Notes:

  • contact_click.channel is phone-only for now (WhatsApp/email channels deferred per spec §13).
  • Drawer-expansion depth has no event name in §9 — propose drawer_expand with depth: peek | half | full, mapped from the existing DrawerStack snap ladder (80px / 300px / 0.97).

One track() seam

A single vendor-agnostic module (proposed src/lib/analytics.ts; src/config/ is fine if vendor init sits better there) exporting track(name, params) + pageview handling, so call sites never import the vendor SDK. The existing pageview dedupe pattern in src/App.tsx:106-128 (one pageview per real navigation via a lastTracked ref) is the reference and moves behind the seam.

origin derivation

  • Surface (atlas_panel vs atlas_list) comes from the call site.
  • Embed vs native: the existing standalone flag (WidgetModeContext, src/config/mode.ts) — true = standalone SPA, false = embedded <sahaj-atlas>.
  • Embed host domain is simply window.location.hostname — the widget runs inside the host page; no iframe/postMessage gymnastics.
  • Flag: §9's origin enum collapses surface and embed-ness into one value (embed:<domain> loses panel-vs-list inside embeds). If the chosen stack supports multiple params (TelemetryDeck does), SHOULD split into origin_surface (panel | list) + embed_domain (empty for native) while preserving the MUST (embed conversions separable). Record the chosen shape with the Phase 1 decision.

Enablement gate + user identifier

  • Reuse/adapt the existing gate (src/App.tsx:116-118): enabled only when the VITE_* analytics ID is set AND the client record's allowedDomains primary domain is non-localhost. TelemetryDeck also offers a testMode for dev traffic — pick one mechanism, don't ship both.
  • clientUser (if TelemetryDeck): random identifier generated in-memory per widget load — no cookie/localStorage persistence, preserving the no-consent posture. Sufficient for the single-session registration funnel (funnels count unique users). Never PII-derived.

Pageviews

Keep pageview tracking coherent with the chosen stack: either Fathom keeps pageviews during a (c) transition, or a pageview signal with the deduped path goes through the seam. No double-counting.

Sequencing

The instrumentation call sites (secondary action row, sticky register bar, ended-state "See nearby events" link, drawer snap changes, …) land with the companion redesign ticket — linked in a follow-up comment. This ticket can be implemented immediately after or alongside it: land the seam + stack + pageviews first, wire events into whichever surfaces exist at the time, and add the remaining calls as the redesigned surfaces merge.

Acceptance criteria

Phase 1:

  • TelemetryDeck evaluated against the four hard constraints; findings (incl. pricing-tier fit for expected signal volume) recorded on this issue
  • Fathom name-only fallback documented with the exact §9 coverage lost
  • Decision (a / b / c) + the origin param shape recorded on this issue before Phase 2 implementation starts
  • Fate of the existing Fathom pageview history decided (archive / export / parallel run)

Phase 2:

  • Vendor-agnostic track() seam exists; no component imports the vendor SDK directly
  • All §9 events fire with the common params; contact_click carries channel: 'phone'; card_click carries the displayed distance bucket (SHOULD)
  • Embed vs native conversions separable in the dashboard (verified with a real embed on a non-localhost host)
  • Core funnel event_panel_view → register_start → register_complete segmented by event_type and origin is reproducible in the dashboard
  • Pageview tracking migrated/kept per the decision; one pageview per real navigation (dedupe preserved); no double-counting
  • No PII in any payload or user identifier; no cookies/localStorage introduced; the enablement gate keeps localhost/dev traffic out
  • No secret in the bundle — public app ID via a VITE_* env var, documented in .claude/docs/environment.md
  • Unit tests cover the seam's param assembly (node-only lane); lint + typecheck + build pass
  • Verified in the running widget: events visible in the vendor dashboard from a standalone run and an embedded run

Files affected

  • src/lib/analytics.ts (new) — the track() seam (or src/config/analytics.ts if vendor init fits config better)
  • src/App.tsx:106-128 — replace the inline Fathom wiring with the seam; keep the dedupe + gating logic
  • package.json — add @telemetrydeck/sdk; remove fathom-client@^3.7.2 after the transition (per decision)
  • .env + .claude/docs/environment.md — new public VITE_TELEMETRYDECK_APP_ID; fate of VITE_FATHOM_ID
  • Call sites (land with the redesign ticket): src/components/organisms/EventDetails/, src/components/molecules/EventCard/, src/views/EventView/, src/views/RegistrationView/, src/views/DrawerStack/
  • Read-only dependency: src/config/mode.ts (standalone flag for origin derivation)

References

Activity

  1. Ardnived commented on Jul 14, 2026

    @Ardnived
    ContributorAuthor

    Companion tickets: the event-surfaces redesign whose surfaces this instruments is #52; the CMS-side changes are sydevs/SahajCloud#577.

  2. added theissue type on Aug 28, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Fields

    Priority

    Low

    Hold Until

    Jan 3, 2027

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions