posthog-react-native 2.0.0-alpha10 → 2.0.0-alpha11

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
@@ -1156,6 +1156,19 @@ var PostHogCore = /** @class */ (function () {
1156
1156
  return PostHogCore;
1157
1157
  }());
1158
1158
 
1159
+ var PostHogMemoryStorage = /** @class */ (function () {
1160
+ function PostHogMemoryStorage() {
1161
+ this._memoryStorage = {};
1162
+ }
1163
+ PostHogMemoryStorage.prototype.getProperty = function (key) {
1164
+ return this._memoryStorage[key];
1165
+ };
1166
+ PostHogMemoryStorage.prototype.setProperty = function (key, value) {
1167
+ this._memoryStorage[key] = value !== null ? value : undefined;
1168
+ };
1169
+ return PostHogMemoryStorage;
1170
+ }());
1171
+
1159
1172
  var getLegacyValues = function () {
1160
1173
  return __awaiter(void 0, void 0, void 0, function () {
1161
1174
  var posthogFileDirectory, posthogDistinctIdFile, posthogAnonymousIdFile, res, _a, _b, _c, _d, _e, _f;
@@ -1369,7 +1382,7 @@ try {
1369
1382
  var OptionalReactNativeNavigation = _OptionalReactNativeNavigation;
1370
1383
  var OptionalExpoLocalization = _OptionalExpoLocalization;
1371
1384
 
1372
- var version = "2.0.0-alpha10";
1385
+ var version = "2.0.0-alpha11";
1373
1386
 
1374
1387
  var PostHog =
1375
1388
  /** @class */
@@ -1379,6 +1392,8 @@ function (_super) {
1379
1392
  function PostHog(apiKey, options) {
1380
1393
  var _this = _super.call(this, apiKey, options) || this;
1381
1394
 
1395
+ _this._memoryStorage = new PostHogMemoryStorage();
1396
+ _this._persistence = options === null || options === void 0 ? void 0 : options.persistence;
1382
1397
  reactNative.AppState.addEventListener('change', function () {
1383
1398
  _this.flush();
1384
1399
  }); // Ensure the async storage has been preloaded (this call is cached)
@@ -1401,10 +1416,18 @@ function (_super) {
1401
1416
  };
1402
1417
 
1403
1418
  PostHog.prototype.getPersistedProperty = function (key) {
1419
+ if (this._persistence === 'memory') {
1420
+ return this._memoryStorage.getProperty(key);
1421
+ }
1422
+
1404
1423
  return SemiAsyncStorage.getItem(key) || undefined;
1405
1424
  };
1406
1425
 
1407
1426
  PostHog.prototype.setPersistedProperty = function (key, value) {
1427
+ if (this._persistence === 'memory') {
1428
+ return this._memoryStorage.getProperty(key);
1429
+ }
1430
+
1408
1431
  return value !== null ? SemiAsyncStorage.setItem(key, value) : SemiAsyncStorage.removeItem(key);
1409
1432
  };
1410
1433