Skip to content

trackkit / index / PageContext

Interface: PageContext

Defined in: types.ts:126

Page-level context computed by the facade at send-time.

This is the canonical representation of “where and when” an event happened. Providers derive their own payloads from this.

Properties

url

url: string

Defined in: types.ts:133

Normalised, masked URL to report (pathname + search + hash).

Any PII-stripping and hash/router normalisation should already have been applied (see FacadeOptions.urlTransform).


title?

optional title: string

Defined in: types.ts:136

Current document title, if available.


hostname?

optional hostname: string

Defined in: types.ts:139

Hostname of the page (e.g. "example.com").


referrer?

optional referrer: string

Defined in: types.ts:149

Referrer to report.

  • First pageview: the external referrer (e.g. document.referrer) after your policy has stripped/normalised it.
  • SPA navigations: previous same-origin URL, or '' if none or if your policy removes it.

userId?

optional userId: string

Defined in: types.ts:157

Application-level user identifier.

This is optional; many providers don’t support user IDs in a privacy-preserving way. If you set it, prefer a stable, anonymised ID.


viewportSize?

optional viewportSize: object

Defined in: types.ts:160

Viewport size in CSS pixels at send-time.

width

width: number

height

height: number


screenSize?

optional screenSize: object

Defined in: types.ts:163

Screen size in CSS pixels at send-time.

width

width: number

height

height: number


language?

optional language: string

Defined in: types.ts:170

Browser language at send-time.

Typically derived from navigator.language.


timestamp?

optional timestamp: number

Defined in: types.ts:177

When the facade created this context (ms since epoch).

Used by some providers and internal diagnostics for ordering and timing.


meta?

optional meta: Readonly<Record<string, unknown>>

Defined in: types.ts:185

Optional bag for future, provider-agnostic additions.

Avoid PII; keep this small to preserve a stable ABI. Provider-specific fields should not go here – they belong in the provider payload.

Released under the MIT License.