Skip to content

📈 Open source, privacy-first web analytics — a cookie-less Google Analytics alternative with built-in error tracking and performance monitoring. Self-host it or use our cloud. Get started for free!

add support for profileId parameter

Blue Moused87931c9c184
diff --git a/src/Lib.ts b/src/Lib.ts
index 8608b6ddd..102f50357 100644
--- a/src/Lib.ts
+++ b/src/Lib.ts
@@ -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 {
@@ -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
@@ -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
@@ -294,6 +306,7 @@ export class Lib {
ca: getUTMCampaign(),
te: getUTMTerm(),
co: getUTMContent(),
+ profileId: event.profileId ?? this.options?.profileId,
}
await this.sendRequest('custom', data)
}
@@ -425,6 +438,7 @@ export class Lib {
ca: getUTMCampaign(),
te: getUTMTerm(),
co: getUTMContent(),
+ profileId: this.options?.profileId,
...payload,
}