@outlit/browser 1.2.0 → 1.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.
- package/dist/index.d.mts +4 -3
- package/dist/index.d.ts +4 -3
- package/dist/index.js +56 -1
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +55 -1
- package/dist/index.mjs.map +1 -1
- package/dist/outlit.global.js +1 -1
- package/dist/outlit.global.js.map +1 -1
- package/dist/react/index.d.mts +7 -1
- package/dist/react/index.d.ts +7 -1
- package/dist/react/index.js +63 -4
- package/dist/react/index.js.map +1 -1
- package/dist/react/index.mjs +63 -4
- package/dist/react/index.mjs.map +1 -1
- package/dist/{tracker-BTkkFb0f.d.mts → tracker-OMgVDwlV.d.mts} +16 -1
- package/dist/{tracker-BTkkFb0f.d.ts → tracker-OMgVDwlV.d.ts} +16 -1
- package/dist/vue/index.d.mts +7 -1
- package/dist/vue/index.d.ts +7 -1
- package/dist/vue/index.js +60 -3
- package/dist/vue/index.js.map +1 -1
- package/dist/vue/index.mjs +60 -3
- package/dist/vue/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/react/index.d.mts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
2
|
import * as react from 'react';
|
|
3
3
|
import { ReactNode } from 'react';
|
|
4
|
-
import {
|
|
4
|
+
import { h as OutlitOptions, U as UserIdentity, O as Outlit, B as BillingOptions } from '../tracker-OMgVDwlV.mjs';
|
|
5
5
|
import { BrowserTrackOptions, BrowserIdentifyOptions } from '@outlit/core';
|
|
6
6
|
export { BrowserIdentifyOptions, BrowserTrackOptions, CustomerIdentifier, ExplicitJourneyStage, TrackerConfig } from '@outlit/core';
|
|
7
7
|
|
|
@@ -10,6 +10,7 @@ interface OutlitContextValue {
|
|
|
10
10
|
isInitialized: boolean;
|
|
11
11
|
isTrackingEnabled: boolean;
|
|
12
12
|
enableTracking: () => void;
|
|
13
|
+
disableTracking: () => void;
|
|
13
14
|
}
|
|
14
15
|
declare const OutlitContext: react.Context<OutlitContextValue>;
|
|
15
16
|
interface OutlitProviderProps extends Omit<OutlitOptions, "trackPageviews"> {
|
|
@@ -147,6 +148,11 @@ interface UseOutlitReturn {
|
|
|
147
148
|
* Only needed if you initialized with autoTrack: false.
|
|
148
149
|
*/
|
|
149
150
|
enableTracking: () => void;
|
|
151
|
+
/**
|
|
152
|
+
* Disable tracking and persist the opt-out decision.
|
|
153
|
+
* Call this when a user revokes consent.
|
|
154
|
+
*/
|
|
155
|
+
disableTracking: () => void;
|
|
150
156
|
}
|
|
151
157
|
/**
|
|
152
158
|
* Hook to access the Outlit client.
|
package/dist/react/index.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
2
|
import * as react from 'react';
|
|
3
3
|
import { ReactNode } from 'react';
|
|
4
|
-
import {
|
|
4
|
+
import { h as OutlitOptions, U as UserIdentity, O as Outlit, B as BillingOptions } from '../tracker-OMgVDwlV.js';
|
|
5
5
|
import { BrowserTrackOptions, BrowserIdentifyOptions } from '@outlit/core';
|
|
6
6
|
export { BrowserIdentifyOptions, BrowserTrackOptions, CustomerIdentifier, ExplicitJourneyStage, TrackerConfig } from '@outlit/core';
|
|
7
7
|
|
|
@@ -10,6 +10,7 @@ interface OutlitContextValue {
|
|
|
10
10
|
isInitialized: boolean;
|
|
11
11
|
isTrackingEnabled: boolean;
|
|
12
12
|
enableTracking: () => void;
|
|
13
|
+
disableTracking: () => void;
|
|
13
14
|
}
|
|
14
15
|
declare const OutlitContext: react.Context<OutlitContextValue>;
|
|
15
16
|
interface OutlitProviderProps extends Omit<OutlitOptions, "trackPageviews"> {
|
|
@@ -147,6 +148,11 @@ interface UseOutlitReturn {
|
|
|
147
148
|
* Only needed if you initialized with autoTrack: false.
|
|
148
149
|
*/
|
|
149
150
|
enableTracking: () => void;
|
|
151
|
+
/**
|
|
152
|
+
* Disable tracking and persist the opt-out decision.
|
|
153
|
+
* Call this when a user revokes consent.
|
|
154
|
+
*/
|
|
155
|
+
disableTracking: () => void;
|
|
150
156
|
}
|
|
151
157
|
/**
|
|
152
158
|
* Hook to access the Outlit client.
|
package/dist/react/index.js
CHANGED
|
@@ -625,6 +625,27 @@ function setCookie(name, value, days) {
|
|
|
625
625
|
}
|
|
626
626
|
document.cookie = cookie;
|
|
627
627
|
}
|
|
628
|
+
var CONSENT_KEY = "outlit_consent";
|
|
629
|
+
function getConsentState() {
|
|
630
|
+
try {
|
|
631
|
+
const stored = localStorage.getItem(CONSENT_KEY);
|
|
632
|
+
if (stored === "1") return true;
|
|
633
|
+
if (stored === "0") return false;
|
|
634
|
+
} catch {
|
|
635
|
+
}
|
|
636
|
+
const cookieValue = getCookie(CONSENT_KEY);
|
|
637
|
+
if (cookieValue === "1") return true;
|
|
638
|
+
if (cookieValue === "0") return false;
|
|
639
|
+
return null;
|
|
640
|
+
}
|
|
641
|
+
function setConsentState(granted) {
|
|
642
|
+
const value = granted ? "1" : "0";
|
|
643
|
+
try {
|
|
644
|
+
localStorage.setItem(CONSENT_KEY, value);
|
|
645
|
+
} catch {
|
|
646
|
+
}
|
|
647
|
+
setCookie(CONSENT_KEY, value, 365);
|
|
648
|
+
}
|
|
628
649
|
|
|
629
650
|
// src/tracker.ts
|
|
630
651
|
var MAX_PENDING_STAGE_EVENTS = 10;
|
|
@@ -667,7 +688,8 @@ var Outlit = class {
|
|
|
667
688
|
window.addEventListener("beforeunload", handleExit);
|
|
668
689
|
}
|
|
669
690
|
this.isInitialized = true;
|
|
670
|
-
|
|
691
|
+
const consent = getConsentState();
|
|
692
|
+
if (consent === true || consent === null && options.autoTrack !== false) {
|
|
671
693
|
this.enableTracking();
|
|
672
694
|
}
|
|
673
695
|
}
|
|
@@ -700,11 +722,38 @@ var Outlit = class {
|
|
|
700
722
|
this.initCalendarTracking();
|
|
701
723
|
}
|
|
702
724
|
this.isTrackingEnabled = true;
|
|
725
|
+
setConsentState(true);
|
|
703
726
|
if (this.pendingUser) {
|
|
704
727
|
this.applyUser(this.pendingUser);
|
|
705
728
|
this.pendingUser = null;
|
|
706
729
|
}
|
|
707
730
|
}
|
|
731
|
+
/**
|
|
732
|
+
* Disable tracking. Call this when a user revokes consent.
|
|
733
|
+
* This will:
|
|
734
|
+
* - Flush any pending events (captured while user had consent)
|
|
735
|
+
* - Stop the flush timer, pageview tracking, form tracking, and session tracking
|
|
736
|
+
* - Persist the opt-out decision so it's remembered across sessions
|
|
737
|
+
*
|
|
738
|
+
* The SDK instance remains usable — enableTracking() can be called again to re-enable.
|
|
739
|
+
*/
|
|
740
|
+
async disableTracking() {
|
|
741
|
+
if (!this.isTrackingEnabled) {
|
|
742
|
+
setConsentState(false);
|
|
743
|
+
return;
|
|
744
|
+
}
|
|
745
|
+
if (this.flushTimer) {
|
|
746
|
+
clearInterval(this.flushTimer);
|
|
747
|
+
this.flushTimer = null;
|
|
748
|
+
}
|
|
749
|
+
stopAutocapture();
|
|
750
|
+
stopCalendarTracking();
|
|
751
|
+
stopSessionTracking();
|
|
752
|
+
await this.flush();
|
|
753
|
+
this.sessionTracker = null;
|
|
754
|
+
this.isTrackingEnabled = false;
|
|
755
|
+
setConsentState(false);
|
|
756
|
+
}
|
|
708
757
|
/**
|
|
709
758
|
* Check if tracking is currently enabled.
|
|
710
759
|
*/
|
|
@@ -1020,6 +1069,8 @@ var OutlitContext = (0, import_react.createContext)({
|
|
|
1020
1069
|
isInitialized: false,
|
|
1021
1070
|
isTrackingEnabled: false,
|
|
1022
1071
|
enableTracking: () => {
|
|
1072
|
+
},
|
|
1073
|
+
disableTracking: () => {
|
|
1023
1074
|
}
|
|
1024
1075
|
});
|
|
1025
1076
|
function OutlitProvider({
|
|
@@ -1078,6 +1129,12 @@ function OutlitProvider({
|
|
|
1078
1129
|
setIsTrackingEnabled(true);
|
|
1079
1130
|
}
|
|
1080
1131
|
}, []);
|
|
1132
|
+
const disableTracking = (0, import_react.useCallback)(() => {
|
|
1133
|
+
if (outlitRef.current) {
|
|
1134
|
+
outlitRef.current.disableTracking();
|
|
1135
|
+
setIsTrackingEnabled(false);
|
|
1136
|
+
}
|
|
1137
|
+
}, []);
|
|
1081
1138
|
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
1082
1139
|
OutlitContext.Provider,
|
|
1083
1140
|
{
|
|
@@ -1085,7 +1142,8 @@ function OutlitProvider({
|
|
|
1085
1142
|
outlit: outlitRef.current,
|
|
1086
1143
|
isInitialized: initializedRef.current,
|
|
1087
1144
|
isTrackingEnabled,
|
|
1088
|
-
enableTracking
|
|
1145
|
+
enableTracking,
|
|
1146
|
+
disableTracking
|
|
1089
1147
|
},
|
|
1090
1148
|
children
|
|
1091
1149
|
}
|
|
@@ -1095,7 +1153,7 @@ function OutlitProvider({
|
|
|
1095
1153
|
// src/react/hooks.ts
|
|
1096
1154
|
var import_react2 = require("react");
|
|
1097
1155
|
function useOutlit() {
|
|
1098
|
-
const { outlit, isInitialized, isTrackingEnabled, enableTracking } = (0, import_react2.useContext)(OutlitContext);
|
|
1156
|
+
const { outlit, isInitialized, isTrackingEnabled, enableTracking, disableTracking } = (0, import_react2.useContext)(OutlitContext);
|
|
1099
1157
|
const track = (0, import_react2.useCallback)(
|
|
1100
1158
|
(eventName, properties) => {
|
|
1101
1159
|
if (!outlit) {
|
|
@@ -1226,7 +1284,8 @@ function useOutlit() {
|
|
|
1226
1284
|
},
|
|
1227
1285
|
isInitialized,
|
|
1228
1286
|
isTrackingEnabled,
|
|
1229
|
-
enableTracking
|
|
1287
|
+
enableTracking,
|
|
1288
|
+
disableTracking
|
|
1230
1289
|
};
|
|
1231
1290
|
}
|
|
1232
1291
|
function useTrack() {
|