@reopt-ai/data-sdk-client 0.1.4 → 0.1.6
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.
- package/README.md +2 -1
- package/dist/{chunk-SRHWNG2G.js → chunk-SYCBGBTH.js} +42 -2
- package/dist/chunk-SYCBGBTH.js.map +1 -0
- package/dist/{chunk-JNIOYR44.js → chunk-YRP3I3OD.js} +2 -2
- package/dist/chunk-YRP3I3OD.js.map +1 -0
- package/dist/{client-CW9DfTlm.d.ts → client-BCd2fgmx.d.ts} +123 -113
- package/dist/index.cjs +40 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +4 -4
- package/dist/index.js +1 -1
- package/dist/next.cjs +40 -1
- package/dist/next.cjs.map +1 -1
- package/dist/next.d.ts +1 -1
- package/dist/next.js +2 -2
- package/dist/react.cjs +40 -1
- package/dist/react.cjs.map +1 -1
- package/dist/react.d.ts +4 -4
- package/dist/react.js +2 -2
- package/package.json +4 -4
- package/dist/chunk-JNIOYR44.js.map +0 -1
- package/dist/chunk-SRHWNG2G.js.map +0 -1
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { R as ReoptClient, a as ReoptClientConfig, b as ReoptClientDefaults, U as UTMParams, Q as QueueResult, W as WebVitalMetric, F as FlushResult, D as DecrementOptions, C as ConsentCategory, I as IdentifyOptions, c as IncrementOptions, P as PageViewOptions, T as TrackEventOptions } from './client-
|
|
2
|
-
export { B as BatchConfig, d as CaptureConfig, e as CircuitBreakerConfig, f as ConsentConfig, E as EventIdentity, g as EventPayload, h as FetchInit, i as FetchLike, j as FetchResponseLike, k as IdentityConfig, l as IdentityStorageKind, N as NormalizePath, m as QueueDropReason, n as RetryConfig, S as StorageBackend, o as WebVitalProperties } from './client-
|
|
1
|
+
import { R as ReoptClient, a as ReoptClientConfig, b as ReoptClientDefaults, U as UTMParams, Q as QueueResult, W as WebVitalMetric, F as FlushResult, D as DecrementOptions, C as ConsentCategory, I as IdentifyOptions, c as IncrementOptions, P as PageViewOptions, T as TrackEventOptions } from './client-BCd2fgmx.js';
|
|
2
|
+
export { B as BatchConfig, d as CaptureConfig, e as CircuitBreakerConfig, f as ConsentConfig, E as EventIdentity, g as EventPayload, h as FetchInit, i as FetchLike, j as FetchResponseLike, k as IdentityConfig, l as IdentityStorageKind, N as NormalizePath, m as QueueDropReason, n as RetryConfig, S as StorageBackend, o as WebVitalProperties } from './client-BCd2fgmx.js';
|
|
3
3
|
export { ReoptBootstrap } from '@reopt-ai/data-contract/identity';
|
|
4
4
|
|
|
5
5
|
/**
|
|
@@ -26,9 +26,9 @@ type PageLeaveProperties = {
|
|
|
26
26
|
path: string;
|
|
27
27
|
origin: string;
|
|
28
28
|
duration: number;
|
|
29
|
-
scroll_depth?: number;
|
|
29
|
+
scroll_depth?: number | undefined;
|
|
30
30
|
/** Deepest threshold reached ("0" | "25" | "50" | "75" | "100") — the value to break down by. */
|
|
31
|
-
scroll_depth_bucket?: string;
|
|
31
|
+
scroll_depth_bucket?: string | undefined;
|
|
32
32
|
};
|
|
33
33
|
|
|
34
34
|
/**
|
package/dist/index.js
CHANGED
package/dist/next.cjs
CHANGED
|
@@ -1556,6 +1556,7 @@ var ReoptClient = class extends ReoptCore {
|
|
|
1556
1556
|
uninstallers = [];
|
|
1557
1557
|
torndown = false;
|
|
1558
1558
|
session;
|
|
1559
|
+
optedOut;
|
|
1559
1560
|
normalize;
|
|
1560
1561
|
/** True when `writeKey` or `baseUrl` was missing: every call is a silent no-op. */
|
|
1561
1562
|
disabled;
|
|
@@ -1566,7 +1567,16 @@ var ReoptClient = class extends ReoptCore {
|
|
|
1566
1567
|
}
|
|
1567
1568
|
const writeKey = config.writeKey || "disabled";
|
|
1568
1569
|
const storagePrefix = config.storagePrefix ?? DEFAULT_STORAGE_PREFIX;
|
|
1569
|
-
const
|
|
1570
|
+
const rawStore = createIdentityStore(writeKey, { ...config.identity, ...disabled ? { storage: "memory" } : {} });
|
|
1571
|
+
const optedOut = {
|
|
1572
|
+
value: (0, import_identity5.isOptedOut)(rawStore.readConsent() ?? config.bootstrap?.consent ?? null) || config.consent?.defaultConsent === false
|
|
1573
|
+
};
|
|
1574
|
+
const store = {
|
|
1575
|
+
...rawStore,
|
|
1576
|
+
writeDevice: (state) => {
|
|
1577
|
+
if (!optedOut.value) rawStore.writeDevice(state);
|
|
1578
|
+
}
|
|
1579
|
+
};
|
|
1570
1580
|
const identity = resolveDeviceId(store, config.bootstrap?.deviceId, storagePrefix);
|
|
1571
1581
|
const now = correctedClock(config.bootstrap);
|
|
1572
1582
|
const queueStorage = disabled ? memoryStorage() : config.queueStorage ?? localStorageBackend() ?? memoryStorage();
|
|
@@ -1619,6 +1629,7 @@ var ReoptClient = class extends ReoptCore {
|
|
|
1619
1629
|
this.writeKey = config.writeKey;
|
|
1620
1630
|
this.disabled = disabled;
|
|
1621
1631
|
this.session = session;
|
|
1632
|
+
this.optedOut = optedOut;
|
|
1622
1633
|
this.normalize = config.normalizePath;
|
|
1623
1634
|
this.store = store;
|
|
1624
1635
|
this.capture = resolveCapture(config.capture, defaults.pageview);
|
|
@@ -1677,6 +1688,34 @@ var ReoptClient = class extends ReoptCore {
|
|
|
1677
1688
|
this.scroll?.reset();
|
|
1678
1689
|
return super.pageView(options);
|
|
1679
1690
|
}
|
|
1691
|
+
setConsent(category, allowed) {
|
|
1692
|
+
super.setConsent(category, allowed);
|
|
1693
|
+
this.syncOptOut();
|
|
1694
|
+
}
|
|
1695
|
+
setAllConsent(allowed) {
|
|
1696
|
+
super.setAllConsent(allowed);
|
|
1697
|
+
this.syncOptOut();
|
|
1698
|
+
}
|
|
1699
|
+
replaceConsentState(state) {
|
|
1700
|
+
super.replaceConsentState(state);
|
|
1701
|
+
this.syncOptOut();
|
|
1702
|
+
}
|
|
1703
|
+
/**
|
|
1704
|
+
* Refusing `analytics` removes the stored identity (the proxy does the
|
|
1705
|
+
* same on its side); granting it again writes the current device through
|
|
1706
|
+
* so the visit is attributable from that point on.
|
|
1707
|
+
*/
|
|
1708
|
+
syncOptOut() {
|
|
1709
|
+
const now = (0, import_identity5.isOptedOut)(this.getConsentState());
|
|
1710
|
+
if (now === this.optedOut.value) return;
|
|
1711
|
+
this.optedOut.value = now;
|
|
1712
|
+
if (now) {
|
|
1713
|
+
this.store.clearDevice();
|
|
1714
|
+
this.session.header = null;
|
|
1715
|
+
} else {
|
|
1716
|
+
this.store.writeDevice({ deviceId: this.getDeviceId() });
|
|
1717
|
+
}
|
|
1718
|
+
}
|
|
1680
1719
|
identify(options) {
|
|
1681
1720
|
const result = super.identify(options);
|
|
1682
1721
|
if (!options.identity && result.queued) {
|