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 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 ? 1000 : _b, _c = props.retryCheck, retryCheck = _c === void 0 ? function () { return true; } : _c;
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
- if (!this.events[event]) {
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
- // TODO: Get this from package.json
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$1,
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
  });
@@ -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-alpha3";
1409
-
1410
1419
  var PostHog =
1411
1420
  /** @class */
1412
1421
  function (_super) {