posthog-js 1.84.2 → 1.84.4
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/array.full.js +1 -10
- package/dist/array.full.js.map +1 -1
- package/dist/array.js +1 -10
- package/dist/array.js.map +1 -1
- package/dist/es.js +1 -10
- package/dist/es.js.map +1 -1
- package/dist/module.d.ts +32 -148
- package/dist/module.js +1 -10
- package/dist/module.js.map +1 -1
- package/dist/recorder-v2.js +2 -2
- package/dist/recorder-v2.js.map +1 -1
- package/dist/recorder.js +1 -1
- package/dist/recorder.js.map +1 -1
- package/dist/surveys.js +1 -1
- package/dist/surveys.js.map +1 -1
- package/lib/package.json +9 -4
- package/lib/src/autocapture-utils.js +6 -6
- package/lib/src/autocapture-utils.js.map +1 -1
- package/lib/src/autocapture.js +5 -5
- package/lib/src/autocapture.js.map +1 -1
- package/lib/src/constants.d.ts +1 -0
- package/lib/src/constants.js +1 -0
- package/lib/src/constants.js.map +1 -1
- package/lib/src/extensions/exceptions/error-conversion.js +3 -2
- package/lib/src/extensions/exceptions/error-conversion.js.map +1 -1
- package/lib/src/extensions/exceptions/exception-autocapture.js +4 -7
- package/lib/src/extensions/exceptions/exception-autocapture.js.map +1 -1
- package/lib/src/extensions/exceptions/stack-trace.js +3 -2
- package/lib/src/extensions/exceptions/stack-trace.js.map +1 -1
- package/lib/src/extensions/exceptions/type-checking.js +3 -2
- package/lib/src/extensions/exceptions/type-checking.js.map +1 -1
- package/lib/src/extensions/{sessionrecording-utils.js → replay/sessionrecording-utils.js} +3 -2
- package/lib/src/extensions/replay/sessionrecording-utils.js.map +1 -0
- package/lib/src/extensions/{sessionrecording.d.ts → replay/sessionrecording.d.ts} +27 -19
- package/lib/src/extensions/{sessionrecording.js → replay/sessionrecording.js} +217 -92
- package/lib/src/extensions/replay/sessionrecording.js.map +1 -0
- package/lib/src/extensions/{web-performance.d.ts → replay/web-performance.d.ts} +2 -2
- package/lib/src/extensions/{web-performance.js → replay/web-performance.js} +3 -3
- package/lib/src/extensions/replay/web-performance.js.map +1 -0
- package/lib/src/extensions/surveys.js +3 -2
- package/lib/src/extensions/surveys.js.map +1 -1
- package/lib/src/loader-recorder-v2.js +2 -3
- package/lib/src/loader-recorder-v2.js.map +1 -1
- package/lib/src/loader-recorder.js +2 -1
- package/lib/src/loader-recorder.js.map +1 -1
- package/lib/src/loader-surveys.js +2 -1
- package/lib/src/loader-surveys.js.map +1 -1
- package/lib/src/posthog-core.d.ts +2 -2
- package/lib/src/posthog-core.js +14 -14
- package/lib/src/posthog-core.js.map +1 -1
- package/lib/src/posthog-featureflags.js +4 -4
- package/lib/src/posthog-featureflags.js.map +1 -1
- package/lib/src/posthog-persistence.js +4 -4
- package/lib/src/posthog-persistence.js.map +1 -1
- package/lib/src/request-queue.js +2 -2
- package/lib/src/request-queue.js.map +1 -1
- package/lib/src/retry-queue.js +7 -3
- package/lib/src/retry-queue.js.map +1 -1
- package/lib/src/send-request.js +3 -3
- package/lib/src/send-request.js.map +1 -1
- package/lib/src/sessionid.d.ts +6 -4
- package/lib/src/sessionid.js +17 -15
- package/lib/src/sessionid.js.map +1 -1
- package/lib/src/storage.js +7 -7
- package/lib/src/storage.js.map +1 -1
- package/lib/src/types.d.ts +3 -0
- package/lib/src/types.js.map +1 -1
- package/lib/src/utils.d.ts +8 -10
- package/lib/src/utils.js +42 -31
- package/lib/src/utils.js.map +1 -1
- package/lib/src/uuidv7.js +6 -4
- package/lib/src/uuidv7.js.map +1 -1
- package/package.json +9 -4
- package/lib/src/extensions/sessionrecording-utils.js.map +0 -1
- package/lib/src/extensions/sessionrecording.js.map +0 -1
- package/lib/src/extensions/web-performance.js.map +0 -1
- /package/lib/src/extensions/{sessionrecording-utils.d.ts → replay/sessionrecording-utils.d.ts} +0 -0
package/lib/src/posthog-core.js
CHANGED
|
@@ -35,13 +35,13 @@ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
|
35
35
|
return to.concat(ar || Array.prototype.slice.call(from));
|
|
36
36
|
};
|
|
37
37
|
import Config from './config';
|
|
38
|
-
import { _copyAndTruncateStrings, _each, _eachArray, _extend, _info, _isArray, _isBlockedUA, _isEmptyObject, _isObject, _isUndefined, _register_event, _safewrap_class, document, userAgent, window, logger, isCrossDomainCookie, } from './utils';
|
|
38
|
+
import { _copyAndTruncateStrings, _each, _eachArray, _extend, _info, _isArray, _isBlockedUA, _isEmptyObject, _isObject, _isUndefined, _register_event, _safewrap_class, document, userAgent, window, logger, isCrossDomainCookie, _isString, _isFunction, } from './utils';
|
|
39
39
|
import { autocapture } from './autocapture';
|
|
40
40
|
import { PostHogFeatureFlags } from './posthog-featureflags';
|
|
41
41
|
import { PostHogPersistence } from './posthog-persistence';
|
|
42
42
|
import { ALIAS_ID_KEY, FLAG_CALL_REPORTED, PEOPLE_DISTINCT_ID_KEY } from './constants';
|
|
43
|
-
import { SessionRecording } from './extensions/sessionrecording';
|
|
44
|
-
import { WebPerformanceObserver } from './extensions/web-performance';
|
|
43
|
+
import { SessionRecording } from './extensions/replay/sessionrecording';
|
|
44
|
+
import { WebPerformanceObserver } from './extensions/replay/web-performance';
|
|
45
45
|
import { Decide } from './decide';
|
|
46
46
|
import { Toolbar } from './extensions/toolbar';
|
|
47
47
|
import { clearOptInOut, hasOptedIn, hasOptedOut, optIn, optOut, userOptedOut } from './gdpr-utils';
|
|
@@ -224,7 +224,7 @@ var create_phlib = function (token, config, name, createComplete) {
|
|
|
224
224
|
Config.DEBUG = Config.DEBUG || instance.config.debug;
|
|
225
225
|
// if target is not defined, we called init after the lib already
|
|
226
226
|
// loaded, so there won't be an array of things to execute
|
|
227
|
-
if (
|
|
227
|
+
if (!_isUndefined(target) && _isArray(target)) {
|
|
228
228
|
// Crunch through the people queue first - we queue this data up &
|
|
229
229
|
// flush on identify, so it's better to do all these operations first
|
|
230
230
|
instance._execute_array.call(instance.people, target.people);
|
|
@@ -260,13 +260,13 @@ var PostHog = /** @class */ (function () {
|
|
|
260
260
|
this.people = {
|
|
261
261
|
set: function (prop, to, callback) {
|
|
262
262
|
var _a;
|
|
263
|
-
var setProps =
|
|
263
|
+
var setProps = _isString(prop) ? (_a = {}, _a[prop] = to, _a) : prop;
|
|
264
264
|
_this.setPersonProperties(setProps);
|
|
265
265
|
callback === null || callback === void 0 ? void 0 : callback({});
|
|
266
266
|
},
|
|
267
267
|
set_once: function (prop, to, callback) {
|
|
268
268
|
var _a;
|
|
269
|
-
var setProps =
|
|
269
|
+
var setProps = _isString(prop) ? (_a = {}, _a[prop] = to, _a) : prop;
|
|
270
270
|
_this.setPersonProperties(undefined, setProps);
|
|
271
271
|
callback === null || callback === void 0 ? void 0 : callback({});
|
|
272
272
|
},
|
|
@@ -382,6 +382,8 @@ var PostHog = /** @class */ (function () {
|
|
|
382
382
|
else {
|
|
383
383
|
updateInitComplete('segmentRegister')();
|
|
384
384
|
}
|
|
385
|
+
// isUndefined doesn't provide typehint here so wouldn't reduce bundle as we'd need to assign
|
|
386
|
+
// eslint-disable-next-line posthog-js/no-direct-undefined-check
|
|
385
387
|
if (((_c = config.bootstrap) === null || _c === void 0 ? void 0 : _c.distinctID) !== undefined) {
|
|
386
388
|
var uuid = this.config.get_device_id(uuidv7());
|
|
387
389
|
var deviceID = ((_d = config.bootstrap) === null || _d === void 0 ? void 0 : _d.isIdentifiedID) ? uuid : config.bootstrap.distinctID;
|
|
@@ -621,16 +623,14 @@ var PostHog = /** @class */ (function () {
|
|
|
621
623
|
if (_isArray(fn_name)) {
|
|
622
624
|
capturing_calls.push(item); // chained call e.g. posthog.get_group().set()
|
|
623
625
|
}
|
|
624
|
-
else if (
|
|
626
|
+
else if (_isFunction(item)) {
|
|
625
627
|
;
|
|
626
628
|
item.call(_this);
|
|
627
629
|
}
|
|
628
630
|
else if (_isArray(item) && fn_name === 'alias') {
|
|
629
631
|
alias_calls.push(item);
|
|
630
632
|
}
|
|
631
|
-
else if (_isArray(item) &&
|
|
632
|
-
fn_name.indexOf('capture') !== -1 &&
|
|
633
|
-
typeof _this[fn_name] === 'function') {
|
|
633
|
+
else if (_isArray(item) && fn_name.indexOf('capture') !== -1 && _isFunction(_this[fn_name])) {
|
|
634
634
|
capturing_calls.push(item);
|
|
635
635
|
}
|
|
636
636
|
else {
|
|
@@ -726,7 +726,7 @@ var PostHog = /** @class */ (function () {
|
|
|
726
726
|
options.transport = transport; // 'transport' prop name can be minified internally
|
|
727
727
|
}
|
|
728
728
|
// typing doesn't prevent interesting data
|
|
729
|
-
if (_isUndefined(event_name) ||
|
|
729
|
+
if (_isUndefined(event_name) || !_isString(event_name)) {
|
|
730
730
|
logger.error('No event name provided to posthog.capture');
|
|
731
731
|
return;
|
|
732
732
|
}
|
|
@@ -818,7 +818,7 @@ var PostHog = /** @class */ (function () {
|
|
|
818
818
|
return properties;
|
|
819
819
|
}
|
|
820
820
|
// set $duration if time_event was previously called for this event
|
|
821
|
-
if (
|
|
821
|
+
if (!_isUndefined(start_timestamp)) {
|
|
822
822
|
var duration_in_ms = new Date().getTime() - start_timestamp;
|
|
823
823
|
properties['$duration'] = parseFloat((duration_in_ms / 1000).toFixed(3));
|
|
824
824
|
}
|
|
@@ -1499,7 +1499,7 @@ var PostHog = /** @class */ (function () {
|
|
|
1499
1499
|
if (this.config.debug) {
|
|
1500
1500
|
Config.DEBUG = true;
|
|
1501
1501
|
}
|
|
1502
|
-
if (this.sessionRecording &&
|
|
1502
|
+
if (this.sessionRecording && !_isUndefined(config.disable_session_recording)) {
|
|
1503
1503
|
if (oldConfig.disable_session_recording !== config.disable_session_recording) {
|
|
1504
1504
|
if (config.disable_session_recording) {
|
|
1505
1505
|
this.sessionRecording.stopRecording();
|
|
@@ -1531,7 +1531,7 @@ var PostHog = /** @class */ (function () {
|
|
|
1531
1531
|
*/
|
|
1532
1532
|
PostHog.prototype.sessionRecordingStarted = function () {
|
|
1533
1533
|
var _a;
|
|
1534
|
-
return !!((_a = this.sessionRecording) === null || _a === void 0 ? void 0 : _a.started
|
|
1534
|
+
return !!((_a = this.sessionRecording) === null || _a === void 0 ? void 0 : _a.started);
|
|
1535
1535
|
};
|
|
1536
1536
|
/**
|
|
1537
1537
|
* returns a boolean indicating whether the toolbar loaded
|