SDKsWeb Tracker SDKTypeScript
@segmentstream/web-tracker
9 public exports from @segmentstream/web-tracker.
Public exports
ANONYMOUS_ID_COOKIE
The cookie that holds the visitor's anonymous ID unless a caller names another.
const ANONYMOUS_ID_COOKIE = "ss_aid"
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"
]Consent
A visitor's analytics consent, recorded as `payload.context.consent` when a site handles consent.
type Consent = "granted" | "denied" | "pending";
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;