posthog-js-lite 2.0.0-alpha3 → 2.0.0-alpha4
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/lib/index.cjs.js +19 -10
- package/lib/index.cjs.js.map +1 -1
- package/lib/index.d.ts +6 -3
- package/lib/index.esm.js +19 -10
- package/lib/index.esm.js.map +1 -1
- package/lib/posthog-core/src/eventemitter.d.ts +2 -2
- package/lib/posthog-core/src/index.d.ts +4 -1
- package/package.json +1 -1
- package/src/context.ts +1 -4
package/lib/index.esm.js
CHANGED
|
@@ -156,7 +156,7 @@ function retriable(fn, props) {
|
|
|
156
156
|
return __generator(this, function (_d) {
|
|
157
157
|
switch (_d.label) {
|
|
158
158
|
case 0:
|
|
159
|
-
_a = props.retryCount, retryCount = _a === void 0 ? 3 : _a, _b = props.retryDelay, retryDelay = _b === void 0 ?
|
|
159
|
+
_a = props.retryCount, retryCount = _a === void 0 ? 3 : _a, _b = props.retryDelay, retryDelay = _b === void 0 ? 5000 : _b, _c = props.retryCheck, retryCheck = _c === void 0 ? function () { return true; } : _c;
|
|
160
160
|
lastError = null;
|
|
161
161
|
i = 0;
|
|
162
162
|
_d.label = 1;
|
|
@@ -670,13 +670,14 @@ var SimpleEventEmitter = /** @class */ (function () {
|
|
|
670
670
|
};
|
|
671
671
|
};
|
|
672
672
|
SimpleEventEmitter.prototype.emit = function (event, payload) {
|
|
673
|
-
|
|
674
|
-
return;
|
|
675
|
-
}
|
|
676
|
-
for (var _i = 0, _a = this.events[event]; _i < _a.length; _i++) {
|
|
673
|
+
for (var _i = 0, _a = this.events[event] || []; _i < _a.length; _i++) {
|
|
677
674
|
var listener = _a[_i];
|
|
678
675
|
listener(payload);
|
|
679
676
|
}
|
|
677
|
+
for (var _b = 0, _c = this.events['*'] || []; _b < _c.length; _b++) {
|
|
678
|
+
var listener = _c[_b];
|
|
679
|
+
listener(event, payload);
|
|
680
|
+
}
|
|
680
681
|
};
|
|
681
682
|
return SimpleEventEmitter;
|
|
682
683
|
}());
|
|
@@ -756,6 +757,14 @@ var PostHogCore = /** @class */ (function () {
|
|
|
756
757
|
}
|
|
757
758
|
this.setPersistedProperty(PostHogPersistedProperty.DistinctId, generateUUID(globalThis));
|
|
758
759
|
};
|
|
760
|
+
PostHogCore.prototype.debug = function (enabled) {
|
|
761
|
+
var _a;
|
|
762
|
+
if (enabled === void 0) { enabled = true; }
|
|
763
|
+
(_a = this.removeDebugCallback) === null || _a === void 0 ? void 0 : _a.call(this);
|
|
764
|
+
if (enabled) {
|
|
765
|
+
this.removeDebugCallback = this.on('*', function (event, payload) { return console.log('PostHog Debug', event, payload); });
|
|
766
|
+
}
|
|
767
|
+
};
|
|
759
768
|
PostHogCore.prototype.buildPayload = function (payload) {
|
|
760
769
|
return {
|
|
761
770
|
distinct_id: payload.distinct_id || this.getDistinctId(),
|
|
@@ -773,6 +782,9 @@ var PostHogCore = /** @class */ (function () {
|
|
|
773
782
|
this.setPersistedProperty(PostHogPersistedProperty.SessionLastTimestamp, Date.now());
|
|
774
783
|
return sessionId;
|
|
775
784
|
};
|
|
785
|
+
PostHogCore.prototype.resetSessionId = function () {
|
|
786
|
+
this.setPersistedProperty(PostHogPersistedProperty.SessionId, null);
|
|
787
|
+
};
|
|
776
788
|
PostHogCore.prototype.getDistinctId = function () {
|
|
777
789
|
var distinctId = this.getPersistedProperty(PostHogPersistedProperty.DistinctId);
|
|
778
790
|
if (!distinctId) {
|
|
@@ -1109,9 +1121,8 @@ var PostHogCore = /** @class */ (function () {
|
|
|
1109
1121
|
return PostHogCore;
|
|
1110
1122
|
}());
|
|
1111
1123
|
|
|
1112
|
-
|
|
1124
|
+
var version = "2.0.0-alpha4";
|
|
1113
1125
|
|
|
1114
|
-
var version$1 = '2.0.0-alpha';
|
|
1115
1126
|
function getContext(window) {
|
|
1116
1127
|
var context = {};
|
|
1117
1128
|
|
|
@@ -1135,7 +1146,7 @@ function getContext(window) {
|
|
|
1135
1146
|
|
|
1136
1147
|
context = __assign(__assign({}, context), {
|
|
1137
1148
|
$lib: 'js',
|
|
1138
|
-
$lib_version: version
|
|
1149
|
+
$lib_version: version,
|
|
1139
1150
|
$insert_id: Math.random().toString(36).substring(2, 10) + Math.random().toString(36).substring(2, 10),
|
|
1140
1151
|
$time: currentTimestamp() / 1000
|
|
1141
1152
|
});
|
|
@@ -1401,8 +1412,6 @@ var checkStoreIsSupported = function (storage, key) {
|
|
|
1401
1412
|
var localStore = checkStoreIsSupported(_localStore) ? _localStore : undefined;
|
|
1402
1413
|
var sessionStorage = checkStoreIsSupported(_sessionStore) ? _sessionStore : undefined;
|
|
1403
1414
|
|
|
1404
|
-
var version = "2.0.0-alpha3";
|
|
1405
|
-
|
|
1406
1415
|
var PostHog =
|
|
1407
1416
|
/** @class */
|
|
1408
1417
|
function (_super) {
|