humanbehavior-js 0.1.8 → 0.2.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/.tsbuildinfo +1 -0
- package/dist/cjs/index.js +145 -71
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/react/index.js +492 -26
- package/dist/cjs/react/index.js.map +1 -1
- package/dist/esm/index.js +145 -72
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/react/index.js +474 -10
- package/dist/esm/react/index.js.map +1 -1
- package/dist/index.min.js +1 -15
- package/dist/index.min.js.map +1 -1
- package/dist/types/index.d.ts +23 -8
- package/dist/types/react/index.d.ts +18 -3
- package/package.json +33 -10
- package/readme.md +2 -0
- package/src/api.ts +75 -16
- package/src/index.ts +2 -2
- package/src/react/index.tsx +49 -4
- package/src/tracker.ts +81 -51
- package/rollup.config.js +0 -106
- package/simple-demo.html +0 -26
- package/simple-spa.html +0 -594
- package/tsconfig.json +0 -24
package/dist/esm/react/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import require$$0, { createContext, useState, useRef, useEffect, useCallback, useMemo, useContext } from 'react';
|
|
2
2
|
import { HumanBehaviorTracker } from '..';
|
|
3
3
|
export { HumanBehaviorTracker } from '..';
|
|
4
4
|
|
|
@@ -34,6 +34,433 @@ typeof SuppressedError === "function" ? SuppressedError : function (error, suppr
|
|
|
34
34
|
return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
|
|
35
35
|
};
|
|
36
36
|
|
|
37
|
+
var jsxRuntime = {exports: {}};
|
|
38
|
+
|
|
39
|
+
var reactJsxRuntime_production = {};
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
* @license React
|
|
43
|
+
* react-jsx-runtime.production.js
|
|
44
|
+
*
|
|
45
|
+
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
46
|
+
*
|
|
47
|
+
* This source code is licensed under the MIT license found in the
|
|
48
|
+
* LICENSE file in the root directory of this source tree.
|
|
49
|
+
*/
|
|
50
|
+
|
|
51
|
+
var hasRequiredReactJsxRuntime_production;
|
|
52
|
+
|
|
53
|
+
function requireReactJsxRuntime_production () {
|
|
54
|
+
if (hasRequiredReactJsxRuntime_production) return reactJsxRuntime_production;
|
|
55
|
+
hasRequiredReactJsxRuntime_production = 1;
|
|
56
|
+
var REACT_ELEMENT_TYPE = Symbol.for("react.transitional.element"),
|
|
57
|
+
REACT_FRAGMENT_TYPE = Symbol.for("react.fragment");
|
|
58
|
+
function jsxProd(type, config, maybeKey) {
|
|
59
|
+
var key = null;
|
|
60
|
+
void 0 !== maybeKey && (key = "" + maybeKey);
|
|
61
|
+
void 0 !== config.key && (key = "" + config.key);
|
|
62
|
+
if ("key" in config) {
|
|
63
|
+
maybeKey = {};
|
|
64
|
+
for (var propName in config)
|
|
65
|
+
"key" !== propName && (maybeKey[propName] = config[propName]);
|
|
66
|
+
} else maybeKey = config;
|
|
67
|
+
config = maybeKey.ref;
|
|
68
|
+
return {
|
|
69
|
+
$$typeof: REACT_ELEMENT_TYPE,
|
|
70
|
+
type: type,
|
|
71
|
+
key: key,
|
|
72
|
+
ref: void 0 !== config ? config : null,
|
|
73
|
+
props: maybeKey
|
|
74
|
+
};
|
|
75
|
+
}
|
|
76
|
+
reactJsxRuntime_production.Fragment = REACT_FRAGMENT_TYPE;
|
|
77
|
+
reactJsxRuntime_production.jsx = jsxProd;
|
|
78
|
+
reactJsxRuntime_production.jsxs = jsxProd;
|
|
79
|
+
return reactJsxRuntime_production;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
var reactJsxRuntime_development = {};
|
|
83
|
+
|
|
84
|
+
/**
|
|
85
|
+
* @license React
|
|
86
|
+
* react-jsx-runtime.development.js
|
|
87
|
+
*
|
|
88
|
+
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
89
|
+
*
|
|
90
|
+
* This source code is licensed under the MIT license found in the
|
|
91
|
+
* LICENSE file in the root directory of this source tree.
|
|
92
|
+
*/
|
|
93
|
+
|
|
94
|
+
var hasRequiredReactJsxRuntime_development;
|
|
95
|
+
|
|
96
|
+
function requireReactJsxRuntime_development () {
|
|
97
|
+
if (hasRequiredReactJsxRuntime_development) return reactJsxRuntime_development;
|
|
98
|
+
hasRequiredReactJsxRuntime_development = 1;
|
|
99
|
+
"production" !== process.env.NODE_ENV &&
|
|
100
|
+
(function () {
|
|
101
|
+
function getComponentNameFromType(type) {
|
|
102
|
+
if (null == type) return null;
|
|
103
|
+
if ("function" === typeof type)
|
|
104
|
+
return type.$$typeof === REACT_CLIENT_REFERENCE
|
|
105
|
+
? null
|
|
106
|
+
: type.displayName || type.name || null;
|
|
107
|
+
if ("string" === typeof type) return type;
|
|
108
|
+
switch (type) {
|
|
109
|
+
case REACT_FRAGMENT_TYPE:
|
|
110
|
+
return "Fragment";
|
|
111
|
+
case REACT_PROFILER_TYPE:
|
|
112
|
+
return "Profiler";
|
|
113
|
+
case REACT_STRICT_MODE_TYPE:
|
|
114
|
+
return "StrictMode";
|
|
115
|
+
case REACT_SUSPENSE_TYPE:
|
|
116
|
+
return "Suspense";
|
|
117
|
+
case REACT_SUSPENSE_LIST_TYPE:
|
|
118
|
+
return "SuspenseList";
|
|
119
|
+
case REACT_ACTIVITY_TYPE:
|
|
120
|
+
return "Activity";
|
|
121
|
+
}
|
|
122
|
+
if ("object" === typeof type)
|
|
123
|
+
switch (
|
|
124
|
+
("number" === typeof type.tag &&
|
|
125
|
+
console.error(
|
|
126
|
+
"Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."
|
|
127
|
+
),
|
|
128
|
+
type.$$typeof)
|
|
129
|
+
) {
|
|
130
|
+
case REACT_PORTAL_TYPE:
|
|
131
|
+
return "Portal";
|
|
132
|
+
case REACT_CONTEXT_TYPE:
|
|
133
|
+
return (type.displayName || "Context") + ".Provider";
|
|
134
|
+
case REACT_CONSUMER_TYPE:
|
|
135
|
+
return (type._context.displayName || "Context") + ".Consumer";
|
|
136
|
+
case REACT_FORWARD_REF_TYPE:
|
|
137
|
+
var innerType = type.render;
|
|
138
|
+
type = type.displayName;
|
|
139
|
+
type ||
|
|
140
|
+
((type = innerType.displayName || innerType.name || ""),
|
|
141
|
+
(type = "" !== type ? "ForwardRef(" + type + ")" : "ForwardRef"));
|
|
142
|
+
return type;
|
|
143
|
+
case REACT_MEMO_TYPE:
|
|
144
|
+
return (
|
|
145
|
+
(innerType = type.displayName || null),
|
|
146
|
+
null !== innerType
|
|
147
|
+
? innerType
|
|
148
|
+
: getComponentNameFromType(type.type) || "Memo"
|
|
149
|
+
);
|
|
150
|
+
case REACT_LAZY_TYPE:
|
|
151
|
+
innerType = type._payload;
|
|
152
|
+
type = type._init;
|
|
153
|
+
try {
|
|
154
|
+
return getComponentNameFromType(type(innerType));
|
|
155
|
+
} catch (x) {}
|
|
156
|
+
}
|
|
157
|
+
return null;
|
|
158
|
+
}
|
|
159
|
+
function testStringCoercion(value) {
|
|
160
|
+
return "" + value;
|
|
161
|
+
}
|
|
162
|
+
function checkKeyStringCoercion(value) {
|
|
163
|
+
try {
|
|
164
|
+
testStringCoercion(value);
|
|
165
|
+
var JSCompiler_inline_result = !1;
|
|
166
|
+
} catch (e) {
|
|
167
|
+
JSCompiler_inline_result = true;
|
|
168
|
+
}
|
|
169
|
+
if (JSCompiler_inline_result) {
|
|
170
|
+
JSCompiler_inline_result = console;
|
|
171
|
+
var JSCompiler_temp_const = JSCompiler_inline_result.error;
|
|
172
|
+
var JSCompiler_inline_result$jscomp$0 =
|
|
173
|
+
("function" === typeof Symbol &&
|
|
174
|
+
Symbol.toStringTag &&
|
|
175
|
+
value[Symbol.toStringTag]) ||
|
|
176
|
+
value.constructor.name ||
|
|
177
|
+
"Object";
|
|
178
|
+
JSCompiler_temp_const.call(
|
|
179
|
+
JSCompiler_inline_result,
|
|
180
|
+
"The provided key is an unsupported type %s. This value must be coerced to a string before using it here.",
|
|
181
|
+
JSCompiler_inline_result$jscomp$0
|
|
182
|
+
);
|
|
183
|
+
return testStringCoercion(value);
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
function getTaskName(type) {
|
|
187
|
+
if (type === REACT_FRAGMENT_TYPE) return "<>";
|
|
188
|
+
if (
|
|
189
|
+
"object" === typeof type &&
|
|
190
|
+
null !== type &&
|
|
191
|
+
type.$$typeof === REACT_LAZY_TYPE
|
|
192
|
+
)
|
|
193
|
+
return "<...>";
|
|
194
|
+
try {
|
|
195
|
+
var name = getComponentNameFromType(type);
|
|
196
|
+
return name ? "<" + name + ">" : "<...>";
|
|
197
|
+
} catch (x) {
|
|
198
|
+
return "<...>";
|
|
199
|
+
}
|
|
200
|
+
}
|
|
201
|
+
function getOwner() {
|
|
202
|
+
var dispatcher = ReactSharedInternals.A;
|
|
203
|
+
return null === dispatcher ? null : dispatcher.getOwner();
|
|
204
|
+
}
|
|
205
|
+
function UnknownOwner() {
|
|
206
|
+
return Error("react-stack-top-frame");
|
|
207
|
+
}
|
|
208
|
+
function hasValidKey(config) {
|
|
209
|
+
if (hasOwnProperty.call(config, "key")) {
|
|
210
|
+
var getter = Object.getOwnPropertyDescriptor(config, "key").get;
|
|
211
|
+
if (getter && getter.isReactWarning) return false;
|
|
212
|
+
}
|
|
213
|
+
return void 0 !== config.key;
|
|
214
|
+
}
|
|
215
|
+
function defineKeyPropWarningGetter(props, displayName) {
|
|
216
|
+
function warnAboutAccessingKey() {
|
|
217
|
+
specialPropKeyWarningShown ||
|
|
218
|
+
((specialPropKeyWarningShown = true),
|
|
219
|
+
console.error(
|
|
220
|
+
"%s: `key` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://react.dev/link/special-props)",
|
|
221
|
+
displayName
|
|
222
|
+
));
|
|
223
|
+
}
|
|
224
|
+
warnAboutAccessingKey.isReactWarning = true;
|
|
225
|
+
Object.defineProperty(props, "key", {
|
|
226
|
+
get: warnAboutAccessingKey,
|
|
227
|
+
configurable: true
|
|
228
|
+
});
|
|
229
|
+
}
|
|
230
|
+
function elementRefGetterWithDeprecationWarning() {
|
|
231
|
+
var componentName = getComponentNameFromType(this.type);
|
|
232
|
+
didWarnAboutElementRef[componentName] ||
|
|
233
|
+
((didWarnAboutElementRef[componentName] = true),
|
|
234
|
+
console.error(
|
|
235
|
+
"Accessing element.ref was removed in React 19. ref is now a regular prop. It will be removed from the JSX Element type in a future release."
|
|
236
|
+
));
|
|
237
|
+
componentName = this.props.ref;
|
|
238
|
+
return void 0 !== componentName ? componentName : null;
|
|
239
|
+
}
|
|
240
|
+
function ReactElement(
|
|
241
|
+
type,
|
|
242
|
+
key,
|
|
243
|
+
self,
|
|
244
|
+
source,
|
|
245
|
+
owner,
|
|
246
|
+
props,
|
|
247
|
+
debugStack,
|
|
248
|
+
debugTask
|
|
249
|
+
) {
|
|
250
|
+
self = props.ref;
|
|
251
|
+
type = {
|
|
252
|
+
$$typeof: REACT_ELEMENT_TYPE,
|
|
253
|
+
type: type,
|
|
254
|
+
key: key,
|
|
255
|
+
props: props,
|
|
256
|
+
_owner: owner
|
|
257
|
+
};
|
|
258
|
+
null !== (void 0 !== self ? self : null)
|
|
259
|
+
? Object.defineProperty(type, "ref", {
|
|
260
|
+
enumerable: false,
|
|
261
|
+
get: elementRefGetterWithDeprecationWarning
|
|
262
|
+
})
|
|
263
|
+
: Object.defineProperty(type, "ref", { enumerable: false, value: null });
|
|
264
|
+
type._store = {};
|
|
265
|
+
Object.defineProperty(type._store, "validated", {
|
|
266
|
+
configurable: false,
|
|
267
|
+
enumerable: false,
|
|
268
|
+
writable: true,
|
|
269
|
+
value: 0
|
|
270
|
+
});
|
|
271
|
+
Object.defineProperty(type, "_debugInfo", {
|
|
272
|
+
configurable: false,
|
|
273
|
+
enumerable: false,
|
|
274
|
+
writable: true,
|
|
275
|
+
value: null
|
|
276
|
+
});
|
|
277
|
+
Object.defineProperty(type, "_debugStack", {
|
|
278
|
+
configurable: false,
|
|
279
|
+
enumerable: false,
|
|
280
|
+
writable: true,
|
|
281
|
+
value: debugStack
|
|
282
|
+
});
|
|
283
|
+
Object.defineProperty(type, "_debugTask", {
|
|
284
|
+
configurable: false,
|
|
285
|
+
enumerable: false,
|
|
286
|
+
writable: true,
|
|
287
|
+
value: debugTask
|
|
288
|
+
});
|
|
289
|
+
Object.freeze && (Object.freeze(type.props), Object.freeze(type));
|
|
290
|
+
return type;
|
|
291
|
+
}
|
|
292
|
+
function jsxDEVImpl(
|
|
293
|
+
type,
|
|
294
|
+
config,
|
|
295
|
+
maybeKey,
|
|
296
|
+
isStaticChildren,
|
|
297
|
+
source,
|
|
298
|
+
self,
|
|
299
|
+
debugStack,
|
|
300
|
+
debugTask
|
|
301
|
+
) {
|
|
302
|
+
var children = config.children;
|
|
303
|
+
if (void 0 !== children)
|
|
304
|
+
if (isStaticChildren)
|
|
305
|
+
if (isArrayImpl(children)) {
|
|
306
|
+
for (
|
|
307
|
+
isStaticChildren = 0;
|
|
308
|
+
isStaticChildren < children.length;
|
|
309
|
+
isStaticChildren++
|
|
310
|
+
)
|
|
311
|
+
validateChildKeys(children[isStaticChildren]);
|
|
312
|
+
Object.freeze && Object.freeze(children);
|
|
313
|
+
} else
|
|
314
|
+
console.error(
|
|
315
|
+
"React.jsx: Static children should always be an array. You are likely explicitly calling React.jsxs or React.jsxDEV. Use the Babel transform instead."
|
|
316
|
+
);
|
|
317
|
+
else validateChildKeys(children);
|
|
318
|
+
if (hasOwnProperty.call(config, "key")) {
|
|
319
|
+
children = getComponentNameFromType(type);
|
|
320
|
+
var keys = Object.keys(config).filter(function (k) {
|
|
321
|
+
return "key" !== k;
|
|
322
|
+
});
|
|
323
|
+
isStaticChildren =
|
|
324
|
+
0 < keys.length
|
|
325
|
+
? "{key: someKey, " + keys.join(": ..., ") + ": ...}"
|
|
326
|
+
: "{key: someKey}";
|
|
327
|
+
didWarnAboutKeySpread[children + isStaticChildren] ||
|
|
328
|
+
((keys =
|
|
329
|
+
0 < keys.length ? "{" + keys.join(": ..., ") + ": ...}" : "{}"),
|
|
330
|
+
console.error(
|
|
331
|
+
'A props object containing a "key" prop is being spread into JSX:\n let props = %s;\n <%s {...props} />\nReact keys must be passed directly to JSX without using spread:\n let props = %s;\n <%s key={someKey} {...props} />',
|
|
332
|
+
isStaticChildren,
|
|
333
|
+
children,
|
|
334
|
+
keys,
|
|
335
|
+
children
|
|
336
|
+
),
|
|
337
|
+
(didWarnAboutKeySpread[children + isStaticChildren] = true));
|
|
338
|
+
}
|
|
339
|
+
children = null;
|
|
340
|
+
void 0 !== maybeKey &&
|
|
341
|
+
(checkKeyStringCoercion(maybeKey), (children = "" + maybeKey));
|
|
342
|
+
hasValidKey(config) &&
|
|
343
|
+
(checkKeyStringCoercion(config.key), (children = "" + config.key));
|
|
344
|
+
if ("key" in config) {
|
|
345
|
+
maybeKey = {};
|
|
346
|
+
for (var propName in config)
|
|
347
|
+
"key" !== propName && (maybeKey[propName] = config[propName]);
|
|
348
|
+
} else maybeKey = config;
|
|
349
|
+
children &&
|
|
350
|
+
defineKeyPropWarningGetter(
|
|
351
|
+
maybeKey,
|
|
352
|
+
"function" === typeof type
|
|
353
|
+
? type.displayName || type.name || "Unknown"
|
|
354
|
+
: type
|
|
355
|
+
);
|
|
356
|
+
return ReactElement(
|
|
357
|
+
type,
|
|
358
|
+
children,
|
|
359
|
+
self,
|
|
360
|
+
source,
|
|
361
|
+
getOwner(),
|
|
362
|
+
maybeKey,
|
|
363
|
+
debugStack,
|
|
364
|
+
debugTask
|
|
365
|
+
);
|
|
366
|
+
}
|
|
367
|
+
function validateChildKeys(node) {
|
|
368
|
+
"object" === typeof node &&
|
|
369
|
+
null !== node &&
|
|
370
|
+
node.$$typeof === REACT_ELEMENT_TYPE &&
|
|
371
|
+
node._store &&
|
|
372
|
+
(node._store.validated = 1);
|
|
373
|
+
}
|
|
374
|
+
var React = require$$0,
|
|
375
|
+
REACT_ELEMENT_TYPE = Symbol.for("react.transitional.element"),
|
|
376
|
+
REACT_PORTAL_TYPE = Symbol.for("react.portal"),
|
|
377
|
+
REACT_FRAGMENT_TYPE = Symbol.for("react.fragment"),
|
|
378
|
+
REACT_STRICT_MODE_TYPE = Symbol.for("react.strict_mode"),
|
|
379
|
+
REACT_PROFILER_TYPE = Symbol.for("react.profiler");
|
|
380
|
+
var REACT_CONSUMER_TYPE = Symbol.for("react.consumer"),
|
|
381
|
+
REACT_CONTEXT_TYPE = Symbol.for("react.context"),
|
|
382
|
+
REACT_FORWARD_REF_TYPE = Symbol.for("react.forward_ref"),
|
|
383
|
+
REACT_SUSPENSE_TYPE = Symbol.for("react.suspense"),
|
|
384
|
+
REACT_SUSPENSE_LIST_TYPE = Symbol.for("react.suspense_list"),
|
|
385
|
+
REACT_MEMO_TYPE = Symbol.for("react.memo"),
|
|
386
|
+
REACT_LAZY_TYPE = Symbol.for("react.lazy"),
|
|
387
|
+
REACT_ACTIVITY_TYPE = Symbol.for("react.activity"),
|
|
388
|
+
REACT_CLIENT_REFERENCE = Symbol.for("react.client.reference"),
|
|
389
|
+
ReactSharedInternals =
|
|
390
|
+
React.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,
|
|
391
|
+
hasOwnProperty = Object.prototype.hasOwnProperty,
|
|
392
|
+
isArrayImpl = Array.isArray,
|
|
393
|
+
createTask = console.createTask
|
|
394
|
+
? console.createTask
|
|
395
|
+
: function () {
|
|
396
|
+
return null;
|
|
397
|
+
};
|
|
398
|
+
React = {
|
|
399
|
+
"react-stack-bottom-frame": function (callStackForError) {
|
|
400
|
+
return callStackForError();
|
|
401
|
+
}
|
|
402
|
+
};
|
|
403
|
+
var specialPropKeyWarningShown;
|
|
404
|
+
var didWarnAboutElementRef = {};
|
|
405
|
+
var unknownOwnerDebugStack = React["react-stack-bottom-frame"].bind(
|
|
406
|
+
React,
|
|
407
|
+
UnknownOwner
|
|
408
|
+
)();
|
|
409
|
+
var unknownOwnerDebugTask = createTask(getTaskName(UnknownOwner));
|
|
410
|
+
var didWarnAboutKeySpread = {};
|
|
411
|
+
reactJsxRuntime_development.Fragment = REACT_FRAGMENT_TYPE;
|
|
412
|
+
reactJsxRuntime_development.jsx = function (type, config, maybeKey, source, self) {
|
|
413
|
+
var trackActualOwner =
|
|
414
|
+
1e4 > ReactSharedInternals.recentlyCreatedOwnerStacks++;
|
|
415
|
+
return jsxDEVImpl(
|
|
416
|
+
type,
|
|
417
|
+
config,
|
|
418
|
+
maybeKey,
|
|
419
|
+
false,
|
|
420
|
+
source,
|
|
421
|
+
self,
|
|
422
|
+
trackActualOwner
|
|
423
|
+
? Error("react-stack-top-frame")
|
|
424
|
+
: unknownOwnerDebugStack,
|
|
425
|
+
trackActualOwner ? createTask(getTaskName(type)) : unknownOwnerDebugTask
|
|
426
|
+
);
|
|
427
|
+
};
|
|
428
|
+
reactJsxRuntime_development.jsxs = function (type, config, maybeKey, source, self) {
|
|
429
|
+
var trackActualOwner =
|
|
430
|
+
1e4 > ReactSharedInternals.recentlyCreatedOwnerStacks++;
|
|
431
|
+
return jsxDEVImpl(
|
|
432
|
+
type,
|
|
433
|
+
config,
|
|
434
|
+
maybeKey,
|
|
435
|
+
true,
|
|
436
|
+
source,
|
|
437
|
+
self,
|
|
438
|
+
trackActualOwner
|
|
439
|
+
? Error("react-stack-top-frame")
|
|
440
|
+
: unknownOwnerDebugStack,
|
|
441
|
+
trackActualOwner ? createTask(getTaskName(type)) : unknownOwnerDebugTask
|
|
442
|
+
);
|
|
443
|
+
};
|
|
444
|
+
})();
|
|
445
|
+
return reactJsxRuntime_development;
|
|
446
|
+
}
|
|
447
|
+
|
|
448
|
+
var hasRequiredJsxRuntime;
|
|
449
|
+
|
|
450
|
+
function requireJsxRuntime () {
|
|
451
|
+
if (hasRequiredJsxRuntime) return jsxRuntime.exports;
|
|
452
|
+
hasRequiredJsxRuntime = 1;
|
|
453
|
+
|
|
454
|
+
if (process.env.NODE_ENV === 'production') {
|
|
455
|
+
jsxRuntime.exports = requireReactJsxRuntime_production();
|
|
456
|
+
} else {
|
|
457
|
+
jsxRuntime.exports = requireReactJsxRuntime_development();
|
|
458
|
+
}
|
|
459
|
+
return jsxRuntime.exports;
|
|
460
|
+
}
|
|
461
|
+
|
|
462
|
+
var jsxRuntimeExports = requireJsxRuntime();
|
|
463
|
+
|
|
37
464
|
var LogLevel;
|
|
38
465
|
(function (LogLevel) {
|
|
39
466
|
LogLevel[LogLevel["NONE"] = 0] = "NONE";
|
|
@@ -207,21 +634,25 @@ const HumanBehaviorProvider = ({ apiKey, client, children, options }) => {
|
|
|
207
634
|
setHumanBehavior(tracker);
|
|
208
635
|
// Wait for initialization to complete
|
|
209
636
|
(_a = tracker.initializationPromise) === null || _a === void 0 ? void 0 : _a.then(() => __awaiter(void 0, void 0, void 0, function* () {
|
|
210
|
-
// Start the tracker to enable event flushing and recording
|
|
211
637
|
yield tracker.start();
|
|
212
638
|
setIsInitialized(true);
|
|
213
639
|
// Process any queued events
|
|
214
640
|
const currentQueue = eventQueueRef.current;
|
|
215
641
|
if (currentQueue.length > 0) {
|
|
216
|
-
|
|
642
|
+
for (const event of currentQueue) {
|
|
217
643
|
if (event.type === 'identify') {
|
|
218
644
|
logDebug('Processing queued identify event', event.userProperties);
|
|
219
|
-
|
|
645
|
+
try {
|
|
646
|
+
yield tracker.addUserInfo(event.userProperties);
|
|
647
|
+
}
|
|
648
|
+
catch (error) {
|
|
649
|
+
logError('Failed to process queued user info:', error);
|
|
650
|
+
}
|
|
220
651
|
}
|
|
221
652
|
else {
|
|
222
653
|
tracker.addEvent(event);
|
|
223
654
|
}
|
|
224
|
-
}
|
|
655
|
+
}
|
|
225
656
|
setEventQueue([]); // Clear the queue
|
|
226
657
|
}
|
|
227
658
|
})).catch(error => {
|
|
@@ -240,11 +671,9 @@ const HumanBehaviorProvider = ({ apiKey, client, children, options }) => {
|
|
|
240
671
|
}, [isMounted, isInitialized, humanBehavior]);
|
|
241
672
|
// If not in browser, render children without context
|
|
242
673
|
if (!(isBrowser())) {
|
|
243
|
-
return
|
|
674
|
+
return jsxRuntimeExports.jsx(jsxRuntimeExports.Fragment, { children: children });
|
|
244
675
|
}
|
|
245
|
-
return (
|
|
246
|
-
React.createElement(HumanBehaviorPageView, null),
|
|
247
|
-
children));
|
|
676
|
+
return (jsxRuntimeExports.jsxs(HumanBehaviorContext.Provider, { value: contextValue, children: [jsxRuntimeExports.jsx(HumanBehaviorPageView, {}), children] }));
|
|
248
677
|
};
|
|
249
678
|
const useHumanBehavior = () => {
|
|
250
679
|
const tracker = useContext(HumanBehaviorContext);
|
|
@@ -253,6 +682,41 @@ const useHumanBehavior = () => {
|
|
|
253
682
|
}
|
|
254
683
|
return tracker;
|
|
255
684
|
};
|
|
685
|
+
// Custom hook for managing redaction fields dynamically
|
|
686
|
+
const useRedaction = () => {
|
|
687
|
+
const tracker = useHumanBehavior();
|
|
688
|
+
const setRedactedFields = useCallback((fields) => {
|
|
689
|
+
tracker.setRedactedFields(fields);
|
|
690
|
+
}, [tracker]);
|
|
691
|
+
const isRedactionActive = useCallback(() => {
|
|
692
|
+
return tracker.isRedactionActive();
|
|
693
|
+
}, [tracker]);
|
|
694
|
+
const getRedactedFields = useCallback(() => {
|
|
695
|
+
return tracker.getRedactedFields();
|
|
696
|
+
}, [tracker]);
|
|
697
|
+
return {
|
|
698
|
+
setRedactedFields,
|
|
699
|
+
isRedactionActive,
|
|
700
|
+
getRedactedFields
|
|
701
|
+
};
|
|
702
|
+
};
|
|
703
|
+
// Custom hook for managing user info
|
|
704
|
+
const useUserTracking = () => {
|
|
705
|
+
const tracker = useHumanBehavior();
|
|
706
|
+
const addUserInfo = useCallback((userId, userProperties) => __awaiter(void 0, void 0, void 0, function* () {
|
|
707
|
+
try {
|
|
708
|
+
yield tracker.addUserInfo({ userId, userProperties });
|
|
709
|
+
return { success: true };
|
|
710
|
+
}
|
|
711
|
+
catch (error) {
|
|
712
|
+
logError('Failed to add user info:', error);
|
|
713
|
+
return { success: false, error };
|
|
714
|
+
}
|
|
715
|
+
}), [tracker]);
|
|
716
|
+
return {
|
|
717
|
+
addUserInfo
|
|
718
|
+
};
|
|
719
|
+
};
|
|
256
720
|
// Automatic page tracking component (similar to PostHog's PostHogPageView)
|
|
257
721
|
function HumanBehaviorPageView() {
|
|
258
722
|
const tracker = useContext(HumanBehaviorContext);
|
|
@@ -287,5 +751,5 @@ function HumanBehaviorPageView() {
|
|
|
287
751
|
return null;
|
|
288
752
|
}
|
|
289
753
|
|
|
290
|
-
export { HumanBehaviorProvider, useHumanBehavior };
|
|
754
|
+
export { HumanBehaviorProvider, useHumanBehavior, useRedaction, useUserTracking };
|
|
291
755
|
//# sourceMappingURL=index.js.map
|