@outlit/browser 1.3.0 → 1.4.1
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.js +11 -1
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +11 -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 +61 -36
- package/dist/react/index.d.ts +61 -36
- package/dist/react/index.js +75 -35
- package/dist/react/index.js.map +1 -1
- package/dist/react/index.mjs +75 -35
- package/dist/react/index.mjs.map +1 -1
- package/dist/vue/index.js +11 -1
- package/dist/vue/index.js.map +1 -1
- package/dist/vue/index.mjs +11 -1
- 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 { U as UserIdentity, h as OutlitOptions, 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
|
|
|
@@ -13,20 +13,8 @@ interface OutlitContextValue {
|
|
|
13
13
|
disableTracking: () => void;
|
|
14
14
|
}
|
|
15
15
|
declare const OutlitContext: react.Context<OutlitContextValue>;
|
|
16
|
-
interface
|
|
16
|
+
interface OutlitProviderBaseProps {
|
|
17
17
|
children: ReactNode;
|
|
18
|
-
/**
|
|
19
|
-
* Whether to automatically track pageviews.
|
|
20
|
-
* When true (default), tracks pageviews on route changes.
|
|
21
|
-
*/
|
|
22
|
-
trackPageviews?: boolean;
|
|
23
|
-
/**
|
|
24
|
-
* Whether to start tracking automatically on mount.
|
|
25
|
-
* Set to false if you need to wait for user consent.
|
|
26
|
-
* Call enableTracking() (from useOutlit hook) after consent is obtained.
|
|
27
|
-
* @default true
|
|
28
|
-
*/
|
|
29
|
-
autoTrack?: boolean;
|
|
30
18
|
/**
|
|
31
19
|
* Current user identity.
|
|
32
20
|
* When provided with email or userId, calls setUser() to identify the user.
|
|
@@ -52,46 +40,83 @@ interface OutlitProviderProps extends Omit<OutlitOptions, "trackPageviews"> {
|
|
|
52
40
|
user?: UserIdentity | null;
|
|
53
41
|
}
|
|
54
42
|
/**
|
|
55
|
-
* Outlit
|
|
56
|
-
*
|
|
43
|
+
* Props for using a pre-existing Outlit instance.
|
|
44
|
+
* The provider will use this instance directly without creating a new one.
|
|
45
|
+
* The caller owns the instance lifecycle — shutdown() will NOT be called on unmount.
|
|
57
46
|
*
|
|
58
47
|
* @example
|
|
59
48
|
* ```tsx
|
|
60
|
-
*
|
|
49
|
+
* import { Outlit } from '@outlit/browser'
|
|
61
50
|
* import { OutlitProvider } from '@outlit/browser/react'
|
|
62
51
|
*
|
|
63
|
-
*
|
|
52
|
+
* const outlit = new Outlit({ publicKey: 'pk_xxx', trackPageviews: false })
|
|
53
|
+
*
|
|
54
|
+
* function App() {
|
|
55
|
+
* const user = useAuth()
|
|
64
56
|
* return (
|
|
65
|
-
* <OutlitProvider
|
|
57
|
+
* <OutlitProvider client={outlit} user={user ? { email: user.email } : null}>
|
|
66
58
|
* {children}
|
|
67
59
|
* </OutlitProvider>
|
|
68
60
|
* )
|
|
69
61
|
* }
|
|
70
62
|
* ```
|
|
63
|
+
*/
|
|
64
|
+
type NeverOutlitOptions = {
|
|
65
|
+
[K in keyof OutlitOptions]?: never;
|
|
66
|
+
};
|
|
67
|
+
interface OutlitProviderClientProps extends OutlitProviderBaseProps, NeverOutlitOptions {
|
|
68
|
+
/** An existing Outlit instance to use. Config props are ignored when this is provided. */
|
|
69
|
+
client: Outlit;
|
|
70
|
+
}
|
|
71
|
+
/**
|
|
72
|
+
* Props for creating a new Outlit instance internally.
|
|
73
|
+
* This is the default behavior — the provider creates and owns the instance.
|
|
74
|
+
*/
|
|
75
|
+
interface OutlitProviderConfigProps extends OutlitProviderBaseProps, Omit<OutlitOptions, "trackPageviews"> {
|
|
76
|
+
client?: never;
|
|
77
|
+
/**
|
|
78
|
+
* Whether to automatically track pageviews.
|
|
79
|
+
* When true (default), tracks pageviews on route changes.
|
|
80
|
+
*/
|
|
81
|
+
trackPageviews?: boolean;
|
|
82
|
+
/**
|
|
83
|
+
* Whether to start tracking automatically on mount.
|
|
84
|
+
* Set to false if you need to wait for user consent.
|
|
85
|
+
* Call enableTracking() (from useOutlit hook) after consent is obtained.
|
|
86
|
+
* @default true
|
|
87
|
+
*/
|
|
88
|
+
autoTrack?: boolean;
|
|
89
|
+
}
|
|
90
|
+
type OutlitProviderProps = OutlitProviderClientProps | OutlitProviderConfigProps;
|
|
91
|
+
/**
|
|
92
|
+
* Outlit Provider component.
|
|
93
|
+
* Initializes the client and provides it to child components via context.
|
|
94
|
+
*
|
|
95
|
+
* Can be used in two ways:
|
|
96
|
+
*
|
|
97
|
+
* 1. **Config mode** (default): Pass `publicKey` and config options to create a new instance.
|
|
98
|
+
* 2. **Client mode**: Pass an existing `client` instance for shared imperative + React usage.
|
|
71
99
|
*
|
|
72
100
|
* @example
|
|
73
101
|
* ```tsx
|
|
74
|
-
* //
|
|
75
|
-
*
|
|
76
|
-
*
|
|
77
|
-
*
|
|
78
|
-
*
|
|
79
|
-
* <OutlitProvider publicKey="pk_xxx" autoTrack={false}>
|
|
80
|
-
* {children}
|
|
81
|
-
* </OutlitProvider>
|
|
82
|
-
* )
|
|
83
|
-
* }
|
|
102
|
+
* // Config mode — provider creates and owns the instance
|
|
103
|
+
* <OutlitProvider publicKey="pk_xxx" trackPageviews>
|
|
104
|
+
* {children}
|
|
105
|
+
* </OutlitProvider>
|
|
106
|
+
* ```
|
|
84
107
|
*
|
|
85
|
-
*
|
|
86
|
-
*
|
|
108
|
+
* @example
|
|
109
|
+
* ```tsx
|
|
110
|
+
* // Client mode — use an existing instance
|
|
111
|
+
* const outlit = new Outlit({ publicKey: 'pk_xxx' })
|
|
112
|
+
* outlit.track('pageview') // imperative usage
|
|
87
113
|
*
|
|
88
|
-
*
|
|
89
|
-
*
|
|
90
|
-
*
|
|
91
|
-
* }
|
|
114
|
+
* <OutlitProvider client={outlit} user={user}>
|
|
115
|
+
* {children}
|
|
116
|
+
* </OutlitProvider>
|
|
92
117
|
* ```
|
|
93
118
|
*/
|
|
94
|
-
declare function OutlitProvider(
|
|
119
|
+
declare function OutlitProvider(props: OutlitProviderProps): react_jsx_runtime.JSX.Element;
|
|
95
120
|
|
|
96
121
|
interface UseOutlitReturn {
|
|
97
122
|
/**
|
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 { U as UserIdentity, h as OutlitOptions, 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
|
|
|
@@ -13,20 +13,8 @@ interface OutlitContextValue {
|
|
|
13
13
|
disableTracking: () => void;
|
|
14
14
|
}
|
|
15
15
|
declare const OutlitContext: react.Context<OutlitContextValue>;
|
|
16
|
-
interface
|
|
16
|
+
interface OutlitProviderBaseProps {
|
|
17
17
|
children: ReactNode;
|
|
18
|
-
/**
|
|
19
|
-
* Whether to automatically track pageviews.
|
|
20
|
-
* When true (default), tracks pageviews on route changes.
|
|
21
|
-
*/
|
|
22
|
-
trackPageviews?: boolean;
|
|
23
|
-
/**
|
|
24
|
-
* Whether to start tracking automatically on mount.
|
|
25
|
-
* Set to false if you need to wait for user consent.
|
|
26
|
-
* Call enableTracking() (from useOutlit hook) after consent is obtained.
|
|
27
|
-
* @default true
|
|
28
|
-
*/
|
|
29
|
-
autoTrack?: boolean;
|
|
30
18
|
/**
|
|
31
19
|
* Current user identity.
|
|
32
20
|
* When provided with email or userId, calls setUser() to identify the user.
|
|
@@ -52,46 +40,83 @@ interface OutlitProviderProps extends Omit<OutlitOptions, "trackPageviews"> {
|
|
|
52
40
|
user?: UserIdentity | null;
|
|
53
41
|
}
|
|
54
42
|
/**
|
|
55
|
-
* Outlit
|
|
56
|
-
*
|
|
43
|
+
* Props for using a pre-existing Outlit instance.
|
|
44
|
+
* The provider will use this instance directly without creating a new one.
|
|
45
|
+
* The caller owns the instance lifecycle — shutdown() will NOT be called on unmount.
|
|
57
46
|
*
|
|
58
47
|
* @example
|
|
59
48
|
* ```tsx
|
|
60
|
-
*
|
|
49
|
+
* import { Outlit } from '@outlit/browser'
|
|
61
50
|
* import { OutlitProvider } from '@outlit/browser/react'
|
|
62
51
|
*
|
|
63
|
-
*
|
|
52
|
+
* const outlit = new Outlit({ publicKey: 'pk_xxx', trackPageviews: false })
|
|
53
|
+
*
|
|
54
|
+
* function App() {
|
|
55
|
+
* const user = useAuth()
|
|
64
56
|
* return (
|
|
65
|
-
* <OutlitProvider
|
|
57
|
+
* <OutlitProvider client={outlit} user={user ? { email: user.email } : null}>
|
|
66
58
|
* {children}
|
|
67
59
|
* </OutlitProvider>
|
|
68
60
|
* )
|
|
69
61
|
* }
|
|
70
62
|
* ```
|
|
63
|
+
*/
|
|
64
|
+
type NeverOutlitOptions = {
|
|
65
|
+
[K in keyof OutlitOptions]?: never;
|
|
66
|
+
};
|
|
67
|
+
interface OutlitProviderClientProps extends OutlitProviderBaseProps, NeverOutlitOptions {
|
|
68
|
+
/** An existing Outlit instance to use. Config props are ignored when this is provided. */
|
|
69
|
+
client: Outlit;
|
|
70
|
+
}
|
|
71
|
+
/**
|
|
72
|
+
* Props for creating a new Outlit instance internally.
|
|
73
|
+
* This is the default behavior — the provider creates and owns the instance.
|
|
74
|
+
*/
|
|
75
|
+
interface OutlitProviderConfigProps extends OutlitProviderBaseProps, Omit<OutlitOptions, "trackPageviews"> {
|
|
76
|
+
client?: never;
|
|
77
|
+
/**
|
|
78
|
+
* Whether to automatically track pageviews.
|
|
79
|
+
* When true (default), tracks pageviews on route changes.
|
|
80
|
+
*/
|
|
81
|
+
trackPageviews?: boolean;
|
|
82
|
+
/**
|
|
83
|
+
* Whether to start tracking automatically on mount.
|
|
84
|
+
* Set to false if you need to wait for user consent.
|
|
85
|
+
* Call enableTracking() (from useOutlit hook) after consent is obtained.
|
|
86
|
+
* @default true
|
|
87
|
+
*/
|
|
88
|
+
autoTrack?: boolean;
|
|
89
|
+
}
|
|
90
|
+
type OutlitProviderProps = OutlitProviderClientProps | OutlitProviderConfigProps;
|
|
91
|
+
/**
|
|
92
|
+
* Outlit Provider component.
|
|
93
|
+
* Initializes the client and provides it to child components via context.
|
|
94
|
+
*
|
|
95
|
+
* Can be used in two ways:
|
|
96
|
+
*
|
|
97
|
+
* 1. **Config mode** (default): Pass `publicKey` and config options to create a new instance.
|
|
98
|
+
* 2. **Client mode**: Pass an existing `client` instance for shared imperative + React usage.
|
|
71
99
|
*
|
|
72
100
|
* @example
|
|
73
101
|
* ```tsx
|
|
74
|
-
* //
|
|
75
|
-
*
|
|
76
|
-
*
|
|
77
|
-
*
|
|
78
|
-
*
|
|
79
|
-
* <OutlitProvider publicKey="pk_xxx" autoTrack={false}>
|
|
80
|
-
* {children}
|
|
81
|
-
* </OutlitProvider>
|
|
82
|
-
* )
|
|
83
|
-
* }
|
|
102
|
+
* // Config mode — provider creates and owns the instance
|
|
103
|
+
* <OutlitProvider publicKey="pk_xxx" trackPageviews>
|
|
104
|
+
* {children}
|
|
105
|
+
* </OutlitProvider>
|
|
106
|
+
* ```
|
|
84
107
|
*
|
|
85
|
-
*
|
|
86
|
-
*
|
|
108
|
+
* @example
|
|
109
|
+
* ```tsx
|
|
110
|
+
* // Client mode — use an existing instance
|
|
111
|
+
* const outlit = new Outlit({ publicKey: 'pk_xxx' })
|
|
112
|
+
* outlit.track('pageview') // imperative usage
|
|
87
113
|
*
|
|
88
|
-
*
|
|
89
|
-
*
|
|
90
|
-
*
|
|
91
|
-
* }
|
|
114
|
+
* <OutlitProvider client={outlit} user={user}>
|
|
115
|
+
* {children}
|
|
116
|
+
* </OutlitProvider>
|
|
92
117
|
* ```
|
|
93
118
|
*/
|
|
94
|
-
declare function OutlitProvider(
|
|
119
|
+
declare function OutlitProvider(props: OutlitProviderProps): react_jsx_runtime.JSX.Element;
|
|
95
120
|
|
|
96
121
|
interface UseOutlitReturn {
|
|
97
122
|
/**
|
package/dist/react/index.js
CHANGED
|
@@ -102,7 +102,17 @@ function handleFormSubmit(event) {
|
|
|
102
102
|
});
|
|
103
103
|
const sanitizedFields = (0, import_core.sanitizeFormFields)(fields, formDenylist);
|
|
104
104
|
if (identityCallback) {
|
|
105
|
-
const
|
|
105
|
+
const identityFields = { ...fields };
|
|
106
|
+
const identityInputTypes = new Map(inputTypes);
|
|
107
|
+
for (let i = 0; i < inputs.length; i++) {
|
|
108
|
+
const input = inputs[i];
|
|
109
|
+
if (input instanceof HTMLInputElement && !input.name && input.value) {
|
|
110
|
+
const syntheticKey = `_unnamed_${i}`;
|
|
111
|
+
identityFields[syntheticKey] = input.value;
|
|
112
|
+
identityInputTypes.set(syntheticKey, input.type);
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
const identity = (0, import_core.extractIdentityFromForm)(identityFields, identityInputTypes);
|
|
106
116
|
if (identity) {
|
|
107
117
|
identityCallback(identity);
|
|
108
118
|
}
|
|
@@ -1073,48 +1083,78 @@ var OutlitContext = (0, import_react.createContext)({
|
|
|
1073
1083
|
disableTracking: () => {
|
|
1074
1084
|
}
|
|
1075
1085
|
});
|
|
1076
|
-
function OutlitProvider({
|
|
1077
|
-
children,
|
|
1078
|
-
publicKey,
|
|
1079
|
-
apiHost,
|
|
1080
|
-
trackPageviews = true,
|
|
1081
|
-
trackForms = true,
|
|
1082
|
-
formFieldDenylist,
|
|
1083
|
-
flushInterval,
|
|
1084
|
-
autoTrack = true,
|
|
1085
|
-
autoIdentify = true,
|
|
1086
|
-
user
|
|
1087
|
-
}) {
|
|
1086
|
+
function OutlitProvider(props) {
|
|
1087
|
+
const { children, user } = props;
|
|
1088
1088
|
const outlitRef = (0, import_react.useRef)(null);
|
|
1089
1089
|
const initializedRef = (0, import_react.useRef)(false);
|
|
1090
|
+
const isExternalClientRef = (0, import_react.useRef)(false);
|
|
1091
|
+
const [isInitialized, setIsInitialized] = (0, import_react.useState)(false);
|
|
1090
1092
|
const [isTrackingEnabled, setIsTrackingEnabled] = (0, import_react.useState)(false);
|
|
1091
1093
|
(0, import_react.useEffect)(() => {
|
|
1092
1094
|
if (initializedRef.current) return;
|
|
1093
|
-
|
|
1094
|
-
|
|
1095
|
-
|
|
1096
|
-
|
|
1097
|
-
|
|
1098
|
-
|
|
1099
|
-
|
|
1100
|
-
|
|
1101
|
-
|
|
1102
|
-
|
|
1095
|
+
if (props.client) {
|
|
1096
|
+
if (process.env.NODE_ENV !== "production") {
|
|
1097
|
+
const configKeys = [
|
|
1098
|
+
"publicKey",
|
|
1099
|
+
"apiHost",
|
|
1100
|
+
"trackPageviews",
|
|
1101
|
+
"trackForms",
|
|
1102
|
+
"formFieldDenylist",
|
|
1103
|
+
"flushInterval",
|
|
1104
|
+
"autoTrack",
|
|
1105
|
+
"autoIdentify",
|
|
1106
|
+
"trackCalendarEmbeds",
|
|
1107
|
+
"trackEngagement",
|
|
1108
|
+
"idleTimeout"
|
|
1109
|
+
];
|
|
1110
|
+
const conflicting = configKeys.filter(
|
|
1111
|
+
(k) => k in props && props[k] !== void 0
|
|
1112
|
+
);
|
|
1113
|
+
if (conflicting.length > 0) {
|
|
1114
|
+
console.warn(
|
|
1115
|
+
`[Outlit] Both \`client\` and config props (${conflicting.join(", ")}) were provided to OutlitProvider. The \`client\` instance will be used and config props will be ignored.`
|
|
1116
|
+
);
|
|
1117
|
+
}
|
|
1118
|
+
}
|
|
1119
|
+
outlitRef.current = props.client;
|
|
1120
|
+
isExternalClientRef.current = true;
|
|
1121
|
+
} else {
|
|
1122
|
+
const {
|
|
1123
|
+
publicKey,
|
|
1124
|
+
apiHost,
|
|
1125
|
+
trackPageviews = true,
|
|
1126
|
+
trackForms = true,
|
|
1127
|
+
formFieldDenylist,
|
|
1128
|
+
flushInterval,
|
|
1129
|
+
autoTrack = true,
|
|
1130
|
+
autoIdentify = true,
|
|
1131
|
+
trackCalendarEmbeds,
|
|
1132
|
+
trackEngagement,
|
|
1133
|
+
idleTimeout
|
|
1134
|
+
} = props;
|
|
1135
|
+
outlitRef.current = new Outlit({
|
|
1136
|
+
publicKey,
|
|
1137
|
+
apiHost,
|
|
1138
|
+
trackPageviews,
|
|
1139
|
+
trackForms,
|
|
1140
|
+
formFieldDenylist,
|
|
1141
|
+
flushInterval,
|
|
1142
|
+
autoTrack,
|
|
1143
|
+
autoIdentify,
|
|
1144
|
+
trackCalendarEmbeds,
|
|
1145
|
+
trackEngagement,
|
|
1146
|
+
idleTimeout
|
|
1147
|
+
});
|
|
1148
|
+
}
|
|
1103
1149
|
initializedRef.current = true;
|
|
1150
|
+
setIsInitialized(true);
|
|
1104
1151
|
setIsTrackingEnabled(outlitRef.current.isEnabled());
|
|
1105
1152
|
return () => {
|
|
1106
|
-
|
|
1153
|
+
if (!isExternalClientRef.current) {
|
|
1154
|
+
outlitRef.current?.shutdown();
|
|
1155
|
+
}
|
|
1107
1156
|
};
|
|
1108
|
-
}, [
|
|
1109
|
-
publicKey,
|
|
1110
|
-
apiHost,
|
|
1111
|
-
trackPageviews,
|
|
1112
|
-
trackForms,
|
|
1113
|
-
formFieldDenylist,
|
|
1114
|
-
flushInterval,
|
|
1115
|
-
autoTrack,
|
|
1116
|
-
autoIdentify
|
|
1117
|
-
]);
|
|
1157
|
+
}, []);
|
|
1118
1158
|
(0, import_react.useEffect)(() => {
|
|
1119
1159
|
if (!outlitRef.current) return;
|
|
1120
1160
|
if (user && (user.email || user.userId)) {
|
|
@@ -1140,7 +1180,7 @@ function OutlitProvider({
|
|
|
1140
1180
|
{
|
|
1141
1181
|
value: {
|
|
1142
1182
|
outlit: outlitRef.current,
|
|
1143
|
-
isInitialized
|
|
1183
|
+
isInitialized,
|
|
1144
1184
|
isTrackingEnabled,
|
|
1145
1185
|
enableTracking,
|
|
1146
1186
|
disableTracking
|