@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/next.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as react from 'react';
|
|
2
|
-
export { R as ReoptClient, a as ReoptClientConfig, W as WebVitalMetric } from './client-
|
|
2
|
+
export { R as ReoptClient, a as ReoptClientConfig, W as WebVitalMetric } from './client-BCd2fgmx.js';
|
|
3
3
|
import { ReoptProviderProps } from './react.js';
|
|
4
4
|
export { ReoptContextValue, useConsent, useIdentify, usePageView, usePageViewOnMount, useReopt, useReoptClient, useTrack, useTrackOnMount } from './react.js';
|
|
5
5
|
export { ReoptBootstrap } from '@reopt-ai/data-contract/identity';
|
package/dist/next.js
CHANGED
package/dist/react.cjs
CHANGED
|
@@ -1549,6 +1549,7 @@ var ReoptClient = class extends ReoptCore {
|
|
|
1549
1549
|
uninstallers = [];
|
|
1550
1550
|
torndown = false;
|
|
1551
1551
|
session;
|
|
1552
|
+
optedOut;
|
|
1552
1553
|
normalize;
|
|
1553
1554
|
/** True when `writeKey` or `baseUrl` was missing: every call is a silent no-op. */
|
|
1554
1555
|
disabled;
|
|
@@ -1559,7 +1560,16 @@ var ReoptClient = class extends ReoptCore {
|
|
|
1559
1560
|
}
|
|
1560
1561
|
const writeKey = config.writeKey || "disabled";
|
|
1561
1562
|
const storagePrefix = config.storagePrefix ?? DEFAULT_STORAGE_PREFIX;
|
|
1562
|
-
const
|
|
1563
|
+
const rawStore = createIdentityStore(writeKey, { ...config.identity, ...disabled ? { storage: "memory" } : {} });
|
|
1564
|
+
const optedOut = {
|
|
1565
|
+
value: (0, import_identity5.isOptedOut)(rawStore.readConsent() ?? config.bootstrap?.consent ?? null) || config.consent?.defaultConsent === false
|
|
1566
|
+
};
|
|
1567
|
+
const store = {
|
|
1568
|
+
...rawStore,
|
|
1569
|
+
writeDevice: (state) => {
|
|
1570
|
+
if (!optedOut.value) rawStore.writeDevice(state);
|
|
1571
|
+
}
|
|
1572
|
+
};
|
|
1563
1573
|
const identity = resolveDeviceId(store, config.bootstrap?.deviceId, storagePrefix);
|
|
1564
1574
|
const now = correctedClock(config.bootstrap);
|
|
1565
1575
|
const queueStorage = disabled ? memoryStorage() : config.queueStorage ?? localStorageBackend() ?? memoryStorage();
|
|
@@ -1612,6 +1622,7 @@ var ReoptClient = class extends ReoptCore {
|
|
|
1612
1622
|
this.writeKey = config.writeKey;
|
|
1613
1623
|
this.disabled = disabled;
|
|
1614
1624
|
this.session = session;
|
|
1625
|
+
this.optedOut = optedOut;
|
|
1615
1626
|
this.normalize = config.normalizePath;
|
|
1616
1627
|
this.store = store;
|
|
1617
1628
|
this.capture = resolveCapture(config.capture, defaults.pageview);
|
|
@@ -1670,6 +1681,34 @@ var ReoptClient = class extends ReoptCore {
|
|
|
1670
1681
|
this.scroll?.reset();
|
|
1671
1682
|
return super.pageView(options);
|
|
1672
1683
|
}
|
|
1684
|
+
setConsent(category, allowed) {
|
|
1685
|
+
super.setConsent(category, allowed);
|
|
1686
|
+
this.syncOptOut();
|
|
1687
|
+
}
|
|
1688
|
+
setAllConsent(allowed) {
|
|
1689
|
+
super.setAllConsent(allowed);
|
|
1690
|
+
this.syncOptOut();
|
|
1691
|
+
}
|
|
1692
|
+
replaceConsentState(state) {
|
|
1693
|
+
super.replaceConsentState(state);
|
|
1694
|
+
this.syncOptOut();
|
|
1695
|
+
}
|
|
1696
|
+
/**
|
|
1697
|
+
* Refusing `analytics` removes the stored identity (the proxy does the
|
|
1698
|
+
* same on its side); granting it again writes the current device through
|
|
1699
|
+
* so the visit is attributable from that point on.
|
|
1700
|
+
*/
|
|
1701
|
+
syncOptOut() {
|
|
1702
|
+
const now = (0, import_identity5.isOptedOut)(this.getConsentState());
|
|
1703
|
+
if (now === this.optedOut.value) return;
|
|
1704
|
+
this.optedOut.value = now;
|
|
1705
|
+
if (now) {
|
|
1706
|
+
this.store.clearDevice();
|
|
1707
|
+
this.session.header = null;
|
|
1708
|
+
} else {
|
|
1709
|
+
this.store.writeDevice({ deviceId: this.getDeviceId() });
|
|
1710
|
+
}
|
|
1711
|
+
}
|
|
1673
1712
|
identify(options) {
|
|
1674
1713
|
const result = super.identify(options);
|
|
1675
1714
|
if (!options.identity && result.queued) {
|