posthog-js-lite 2.0.0-alpha1 → 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 +24 -17
- package/lib/index.cjs.js.map +1 -1
- package/lib/index.d.ts +6 -3
- package/lib/index.esm.js +24 -17
- 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 +6 -2
- package/src/context.ts +1 -4
- package/src/posthog-web.ts +3 -3
- package/src/storage.ts +2 -3
package/lib/index.cjs.js
CHANGED
|
@@ -160,7 +160,7 @@ function retriable(fn, props) {
|
|
|
160
160
|
return __generator(this, function (_d) {
|
|
161
161
|
switch (_d.label) {
|
|
162
162
|
case 0:
|
|
163
|
-
_a = props.retryCount, retryCount = _a === void 0 ? 3 : _a, _b = props.retryDelay, retryDelay = _b === void 0 ?
|
|
163
|
+
_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;
|
|
164
164
|
lastError = null;
|
|
165
165
|
i = 0;
|
|
166
166
|
_d.label = 1;
|
|
@@ -674,13 +674,14 @@ var SimpleEventEmitter = /** @class */ (function () {
|
|
|
674
674
|
};
|
|
675
675
|
};
|
|
676
676
|
SimpleEventEmitter.prototype.emit = function (event, payload) {
|
|
677
|
-
|
|
678
|
-
return;
|
|
679
|
-
}
|
|
680
|
-
for (var _i = 0, _a = this.events[event]; _i < _a.length; _i++) {
|
|
677
|
+
for (var _i = 0, _a = this.events[event] || []; _i < _a.length; _i++) {
|
|
681
678
|
var listener = _a[_i];
|
|
682
679
|
listener(payload);
|
|
683
680
|
}
|
|
681
|
+
for (var _b = 0, _c = this.events['*'] || []; _b < _c.length; _b++) {
|
|
682
|
+
var listener = _c[_b];
|
|
683
|
+
listener(event, payload);
|
|
684
|
+
}
|
|
684
685
|
};
|
|
685
686
|
return SimpleEventEmitter;
|
|
686
687
|
}());
|
|
@@ -760,6 +761,14 @@ var PostHogCore = /** @class */ (function () {
|
|
|
760
761
|
}
|
|
761
762
|
this.setPersistedProperty(PostHogPersistedProperty.DistinctId, generateUUID(globalThis));
|
|
762
763
|
};
|
|
764
|
+
PostHogCore.prototype.debug = function (enabled) {
|
|
765
|
+
var _a;
|
|
766
|
+
if (enabled === void 0) { enabled = true; }
|
|
767
|
+
(_a = this.removeDebugCallback) === null || _a === void 0 ? void 0 : _a.call(this);
|
|
768
|
+
if (enabled) {
|
|
769
|
+
this.removeDebugCallback = this.on('*', function (event, payload) { return console.log('PostHog Debug', event, payload); });
|
|
770
|
+
}
|
|
771
|
+
};
|
|
763
772
|
PostHogCore.prototype.buildPayload = function (payload) {
|
|
764
773
|
return {
|
|
765
774
|
distinct_id: payload.distinct_id || this.getDistinctId(),
|
|
@@ -777,6 +786,9 @@ var PostHogCore = /** @class */ (function () {
|
|
|
777
786
|
this.setPersistedProperty(PostHogPersistedProperty.SessionLastTimestamp, Date.now());
|
|
778
787
|
return sessionId;
|
|
779
788
|
};
|
|
789
|
+
PostHogCore.prototype.resetSessionId = function () {
|
|
790
|
+
this.setPersistedProperty(PostHogPersistedProperty.SessionId, null);
|
|
791
|
+
};
|
|
780
792
|
PostHogCore.prototype.getDistinctId = function () {
|
|
781
793
|
var distinctId = this.getPersistedProperty(PostHogPersistedProperty.DistinctId);
|
|
782
794
|
if (!distinctId) {
|
|
@@ -1113,9 +1125,8 @@ var PostHogCore = /** @class */ (function () {
|
|
|
1113
1125
|
return PostHogCore;
|
|
1114
1126
|
}());
|
|
1115
1127
|
|
|
1116
|
-
|
|
1128
|
+
var version = "2.0.0-alpha4";
|
|
1117
1129
|
|
|
1118
|
-
var version$1 = '2.0.0-alpha';
|
|
1119
1130
|
function getContext(window) {
|
|
1120
1131
|
var context = {};
|
|
1121
1132
|
|
|
@@ -1139,7 +1150,7 @@ function getContext(window) {
|
|
|
1139
1150
|
|
|
1140
1151
|
context = __assign(__assign({}, context), {
|
|
1141
1152
|
$lib: 'js',
|
|
1142
|
-
$lib_version: version
|
|
1153
|
+
$lib_version: version,
|
|
1143
1154
|
$insert_id: Math.random().toString(36).substring(2, 10) + Math.random().toString(36).substring(2, 10),
|
|
1144
1155
|
$time: currentTimestamp() / 1000
|
|
1145
1156
|
});
|
|
@@ -1315,7 +1326,7 @@ var cookieStore = {
|
|
|
1315
1326
|
var cdomain = '',
|
|
1316
1327
|
expires = '',
|
|
1317
1328
|
secure = '';
|
|
1318
|
-
var new_cookie_val = key + '=' + encodeURIComponent(
|
|
1329
|
+
var new_cookie_val = key + '=' + encodeURIComponent(value) + expires + '; path=/' + cdomain + secure;
|
|
1319
1330
|
document.cookie = new_cookie_val;
|
|
1320
1331
|
} catch (err) {
|
|
1321
1332
|
return;
|
|
@@ -1355,7 +1366,7 @@ var createStorageLike = function (store) {
|
|
|
1355
1366
|
return store.getItem(key);
|
|
1356
1367
|
},
|
|
1357
1368
|
setItem: function (key, value) {
|
|
1358
|
-
store.setItem(key,
|
|
1369
|
+
store.setItem(key, value);
|
|
1359
1370
|
},
|
|
1360
1371
|
removeItem: function (key) {
|
|
1361
1372
|
store.removeItem(key);
|
|
@@ -1405,8 +1416,6 @@ var checkStoreIsSupported = function (storage, key) {
|
|
|
1405
1416
|
var localStore = checkStoreIsSupported(_localStore) ? _localStore : undefined;
|
|
1406
1417
|
var sessionStorage = checkStoreIsSupported(_sessionStore) ? _sessionStore : undefined;
|
|
1407
1418
|
|
|
1408
|
-
var version = "2.0.0-alpha1";
|
|
1409
|
-
|
|
1410
1419
|
var PostHog =
|
|
1411
1420
|
/** @class */
|
|
1412
1421
|
function (_super) {
|
|
@@ -1436,13 +1445,11 @@ function (_super) {
|
|
|
1436
1445
|
|
|
1437
1446
|
if (value === null) {
|
|
1438
1447
|
delete this._storageCache[key];
|
|
1439
|
-
|
|
1440
|
-
this._storage.removeItem(this._storageKey);
|
|
1441
1448
|
} else {
|
|
1442
1449
|
this._storageCache[key] = value;
|
|
1443
|
-
|
|
1444
|
-
this._storage.setItem(this._storageKey, JSON.stringify(this._storageCache));
|
|
1445
1450
|
}
|
|
1451
|
+
|
|
1452
|
+
this._storage.setItem(this._storageKey, JSON.stringify(this._storageCache));
|
|
1446
1453
|
};
|
|
1447
1454
|
|
|
1448
1455
|
PostHog.prototype.fetch = function (url, options) {
|
|
@@ -1450,7 +1457,7 @@ function (_super) {
|
|
|
1450
1457
|
};
|
|
1451
1458
|
|
|
1452
1459
|
PostHog.prototype.getLibraryId = function () {
|
|
1453
|
-
return 'posthog-
|
|
1460
|
+
return 'posthog-js-lite';
|
|
1454
1461
|
};
|
|
1455
1462
|
|
|
1456
1463
|
PostHog.prototype.getLibraryVersion = function () {
|