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 +24 -1
- package/lib/index.cjs.js.map +1 -1
- package/lib/index.d.ts +5 -1
- package/lib/index.esm.js +24 -1
- package/lib/index.esm.js.map +1 -1
- package/lib/posthog-core/src/storage-memory.d.ts +6 -0
- package/lib/posthog-react-native/src/posthog-rn.d.ts +5 -1
- package/package.json +1 -1
package/lib/index.d.ts
CHANGED
|
@@ -163,8 +163,12 @@ declare abstract class PostHogCore {
|
|
|
163
163
|
shutdown(): void;
|
|
164
164
|
}
|
|
165
165
|
|
|
166
|
-
declare type PostHogOptions = PosthogCoreOptions
|
|
166
|
+
declare type PostHogOptions = PosthogCoreOptions & {
|
|
167
|
+
persistence?: 'memory' | 'file';
|
|
168
|
+
};
|
|
167
169
|
declare class PostHog extends PostHogCore {
|
|
170
|
+
private _persistence;
|
|
171
|
+
private _memoryStorage;
|
|
168
172
|
static initAsync(): Promise<void>;
|
|
169
173
|
constructor(apiKey: string, options?: PostHogOptions);
|
|
170
174
|
getPersistedProperty<T>(key: PostHogPersistedProperty): T | undefined;
|
package/lib/index.esm.js
CHANGED
|
@@ -1127,6 +1127,19 @@ var PostHogCore = /** @class */ (function () {
|
|
|
1127
1127
|
return PostHogCore;
|
|
1128
1128
|
}());
|
|
1129
1129
|
|
|
1130
|
+
var PostHogMemoryStorage = /** @class */ (function () {
|
|
1131
|
+
function PostHogMemoryStorage() {
|
|
1132
|
+
this._memoryStorage = {};
|
|
1133
|
+
}
|
|
1134
|
+
PostHogMemoryStorage.prototype.getProperty = function (key) {
|
|
1135
|
+
return this._memoryStorage[key];
|
|
1136
|
+
};
|
|
1137
|
+
PostHogMemoryStorage.prototype.setProperty = function (key, value) {
|
|
1138
|
+
this._memoryStorage[key] = value !== null ? value : undefined;
|
|
1139
|
+
};
|
|
1140
|
+
return PostHogMemoryStorage;
|
|
1141
|
+
}());
|
|
1142
|
+
|
|
1130
1143
|
var getLegacyValues = function () {
|
|
1131
1144
|
return __awaiter(void 0, void 0, void 0, function () {
|
|
1132
1145
|
var posthogFileDirectory, posthogDistinctIdFile, posthogAnonymousIdFile, res, _a, _b, _c, _d, _e, _f;
|
|
@@ -1340,7 +1353,7 @@ try {
|
|
|
1340
1353
|
var OptionalReactNativeNavigation = _OptionalReactNativeNavigation;
|
|
1341
1354
|
var OptionalExpoLocalization = _OptionalExpoLocalization;
|
|
1342
1355
|
|
|
1343
|
-
var version = "2.0.0-
|
|
1356
|
+
var version = "2.0.0-alpha11";
|
|
1344
1357
|
|
|
1345
1358
|
var PostHog =
|
|
1346
1359
|
/** @class */
|
|
@@ -1350,6 +1363,8 @@ function (_super) {
|
|
|
1350
1363
|
function PostHog(apiKey, options) {
|
|
1351
1364
|
var _this = _super.call(this, apiKey, options) || this;
|
|
1352
1365
|
|
|
1366
|
+
_this._memoryStorage = new PostHogMemoryStorage();
|
|
1367
|
+
_this._persistence = options === null || options === void 0 ? void 0 : options.persistence;
|
|
1353
1368
|
AppState.addEventListener('change', function () {
|
|
1354
1369
|
_this.flush();
|
|
1355
1370
|
}); // Ensure the async storage has been preloaded (this call is cached)
|
|
@@ -1372,10 +1387,18 @@ function (_super) {
|
|
|
1372
1387
|
};
|
|
1373
1388
|
|
|
1374
1389
|
PostHog.prototype.getPersistedProperty = function (key) {
|
|
1390
|
+
if (this._persistence === 'memory') {
|
|
1391
|
+
return this._memoryStorage.getProperty(key);
|
|
1392
|
+
}
|
|
1393
|
+
|
|
1375
1394
|
return SemiAsyncStorage.getItem(key) || undefined;
|
|
1376
1395
|
};
|
|
1377
1396
|
|
|
1378
1397
|
PostHog.prototype.setPersistedProperty = function (key, value) {
|
|
1398
|
+
if (this._persistence === 'memory') {
|
|
1399
|
+
return this._memoryStorage.getProperty(key);
|
|
1400
|
+
}
|
|
1401
|
+
|
|
1379
1402
|
return value !== null ? SemiAsyncStorage.setItem(key, value) : SemiAsyncStorage.removeItem(key);
|
|
1380
1403
|
};
|
|
1381
1404
|
|