Skip to content
SegmentStream/ Docs

Loading documentation…

↑ ↓ to navigate  ↵ to open  Esc to close
Website Console
Section menu

@segmentstream/web-tracker

9 public exports from @segmentstream/web-tracker.

Public exports

CAMPAIGN_KEYS

Campaign and advertising click parameters kept in page URLs and `payload.context.campaign`.

const CAMPAIGN_KEYS: readonly [
    "utm_source",
    "utm_medium",
    "utm_campaign",
    "utm_id",
    "utm_term",
    "utm_content",
    "gclid",
    "gbraid",
    "wbraid",
    "msclkid",
    "fbclid",
    "dclid",
    "ttclid",
    "li_fat_id",
    "twclid",
    "rdt_cid"
]
Sdk

The producer recorded in `payload.context.sdk`.

type Sdk = {
    name: string;
    version: string;
};
WebEvent

One event as a SegmentStream event stream accepts it, alone or in a `{ batch }` of up to 100.

type WebEvent<Type extends string = string> = {
    event_id: string;
    event_time: string;
    event_type: Type;
    schema_version: number;
    payload: Record<string, unknown>;
};
campaign
function campaign(url: URL): Record<string, string>;
cookieValue

A cookie's value from a `document.cookie` string or a `Cookie` header; empty values are absent.

function cookieValue(cookies: string | null | undefined, name: string): string | null;
querySnapshot

Preserve query evidence, redacting sensitive values in both representations.

function querySnapshot(url: URL): {
    query_raw: string;
    query_params: {
        [k: string]: string;
    };
};
sanitizeUrl

Keep only campaign parameters on pages; referrers never include query or hash.

function sanitizeUrl(value: string, referrer?: boolean): string | null;