Skip to content
This repository was archived by the owner on Feb 15, 2026. It is now read-only.
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions src/Lib.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,12 @@ export interface LibOptions {

/** Set a custom URL of the API server (for selfhosted variants of Swetrix). */
apiURL?: string

/**
* Optional profile ID for long-term user tracking.
* If set, it will be used for all pageviews and events unless overridden per-call.
*/
profileId?: string
}

export interface TrackEventOptions {
Expand All @@ -45,6 +51,9 @@ export interface TrackEventOptions {
meta?: {
[key: string]: string | number | boolean | null | undefined
}

/** Optional profile ID for long-term user tracking. Overrides the global profileId if set. */
profileId?: string
}

// Partial user-editable pageview payload
Expand All @@ -63,6 +72,9 @@ export interface IPageViewPayload {
meta?: {
[key: string]: string | number | boolean | null | undefined
}

/** Optional profile ID for long-term user tracking. Overrides the global profileId if set. */
profileId?: string
}

// Partial user-editable error payload
Expand Down Expand Up @@ -294,6 +306,7 @@ export class Lib {
ca: getUTMCampaign(),
te: getUTMTerm(),
co: getUTMContent(),
profileId: event.profileId ?? this.options?.profileId,
}
await this.sendRequest('custom', data)
}
Expand Down Expand Up @@ -425,6 +438,7 @@ export class Lib {
ca: getUTMCampaign(),
te: getUTMTerm(),
co: getUTMContent(),
profileId: this.options?.profileId,
...payload,
}

Expand Down