posthog-react-native 2.0.0-alpha10 → 2.0.0-alpha13
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 +115 -89
- package/lib/index.cjs.js.map +1 -1
- package/lib/index.d.ts +10 -4
- package/lib/index.esm.js +114 -89
- package/lib/index.esm.js.map +1 -1
- package/lib/posthog-core/src/index.d.ts +2 -2
- package/lib/posthog-core/src/storage-memory.d.ts +6 -0
- package/lib/posthog-core/src/types.d.ts +2 -1
- package/lib/posthog-core/src/utils.d.ts +0 -1
- package/lib/posthog-react-native/src/optional-imports.d.ts +0 -4
- package/lib/posthog-react-native/src/posthog-rn.d.ts +5 -1
- package/lib/posthog-react-native/src/types.d.ts +1 -0
- package/package.json +6 -14
package/lib/index.d.ts
CHANGED
|
@@ -9,13 +9,13 @@ declare type PosthogCoreOptions = {
|
|
|
9
9
|
enable?: boolean;
|
|
10
10
|
sendFeatureFlagEvent?: boolean;
|
|
11
11
|
preloadFeatureFlags?: boolean;
|
|
12
|
-
decidePollInterval?: number;
|
|
13
12
|
fetchRetryCount?: number;
|
|
14
13
|
fetchRetryDelay?: number;
|
|
15
14
|
sessionExpirationTimeSeconds?: number;
|
|
16
15
|
captureMode?: 'json' | 'form';
|
|
17
16
|
};
|
|
18
17
|
declare enum PostHogPersistedProperty {
|
|
18
|
+
AnonymousId = "anonymous_id",
|
|
19
19
|
DistinctId = "distinct_id",
|
|
20
20
|
Props = "props",
|
|
21
21
|
FeatureFlags = "feature_flags",
|
|
@@ -37,6 +37,7 @@ declare type PostHogFetchOptions = {
|
|
|
37
37
|
declare type PostHogFetchResponse = {
|
|
38
38
|
status: number;
|
|
39
39
|
text: () => Promise<string>;
|
|
40
|
+
json: () => Promise<any>;
|
|
40
41
|
};
|
|
41
42
|
declare type PostHogEventProperties = {
|
|
42
43
|
[key: string]: any;
|
|
@@ -94,8 +95,6 @@ declare abstract class PostHogCore {
|
|
|
94
95
|
protected _events: SimpleEventEmitter;
|
|
95
96
|
protected _flushTimer?: any;
|
|
96
97
|
protected _decideResponsePromise?: Promise<PostHogDecideResponse>;
|
|
97
|
-
protected _decideTimer?: any;
|
|
98
|
-
protected _decidePollInterval: number;
|
|
99
98
|
protected _retryOptions: RetriableOptions;
|
|
100
99
|
protected _sessionExpirationTimeSeconds: number;
|
|
101
100
|
abstract fetch(url: string, options: PostHogFetchOptions): Promise<PostHogFetchResponse>;
|
|
@@ -119,6 +118,7 @@ declare abstract class PostHogCore {
|
|
|
119
118
|
private buildPayload;
|
|
120
119
|
getSessionId(): string | undefined;
|
|
121
120
|
resetSessionId(): void;
|
|
121
|
+
getAnonymousId(): string;
|
|
122
122
|
getDistinctId(): string;
|
|
123
123
|
register(properties: {
|
|
124
124
|
[key: string]: any;
|
|
@@ -151,6 +151,7 @@ declare abstract class PostHogCore {
|
|
|
151
151
|
isFeatureEnabled(key: string, defaultResult?: boolean): boolean;
|
|
152
152
|
reloadFeatureFlagsAsync(): Promise<PostHogDecideResponse['featureFlags']>;
|
|
153
153
|
onFeatureFlags(cb: (flags: PostHogDecideResponse['featureFlags']) => void): () => void;
|
|
154
|
+
onFeatureFlag(key: string, cb: (value: string | boolean) => void): () => void;
|
|
154
155
|
overrideFeatureFlag(flags: PostHogDecideResponse['featureFlags'] | null): void;
|
|
155
156
|
/***
|
|
156
157
|
*** QUEUEING AND FLUSHING
|
|
@@ -163,8 +164,12 @@ declare abstract class PostHogCore {
|
|
|
163
164
|
shutdown(): void;
|
|
164
165
|
}
|
|
165
166
|
|
|
166
|
-
declare type PostHogOptions = PosthogCoreOptions
|
|
167
|
+
declare type PostHogOptions = PosthogCoreOptions & {
|
|
168
|
+
persistence?: 'memory' | 'file';
|
|
169
|
+
};
|
|
167
170
|
declare class PostHog extends PostHogCore {
|
|
171
|
+
private _persistence;
|
|
172
|
+
private _memoryStorage;
|
|
168
173
|
static initAsync(): Promise<void>;
|
|
169
174
|
constructor(apiKey: string, options?: PostHogOptions);
|
|
170
175
|
getPersistedProperty<T>(key: PostHogPersistedProperty): T | undefined;
|
|
@@ -189,6 +194,7 @@ declare type PostHogAutocaptureOptions = {
|
|
|
189
194
|
noCaptureProp?: string;
|
|
190
195
|
maxElementsCaptured?: number;
|
|
191
196
|
ignoreLabels?: string[];
|
|
197
|
+
propsToCapture?: string[];
|
|
192
198
|
navigation?: PostHogAutocaptureNavigationTrackerOptions;
|
|
193
199
|
};
|
|
194
200
|
|
package/lib/index.esm.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { Platform, Dimensions, AppState, View } from 'react-native';
|
|
2
2
|
import * as ExpoApplication from 'expo-application';
|
|
3
3
|
import * as ExpoDevice from 'expo-device';
|
|
4
|
+
import * as ExpoLocalization from 'expo-localization';
|
|
4
5
|
import * as FileSystem from 'expo-file-system';
|
|
5
6
|
import React, { useRef, useEffect, useState, useCallback } from 'react';
|
|
6
7
|
|
|
@@ -137,6 +138,7 @@ function __generator(thisArg, body) {
|
|
|
137
138
|
|
|
138
139
|
var PostHogPersistedProperty;
|
|
139
140
|
(function (PostHogPersistedProperty) {
|
|
141
|
+
PostHogPersistedProperty["AnonymousId"] = "anonymous_id";
|
|
140
142
|
PostHogPersistedProperty["DistinctId"] = "distinct_id";
|
|
141
143
|
PostHogPersistedProperty["Props"] = "props";
|
|
142
144
|
PostHogPersistedProperty["FeatureFlags"] = "feature_flags";
|
|
@@ -691,7 +693,7 @@ var SimpleEventEmitter = /** @class */ (function () {
|
|
|
691
693
|
var PostHogCore = /** @class */ (function () {
|
|
692
694
|
function PostHogCore(apiKey, options) {
|
|
693
695
|
var _this = this;
|
|
694
|
-
var _a, _b, _c, _d, _e
|
|
696
|
+
var _a, _b, _c, _d, _e;
|
|
695
697
|
this.flagCallReported = {};
|
|
696
698
|
// internal
|
|
697
699
|
this._events = new SimpleEventEmitter();
|
|
@@ -702,14 +704,13 @@ var PostHogCore = /** @class */ (function () {
|
|
|
702
704
|
this.flushInterval = (_a = options === null || options === void 0 ? void 0 : options.flushInterval) !== null && _a !== void 0 ? _a : 10000;
|
|
703
705
|
this.captureMode = (options === null || options === void 0 ? void 0 : options.captureMode) || 'form';
|
|
704
706
|
this.sendFeatureFlagEvent = (_b = options === null || options === void 0 ? void 0 : options.sendFeatureFlagEvent) !== null && _b !== void 0 ? _b : true;
|
|
705
|
-
this._decidePollInterval = Math.max(0, (_c = options === null || options === void 0 ? void 0 : options.decidePollInterval) !== null && _c !== void 0 ? _c : 30000);
|
|
706
707
|
// If enable is explicitly set to false we override the optout
|
|
707
708
|
this._optoutOverride = (options === null || options === void 0 ? void 0 : options.enable) === false;
|
|
708
709
|
this._retryOptions = {
|
|
709
|
-
retryCount: (
|
|
710
|
-
retryDelay: (
|
|
710
|
+
retryCount: (_c = options === null || options === void 0 ? void 0 : options.fetchRetryCount) !== null && _c !== void 0 ? _c : 3,
|
|
711
|
+
retryDelay: (_d = options === null || options === void 0 ? void 0 : options.fetchRetryDelay) !== null && _d !== void 0 ? _d : 3000,
|
|
711
712
|
};
|
|
712
|
-
this._sessionExpirationTimeSeconds = (
|
|
713
|
+
this._sessionExpirationTimeSeconds = (_e = options === null || options === void 0 ? void 0 : options.sessionExpirationTimeSeconds) !== null && _e !== void 0 ? _e : 1800; // 30 minutes
|
|
713
714
|
// NOTE: It is important we don't initiate anything in the constructor as some async IO may still be underway on the parent
|
|
714
715
|
if ((options === null || options === void 0 ? void 0 : options.preloadFeatureFlags) !== false) {
|
|
715
716
|
safeSetTimeout(function () {
|
|
@@ -761,7 +762,6 @@ var PostHogCore = /** @class */ (function () {
|
|
|
761
762
|
for (var key in PostHogPersistedProperty) {
|
|
762
763
|
this.setPersistedProperty(PostHogPersistedProperty[key], null);
|
|
763
764
|
}
|
|
764
|
-
this.setPersistedProperty(PostHogPersistedProperty.DistinctId, generateUUID(globalThis));
|
|
765
765
|
};
|
|
766
766
|
PostHogCore.prototype.debug = function (enabled) {
|
|
767
767
|
var _a;
|
|
@@ -791,13 +791,16 @@ var PostHogCore = /** @class */ (function () {
|
|
|
791
791
|
PostHogCore.prototype.resetSessionId = function () {
|
|
792
792
|
this.setPersistedProperty(PostHogPersistedProperty.SessionId, null);
|
|
793
793
|
};
|
|
794
|
-
PostHogCore.prototype.
|
|
795
|
-
var
|
|
796
|
-
if (!
|
|
797
|
-
|
|
798
|
-
this.setPersistedProperty(PostHogPersistedProperty.
|
|
794
|
+
PostHogCore.prototype.getAnonymousId = function () {
|
|
795
|
+
var anonId = this.getPersistedProperty(PostHogPersistedProperty.AnonymousId);
|
|
796
|
+
if (!anonId) {
|
|
797
|
+
anonId = generateUUID(globalThis);
|
|
798
|
+
this.setPersistedProperty(PostHogPersistedProperty.AnonymousId, anonId);
|
|
799
799
|
}
|
|
800
|
-
return
|
|
800
|
+
return anonId;
|
|
801
|
+
};
|
|
802
|
+
PostHogCore.prototype.getDistinctId = function () {
|
|
803
|
+
return this.getPersistedProperty(PostHogPersistedProperty.DistinctId) || this.getAnonymousId();
|
|
801
804
|
};
|
|
802
805
|
PostHogCore.prototype.register = function (properties) {
|
|
803
806
|
this.props = __assign(__assign({}, this.props), properties);
|
|
@@ -811,27 +814,28 @@ var PostHogCore = /** @class */ (function () {
|
|
|
811
814
|
*** TRACKING
|
|
812
815
|
***/
|
|
813
816
|
PostHogCore.prototype.identify = function (distinctId, properties) {
|
|
814
|
-
|
|
817
|
+
var previousDistinctId = this.getDistinctId();
|
|
818
|
+
distinctId = distinctId || previousDistinctId;
|
|
815
819
|
if (properties === null || properties === void 0 ? void 0 : properties.$groups) {
|
|
816
820
|
this.groups(properties.$groups);
|
|
817
821
|
}
|
|
818
822
|
var payload = __assign(__assign({}, this.buildPayload({
|
|
819
823
|
distinct_id: distinctId,
|
|
820
824
|
event: '$identify',
|
|
821
|
-
properties: __assign(__assign({}, (properties || {})), { $anon_distinct_id: this.
|
|
825
|
+
properties: __assign(__assign({}, (properties || {})), { $anon_distinct_id: this.getAnonymousId() }),
|
|
822
826
|
})), { $set: properties });
|
|
823
|
-
if (distinctId !==
|
|
827
|
+
if (distinctId !== previousDistinctId) {
|
|
828
|
+
// We keep the AnonymousId to be used by decide calls and identify to link the previousId
|
|
829
|
+
this.setPersistedProperty(PostHogPersistedProperty.AnonymousId, previousDistinctId);
|
|
824
830
|
this.setPersistedProperty(PostHogPersistedProperty.DistinctId, distinctId);
|
|
831
|
+
if (this.getFeatureFlags()) {
|
|
832
|
+
void this.reloadFeatureFlagsAsync();
|
|
833
|
+
}
|
|
825
834
|
}
|
|
826
835
|
this.enqueue('identify', payload);
|
|
827
836
|
return this;
|
|
828
837
|
};
|
|
829
838
|
PostHogCore.prototype.capture = function (event, properties) {
|
|
830
|
-
// NOTE: Legacy nodejs implementation uses groups
|
|
831
|
-
if (properties && properties['groups']) {
|
|
832
|
-
properties.$groups = properties.groups;
|
|
833
|
-
delete properties.groups;
|
|
834
|
-
}
|
|
835
839
|
if (properties === null || properties === void 0 ? void 0 : properties.$groups) {
|
|
836
840
|
this.groups(properties.$groups);
|
|
837
841
|
}
|
|
@@ -870,7 +874,7 @@ var PostHogCore = /** @class */ (function () {
|
|
|
870
874
|
this.register({
|
|
871
875
|
$groups: __assign(__assign({}, existingGroups), groups),
|
|
872
876
|
});
|
|
873
|
-
if (Object.keys(groups).find(function (type) { return existingGroups[type] !== groups[type]; }) && this.
|
|
877
|
+
if (Object.keys(groups).find(function (type) { return existingGroups[type] !== groups[type]; }) && this.getFeatureFlags()) {
|
|
874
878
|
void this.reloadFeatureFlagsAsync();
|
|
875
879
|
}
|
|
876
880
|
return this;
|
|
@@ -914,16 +918,24 @@ var PostHogCore = /** @class */ (function () {
|
|
|
914
918
|
fetchOptions = {
|
|
915
919
|
method: 'POST',
|
|
916
920
|
headers: { 'Content-Type': 'application/json' },
|
|
917
|
-
body: JSON.stringify({
|
|
921
|
+
body: JSON.stringify({
|
|
922
|
+
token: this.apiKey,
|
|
923
|
+
distinct_id: distinctId,
|
|
924
|
+
$anon_distinct_id: this.getAnonymousId(),
|
|
925
|
+
groups: groups,
|
|
926
|
+
}),
|
|
918
927
|
};
|
|
919
928
|
this._decideResponsePromise = this.fetchWithRetry(url, fetchOptions)
|
|
920
929
|
.then(function (r) { return r.json(); })
|
|
921
930
|
.then(function (res) {
|
|
922
931
|
if (res.featureFlags) {
|
|
923
932
|
_this.setPersistedProperty(PostHogPersistedProperty.FeatureFlags, res.featureFlags);
|
|
933
|
+
_this._events.emit('featureflags', res.featureFlags);
|
|
924
934
|
}
|
|
925
|
-
_this._events.emit('featureflags', res.featureFlags);
|
|
926
935
|
return res;
|
|
936
|
+
})
|
|
937
|
+
.finally(function () {
|
|
938
|
+
_this._decideResponsePromise = undefined;
|
|
927
939
|
});
|
|
928
940
|
return [2 /*return*/, this._decideResponsePromise];
|
|
929
941
|
});
|
|
@@ -972,27 +984,16 @@ var PostHogCore = /** @class */ (function () {
|
|
|
972
984
|
};
|
|
973
985
|
PostHogCore.prototype.reloadFeatureFlagsAsync = function () {
|
|
974
986
|
return __awaiter(this, void 0, void 0, function () {
|
|
975
|
-
var _this = this;
|
|
976
987
|
return __generator(this, function (_a) {
|
|
977
988
|
switch (_a.label) {
|
|
978
|
-
case 0:
|
|
979
|
-
clearTimeout(this._decideTimer);
|
|
980
|
-
if (this._decidePollInterval) {
|
|
981
|
-
this._decideTimer = safeSetTimeout(function () { return _this.reloadFeatureFlagsAsync(); }, this._decidePollInterval);
|
|
982
|
-
}
|
|
983
|
-
this._decideResponsePromise = undefined;
|
|
984
|
-
return [4 /*yield*/, this.decideAsync()];
|
|
989
|
+
case 0: return [4 /*yield*/, this.decideAsync()];
|
|
985
990
|
case 1: return [2 /*return*/, (_a.sent()).featureFlags];
|
|
986
991
|
}
|
|
987
992
|
});
|
|
988
993
|
});
|
|
989
994
|
};
|
|
990
|
-
// When listening to feature flags polling is active
|
|
991
995
|
PostHogCore.prototype.onFeatureFlags = function (cb) {
|
|
992
996
|
var _this = this;
|
|
993
|
-
if (!this._decideTimer) {
|
|
994
|
-
void this.reloadFeatureFlagsAsync();
|
|
995
|
-
}
|
|
996
997
|
return this.on('featureflags', function () { return __awaiter(_this, void 0, void 0, function () {
|
|
997
998
|
var flags;
|
|
998
999
|
return __generator(this, function (_a) {
|
|
@@ -1004,6 +1005,19 @@ var PostHogCore = /** @class */ (function () {
|
|
|
1004
1005
|
});
|
|
1005
1006
|
}); });
|
|
1006
1007
|
};
|
|
1008
|
+
PostHogCore.prototype.onFeatureFlag = function (key, cb) {
|
|
1009
|
+
var _this = this;
|
|
1010
|
+
return this.on('featureflags', function () { return __awaiter(_this, void 0, void 0, function () {
|
|
1011
|
+
var flagResponse;
|
|
1012
|
+
return __generator(this, function (_a) {
|
|
1013
|
+
flagResponse = this.getFeatureFlag(key);
|
|
1014
|
+
if (flagResponse !== undefined) {
|
|
1015
|
+
cb(flagResponse);
|
|
1016
|
+
}
|
|
1017
|
+
return [2 /*return*/];
|
|
1018
|
+
});
|
|
1019
|
+
}); });
|
|
1020
|
+
};
|
|
1007
1021
|
PostHogCore.prototype.overrideFeatureFlag = function (flags) {
|
|
1008
1022
|
if (flags === null) {
|
|
1009
1023
|
return this.setPersistedProperty(PostHogPersistedProperty.OverrideFeatureFlags, null);
|
|
@@ -1111,7 +1125,6 @@ var PostHogCore = /** @class */ (function () {
|
|
|
1111
1125
|
return __generator(this, function (_a) {
|
|
1112
1126
|
switch (_a.label) {
|
|
1113
1127
|
case 0:
|
|
1114
|
-
clearTimeout(this._decideTimer);
|
|
1115
1128
|
clearTimeout(this._flushTimer);
|
|
1116
1129
|
return [4 /*yield*/, this.flushAsync()];
|
|
1117
1130
|
case 1:
|
|
@@ -1127,6 +1140,19 @@ var PostHogCore = /** @class */ (function () {
|
|
|
1127
1140
|
return PostHogCore;
|
|
1128
1141
|
}());
|
|
1129
1142
|
|
|
1143
|
+
var PostHogMemoryStorage = /** @class */ (function () {
|
|
1144
|
+
function PostHogMemoryStorage() {
|
|
1145
|
+
this._memoryStorage = {};
|
|
1146
|
+
}
|
|
1147
|
+
PostHogMemoryStorage.prototype.getProperty = function (key) {
|
|
1148
|
+
return this._memoryStorage[key];
|
|
1149
|
+
};
|
|
1150
|
+
PostHogMemoryStorage.prototype.setProperty = function (key, value) {
|
|
1151
|
+
this._memoryStorage[key] = value !== null ? value : undefined;
|
|
1152
|
+
};
|
|
1153
|
+
return PostHogMemoryStorage;
|
|
1154
|
+
}());
|
|
1155
|
+
|
|
1130
1156
|
var getLegacyValues = function () {
|
|
1131
1157
|
return __awaiter(void 0, void 0, void 0, function () {
|
|
1132
1158
|
var posthogFileDirectory, posthogDistinctIdFile, posthogAnonymousIdFile, res, _a, _b, _c, _d, _e, _f;
|
|
@@ -1311,36 +1337,7 @@ var preloadSemiAsyncStorage = function () {
|
|
|
1311
1337
|
return _preloadSemiAsyncStoragePromise;
|
|
1312
1338
|
};
|
|
1313
1339
|
|
|
1314
|
-
var
|
|
1315
|
-
var _OptionalExpoLocalization = undefined;
|
|
1316
|
-
var _OptionalExpoNetwork = undefined;
|
|
1317
|
-
|
|
1318
|
-
var warn = function (name) {
|
|
1319
|
-
console.warn("PostHog: Missing ".concat(name, " optional dependency. Some functions may not work as expected..."));
|
|
1320
|
-
};
|
|
1321
|
-
|
|
1322
|
-
try {
|
|
1323
|
-
_OptionalReactNativeNavigation = require('@react-navigation/native');
|
|
1324
|
-
} catch (e) {
|
|
1325
|
-
warn('@react-navigation/native');
|
|
1326
|
-
}
|
|
1327
|
-
|
|
1328
|
-
try {
|
|
1329
|
-
_OptionalExpoLocalization = require('expo-localization');
|
|
1330
|
-
} catch (e) {
|
|
1331
|
-
warn('expo-localization');
|
|
1332
|
-
}
|
|
1333
|
-
|
|
1334
|
-
try {
|
|
1335
|
-
_OptionalExpoNetwork = require('expo-network');
|
|
1336
|
-
} catch (e) {
|
|
1337
|
-
warn('expo-network');
|
|
1338
|
-
}
|
|
1339
|
-
|
|
1340
|
-
var OptionalReactNativeNavigation = _OptionalReactNativeNavigation;
|
|
1341
|
-
var OptionalExpoLocalization = _OptionalExpoLocalization;
|
|
1342
|
-
|
|
1343
|
-
var version = "2.0.0-alpha10";
|
|
1340
|
+
var version = "2.0.0-alpha13";
|
|
1344
1341
|
|
|
1345
1342
|
var PostHog =
|
|
1346
1343
|
/** @class */
|
|
@@ -1350,16 +1347,19 @@ function (_super) {
|
|
|
1350
1347
|
function PostHog(apiKey, options) {
|
|
1351
1348
|
var _this = _super.call(this, apiKey, options) || this;
|
|
1352
1349
|
|
|
1350
|
+
_this._memoryStorage = new PostHogMemoryStorage();
|
|
1351
|
+
_this._persistence = options === null || options === void 0 ? void 0 : options.persistence;
|
|
1353
1352
|
AppState.addEventListener('change', function () {
|
|
1354
1353
|
_this.flush();
|
|
1355
1354
|
}); // Ensure the async storage has been preloaded (this call is cached)
|
|
1356
1355
|
// It is possible that the old library was used so we try to get the legacy distinctID
|
|
1357
1356
|
|
|
1358
1357
|
void preloadSemiAsyncStorage().then(function () {
|
|
1359
|
-
if (!SemiAsyncStorage.getItem(PostHogPersistedProperty.
|
|
1358
|
+
if (!SemiAsyncStorage.getItem(PostHogPersistedProperty.AnonymousId)) {
|
|
1360
1359
|
getLegacyValues().then(function (legacyValues) {
|
|
1361
1360
|
if (legacyValues === null || legacyValues === void 0 ? void 0 : legacyValues.distinctId) {
|
|
1362
1361
|
SemiAsyncStorage.setItem(PostHogPersistedProperty.DistinctId, legacyValues.distinctId);
|
|
1362
|
+
SemiAsyncStorage.setItem(PostHogPersistedProperty.AnonymousId, legacyValues.anonymousId);
|
|
1363
1363
|
}
|
|
1364
1364
|
});
|
|
1365
1365
|
}
|
|
@@ -1372,10 +1372,18 @@ function (_super) {
|
|
|
1372
1372
|
};
|
|
1373
1373
|
|
|
1374
1374
|
PostHog.prototype.getPersistedProperty = function (key) {
|
|
1375
|
+
if (this._persistence === 'memory') {
|
|
1376
|
+
return this._memoryStorage.getProperty(key);
|
|
1377
|
+
}
|
|
1378
|
+
|
|
1375
1379
|
return SemiAsyncStorage.getItem(key) || undefined;
|
|
1376
1380
|
};
|
|
1377
1381
|
|
|
1378
1382
|
PostHog.prototype.setPersistedProperty = function (key, value) {
|
|
1383
|
+
if (this._persistence === 'memory') {
|
|
1384
|
+
return this._memoryStorage.getProperty(key);
|
|
1385
|
+
}
|
|
1386
|
+
|
|
1379
1387
|
return value !== null ? SemiAsyncStorage.setItem(key, value) : SemiAsyncStorage.removeItem(key);
|
|
1380
1388
|
};
|
|
1381
1389
|
|
|
@@ -1392,29 +1400,25 @@ function (_super) {
|
|
|
1392
1400
|
};
|
|
1393
1401
|
|
|
1394
1402
|
PostHog.prototype.getCustomUserAgent = function () {
|
|
1395
|
-
// TODO
|
|
1396
1403
|
return;
|
|
1397
1404
|
};
|
|
1398
1405
|
|
|
1399
1406
|
PostHog.prototype.getCommonEventProperties = function () {
|
|
1407
|
+
console.log('DeviceInfo', ExpoDevice);
|
|
1400
1408
|
return __assign(__assign({}, _super.prototype.getCommonEventProperties.call(this)), {
|
|
1401
1409
|
$app_build: '1',
|
|
1402
|
-
$app_name: ExpoApplication
|
|
1403
|
-
$app_namespace: ExpoApplication
|
|
1404
|
-
$app_version: ExpoApplication
|
|
1405
|
-
|
|
1406
|
-
$
|
|
1407
|
-
|
|
1408
|
-
$
|
|
1409
|
-
|
|
1410
|
-
$
|
|
1411
|
-
// "$network_cellular": false,
|
|
1412
|
-
// "$network_wifi": true,
|
|
1413
|
-
$os_name: ExpoDevice === null || ExpoDevice === void 0 ? void 0 : ExpoDevice.osName,
|
|
1414
|
-
$os_version: ExpoDevice === null || ExpoDevice === void 0 ? void 0 : ExpoDevice.osVersion,
|
|
1410
|
+
$app_name: ExpoApplication.applicationName,
|
|
1411
|
+
$app_namespace: ExpoApplication.applicationId,
|
|
1412
|
+
$app_version: ExpoApplication.nativeApplicationVersion,
|
|
1413
|
+
$device_manufacturer: ExpoDevice.manufacturer,
|
|
1414
|
+
$device_name: ExpoDevice.modelName,
|
|
1415
|
+
$device_type: Platform.OS,
|
|
1416
|
+
$locale: ExpoLocalization.locale,
|
|
1417
|
+
$os_name: ExpoDevice.osName,
|
|
1418
|
+
$os_version: ExpoDevice.osVersion,
|
|
1415
1419
|
$screen_height: Dimensions.get('screen').height,
|
|
1416
1420
|
$screen_width: Dimensions.get('screen').width,
|
|
1417
|
-
$timezone:
|
|
1421
|
+
$timezone: ExpoLocalization.timezone
|
|
1418
1422
|
});
|
|
1419
1423
|
}; // Custom methods
|
|
1420
1424
|
|
|
@@ -1472,6 +1476,20 @@ function useLifecycleTracker(client) {
|
|
|
1472
1476
|
}, [posthog]);
|
|
1473
1477
|
}
|
|
1474
1478
|
|
|
1479
|
+
var _OptionalReactNativeNavigation = undefined;
|
|
1480
|
+
|
|
1481
|
+
var warn = function (name) {
|
|
1482
|
+
console.warn("PostHog: Missing ".concat(name, " optional dependency. Some functions may not work as expected..."));
|
|
1483
|
+
};
|
|
1484
|
+
|
|
1485
|
+
try {
|
|
1486
|
+
_OptionalReactNativeNavigation = require('@react-navigation/native');
|
|
1487
|
+
} catch (e) {
|
|
1488
|
+
warn('@react-navigation/native');
|
|
1489
|
+
}
|
|
1490
|
+
|
|
1491
|
+
var OptionalReactNativeNavigation = _OptionalReactNativeNavigation;
|
|
1492
|
+
|
|
1475
1493
|
function _useNavigationTrackerDisabled() {
|
|
1476
1494
|
return;
|
|
1477
1495
|
}
|
|
@@ -1618,7 +1636,9 @@ var autocaptureFromTouchEvent = function (e, posthog, options) {
|
|
|
1618
1636
|
_e = options.maxElementsCaptured,
|
|
1619
1637
|
maxElementsCaptured = _e === void 0 ? 20 : _e,
|
|
1620
1638
|
_f = options.ignoreLabels,
|
|
1621
|
-
ignoreLabels = _f === void 0 ? [] : _f
|
|
1639
|
+
ignoreLabels = _f === void 0 ? [] : _f,
|
|
1640
|
+
_g = options.propsToCapture,
|
|
1641
|
+
propsToCapture = _g === void 0 ? ['style', 'testID', 'accessibilityLabel', 'ph-label'] : _g;
|
|
1622
1642
|
|
|
1623
1643
|
if (!e._targetInst) {
|
|
1624
1644
|
return;
|
|
@@ -1633,8 +1653,19 @@ var autocaptureFromTouchEvent = function (e, posthog, options) {
|
|
|
1633
1653
|
};
|
|
1634
1654
|
var props = currentInst.memoizedProps;
|
|
1635
1655
|
|
|
1656
|
+
if (props === null || props === void 0 ? void 0 : props[noCaptureProp]) {
|
|
1657
|
+
return {
|
|
1658
|
+
value: void 0
|
|
1659
|
+
};
|
|
1660
|
+
}
|
|
1661
|
+
|
|
1636
1662
|
if (props) {
|
|
1663
|
+
// Capture only props we have said to capture. By default this is only "safe" props
|
|
1637
1664
|
Object.keys(props).forEach(function (key) {
|
|
1665
|
+
if (!propsToCapture.includes(key)) {
|
|
1666
|
+
return;
|
|
1667
|
+
}
|
|
1668
|
+
|
|
1638
1669
|
var value = props[key];
|
|
1639
1670
|
|
|
1640
1671
|
if (key === 'style') {
|
|
@@ -1647,12 +1678,6 @@ var autocaptureFromTouchEvent = function (e, posthog, options) {
|
|
|
1647
1678
|
}
|
|
1648
1679
|
}
|
|
1649
1680
|
});
|
|
1650
|
-
}
|
|
1651
|
-
|
|
1652
|
-
if (props === null || props === void 0 ? void 0 : props[noCaptureProp]) {
|
|
1653
|
-
return {
|
|
1654
|
-
value: void 0
|
|
1655
|
-
};
|
|
1656
1681
|
} // Try and find a sensible label
|
|
1657
1682
|
|
|
1658
1683
|
|