@reopt-ai/data-sdk-client 0.1.6 → 0.3.0

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.
Files changed (57) hide show
  1. package/README.md +141 -7
  2. package/dist/client-B1GlWwVq.d.ts +744 -0
  3. package/dist/client-B1GlWwVq.d.ts.map +1 -0
  4. package/dist/client-BCrui21p.d.cts +744 -0
  5. package/dist/client-BCrui21p.d.cts.map +1 -0
  6. package/dist/exceptions-C9Fh0BIR.js +285 -0
  7. package/dist/exceptions-C9Fh0BIR.js.map +1 -0
  8. package/dist/exceptions-CuhGo9A5.cjs +289 -0
  9. package/dist/exceptions-CuhGo9A5.cjs.map +1 -0
  10. package/dist/index.cjs +75 -1874
  11. package/dist/index.cjs.map +1 -1
  12. package/dist/index.d.cts +83 -0
  13. package/dist/index.d.cts.map +1 -0
  14. package/dist/index.d.ts +35 -33
  15. package/dist/index.d.ts.map +1 -0
  16. package/dist/index.js +49 -70
  17. package/dist/index.js.map +1 -1
  18. package/dist/next.cjs +51 -1919
  19. package/dist/next.cjs.map +1 -1
  20. package/dist/next.d.cts +31 -0
  21. package/dist/next.d.cts.map +1 -0
  22. package/dist/next.d.ts +8 -10
  23. package/dist/next.d.ts.map +1 -0
  24. package/dist/next.js +36 -49
  25. package/dist/next.js.map +1 -1
  26. package/dist/observe-D-BHMwrO.cjs +54 -0
  27. package/dist/observe-D-BHMwrO.cjs.map +1 -0
  28. package/dist/observe-D1pNg1qL.js +54 -0
  29. package/dist/observe-D1pNg1qL.js.map +1 -0
  30. package/dist/react.cjs +105 -1863
  31. package/dist/react.cjs.map +1 -1
  32. package/dist/react.d.cts +80 -0
  33. package/dist/react.d.cts.map +1 -0
  34. package/dist/react.d.ts +52 -46
  35. package/dist/react.d.ts.map +1 -0
  36. package/dist/react.js +118 -23
  37. package/dist/react.js.map +1 -1
  38. package/dist/registry-BPhiH_l9.js +1775 -0
  39. package/dist/registry-BPhiH_l9.js.map +1 -0
  40. package/dist/registry-CGqrOtf4.cjs +1810 -0
  41. package/dist/registry-CGqrOtf4.cjs.map +1 -0
  42. package/dist/tracing-DAhaKkl0.cjs +93 -0
  43. package/dist/tracing-DAhaKkl0.cjs.map +1 -0
  44. package/dist/tracing-Dt1RVuQ9.js +93 -0
  45. package/dist/tracing-Dt1RVuQ9.js.map +1 -0
  46. package/package.json +33 -18
  47. package/dist/chunk-4MTDZBRS.js +0 -57
  48. package/dist/chunk-4MTDZBRS.js.map +0 -1
  49. package/dist/chunk-SYCBGBTH.js +0 -1627
  50. package/dist/chunk-SYCBGBTH.js.map +0 -1
  51. package/dist/chunk-YRP3I3OD.js +0 -106
  52. package/dist/chunk-YRP3I3OD.js.map +0 -1
  53. package/dist/client-BCd2fgmx.d.ts +0 -581
  54. package/dist/exceptions-NQHZUDYO.js +0 -9
  55. package/dist/exceptions-NQHZUDYO.js.map +0 -1
  56. package/dist/tracing-LC3NZND7.js +0 -91
  57. package/dist/tracing-LC3NZND7.js.map +0 -1
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","names":[],"sources":["../src/registry.ts","../src/capture/utm.ts","../src/capture/exception-properties.ts","../src/capture/pageleave.ts","../src/index.ts"],"mappings":";;;;;;;;iBA0BgB,kBAAkB,QAAQ,mBAAmB,WAAW,sBAAsB;iBAS9E,UAAU,oBAAoB;;;;iBC9B9B,iBAAiB,kBAA0E;;;KCQ/F;KAEA;EACV;EACA;EACA;EACA,mBAAmB;EACnB;;;;;;;;EAQA,kBAAkB;EAClB;;;;KCbU;EACV;EACA;EACA;EACA;;EAEA;;;;;iBC4Cc,KAAK,QAAQ,oBAAoB;;iBAKjC,eAAe;iBAgBf,MAAM,SAAS,oBAAoB;iBACnC,MAAM,cAAc,aAAa,0BAA0B;iBAQ3D,SAAS,SAAS,kBAAkB;iBACpC,SAAS,4BAA4B,aAAa,0BAA0B;iBAQ5E,UAAU,SAAS,mBAAmB;iBACtC,UAAU,4BAA4B,kBAAkB,iBAAiB;iBASzE,UAAU,SAAS,mBAAmB;iBACtC,UAAU,4BAA4B,kBAAkB,iBAAiB;iBASzE,SAAS,UAAU,kBAAkB;iBAIrC,WAAW,oBAAoB,aAAa,0BAA0B;iBAItE,gBAAgB,QAAQ,iBAAiB;iBAIzC,iBAAiB,gBAAgB,aAAa,0BAA0B;;;;;;iBASxE;;iBAMA,SAAS,YAAY;iBAIrB,cAAc;iBAId,aAAa;iBAIb;iBAIA,SAAS,QAAQ;;iBAMX,SAAS,QAAQ;iBAOvB,WAAW,UAAU,iBAAiB;iBAItC,WAAW,UAAU;iBAIrB,cAAc;iBAId;iBAIA"}
package/dist/index.js CHANGED
@@ -1,116 +1,95 @@
1
- import {
2
- ReoptClient,
3
- extractUTMParams,
4
- forgetClient,
5
- getClient,
6
- getOrCreateClient
7
- } from "./chunk-SYCBGBTH.js";
8
- import "./chunk-4MTDZBRS.js";
9
-
10
- // src/index.ts
1
+ import { a as extractUTMParams, i as ReoptClient, n as getClient, r as getOrCreateClient, t as forgetClient } from "./registry-BPhiH_l9.js";
2
+ //#region src/index.ts
11
3
  function init(config) {
12
- return getOrCreateClient(config);
4
+ return getOrCreateClient(config);
13
5
  }
14
6
  function getInstance() {
15
- return getClient();
7
+ return getClient();
16
8
  }
17
9
  function current() {
18
- const client = getClient();
19
- if (!client) console.warn("[reopt] not initialized \u2014 call init() first");
20
- return client;
10
+ const client = getClient();
11
+ if (!client) console.warn("[reopt] not initialized call init() first");
12
+ return client;
21
13
  }
22
- var withId = (idOrOptions, rest) => typeof idOrOptions === "object" ? idOrOptions : { profileId: idOrOptions, ...rest };
14
+ const withId = (idOrOptions, rest) => typeof idOrOptions === "object" ? idOrOptions : {
15
+ profileId: idOrOptions,
16
+ ...rest
17
+ };
23
18
  function track(nameOrOptions, properties) {
24
- return current()?.track(typeof nameOrOptions === "string" ? { name: nameOrOptions, properties } : nameOrOptions);
19
+ return current()?.track(typeof nameOrOptions === "string" ? {
20
+ name: nameOrOptions,
21
+ properties
22
+ } : nameOrOptions);
25
23
  }
26
24
  function identify(idOrOptions, properties) {
27
- return current()?.identify(withId(idOrOptions, { properties }));
25
+ return current()?.identify(withId(idOrOptions, { properties }));
28
26
  }
29
27
  function increment(idOrOptions, property, value) {
30
- return current()?.increment(withId(idOrOptions, { property: property ?? "", value }));
28
+ return current()?.increment(withId(idOrOptions, {
29
+ property: property ?? "",
30
+ value
31
+ }));
31
32
  }
32
33
  function decrement(idOrOptions, property, value) {
33
- return current()?.decrement(withId(idOrOptions, { property: property ?? "", value }));
34
+ return current()?.decrement(withId(idOrOptions, {
35
+ property: property ?? "",
36
+ value
37
+ }));
34
38
  }
35
39
  function pageView(options) {
36
- return current()?.pageView(options);
40
+ return current()?.pageView(options);
37
41
  }
38
42
  function screenView(screenName, properties) {
39
- return current()?.screenView(screenName, properties);
43
+ return current()?.screenView(screenName, properties);
40
44
  }
41
45
  function captureWebVital(metric) {
42
- return current()?.captureWebVital(metric);
46
+ return current()?.captureWebVital(metric);
43
47
  }
44
48
  function captureException(error, properties) {
45
- return current()?.captureException(error, properties);
49
+ return current()?.captureException(error, properties);
46
50
  }
47
51
  function getDeviceId() {
48
- const client = getClient();
49
- return client && !client.disabled ? client.getDeviceId() : null;
52
+ const client = getClient();
53
+ return client && !client.disabled ? client.getDeviceId() : null;
50
54
  }
51
55
  function register(properties) {
52
- current()?.register(properties);
56
+ current()?.register(properties);
53
57
  }
54
58
  function unregister(...keys) {
55
- current()?.unregister(...keys);
59
+ current()?.unregister(...keys);
56
60
  }
57
61
  function setProfileId(profileId) {
58
- current()?.setProfileId(profileId);
62
+ current()?.setProfileId(profileId);
59
63
  }
60
64
  function reset() {
61
- getClient()?.reset();
65
+ getClient()?.reset();
62
66
  }
63
67
  function flush() {
64
- const client = getClient();
65
- return client ? client.flush() : Promise.resolve(void 0);
68
+ const client = getClient();
69
+ return client ? client.flush() : Promise.resolve(void 0);
66
70
  }
67
71
  async function close() {
68
- const client = getClient();
69
- if (!client) return void 0;
70
- forgetClient(client);
71
- return client.close();
72
+ const client = getClient();
73
+ if (!client) return void 0;
74
+ forgetClient(client);
75
+ return client.close();
72
76
  }
73
77
  function setConsent(category, allowed) {
74
- current()?.setConsent(category, allowed);
78
+ current()?.setConsent(category, allowed);
75
79
  }
76
80
  function getConsent(category) {
77
- return current()?.getConsent(category) ?? false;
81
+ return current()?.getConsent(category) ?? false;
78
82
  }
79
83
  function setAllConsent(allowed) {
80
- current()?.setAllConsent(allowed);
84
+ current()?.setAllConsent(allowed);
81
85
  }
82
86
  function pauseTracking() {
83
- current()?.pauseTracking();
87
+ current()?.pauseTracking();
84
88
  }
85
89
  function resumeTracking() {
86
- current()?.resumeTracking();
87
- }
88
- export {
89
- ReoptClient,
90
- captureException,
91
- captureWebVital,
92
- close,
93
- decrement,
94
- extractUTMParams,
95
- flush,
96
- getClient,
97
- getConsent,
98
- getDeviceId,
99
- getInstance,
100
- getOrCreateClient,
101
- identify,
102
- increment,
103
- init,
104
- pageView,
105
- pauseTracking,
106
- register,
107
- reset,
108
- resumeTracking,
109
- screenView,
110
- setAllConsent,
111
- setConsent,
112
- setProfileId,
113
- track,
114
- unregister
115
- };
90
+ current()?.resumeTracking();
91
+ }
92
+ //#endregion
93
+ export { ReoptClient, captureException, captureWebVital, close, decrement, extractUTMParams, flush, getClient, getConsent, getDeviceId, getInstance, getOrCreateClient, identify, increment, init, pageView, pauseTracking, register, reset, resumeTracking, screenView, setAllConsent, setConsent, setProfileId, track, unregister };
94
+
116
95
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/index.ts"],"sourcesContent":["/**\n * `@reopt-ai/data-sdk-client` — the browser SDK.\n *\n * This entry has no framework directive: it works from a `<script>` tag, a\n * plain SPA, or any framework. `./react` and `./next` add the components.\n *\n * The module-level functions (`track`, `identify`, …) operate on the client\n * created by `init()`. They warn and return `undefined` before `init()`, so a\n * call that runs too early is visible in the console rather than lost.\n */\nimport type {\n ConsentCategory,\n DecrementOptions,\n FlushResult,\n IdentifyOptions,\n IncrementOptions,\n PageViewOptions,\n QueueResult,\n TrackEventOptions,\n} from \"@reopt-ai/data-sdk-core\";\nimport { ReoptClient } from \"./client.js\";\nimport type { WebVitalMetric } from \"./capture/web-vitals.js\";\nimport type { ReoptClientConfig } from \"./config.js\";\nimport { forgetClient, getClient, getOrCreateClient } from \"./registry.js\";\n\nexport { ReoptClient } from \"./client.js\";\nexport { getClient, getOrCreateClient } from \"./registry.js\";\nexport { extractUTMParams } from \"./capture/utm.js\";\nexport type { WebVitalMetric, WebVitalProperties } from \"./capture/web-vitals.js\";\nexport type { ExceptionProperties } from \"./capture/exceptions.js\";\nexport type { PageLeaveProperties } from \"./capture/pageleave.js\";\nexport type {\n CaptureConfig,\n IdentityConfig,\n IdentityStorageKind,\n NormalizePath,\n ReoptBootstrap,\n ReoptClientConfig,\n} from \"./config.js\";\nexport type {\n BatchConfig,\n CircuitBreakerConfig,\n ConsentCategory,\n ConsentConfig,\n DecrementOptions,\n EventIdentity,\n EventPayload,\n FetchInit,\n FetchLike,\n FetchResponseLike,\n FlushResult,\n IdentifyOptions,\n IncrementOptions,\n PageViewOptions,\n QueueDropReason,\n QueueResult,\n RetryConfig,\n StorageBackend,\n TrackEventOptions,\n UTMParams,\n} from \"@reopt-ai/data-sdk-core\";\n\n/** Creates (or returns) the page's client for `config.writeKey`. */\nexport function init(config: ReoptClientConfig): ReoptClient {\n return getOrCreateClient(config);\n}\n\n/** The client created by `init()`, or `null`. */\nexport function getInstance(): ReoptClient | null {\n return getClient();\n}\n\nfunction current(): ReoptClient | null {\n const client = getClient();\n if (!client) console.warn(\"[reopt] not initialized — call init() first\");\n return client;\n}\n\n/** Normalises the `(id, …)` and `(options)` call forms the module functions accept. */\nconst withId = <T extends { profileId: string | number }>(\n idOrOptions: string | number | T,\n rest: Omit<T, \"profileId\">\n): T => (typeof idOrOptions === \"object\" ? idOrOptions : ({ profileId: idOrOptions, ...rest } as T));\n\nexport function track(options: TrackEventOptions): QueueResult | undefined;\nexport function track(name: string, properties?: Record<string, unknown>): QueueResult | undefined;\nexport function track(\n nameOrOptions: string | TrackEventOptions,\n properties?: Record<string, unknown>\n): QueueResult | undefined {\n return current()?.track(typeof nameOrOptions === \"string\" ? { name: nameOrOptions, properties } : nameOrOptions);\n}\n\nexport function identify(options: IdentifyOptions): QueueResult | undefined;\nexport function identify(profileId: string | number, properties?: Record<string, unknown>): QueueResult | undefined;\nexport function identify(\n idOrOptions: string | number | IdentifyOptions,\n properties?: Record<string, unknown>\n): QueueResult | undefined {\n return current()?.identify(withId<IdentifyOptions>(idOrOptions, { properties }));\n}\n\nexport function increment(options: IncrementOptions): QueueResult | undefined;\nexport function increment(profileId: string | number, property: string, value?: number): QueueResult | undefined;\nexport function increment(\n idOrOptions: string | number | IncrementOptions,\n property?: string,\n value?: number\n): QueueResult | undefined {\n return current()?.increment(withId<IncrementOptions>(idOrOptions, { property: property ?? \"\", value }));\n}\n\nexport function decrement(options: DecrementOptions): QueueResult | undefined;\nexport function decrement(profileId: string | number, property: string, value?: number): QueueResult | undefined;\nexport function decrement(\n idOrOptions: string | number | DecrementOptions,\n property?: string,\n value?: number\n): QueueResult | undefined {\n return current()?.decrement(withId<DecrementOptions>(idOrOptions, { property: property ?? \"\", value }));\n}\n\nexport function pageView(options?: PageViewOptions): QueueResult | undefined {\n return current()?.pageView(options);\n}\n\nexport function screenView(screenName: string, properties?: Record<string, unknown>): QueueResult | undefined {\n return current()?.screenView(screenName, properties);\n}\n\nexport function captureWebVital(metric: WebVitalMetric): QueueResult | undefined {\n return current()?.captureWebVital(metric);\n}\n\nexport function captureException(error: unknown, properties?: Record<string, unknown>): QueueResult | undefined {\n return current()?.captureException(error, properties);\n}\n\n/**\n * The device id this page is tracked under, for passing to your own server\n * calls explicitly (e.g. as a body field a route handler forwards as the\n * event's `deviceId`). `null` before `init()` or when analytics is disabled.\n */\nexport function getDeviceId(): string | null {\n const client = getClient();\n return client && !client.disabled ? client.getDeviceId() : null;\n}\n\n/** Attach `properties` to every event from now on (an event's own properties win). */\nexport function register(properties: Record<string, unknown>): void {\n current()?.register(properties);\n}\n\nexport function unregister(...keys: string[]): void {\n current()?.unregister(...keys);\n}\n\nexport function setProfileId(profileId: string | number | null): void {\n current()?.setProfileId(profileId);\n}\n\nexport function reset(): void {\n getClient()?.reset();\n}\n\nexport function flush(): Promise<FlushResult | undefined> {\n const client = getClient();\n return client ? client.flush() : Promise.resolve(undefined);\n}\n\n/** Flushes, tears down listeners, and forgets the client so `init()` starts fresh. */\nexport async function close(): Promise<FlushResult | undefined> {\n const client = getClient();\n if (!client) return undefined;\n forgetClient(client);\n return client.close();\n}\n\nexport function setConsent(category: ConsentCategory, allowed: boolean): void {\n current()?.setConsent(category, allowed);\n}\n\nexport function getConsent(category: ConsentCategory): boolean {\n return current()?.getConsent(category) ?? false;\n}\n\nexport function setAllConsent(allowed: boolean): void {\n current()?.setAllConsent(allowed);\n}\n\nexport function pauseTracking(): void {\n current()?.pauseTracking();\n}\n\nexport function resumeTracking(): void {\n current()?.resumeTracking();\n}\n"],"mappings":";;;;;;;;;;AA+DO,SAAS,KAAK,QAAwC;AAC3D,SAAO,kBAAkB,MAAM;AACjC;AAGO,SAAS,cAAkC;AAChD,SAAO,UAAU;AACnB;AAEA,SAAS,UAA8B;AACrC,QAAM,SAAS,UAAU;AACzB,MAAI,CAAC,OAAQ,SAAQ,KAAK,kDAA6C;AACvE,SAAO;AACT;AAGA,IAAM,SAAS,CACb,aACA,SACO,OAAO,gBAAgB,WAAW,cAAe,EAAE,WAAW,aAAa,GAAG,KAAK;AAIrF,SAAS,MACd,eACA,YACyB;AACzB,SAAO,QAAQ,GAAG,MAAM,OAAO,kBAAkB,WAAW,EAAE,MAAM,eAAe,WAAW,IAAI,aAAa;AACjH;AAIO,SAAS,SACd,aACA,YACyB;AACzB,SAAO,QAAQ,GAAG,SAAS,OAAwB,aAAa,EAAE,WAAW,CAAC,CAAC;AACjF;AAIO,SAAS,UACd,aACA,UAC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D,SAAO,QAAQ,GAAG,WAAW,QAAQ,KAAK;AAC5C;AAEO,SAAS,cAAc,SAAwB;AACpD,UAAQ,GAAG,cAAc,OAAO;AAClC;AAEO,SAAS,gBAAsB;AACpC,UAAQ,GAAG,cAAc;AAC3B;AAEO,SAAS,iBAAuB;AACrC,UAAQ,GAAG,eAAe;AAC5B;","names":[]}
1
+ {"version":3,"file":"index.js","names":[],"sources":["../src/index.ts"],"sourcesContent":["/**\n * `@reopt-ai/data-sdk-client` — the browser SDK.\n *\n * This entry has no framework directive: it works from a `<script>` tag, a\n * plain SPA, or any framework. `./react` and `./next` add the components.\n *\n * The module-level functions (`track`, `identify`, …) operate on the client\n * created by `init()`. They warn and return `undefined` before `init()`, so a\n * call that runs too early is visible in the console rather than lost.\n */\nimport type {\n ConsentCategory,\n DecrementOptions,\n FlushResult,\n IdentifyOptions,\n IncrementOptions,\n PageViewOptions,\n QueueResult,\n TrackEventOptions,\n} from \"@reopt-ai/data-sdk-core\";\nimport { ReoptClient } from \"./client.js\";\nimport type { WebVitalMetric } from \"./capture/web-vitals.js\";\nimport type { ReoptClientConfig } from \"./config.js\";\nimport { forgetClient, getClient, getOrCreateClient } from \"./registry.js\";\n\nexport { ReoptClient } from \"./client.js\";\nexport { getClient, getOrCreateClient } from \"./registry.js\";\nexport { extractUTMParams } from \"./capture/utm.js\";\nexport type { WebVitalMetric, WebVitalProperties } from \"./capture/web-vitals.js\";\nexport type { ExceptionProperties } from \"./capture/describe-error.js\";\nexport type { PageLeaveProperties } from \"./capture/pageleave.js\";\nexport type {\n CaptureConfig,\n IdentityConfig,\n IdentityStorageKind,\n NormalizePath,\n ReoptBootstrap,\n ReoptClientConfig,\n ReoptClientObservation,\n ReoptClientObserver,\n ReoptObservedEventType,\n} from \"./config.js\";\nexport type {\n BatchConfig,\n CircuitBreakerConfig,\n ConsentCategory,\n ConsentConfig,\n DecrementOptions,\n EventIdentity,\n EventPayload,\n FetchInit,\n FetchLike,\n FetchResponseLike,\n FlushResult,\n IdentifyOptions,\n IncrementOptions,\n PageViewOptions,\n QueueDropReason,\n QueueResult,\n RetryConfig,\n StorageBackend,\n TrackEventOptions,\n UTMParams,\n} from \"@reopt-ai/data-sdk-core\";\n\n/** Creates (or returns) the page's client for `config.writeKey`. */\nexport function init(config: ReoptClientConfig): ReoptClient {\n return getOrCreateClient(config);\n}\n\n/** The client created by `init()`, or `null`. */\nexport function getInstance(): ReoptClient | null {\n return getClient();\n}\n\nfunction current(): ReoptClient | null {\n const client = getClient();\n if (!client) console.warn(\"[reopt] not initialized — call init() first\");\n return client;\n}\n\n/** Normalises the `(id, …)` and `(options)` call forms the module functions accept. */\nconst withId = <T extends { profileId: string | number }>(\n idOrOptions: string | number | T,\n rest: Omit<T, \"profileId\">\n): T => (typeof idOrOptions === \"object\" ? idOrOptions : ({ profileId: idOrOptions, ...rest } as T));\n\nexport function track(options: TrackEventOptions): QueueResult | undefined;\nexport function track(name: string, properties?: Record<string, unknown>): QueueResult | undefined;\nexport function track(\n nameOrOptions: string | TrackEventOptions,\n properties?: Record<string, unknown>\n): QueueResult | undefined {\n return current()?.track(typeof nameOrOptions === \"string\" ? { name: nameOrOptions, properties } : nameOrOptions);\n}\n\nexport function identify(options: IdentifyOptions): QueueResult | undefined;\nexport function identify(profileId: string | number, properties?: Record<string, unknown>): QueueResult | undefined;\nexport function identify(\n idOrOptions: string | number | IdentifyOptions,\n properties?: Record<string, unknown>\n): QueueResult | undefined {\n return current()?.identify(withId<IdentifyOptions>(idOrOptions, { properties }));\n}\n\nexport function increment(options: IncrementOptions): QueueResult | undefined;\nexport function increment(profileId: string | number, property: string, value?: number): QueueResult | undefined;\nexport function increment(\n idOrOptions: string | number | IncrementOptions,\n property?: string,\n value?: number\n): QueueResult | undefined {\n return current()?.increment(withId<IncrementOptions>(idOrOptions, { property: property ?? \"\", value }));\n}\n\nexport function decrement(options: DecrementOptions): QueueResult | undefined;\nexport function decrement(profileId: string | number, property: string, value?: number): QueueResult | undefined;\nexport function decrement(\n idOrOptions: string | number | DecrementOptions,\n property?: string,\n value?: number\n): QueueResult | undefined {\n return current()?.decrement(withId<DecrementOptions>(idOrOptions, { property: property ?? \"\", value }));\n}\n\nexport function pageView(options?: PageViewOptions): QueueResult | undefined {\n return current()?.pageView(options);\n}\n\nexport function screenView(screenName: string, properties?: Record<string, unknown>): QueueResult | undefined {\n return current()?.screenView(screenName, properties);\n}\n\nexport function captureWebVital(metric: WebVitalMetric): QueueResult | undefined {\n return current()?.captureWebVital(metric);\n}\n\nexport function captureException(error: unknown, properties?: Record<string, unknown>): QueueResult | undefined {\n return current()?.captureException(error, properties);\n}\n\n/**\n * The device id this page is tracked under, for passing to your own server\n * calls explicitly (e.g. as a body field a route handler forwards as the\n * event's `deviceId`). `null` before `init()` or when analytics is disabled.\n */\nexport function getDeviceId(): string | null {\n const client = getClient();\n return client && !client.disabled ? client.getDeviceId() : null;\n}\n\n/** Attach `properties` to every event from now on (an event's own properties win). */\nexport function register(properties: Record<string, unknown>): void {\n current()?.register(properties);\n}\n\nexport function unregister(...keys: string[]): void {\n current()?.unregister(...keys);\n}\n\nexport function setProfileId(profileId: string | number | null): void {\n current()?.setProfileId(profileId);\n}\n\nexport function reset(): void {\n getClient()?.reset();\n}\n\nexport function flush(): Promise<FlushResult | undefined> {\n const client = getClient();\n return client ? client.flush() : Promise.resolve(undefined);\n}\n\n/** Flushes, tears down listeners, and forgets the client so `init()` starts fresh. */\nexport async function close(): Promise<FlushResult | undefined> {\n const client = getClient();\n if (!client) return undefined;\n forgetClient(client);\n return client.close();\n}\n\nexport function setConsent(category: ConsentCategory, allowed: boolean): void {\n current()?.setConsent(category, allowed);\n}\n\nexport function getConsent(category: ConsentCategory): boolean {\n return current()?.getConsent(category) ?? false;\n}\n\nexport function setAllConsent(allowed: boolean): void {\n current()?.setAllConsent(allowed);\n}\n\nexport function pauseTracking(): void {\n current()?.pauseTracking();\n}\n\nexport function resumeTracking(): void {\n current()?.resumeTracking();\n}\n"],"mappings":";;AAkE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