Analytics tracking
What the TVS mini app tracks today: events, properties, identity and privacy, the funnel on the dashboard, and known limits. Facts from the code only.
Version: code on main at commit a5a17a2, read on 2026-10-15. This page lists only what the code does today. When the code does not make something clear, we write "unclear".
1. Overview
The Mini App sends small messages called "events" when the viewer does something: opens a page, signs in, opens a title, plays a video, taps "Subscribe". Most events come from the browser (the WebView in the host app). Two events come from our server. All events go to Jitsu (an event collector). Jitsu writes them into one ClickHouse table. Our dashboards read that table.
Browser (WebView) ─┐
├──► Jitsu ──► ClickHouse table `events` ──► Dashboards
Our server (s2s) ─┘ (TRUEVISION = production, /analytic, /analytic/journey,
TRUEVISION_STAGING = staging) /analytic/timing, /analytic/requests,
/1stevaluationKey facts:
- If the Jitsu settings (
NEXT_PUBLIC_JITSU_HOST,NEXT_PUBLIC_JITSU_WRITE_KEY) are not set, nothing is sent. The app works the same. - Tracking must never break the app. Send errors are ignored.
- Browser events use
keepalive, so events sent while the page or WebView closes still arrive. - Each event property becomes its own column in ClickHouse, with the same name (for example
content_id,startup_ms). Jitsu adds a new column the first time it sees a new property. - Jitsu adds its own context columns too, named with
_(for examplecontext_user_agent,context_ip). The full list of these comes from the Jitsu library, not from our code. - Times are stored in UTC. Dashboards group by day and hour in Thai time (Asia/Bangkok).
2. Identity and privacy
IDs we use
| ID | What it is | Where it lives | Lifetime |
|---|---|---|---|
viewer_id | Random ID made by the app (UUID). One per browser / WebView. | Browser localStorage, key tv-viewer | Until the app storage is cleared. "unknown" if storage is blocked. |
device_id | The host app's device ID, from the sign-in hand-off. | Sent by the host app | Set by the host. Empty when the host sends "UNKNOWN" or before sign-in. |
host_session_id | The host app's session ID, from the sign-in hand-off. | Sent by the host app | Set by the host. Empty before sign-in. |
journey_id | Random ID for one "sign-in → first video frame" journey. | Browser sessionStorage, key tv-journey | One browser tab. A new sign-in starts a new journey. |
play_id | Random ID for one playback attempt (one try to play one title / episode). | In memory | One attempt. A retry or episode change makes a new one. |
host_system | The host's source system ID from the sign-in hand-off. | Sent with the token hand-off | Per sign-in. Not used by any dashboard today. |
viewer_id is also used as the Streamer device ID when the host gives no device ID.
Cookie-free
- The app sets no cookies for tracking.
- Jitsu's own user IDs (anonymous ID cookie, user ID) are switched off (
disableUserIds: true). - Jitsu removes the last part of the viewer's IP address (
ipPolicy: "stripLastOctet") for browser events.
What is NOT collected
- No TrueID account ID. No name, email or phone number.
- No access token, partner token, auth code or PKCE verifier in any viewer event.
auth_successonly says *how* the token arrived (for examplequery:auth_token), never the value. aaa_responsenever logs a token, code or verifier.- Player error details: URL query strings are cut (they hold session tokens),
Bearer ...values and JWTs are masked, text is cut to 1,000 characters.
Privacy points to know (facts from code)
page_request(debug log, server side) stores the request's query, headers and cookies. Values whose name looks secret (matchesauth|token|secret|passw|api_key|sig|jwt|oidc|bearer|credential|verifier|code) are masked to the first 6 and last 4 characters plus length. Other headers are stored as sent. This includes the user agent and any IP headers the hosting adds (for examplex-forwarded-for), if present. Values are cut to 500 characters.- With the switch
REQUEST_LOG_FULL=1,page_requeststores secret values in full (up to 8,000 characters). The code says this is for debugging a host integration only. Whether it is on in production today cannot be seen from the code. REQUEST_LOG=0turnspage_requestoff.- Content titles are sent with content and play events.
3. Common properties
On every browser event (track and page view)
| Name | Type | Example | Where it comes from |
|---|---|---|---|
viewer_id | string | 3f2a…-… (UUID) | localStorage tv-viewer |
lang | string | th, en | 1st part of the page path /<lang>/<partner>/… |
partner | string | trueapp | 2nd part of the page path |
embedded | boolean | true | true when inside an iframe, or opened with ?embed=1 (remembered for the tab) |
host_system | string or null | source system ID | Sign-in hand-off |
device_id | string or null | host device ID | Sign-in hand-off (null if "UNKNOWN" or not signed in) |
host_session_id | string or null | host session ID | Sign-in hand-off |
journey_id | string | UUID | sessionStorage tv-journey |
Jitsu context, e.g. context_user_agent, context_ip | string | browser user agent | Added by Jitsu, not by our code. IP has its last part removed. |
timestamp, type, event, message_id | type = track or page | Added by Jitsu |
Only on content_view and play_start:
| Name | Type | Meaning |
|---|---|---|
explore_ms | number or null | Time since the first page of the journey was ready ("browsing time"). Null if no page was ready yet. |
journey_ms | number | Time since the journey started (entry). |
There is no platform property on browser events. Dashboards guess iOS / Android from context_user_agent.
On server events (aaa_response, page_request)
These do not have viewer_id, embedded, journey_id or Jitsu browser context. They carry partner, lang, device_id, host_session_id, credential_via (see section 4.6). aaa_response also has platform.
Because the main dashboard filter needs viewer_id != '', server events only show on the AAA, Journey, Timing (AAA rows), Requests and 1st evaluation views.
4. Event catalogue
19 event types in total: 16 browser track events, 1 browser page view, 2 server events. File and line references are in the Source map (Appendix).
4.1 App and navigation
| Event | Source | When it fires | Key properties |
|---|---|---|---|
page view (type = 'page') | browser | Every path change on a signed-in app page (home, series, sport, content, play, …). Not on /auth/* pages. Query changes alone do not fire it. | path — page path, no query string |
page_timing | browser | (a) Once per full page load: 1 s after load, or when the page hides, whichever comes first. (b) After each in-app page change. | path; nav_type — navigate / reload / back_forward / prerender (from the browser) or client (in-app change) or unknown; full load only: redirect_ms, ttfb_ms, response_ms, dom_ms, load_ms, hydrate_ms (React running), lcp_ms (largest paint); in-app only: route_ms (link tap → new page; null if no tap in last 15 s); both: ready_ms (journey start → first page ready, only on the first page of a journey), journey_ms |
4.2 Sign-in (auth)
| Event | Source | When it fires | Key properties |
|---|---|---|---|
auth_success | browser | A page opens with a fresh token in the URL fragment (after landing / callback hand-off). | credential_via — how the token arrived: header:<name>, query:<name>, body, login (TrueID web login), … |
auth_timing | browser | (a) Same moment as auth_success (fired just before it). (b) Fast re-entry: the landing's fast path reuses a stored token (no auth_success in this case). | credential_via; auth_path — login, fast_path_signin, gated_page, redirect, fast_reuse; total_ms (entry → page code running); page_ms (this page download + start); redirect_ms (the rest: entry page, auth hops, server); server_ms (server work, measured on server; null for fast_reuse) |
auth_error | browser | The /auth/error page is shown (sign-in failed). | code — see list below; credential_via; device_id, host_session_id (from the error URL, override the common ones) |
aaa_response | server | Each AAA / TrueApp Service answer during sign-in. Sent after the response, so it never slows sign-in. | See section 5.2 |
auth_error code values (from AuthErrorCode): missing_credentials, unknown_partner, invalid_state, trueapp_token, request_code, exchange, or aaa_<code> (AAA's own code or the binding page's error value, passed through). The full list of aaa_* values is set by AAA, so it is unclear from our code.
4.3 Discover (content)
| Event | Source | When it fires | Key properties |
|---|---|---|---|
content_view | browser | A title detail page opens (/content/<id>). Same props within 2 s are counted once. | content_id; kind — livetv (sport / live) or movie (series, movies); title; live (event is live now); upcoming (not started / not released yet); plus explore_ms, journey_ms |
Sport cards can open the player directly without a detail page. So there is no content_view for those. The funnel counts a sport list page view instead (section 6).
4.4 Play
Most play events share these "play base" properties: play_id, content_id, episode_id (null for non-series), kind, title, preview (true when the source is a free preview), drm (L1 / L3 / none, see 5.1). Events from the player shell (play_abandon, playback_denied, overlay_view, play_error stage resolve, play_warning stages licence_retry / refresh, player purchase_click) carry content_id, episode_id, kind, title, drm but not preview; only play_abandon adds play_id.
| Event | Source | When it fires | Key properties |
|---|---|---|---|
play_start | browser | First video frame of a play attempt (once per attempt). | play base; live; ttff_ms (player opened → first frame); startup_ms (source load → first frame); play_to_frame_ms (last play tap → first frame); resolve_ms (Streamer lookup time); player_created_ms, source_load_ms, manifest_ms, licence_request_ms, licence_ok_ms (ms since player opened; player_created_ms = 0 means the player was already warm); licence_requests (count; >1 means a retry); explore_ms, journey_ms |
play_heartbeat | browser | Every 30 s (HEARTBEAT_SECONDS), only if the video is playing at that moment. | play base; position (seconds) |
play_pause | browser | Player paused. | play base; position |
play_end | browser | Video played to the end. | play base; position |
rebuffer | browser | (a) A stall after the first frame ends. (b) A seek finishes. Open ones are closed when the player unmounts or the page hides. Stalls before the first frame are not counted (they are part of startup). | play base; cause — stall or seek; duration_ms; ended_by — resume, pause (stall only), exit; position |
play_abandon | browser | The viewer leaves (player closed or page hidden) before the first frame, while the video is still loading. Not at a sign-in wall, plan wall, error or live countdown. Waits under 250 ms are ignored. | play_id; content props; stage — lookup (Streamer lookup running) or player (source loading); waited_ms; the same step marks as play_start |
play_error | browser | Playback failed. Only the first error per title within 5 s is sent. | See 5.1. stage — resolve, load, player |
play_warning | browser | A non-fatal or recovered problem. | See 5.1. stage — licence_retry, refresh, bitmovin, freeze, fullscreen, orientation_lock |
playback_denied | browser | The playback lookup ends at a wall instead of a stream (once per request). | content props; reason — login (no / bad token), expired (token expired mid-session), not_entitled (no package); upcoming; and the lookup's code, http_status, message, detail when known |
overlay_view | browser | A player overlay is shown. | content props; overlay — preview-ended or open-app |
Notes from code:
- Watch time on the dashboard = number of
play_heartbeat× 30 s. The 30 s timer starts when the player is set up, not at the first frame, so this is an estimate. - In Streamer mode (the production setup), the Streamer source never sets
previeworrequiresApp. Sopreviewis always false andoverlay_viewis expected not to fire there. These only happen with the older/api/playbackpath.
4.5 Payment
| Event | Source | When it fires | Key properties |
|---|---|---|---|
purchase_click | browser | The viewer taps a buy / subscribe button. | content_id; source — where the tap was: detail (detail page), gate (not-entitled wall in the player), preview-ended, open-app, player; target — the offer page URL (without the sign-in token); player taps also carry episode_id, kind, title, drm |
The target is always a TrueVisions offer page on the account site (<lang> is th or en):
kind = livetv(sport, Sports 499) →https://account.truevisions.co.th/<lang>/package/NOW_SPORT/offer/NOW_SP_1CCU?<UTM>- other (ENT 99) →
https://account.truevisions.co.th/<lang>/package/NOWTM_0_1/offer/NOW_TM_99_1?<UTM>
The tab that opens signs the viewer in to the account site with their token first. The token is never in target.
UTM (same on every link, quoted from src/lib/embed.ts):
utm_source=internal_truemoveh_app-banner&utm_medium=app-banner&utm_campaign=app_miniapp_2026Embedded, the app also posts a subscribe message to the host with opened: true/false (did the mini-app open the offer; false only when an iframe could not open a new window). This opened value is not in the tracking event.
4.6 Debug and operations (server side)
| Event | Source | When it fires | Key properties |
|---|---|---|---|
page_request | server (from proxy.ts) | Every page request on a viewer path /th/<partner>/… or /en/<partner>/… (auth routes included). Not for in-app (RSC) fetches or prefetches. Not for /analytic. | path, partner, lang, req_method; credential_via — header:<name>, query:<name>, body (any POST), cookie:<name>, or empty = no token; req_query, req_headers, req_cookies (JSON text, secrets masked, see section 2); device_id (from ?device_id or trueapp-device-id cookie); host_session_id (from ?session_id or trueapp-session-id cookie) |
aaa_response | server | See 5.2. | See 5.2 |
Timing data is not a separate system. It is carried in auth_timing, page_timing, play_start, play_abandon, content_view and aaa_response (duration_ms), described above.
5. Property dictionaries
5.1 Playback errors and warnings
| Property | Type | Meaning | |||
|---|---|---|---|---|---|
stage | string | Where it failed. play_error: resolve (Streamer / playback lookup), load (player could not load the source), player (Bitmovin error event). play_warning: licence_retry (licence refused; one new Streamer session, at most once per minute), refresh (background Streamer refresh failed), bitmovin (Bitmovin warning, once per code per player), freeze (video frozen with data buffered; app caps quality and seeks), fullscreen / orientation_lock (browser refused; once per page load). | |||
code | string | Machine code. player / load / bitmovin: Bitmovin code (e.g. 2006, 2009, 2013, 1208, 1210). resolve / refresh / playback_denied: streamer_<code> (Streamer API code, e.g. streamer_14168 = no package, streamer_12005 = not found), Streamer library codes (e.g. TOKEN_FETCH_FAILED, HTTP_ERROR), api_streamer, api_playback, network, exception, fairplay_no_certificate, not-found, unconfigured, no_token. | |||
name | string | Bitmovin error / warning name (e.g. DRM_NO_KEY_SYSTEM). | |||
message | string | Error text from the SDK / API (not the text shown to the viewer). For licence_retry and freeze, a short text written by our code. | |||
detail | string | Extra error data, compacted: URL queries cut, bearer tokens and JWTs masked, max 1,000 chars. For DRM errors (Bitmovin codes 2000–2999 at stage player) the browser's DRM support is added: `eme=yes widevine=yes | no fairplay=yes | no webkit=yes | no (or eme=no webkit=…). For fullscreen / orientation_lock: activation=<bool> fullscreen=<bool>`. |
http_status | number | HTTP status of the failing request, when there was one. | |||
drm | string | L1 = DRM source without an SD cap; L3 = Widevine software level, video capped at 576p; none = no DRM. Note: a FairPlay (iOS) source has no SD cap, so it is also labelled L1. | |||
before_start | boolean | Only on stage player: true if the error came before the first frame. Dashboard counts these as "start failures". | |||
position | number | Playback position in seconds. |
Not every event has every property. For example play_error stage load has content_id and drm but no play_id, episode_id, kind or title. bitmovin and freeze warnings carry only content_id. fullscreen / orientation_lock warnings carry no content ID.
5.2 aaa_response
| Property | Type | Meaning |
|---|---|---|
op | string | Which call. request_code (AAA Get Partner Request Code), exchange_token (AAA exchange token), binding_result (what the AAA binding page sent back to our callback), login_result (same, after TrueID web login), trueapp_guest_token (TrueApp Service token request), trueapp_login_partner (TrueApp Service login for partner). |
outcome | string | ok, bind_required (AAA says the account must be bound first; only request_code), error, transport_error (no HTTP answer). |
http_status | number | HTTP status. 0 when there was no HTTP call (binding / login results) or no answer. |
aaa_code | string | AAA / TrueApp error code. "0" on success for some ops; empty when unknown. For binding_result / login_result: the callback's error value. |
aaa_message | string | AAA / TrueApp error message (max 300 chars). |
duration_ms | number | How long the call took. 0 for binding / login results. |
partner, lang, platform, credential_via, device_id, host_session_id | string | Context of the sign-in. device_id is empty if the host sent "UNKNOWN". |
6. Funnel on the dashboard today (/analytic)
Counts unique viewer_id that reached each step in the selected time window (24 h / 7 d / 30 d / 90 d, optional partner filter). Steps are not required to happen in order.
| Step | Rule (exact, from analytics-db.ts) |
|---|---|
| Auth | event = 'auth_success' |
| Discover (any) | Series rule OR Sport rule |
| Discover – series | (event = 'content_view' AND kind != 'livetv') OR (type = 'page' AND path matches '/(series|thevoice)(/|$)') |
| Discover – sport | (event = 'content_view' AND kind = 'livetv') OR (type = 'page' AND path matches '/sport(/|$)') |
| Play | event = 'play_start' |
| Payment | event = 'purchase_click' |
Base filter on all main dashboard numbers: viewer_id != '' (so server events are left out) and the partner filter.
Other dashboard numbers built from the same events: viewers, page views, plays, watch minutes (play_heartbeat × 30 / 60), purchase clicks, denied, errors, sign-ins, sign-in errors; top content; partner × Web/Embedded table; "why playback did not start" (playback_denied reason, play_error stage + code); QoE (startup p50/p90, rebuffer ratio = stall time / (watch time + stall time), abandon %); AAA responses table; player errors.
Other pages:
| Page | Reads |
|---|---|
/analytic/journey | All events for one device_id, viewer_id, host_session_id or journey_id, browser and server together |
/analytic/timing | Step times p50 / p90 from auth_timing, aaa_response duration_ms, page_timing, content_view, play_start, play_abandon |
/analytic/requests | page_request |
/1stevaluation | play_error (codes 2006, 2009, 2013, 1208/1210 with CDN 404 or 400/415) and aaa_response errors (binding_result, trueapp_login_partner). Open without password. /analytic* needs a password. |
7. Known gaps and limits (facts from code)
- Purchases are not tracked. The sale happens on truevisions.co.th. We only track the tap (
purchase_click). Conversion can only come from TrueVisions' own analytics, using the UTM tags. - UTM has no partner and no title. All links use the same UTM:
utm_source=internal_truemoveh_app-banner&utm_medium=app-banner&utm_campaign=app_miniapp_2026. The sameutm_sourceis used for every partner (TrueApp, others). Nothing in the UTM tells which partner, title or button (source) led to the sale. - "Payment" in the funnel means a tap, not a payment. And we do not record if the sales page really opened (
openedis only sent to the host, not to tracking). - "Auth" in the funnel counts only
auth_success. A fast re-entry with a stored token (auth_path = fast_reuse) and a page reload with a stored token do not sendauth_success. So signed-in viewers can be missing from the Auth step. - Funnel steps are not ordered. A viewer who played but whose sign-in was before the time window still counts in Play, not in Auth.
- Sport cards skip the detail page, so sport discovery uses list page views, not
content_view. - Watch time is an estimate: heartbeats every 30 s while playing; the timer is not aligned to the first frame.
viewer_idis per browser storage. Clearing the WebView storage makes a new viewer. One person on two devices = two viewers. There is no account-level ID (by design).- No platform property on browser events. iOS / Android is guessed from the user agent text.
- Android TrueApp WebView DRM: error
2006 DRM_NO_KEY_SYSTEMwitheme=yes widevine=noindetail./1stevaluationstates the TrueApp Android WebView does not allow Widevine (protected media), and the fix is on TrueApp's side. These viewers show asplay_error, not as plays. - Error de-duplication: only the first
play_errorper title within 5 s; Bitmovin warnings once per code per player; fullscreen warnings once per page load. Counts are "failures", not raw SDK events. - Short exits are ignored:
play_abandonunder 250 ms is dropped. Exits at a wall, error or countdown are not abandons. - Overlay and preview events do not fire in Streamer mode (production), because the Streamer source sets no
preview/requiresApp. - Not tracked at all today: episode picks, audio / subtitle / quality changes, close (X) button, sign-out, search, host bridge messages (
open-content,sign-in,open-app, etc.). - New properties need a column. Jitsu adds a column the first time a property is seen; the dashboard adds some columns up front. A query can fail with "unknown column" until the first such event arrives.
- Tracking is off in any environment without the Jitsu settings.
page_requestis a debug log and can hold personal data in headers (IP headers if present, user agent), and full tokens ifREQUEST_LOG_FULL=1.
Appendix: Source map
Paths are relative to the repo root.
| What | File:line |
|---|---|
Event name list (AnalyticsEvent) | src/lib/analytics.ts:22-42 |
HEARTBEAT_SECONDS = 30 | src/lib/analytics.ts:47 |
| Jitsu client, privacy settings, keepalive | src/lib/analytics.ts:51-64 |
viewer_id (tv-viewer) | src/lib/analytics.ts:67-78 |
Common properties (baseProps) | src/lib/analytics.ts:80-98 |
explore_ms / journey_ms on content_view, play_start | src/lib/analytics.ts:106-116 |
Page view (trackPage) | src/lib/analytics.ts:118-122, called at src/components/partner/nav-tracker.tsx:15 |
TrackEvent component (2 s de-dupe) | src/components/track-event.tsx:15-24 |
content_view | src/app/[lang]/[partner]/(app)/content/[id]/page.tsx:109-112 |
auth_error | src/app/[lang]/[partner]/auth/error/page.tsx:70-73 |
AuthErrorCode values | src/lib/auth/types.ts:48-55 |
auth_timing | src/components/partner/auth-context.tsx:75-94 (calls at 132, 153) |
auth_success | src/components/partner/auth-context.tsx:135 |
page_timing | src/components/partner/page-timing.tsx:43, 65-77 |
| Journey / timing helpers, play marks | src/lib/timing.ts:88-165 |
play_start, play_heartbeat, play_pause, play_end, rebuffer, play_error (player) | src/components/player/player-controls.tsx:300-417 (lines 315, 320, 336, 362, 364, 382, 384, 388) |
play_warning licence_retry / refresh | src/components/player/player-shell.tsx:334, 367 |
drm label (L1 / L3 / none) | src/components/player/player-shell.tsx:312 |
play_error resolve, playback_denied | src/components/player/player-shell.tsx:387-403 |
overlay_view | src/components/player/player-shell.tsx:405 |
play_abandon | src/components/player/player-shell.tsx:420-436 |
purchase_click (player) | src/components/player/player-shell.tsx:481-485 |
purchase_click (detail) | src/components/miniapp/purchase-link.tsx:32 |
play_warning bitmovin / freeze | src/components/player/bitmovin-player.tsx:257, 296 |
play_error load | src/components/player/bitmovin-player.tsx:345-354 |
play_warning fullscreen / orientation_lock | src/lib/player-fullscreen.ts:87-97 |
| Error de-dupe, detail masking, HTTP status | src/lib/playback/diag.ts:24-63 |
eme=… DRM check | src/lib/playback/widevine-level.ts:13-30 |
| Streamer diag codes | src/lib/playback/streamer.ts:60-175 |
aaa_response sender | src/lib/auth/aaa-log.ts:34-74 |
aaa_response callers | src/lib/auth/aaa.ts:108, 171; src/lib/auth/callback.ts:139; src/lib/auth/trueapp-service.ts:74 |
page_request sender, masking rules | src/lib/request-log.ts:15-92 |
page_request caller, credential_via | src/proxy.ts:48-55, 97 |
PURCHASE_UTM, purchaseUrl() | src/lib/embed.ts:69-77 |
| Dashboard base filter, Bangkok time, heartbeat | src/lib/analytics-db.ts:47-59 |
| Funnel rules | src/lib/analytics-db.ts:200-217 |
| QoE rules | src/lib/analytics-db.ts:313-400 |
| AAA table | src/lib/analytics-db.ts:405-437 |
| Columns added up front | src/lib/analytics-db.ts:449-480 |
/1stevaluation cases | src/lib/analytics-db.ts:561-593; src/app/1stevaluation/page.tsx:84-117 |
| Journey, requests, timing queries | src/lib/analytics-db.ts:635-875 |
/analytic password gate | src/proxy.ts:57-85 |