@faststats/web 0.13.1 → 0.13.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,4 +1,3 @@
1
- //#region src/extensions.d.ts
2
1
  type ExtensionHooks = {
3
2
  pageChange: {
4
3
  url: string;
@@ -40,5 +39,4 @@ interface AnalyticsExtension {
40
39
  type ExtensionCleanup = (options: {
41
40
  discard: boolean;
42
41
  }) => void;
43
- //#endregion
44
42
  export { ExtensionHook as a, ExtensionHandler as i, AnalyticsExtensionContext as n, ExtensionHooks as o, ExtensionCleanup as r, AnalyticsExtension as t };
@@ -1,5 +1,5 @@
1
- import { o as getStorageItem, s as setStorageItem, t as createId } from "./session-manager-VM5RZj9H.js";
2
- //#region src/utils/identifiers.ts
1
+ import { o as getStorageItem, s as setStorageItem, t as createId } from "./session-manager-DBWYTyfd.js";
2
+ // src/utils/identifiers.ts
3
3
  const key = (siteKey) => `faststats_anon_id_${siteKey}`;
4
4
  /** The visitor's persisted anonymous ID, or "" when it cannot be stored. */
5
5
  function getAnonymousId(siteKey, cookieless = false) {
@@ -12,5 +12,4 @@ function getAnonymousId(siteKey, cookieless = false) {
12
12
  function resetAnonymousId(siteKey, cookieless = false) {
13
13
  return !cookieless && setStorageItem("localStorage", key(siteKey), null) ? getAnonymousId(siteKey) : "";
14
14
  }
15
- //#endregion
16
15
  export { resetAnonymousId as n, getAnonymousId as t };
@@ -1,4 +1,4 @@
1
- //#region src/extensions.ts
1
+ // src/extensions.ts
2
2
  /** Runs a built-in tracker with the client's settings and page lifecycle. */
3
3
  function trackerExtension(name, create, hook) {
4
4
  return {
@@ -76,8 +76,7 @@ var ExtensionHost = class {
76
76
  }
77
77
  }
78
78
  };
79
- //#endregion
80
- //#region src/utils/api-urls.ts
79
+ // src/utils/api-urls.ts
81
80
  function resolveBaseUrl(baseUrl) {
82
81
  return baseUrl?.replace(/\/+$/, "") || "https://metrics.faststats.dev";
83
82
  }
@@ -139,8 +138,7 @@ function getPageContext(includeHash = false) {
139
138
  }
140
139
  return ctx;
141
140
  }
142
- //#endregion
143
- //#region src/utils/send-data.ts
141
+ // src/utils/send-data.ts
144
142
  async function sendData(options) {
145
143
  const { url, data, contentType = "application/json", debug = false, debugPrefix = "[Analytics]", useBeacon = true, keepalive = true, settleRejected } = options;
146
144
  const log = (...details) => {
@@ -173,5 +171,4 @@ async function sendData(options) {
173
171
  return false;
174
172
  }
175
173
  }
176
- //#endregion
177
174
  export { resolveBaseUrl as a, trackerExtension as c, getPageContext as i, URLS as n, sanitizeUrl as o, getClientContext as r, ExtensionHost as s, sendData as t };
@@ -1,4 +1,4 @@
1
- //#region src/utils/storage.ts
1
+ // src/utils/storage.ts
2
2
  function getStorageItem(name, key) {
3
3
  try {
4
4
  return globalThis[name]?.getItem(key) ?? null;
@@ -18,8 +18,7 @@ function setStorageItem(name, key, value) {
18
18
  return false;
19
19
  }
20
20
  }
21
- //#endregion
22
- //#region src/utils/session-manager.ts
21
+ // src/utils/session-manager.ts
23
22
  const IDLE_MS = 18e5;
24
23
  const MAX_AGE_MS = 864e5;
25
24
  const SESSION_KEY = "faststats_session_";
@@ -112,5 +111,4 @@ function onSessionRotated(siteKey, cookieless, listener) {
112
111
  if (!set.size) listeners.delete(key);
113
112
  };
114
113
  }
115
- //#endregion
116
114
  export { touchActivity as a, resetSession as i, getSessionContext as n, getStorageItem as o, onSessionRotated as r, setStorageItem as s, createId as t };
package/dist/error.d.ts CHANGED
@@ -1,5 +1,4 @@
1
- import { t as AnalyticsExtension } from "./chunks/extensions-BfubKIzk.js";
2
- //#region src/error.d.ts
1
+ import { t as AnalyticsExtension } from "./chunks/extensions-C2k9Im6I.js";
3
2
  export type ErrorEntry = {
4
3
  error: string;
5
4
  message?: string;
@@ -42,5 +41,4 @@ export default class ErrorTracker {
42
41
  /** Returns true when the error was already queued. */
43
42
  private add;
44
43
  private flush;
45
- }
46
- //#endregion
44
+ }
package/dist/error.js CHANGED
@@ -1,9 +1,9 @@
1
- import { a as resolveBaseUrl, c as trackerExtension, i as getPageContext, n as URLS, t as sendData } from "./chunks/send-data-B7P3f5PT.js";
2
- import { n as getSessionContext } from "./chunks/session-manager-VM5RZj9H.js";
3
- import { t as getAnonymousId } from "./chunks/identifiers-3X8XI1pD.js";
4
- //#region src/error.ts
1
+ import { a as resolveBaseUrl, c as trackerExtension, i as getPageContext, n as URLS, t as sendData } from "./chunks/send-data-BCVUgwry.js";
2
+ import { n as getSessionContext } from "./chunks/session-manager-DBWYTyfd.js";
3
+ import { t as getAnonymousId } from "./chunks/identifiers-BHYhM7DM.js";
4
+ // src/error.ts
5
5
  const SDK_NAME = "@faststats/web";
6
- const SDK_VERSION = "0.13.1";
6
+ const SDK_VERSION = "0.13.2";
7
7
  function errorTracking(options = {}) {
8
8
  return trackerExtension("error-tracking", (context) => new ErrorTracker({
9
9
  ...options,
@@ -156,5 +156,4 @@ var ErrorTracker = class {
156
156
  if (!this.started && !failed.length) this.flush();
157
157
  }
158
158
  };
159
- //#endregion
160
159
  export { ErrorTracker as default, errorTracking };
package/dist/flags.d.ts CHANGED
@@ -1,5 +1,4 @@
1
- import { n as AnalyticsExtensionContext, r as ExtensionCleanup, t as AnalyticsExtension } from "./chunks/extensions-BfubKIzk.js";
2
- //#region src/flags.d.ts
1
+ import { n as AnalyticsExtensionContext, r as ExtensionCleanup, t as AnalyticsExtension } from "./chunks/extensions-C2k9Im6I.js";
3
2
  export interface FeatureFlagsOptions {
4
3
  /**
5
4
  * Flag keys this app reads. Every loaded flag is recorded as an exposure,
@@ -75,5 +74,4 @@ export declare class FeatureFlags implements AnalyticsExtension {
75
74
  private evaluate;
76
75
  private update;
77
76
  }
78
- export declare function featureFlags(options?: FeatureFlagsOptions): FeatureFlags;
79
- //#endregion
77
+ export declare function featureFlags(options?: FeatureFlagsOptions): FeatureFlags;
package/dist/flags.js CHANGED
@@ -1,6 +1,6 @@
1
- import { n as getSessionContext } from "./chunks/session-manager-VM5RZj9H.js";
2
- import { t as getAnonymousId } from "./chunks/identifiers-3X8XI1pD.js";
3
- //#region src/flags.ts
1
+ import { n as getSessionContext } from "./chunks/session-manager-DBWYTyfd.js";
2
+ import { t as getAnonymousId } from "./chunks/identifiers-BHYhM7DM.js";
3
+ // src/flags.ts
4
4
  const DEFAULT_ENDPOINT = "https://flags.faststats.dev";
5
5
  const DEFAULT_TIMEOUT_MS = 3e3;
6
6
  /**
@@ -141,5 +141,4 @@ var FeatureFlags = class {
141
141
  function featureFlags(options) {
142
142
  return new FeatureFlags(options);
143
143
  }
144
- //#endregion
145
144
  export { FeatureFlags, featureFlags };
package/dist/index.d.ts CHANGED
@@ -1,5 +1,4 @@
1
- import { a as ExtensionHook, i as ExtensionHandler, n as AnalyticsExtensionContext, o as ExtensionHooks, r as ExtensionCleanup, t as AnalyticsExtension } from "./chunks/extensions-BfubKIzk.js";
2
- //#region src/analytics.d.ts
1
+ import { a as ExtensionHook, i as ExtensionHandler, n as AnalyticsExtensionContext, o as ExtensionHooks, r as ExtensionCleanup, t as AnalyticsExtension } from "./chunks/extensions-C2k9Im6I.js";
3
2
  type ConsentMode = "anonymous" | "granted" | "denied";
4
3
  interface IdentifyOptions {
5
4
  name?: string | null;
@@ -75,8 +74,6 @@ export declare class WebAnalytics {
75
74
  private resumeVisit;
76
75
  private send;
77
76
  }
78
- //#endregion
79
- //#region src/client.d.ts
80
77
  /** Creates an independent client. Call `start()` when it should begin tracking. */
81
78
  export declare function createClient(options: WebAnalyticsOptions): WebAnalytics;
82
79
  /** Initializes and starts the shared client used by the convenience functions. */
@@ -90,5 +87,4 @@ export declare function identify(externalId: string, email?: string, options?: I
90
87
  export declare function logout(resetAnonymousIdentity?: boolean): void;
91
88
  export declare function setConsentMode(mode: ConsentMode): void;
92
89
  export declare function reportError(error: Error): void;
93
- //#endregion
94
90
  export type { AnalyticsExtension, AnalyticsExtensionContext, ConsentMode, ExtensionCleanup, ExtensionHandler, ExtensionHook, ExtensionHooks, IdentifyOptions, IdentifyUser, WebAnalyticsOptions };
package/dist/index.js CHANGED
@@ -1,7 +1,7 @@
1
- import { a as resolveBaseUrl, i as getPageContext, n as URLS, o as sanitizeUrl, r as getClientContext, s as ExtensionHost, t as sendData } from "./chunks/send-data-B7P3f5PT.js";
2
- import { a as touchActivity, i as resetSession, n as getSessionContext, t as createId } from "./chunks/session-manager-VM5RZj9H.js";
3
- import { n as resetAnonymousId, t as getAnonymousId } from "./chunks/identifiers-3X8XI1pD.js";
4
- //#region src/outbound-links.ts
1
+ import { a as resolveBaseUrl, i as getPageContext, n as URLS, o as sanitizeUrl, r as getClientContext, s as ExtensionHost, t as sendData } from "./chunks/send-data-BCVUgwry.js";
2
+ import { a as touchActivity, i as resetSession, n as getSessionContext, t as createId } from "./chunks/session-manager-DBWYTyfd.js";
3
+ import { n as resetAnonymousId, t as getAnonymousId } from "./chunks/identifiers-BHYhM7DM.js";
4
+ // src/outbound-links.ts
5
5
  const DEDUPE_MS = 500;
6
6
  function outboundHref(event) {
7
7
  for (const node of event.composedPath()) if (node instanceof HTMLAnchorElement && (node.protocol === "http:" || node.protocol === "https:") && node.host !== location.host) return node.href;
@@ -29,8 +29,7 @@ function trackOutboundLinks(report) {
29
29
  document.removeEventListener("auxclick", onClick, true);
30
30
  };
31
31
  }
32
- //#endregion
33
- //#region src/analytics.ts
32
+ // src/analytics.ts
34
33
  const navigationListeners = /* @__PURE__ */ new Set();
35
34
  const historyPatches = /* @__PURE__ */ new Map();
36
35
  function observeHistory(listener) {
@@ -394,8 +393,7 @@ var WebAnalytics = class {
394
393
  });
395
394
  }
396
395
  };
397
- //#endregion
398
- //#region src/client.ts
396
+ // src/client.ts
399
397
  let client;
400
398
  /** Creates an independent client. Call `start()` when it should begin tracking. */
401
399
  function createClient(options) {
@@ -432,5 +430,4 @@ function setConsentMode(mode) {
432
430
  function reportError(error) {
433
431
  client?.reportError(error);
434
432
  }
435
- //#endregion
436
433
  export { WebAnalytics, createClient, identify, init, logout, pageview, reportError, setConsentMode, shutdown, track };
package/dist/replay.d.ts CHANGED
@@ -1,22 +1,17 @@
1
- import { t as AnalyticsExtension } from "./chunks/extensions-BfubKIzk.js";
1
+ import { t as AnalyticsExtension } from "./chunks/extensions-C2k9Im6I.js";
2
2
  import { record } from "@rrweb/record";
3
3
  import { LogLevel } from "@rrweb/rrweb-plugin-console-record";
4
4
  import { NetworkRecordOptions } from "@rrweb/rrweb-plugin-network-record";
5
- //#region ../../node_modules/.bun/@rrweb+types@2.1.7/node_modules/@rrweb/types/dist/index.d.ts
6
5
  declare global {
7
6
  interface Window {
8
7
  FontFace: typeof FontFace;
9
8
  }
10
9
  }
11
- //#endregion
12
- //#region src/replay-mutation-throttler.d.ts
13
10
  type ReplayMutationThrottleOptions = {
14
11
  enabled?: boolean;
15
12
  bucketSize?: number;
16
13
  refillRate?: number;
17
14
  };
18
- //#endregion
19
- //#region src/replay.d.ts
20
15
  type RecordOptions = NonNullable<Parameters<typeof record>[0]>;
21
16
  export interface ReplayTrackerOptions {
22
17
  siteKey: string;
@@ -106,5 +101,4 @@ export default class ReplayTracker {
106
101
  private endStream;
107
102
  private enqueue;
108
103
  }
109
- //#endregion
110
104
  export {};
package/dist/replay.js CHANGED
@@ -1,10 +1,10 @@
1
- import { a as resolveBaseUrl, c as trackerExtension, n as URLS, o as sanitizeUrl, t as sendData } from "./chunks/send-data-B7P3f5PT.js";
2
- import { a as touchActivity, n as getSessionContext, o as getStorageItem, r as onSessionRotated, s as setStorageItem, t as createId } from "./chunks/session-manager-VM5RZj9H.js";
3
- import { t as getAnonymousId } from "./chunks/identifiers-3X8XI1pD.js";
1
+ import { a as resolveBaseUrl, c as trackerExtension, n as URLS, o as sanitizeUrl, t as sendData } from "./chunks/send-data-BCVUgwry.js";
2
+ import { a as touchActivity, n as getSessionContext, o as getStorageItem, r as onSessionRotated, s as setStorageItem, t as createId } from "./chunks/session-manager-DBWYTyfd.js";
3
+ import { t as getAnonymousId } from "./chunks/identifiers-BHYhM7DM.js";
4
4
  import { record } from "@rrweb/record";
5
5
  import { getRecordConsolePlugin } from "@rrweb/rrweb-plugin-console-record";
6
6
  import { getRecordNetworkPlugin } from "@rrweb/rrweb-plugin-network-record";
7
- //#region src/replay-mutation-throttler.ts
7
+ // src/replay-mutation-throttler.ts
8
8
  const INCREMENTAL_SNAPSHOT_EVENT_TYPE = 3;
9
9
  const MUTATION_SOURCE_TYPE = 0;
10
10
  const MAX_TRACKED_NODES = 1e4;
@@ -51,8 +51,7 @@ var ReplayMutationThrottler = class {
51
51
  return true;
52
52
  }
53
53
  };
54
- //#endregion
55
- //#region src/replay-sequence.ts
54
+ // src/replay-sequence.ts
56
55
  const counters = /* @__PURE__ */ new Map();
57
56
  function sameRecording(counter, context) {
58
57
  return counter?.sessionId === context.sessionId && counter.windowId === context.windowId;
@@ -91,8 +90,7 @@ function nextReplaySequence(siteKey, context, cookieless) {
91
90
  if (!cookieless) setStorageItem("sessionStorage", sequenceKey(siteKey), JSON.stringify(counter));
92
91
  return sequence;
93
92
  }
94
- //#endregion
95
- //#region src/replay-uploader.ts
93
+ // src/replay-uploader.ts
96
94
  const RETRY_BASE_DELAY_MS = 2e3;
97
95
  const RETRY_MAX_ATTEMPTS = 5;
98
96
  const RETRY_COOLDOWN_MS = 3e5;
@@ -222,8 +220,7 @@ var ReplayUploader = class {
222
220
  });
223
221
  }
224
222
  };
225
- //#endregion
226
- //#region src/replay.ts
223
+ // src/replay.ts
227
224
  const MAX_TIMEOUT_MS = 2147483647;
228
225
  const LOW_LATENCY_BATCH_BYTES = 57344;
229
226
  const LIMITS = {
@@ -648,5 +645,4 @@ var ReplayTracker = class {
648
645
  return true;
649
646
  }
650
647
  };
651
- //#endregion
652
648
  export { ReplayTracker as default, sessionReplay };
@@ -1,5 +1,4 @@
1
- import { t as AnalyticsExtension } from "./chunks/extensions-BfubKIzk.js";
2
- //#region src/web-vitals.d.ts
1
+ import { t as AnalyticsExtension } from "./chunks/extensions-C2k9Im6I.js";
3
2
  export interface WebVitalsOptions {
4
3
  siteKey: string;
5
4
  baseUrl?: string;
@@ -30,5 +29,4 @@ export default class WebVitalsTracker {
30
29
  private onMetric;
31
30
  private discard;
32
31
  private flush;
33
- }
34
- //#endregion
32
+ }
@@ -1,7 +1,7 @@
1
- import { a as resolveBaseUrl, c as trackerExtension, n as URLS, o as sanitizeUrl, t as sendData } from "./chunks/send-data-B7P3f5PT.js";
2
- import { n as getSessionContext, r as onSessionRotated } from "./chunks/session-manager-VM5RZj9H.js";
1
+ import { a as resolveBaseUrl, c as trackerExtension, n as URLS, o as sanitizeUrl, t as sendData } from "./chunks/send-data-BCVUgwry.js";
2
+ import { n as getSessionContext, r as onSessionRotated } from "./chunks/session-manager-DBWYTyfd.js";
3
3
  import { onCLS, onFCP, onINP, onLCP, onTTFB } from "web-vitals/attribution";
4
- //#region src/utils/web-vitals-collector.ts
4
+ // src/utils/web-vitals-collector.ts
5
5
  const collectors = /* @__PURE__ */ new WeakMap();
6
6
  function getCollector() {
7
7
  const existing = collectors.get(document);
@@ -44,8 +44,7 @@ function sentVitals(destination) {
44
44
  sent.set(destination, vitals);
45
45
  return vitals;
46
46
  }
47
- //#endregion
48
- //#region src/web-vitals.ts
47
+ // src/web-vitals.ts
49
48
  function webVitals() {
50
49
  return trackerExtension("web-vitals", (context) => new WebVitalsTracker(context));
51
50
  }
@@ -155,5 +154,4 @@ var WebVitalsTracker = class {
155
154
  else if (generation === this.generation && !this.metrics.has(vital.name)) this.metrics.set(vital.name, vital);
156
155
  }
157
156
  };
158
- //#endregion
159
157
  export { WebVitalsTracker as default, webVitals };
package/package.json CHANGED
@@ -42,7 +42,7 @@
42
42
  "publishConfig": {
43
43
  "access": "public"
44
44
  },
45
- "version": "0.13.1",
45
+ "version": "0.13.2",
46
46
  "scripts": {
47
47
  "build": "tsdown && bun run check-size",
48
48
  "dev": "bun run build",