@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.mjs
CHANGED
|
@@ -82,7 +82,17 @@ function handleFormSubmit(event) {
|
|
|
82
82
|
});
|
|
83
83
|
const sanitizedFields = sanitizeFormFields(fields, formDenylist);
|
|
84
84
|
if (identityCallback) {
|
|
85
|
-
const
|
|
85
|
+
const identityFields = { ...fields };
|
|
86
|
+
const identityInputTypes = new Map(inputTypes);
|
|
87
|
+
for (let i = 0; i < inputs.length; i++) {
|
|
88
|
+
const input = inputs[i];
|
|
89
|
+
if (input instanceof HTMLInputElement && !input.name && input.value) {
|
|
90
|
+
const syntheticKey = `_unnamed_${i}`;
|
|
91
|
+
identityFields[syntheticKey] = input.value;
|
|
92
|
+
identityInputTypes.set(syntheticKey, input.type);
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
const identity = extractIdentityFromForm(identityFields, identityInputTypes);
|
|
86
96
|
if (identity) {
|
|
87
97
|
identityCallback(identity);
|
|
88
98
|
}
|
|
@@ -1053,48 +1063,78 @@ var OutlitContext = createContext({
|
|
|
1053
1063
|
disableTracking: () => {
|
|
1054
1064
|
}
|
|
1055
1065
|
});
|
|
1056
|
-
function OutlitProvider({
|
|
1057
|
-
children,
|
|
1058
|
-
publicKey,
|
|
1059
|
-
apiHost,
|
|
1060
|
-
trackPageviews = true,
|
|
1061
|
-
trackForms = true,
|
|
1062
|
-
formFieldDenylist,
|
|
1063
|
-
flushInterval,
|
|
1064
|
-
autoTrack = true,
|
|
1065
|
-
autoIdentify = true,
|
|
1066
|
-
user
|
|
1067
|
-
}) {
|
|
1066
|
+
function OutlitProvider(props) {
|
|
1067
|
+
const { children, user } = props;
|
|
1068
1068
|
const outlitRef = useRef(null);
|
|
1069
1069
|
const initializedRef = useRef(false);
|
|
1070
|
+
const isExternalClientRef = useRef(false);
|
|
1071
|
+
const [isInitialized, setIsInitialized] = useState(false);
|
|
1070
1072
|
const [isTrackingEnabled, setIsTrackingEnabled] = useState(false);
|
|
1071
1073
|
useEffect(() => {
|
|
1072
1074
|
if (initializedRef.current) return;
|
|
1073
|
-
|
|
1074
|
-
|
|
1075
|
-
|
|
1076
|
-
|
|
1077
|
-
|
|
1078
|
-
|
|
1079
|
-
|
|
1080
|
-
|
|
1081
|
-
|
|
1082
|
-
|
|
1075
|
+
if (props.client) {
|
|
1076
|
+
if (process.env.NODE_ENV !== "production") {
|
|
1077
|
+
const configKeys = [
|
|
1078
|
+
"publicKey",
|
|
1079
|
+
"apiHost",
|
|
1080
|
+
"trackPageviews",
|
|
1081
|
+
"trackForms",
|
|
1082
|
+
"formFieldDenylist",
|
|
1083
|
+
"flushInterval",
|
|
1084
|
+
"autoTrack",
|
|
1085
|
+
"autoIdentify",
|
|
1086
|
+
"trackCalendarEmbeds",
|
|
1087
|
+
"trackEngagement",
|
|
1088
|
+
"idleTimeout"
|
|
1089
|
+
];
|
|
1090
|
+
const conflicting = configKeys.filter(
|
|
1091
|
+
(k) => k in props && props[k] !== void 0
|
|
1092
|
+
);
|
|
1093
|
+
if (conflicting.length > 0) {
|
|
1094
|
+
console.warn(
|
|
1095
|
+
`[Outlit] Both \`client\` and config props (${conflicting.join(", ")}) were provided to OutlitProvider. The \`client\` instance will be used and config props will be ignored.`
|
|
1096
|
+
);
|
|
1097
|
+
}
|
|
1098
|
+
}
|
|
1099
|
+
outlitRef.current = props.client;
|
|
1100
|
+
isExternalClientRef.current = true;
|
|
1101
|
+
} else {
|
|
1102
|
+
const {
|
|
1103
|
+
publicKey,
|
|
1104
|
+
apiHost,
|
|
1105
|
+
trackPageviews = true,
|
|
1106
|
+
trackForms = true,
|
|
1107
|
+
formFieldDenylist,
|
|
1108
|
+
flushInterval,
|
|
1109
|
+
autoTrack = true,
|
|
1110
|
+
autoIdentify = true,
|
|
1111
|
+
trackCalendarEmbeds,
|
|
1112
|
+
trackEngagement,
|
|
1113
|
+
idleTimeout
|
|
1114
|
+
} = props;
|
|
1115
|
+
outlitRef.current = new Outlit({
|
|
1116
|
+
publicKey,
|
|
1117
|
+
apiHost,
|
|
1118
|
+
trackPageviews,
|
|
1119
|
+
trackForms,
|
|
1120
|
+
formFieldDenylist,
|
|
1121
|
+
flushInterval,
|
|
1122
|
+
autoTrack,
|
|
1123
|
+
autoIdentify,
|
|
1124
|
+
trackCalendarEmbeds,
|
|
1125
|
+
trackEngagement,
|
|
1126
|
+
idleTimeout
|
|
1127
|
+
});
|
|
1128
|
+
}
|
|
1083
1129
|
initializedRef.current = true;
|
|
1130
|
+
setIsInitialized(true);
|
|
1084
1131
|
setIsTrackingEnabled(outlitRef.current.isEnabled());
|
|
1085
1132
|
return () => {
|
|
1086
|
-
|
|
1133
|
+
if (!isExternalClientRef.current) {
|
|
1134
|
+
outlitRef.current?.shutdown();
|
|
1135
|
+
}
|
|
1087
1136
|
};
|
|
1088
|
-
}, [
|
|
1089
|
-
publicKey,
|
|
1090
|
-
apiHost,
|
|
1091
|
-
trackPageviews,
|
|
1092
|
-
trackForms,
|
|
1093
|
-
formFieldDenylist,
|
|
1094
|
-
flushInterval,
|
|
1095
|
-
autoTrack,
|
|
1096
|
-
autoIdentify
|
|
1097
|
-
]);
|
|
1137
|
+
}, []);
|
|
1098
1138
|
useEffect(() => {
|
|
1099
1139
|
if (!outlitRef.current) return;
|
|
1100
1140
|
if (user && (user.email || user.userId)) {
|
|
@@ -1120,7 +1160,7 @@ function OutlitProvider({
|
|
|
1120
1160
|
{
|
|
1121
1161
|
value: {
|
|
1122
1162
|
outlit: outlitRef.current,
|
|
1123
|
-
isInitialized
|
|
1163
|
+
isInitialized,
|
|
1124
1164
|
isTrackingEnabled,
|
|
1125
1165
|
enableTracking,
|
|
1126
1166
|
disableTracking
|