posthog-react-native 2.0.0-alpha7 → 2.0.0
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 +131 -94
- package/lib/index.cjs.js.map +1 -1
- package/lib/index.d.ts +16 -7
- package/lib/index.esm.js +130 -94
- 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 +6 -3
- 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.cjs.js
CHANGED
|
@@ -5,6 +5,7 @@ Object.defineProperty(exports, '__esModule', { value: true });
|
|
|
5
5
|
var reactNative = require('react-native');
|
|
6
6
|
var ExpoApplication = require('expo-application');
|
|
7
7
|
var ExpoDevice = require('expo-device');
|
|
8
|
+
var ExpoLocalization = require('expo-localization');
|
|
8
9
|
var FileSystem = require('expo-file-system');
|
|
9
10
|
var React = require('react');
|
|
10
11
|
|
|
@@ -30,6 +31,7 @@ function _interopNamespace(e) {
|
|
|
30
31
|
|
|
31
32
|
var ExpoApplication__namespace = /*#__PURE__*/_interopNamespace(ExpoApplication);
|
|
32
33
|
var ExpoDevice__namespace = /*#__PURE__*/_interopNamespace(ExpoDevice);
|
|
34
|
+
var ExpoLocalization__namespace = /*#__PURE__*/_interopNamespace(ExpoLocalization);
|
|
33
35
|
var FileSystem__namespace = /*#__PURE__*/_interopNamespace(FileSystem);
|
|
34
36
|
var React__default = /*#__PURE__*/_interopDefaultLegacy(React);
|
|
35
37
|
|
|
@@ -166,6 +168,7 @@ function __generator(thisArg, body) {
|
|
|
166
168
|
|
|
167
169
|
var PostHogPersistedProperty;
|
|
168
170
|
(function (PostHogPersistedProperty) {
|
|
171
|
+
PostHogPersistedProperty["AnonymousId"] = "anonymous_id";
|
|
169
172
|
PostHogPersistedProperty["DistinctId"] = "distinct_id";
|
|
170
173
|
PostHogPersistedProperty["Props"] = "props";
|
|
171
174
|
PostHogPersistedProperty["FeatureFlags"] = "feature_flags";
|
|
@@ -191,7 +194,7 @@ function retriable(fn, props) {
|
|
|
191
194
|
return __generator(this, function (_d) {
|
|
192
195
|
switch (_d.label) {
|
|
193
196
|
case 0:
|
|
194
|
-
_a = props.retryCount, retryCount = _a === void 0 ? 3 : _a, _b = props.retryDelay, retryDelay = _b === void 0 ?
|
|
197
|
+
_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;
|
|
195
198
|
lastError = null;
|
|
196
199
|
i = 0;
|
|
197
200
|
_d.label = 1;
|
|
@@ -705,13 +708,14 @@ var SimpleEventEmitter = /** @class */ (function () {
|
|
|
705
708
|
};
|
|
706
709
|
};
|
|
707
710
|
SimpleEventEmitter.prototype.emit = function (event, payload) {
|
|
708
|
-
|
|
709
|
-
return;
|
|
710
|
-
}
|
|
711
|
-
for (var _i = 0, _a = this.events[event]; _i < _a.length; _i++) {
|
|
711
|
+
for (var _i = 0, _a = this.events[event] || []; _i < _a.length; _i++) {
|
|
712
712
|
var listener = _a[_i];
|
|
713
713
|
listener(payload);
|
|
714
714
|
}
|
|
715
|
+
for (var _b = 0, _c = this.events['*'] || []; _b < _c.length; _b++) {
|
|
716
|
+
var listener = _c[_b];
|
|
717
|
+
listener(event, payload);
|
|
718
|
+
}
|
|
715
719
|
};
|
|
716
720
|
return SimpleEventEmitter;
|
|
717
721
|
}());
|
|
@@ -719,7 +723,7 @@ var SimpleEventEmitter = /** @class */ (function () {
|
|
|
719
723
|
var PostHogCore = /** @class */ (function () {
|
|
720
724
|
function PostHogCore(apiKey, options) {
|
|
721
725
|
var _this = this;
|
|
722
|
-
var _a, _b, _c, _d, _e
|
|
726
|
+
var _a, _b, _c, _d, _e;
|
|
723
727
|
this.flagCallReported = {};
|
|
724
728
|
// internal
|
|
725
729
|
this._events = new SimpleEventEmitter();
|
|
@@ -730,14 +734,13 @@ var PostHogCore = /** @class */ (function () {
|
|
|
730
734
|
this.flushInterval = (_a = options === null || options === void 0 ? void 0 : options.flushInterval) !== null && _a !== void 0 ? _a : 10000;
|
|
731
735
|
this.captureMode = (options === null || options === void 0 ? void 0 : options.captureMode) || 'form';
|
|
732
736
|
this.sendFeatureFlagEvent = (_b = options === null || options === void 0 ? void 0 : options.sendFeatureFlagEvent) !== null && _b !== void 0 ? _b : true;
|
|
733
|
-
this._decidePollInterval = Math.max(0, (_c = options === null || options === void 0 ? void 0 : options.decidePollInterval) !== null && _c !== void 0 ? _c : 30000);
|
|
734
737
|
// If enable is explicitly set to false we override the optout
|
|
735
738
|
this._optoutOverride = (options === null || options === void 0 ? void 0 : options.enable) === false;
|
|
736
739
|
this._retryOptions = {
|
|
737
|
-
retryCount: (
|
|
738
|
-
retryDelay: (
|
|
740
|
+
retryCount: (_c = options === null || options === void 0 ? void 0 : options.fetchRetryCount) !== null && _c !== void 0 ? _c : 3,
|
|
741
|
+
retryDelay: (_d = options === null || options === void 0 ? void 0 : options.fetchRetryDelay) !== null && _d !== void 0 ? _d : 3000,
|
|
739
742
|
};
|
|
740
|
-
this._sessionExpirationTimeSeconds = (
|
|
743
|
+
this._sessionExpirationTimeSeconds = (_e = options === null || options === void 0 ? void 0 : options.sessionExpirationTimeSeconds) !== null && _e !== void 0 ? _e : 1800; // 30 minutes
|
|
741
744
|
// NOTE: It is important we don't initiate anything in the constructor as some async IO may still be underway on the parent
|
|
742
745
|
if ((options === null || options === void 0 ? void 0 : options.preloadFeatureFlags) !== false) {
|
|
743
746
|
safeSetTimeout(function () {
|
|
@@ -789,7 +792,14 @@ var PostHogCore = /** @class */ (function () {
|
|
|
789
792
|
for (var key in PostHogPersistedProperty) {
|
|
790
793
|
this.setPersistedProperty(PostHogPersistedProperty[key], null);
|
|
791
794
|
}
|
|
792
|
-
|
|
795
|
+
};
|
|
796
|
+
PostHogCore.prototype.debug = function (enabled) {
|
|
797
|
+
var _a;
|
|
798
|
+
if (enabled === void 0) { enabled = true; }
|
|
799
|
+
(_a = this.removeDebugCallback) === null || _a === void 0 ? void 0 : _a.call(this);
|
|
800
|
+
if (enabled) {
|
|
801
|
+
this.removeDebugCallback = this.on('*', function (event, payload) { return console.log('PostHog Debug', event, payload); });
|
|
802
|
+
}
|
|
793
803
|
};
|
|
794
804
|
PostHogCore.prototype.buildPayload = function (payload) {
|
|
795
805
|
return {
|
|
@@ -808,13 +818,19 @@ var PostHogCore = /** @class */ (function () {
|
|
|
808
818
|
this.setPersistedProperty(PostHogPersistedProperty.SessionLastTimestamp, Date.now());
|
|
809
819
|
return sessionId;
|
|
810
820
|
};
|
|
811
|
-
PostHogCore.prototype.
|
|
812
|
-
|
|
813
|
-
|
|
814
|
-
|
|
815
|
-
|
|
821
|
+
PostHogCore.prototype.resetSessionId = function () {
|
|
822
|
+
this.setPersistedProperty(PostHogPersistedProperty.SessionId, null);
|
|
823
|
+
};
|
|
824
|
+
PostHogCore.prototype.getAnonymousId = function () {
|
|
825
|
+
var anonId = this.getPersistedProperty(PostHogPersistedProperty.AnonymousId);
|
|
826
|
+
if (!anonId) {
|
|
827
|
+
anonId = generateUUID(globalThis);
|
|
828
|
+
this.setPersistedProperty(PostHogPersistedProperty.AnonymousId, anonId);
|
|
816
829
|
}
|
|
817
|
-
return
|
|
830
|
+
return anonId;
|
|
831
|
+
};
|
|
832
|
+
PostHogCore.prototype.getDistinctId = function () {
|
|
833
|
+
return this.getPersistedProperty(PostHogPersistedProperty.DistinctId) || this.getAnonymousId();
|
|
818
834
|
};
|
|
819
835
|
PostHogCore.prototype.register = function (properties) {
|
|
820
836
|
this.props = __assign(__assign({}, this.props), properties);
|
|
@@ -828,27 +844,28 @@ var PostHogCore = /** @class */ (function () {
|
|
|
828
844
|
*** TRACKING
|
|
829
845
|
***/
|
|
830
846
|
PostHogCore.prototype.identify = function (distinctId, properties) {
|
|
831
|
-
|
|
847
|
+
var previousDistinctId = this.getDistinctId();
|
|
848
|
+
distinctId = distinctId || previousDistinctId;
|
|
832
849
|
if (properties === null || properties === void 0 ? void 0 : properties.$groups) {
|
|
833
850
|
this.groups(properties.$groups);
|
|
834
851
|
}
|
|
835
852
|
var payload = __assign(__assign({}, this.buildPayload({
|
|
836
853
|
distinct_id: distinctId,
|
|
837
854
|
event: '$identify',
|
|
838
|
-
properties: __assign(__assign({}, (properties || {})), { $anon_distinct_id: this.
|
|
855
|
+
properties: __assign(__assign({}, (properties || {})), { $anon_distinct_id: this.getAnonymousId() }),
|
|
839
856
|
})), { $set: properties });
|
|
840
|
-
if (distinctId !==
|
|
857
|
+
if (distinctId !== previousDistinctId) {
|
|
858
|
+
// We keep the AnonymousId to be used by decide calls and identify to link the previousId
|
|
859
|
+
this.setPersistedProperty(PostHogPersistedProperty.AnonymousId, previousDistinctId);
|
|
841
860
|
this.setPersistedProperty(PostHogPersistedProperty.DistinctId, distinctId);
|
|
861
|
+
if (this.getFeatureFlags()) {
|
|
862
|
+
void this.reloadFeatureFlagsAsync();
|
|
863
|
+
}
|
|
842
864
|
}
|
|
843
865
|
this.enqueue('identify', payload);
|
|
844
866
|
return this;
|
|
845
867
|
};
|
|
846
868
|
PostHogCore.prototype.capture = function (event, properties) {
|
|
847
|
-
// NOTE: Legacy nodejs implementation uses groups
|
|
848
|
-
if (properties && properties['groups']) {
|
|
849
|
-
properties.$groups = properties.groups;
|
|
850
|
-
delete properties.groups;
|
|
851
|
-
}
|
|
852
869
|
if (properties === null || properties === void 0 ? void 0 : properties.$groups) {
|
|
853
870
|
this.groups(properties.$groups);
|
|
854
871
|
}
|
|
@@ -887,7 +904,7 @@ var PostHogCore = /** @class */ (function () {
|
|
|
887
904
|
this.register({
|
|
888
905
|
$groups: __assign(__assign({}, existingGroups), groups),
|
|
889
906
|
});
|
|
890
|
-
if (Object.keys(groups).find(function (type) { return existingGroups[type] !== groups[type]; }) && this.
|
|
907
|
+
if (Object.keys(groups).find(function (type) { return existingGroups[type] !== groups[type]; }) && this.getFeatureFlags()) {
|
|
891
908
|
void this.reloadFeatureFlagsAsync();
|
|
892
909
|
}
|
|
893
910
|
return this;
|
|
@@ -931,16 +948,24 @@ var PostHogCore = /** @class */ (function () {
|
|
|
931
948
|
fetchOptions = {
|
|
932
949
|
method: 'POST',
|
|
933
950
|
headers: { 'Content-Type': 'application/json' },
|
|
934
|
-
body: JSON.stringify({
|
|
951
|
+
body: JSON.stringify({
|
|
952
|
+
token: this.apiKey,
|
|
953
|
+
distinct_id: distinctId,
|
|
954
|
+
$anon_distinct_id: this.getAnonymousId(),
|
|
955
|
+
groups: groups,
|
|
956
|
+
}),
|
|
935
957
|
};
|
|
936
958
|
this._decideResponsePromise = this.fetchWithRetry(url, fetchOptions)
|
|
937
959
|
.then(function (r) { return r.json(); })
|
|
938
960
|
.then(function (res) {
|
|
939
961
|
if (res.featureFlags) {
|
|
940
962
|
_this.setPersistedProperty(PostHogPersistedProperty.FeatureFlags, res.featureFlags);
|
|
963
|
+
_this._events.emit('featureflags', res.featureFlags);
|
|
941
964
|
}
|
|
942
|
-
_this._events.emit('featureflags', res.featureFlags);
|
|
943
965
|
return res;
|
|
966
|
+
})
|
|
967
|
+
.finally(function () {
|
|
968
|
+
_this._decideResponsePromise = undefined;
|
|
944
969
|
});
|
|
945
970
|
return [2 /*return*/, this._decideResponsePromise];
|
|
946
971
|
});
|
|
@@ -989,27 +1014,16 @@ var PostHogCore = /** @class */ (function () {
|
|
|
989
1014
|
};
|
|
990
1015
|
PostHogCore.prototype.reloadFeatureFlagsAsync = function () {
|
|
991
1016
|
return __awaiter(this, void 0, void 0, function () {
|
|
992
|
-
var _this = this;
|
|
993
1017
|
return __generator(this, function (_a) {
|
|
994
1018
|
switch (_a.label) {
|
|
995
|
-
case 0:
|
|
996
|
-
clearTimeout(this._decideTimer);
|
|
997
|
-
if (this._decidePollInterval) {
|
|
998
|
-
this._decideTimer = safeSetTimeout(function () { return _this.reloadFeatureFlagsAsync(); }, this._decidePollInterval);
|
|
999
|
-
}
|
|
1000
|
-
this._decideResponsePromise = undefined;
|
|
1001
|
-
return [4 /*yield*/, this.decideAsync()];
|
|
1019
|
+
case 0: return [4 /*yield*/, this.decideAsync()];
|
|
1002
1020
|
case 1: return [2 /*return*/, (_a.sent()).featureFlags];
|
|
1003
1021
|
}
|
|
1004
1022
|
});
|
|
1005
1023
|
});
|
|
1006
1024
|
};
|
|
1007
|
-
// When listening to feature flags polling is active
|
|
1008
1025
|
PostHogCore.prototype.onFeatureFlags = function (cb) {
|
|
1009
1026
|
var _this = this;
|
|
1010
|
-
if (!this._decideTimer) {
|
|
1011
|
-
void this.reloadFeatureFlagsAsync();
|
|
1012
|
-
}
|
|
1013
1027
|
return this.on('featureflags', function () { return __awaiter(_this, void 0, void 0, function () {
|
|
1014
1028
|
var flags;
|
|
1015
1029
|
return __generator(this, function (_a) {
|
|
@@ -1021,6 +1035,19 @@ var PostHogCore = /** @class */ (function () {
|
|
|
1021
1035
|
});
|
|
1022
1036
|
}); });
|
|
1023
1037
|
};
|
|
1038
|
+
PostHogCore.prototype.onFeatureFlag = function (key, cb) {
|
|
1039
|
+
var _this = this;
|
|
1040
|
+
return this.on('featureflags', function () { return __awaiter(_this, void 0, void 0, function () {
|
|
1041
|
+
var flagResponse;
|
|
1042
|
+
return __generator(this, function (_a) {
|
|
1043
|
+
flagResponse = this.getFeatureFlag(key);
|
|
1044
|
+
if (flagResponse !== undefined) {
|
|
1045
|
+
cb(flagResponse);
|
|
1046
|
+
}
|
|
1047
|
+
return [2 /*return*/];
|
|
1048
|
+
});
|
|
1049
|
+
}); });
|
|
1050
|
+
};
|
|
1024
1051
|
PostHogCore.prototype.overrideFeatureFlag = function (flags) {
|
|
1025
1052
|
if (flags === null) {
|
|
1026
1053
|
return this.setPersistedProperty(PostHogPersistedProperty.OverrideFeatureFlags, null);
|
|
@@ -1128,7 +1155,6 @@ var PostHogCore = /** @class */ (function () {
|
|
|
1128
1155
|
return __generator(this, function (_a) {
|
|
1129
1156
|
switch (_a.label) {
|
|
1130
1157
|
case 0:
|
|
1131
|
-
clearTimeout(this._decideTimer);
|
|
1132
1158
|
clearTimeout(this._flushTimer);
|
|
1133
1159
|
return [4 /*yield*/, this.flushAsync()];
|
|
1134
1160
|
case 1:
|
|
@@ -1144,6 +1170,19 @@ var PostHogCore = /** @class */ (function () {
|
|
|
1144
1170
|
return PostHogCore;
|
|
1145
1171
|
}());
|
|
1146
1172
|
|
|
1173
|
+
var PostHogMemoryStorage = /** @class */ (function () {
|
|
1174
|
+
function PostHogMemoryStorage() {
|
|
1175
|
+
this._memoryStorage = {};
|
|
1176
|
+
}
|
|
1177
|
+
PostHogMemoryStorage.prototype.getProperty = function (key) {
|
|
1178
|
+
return this._memoryStorage[key];
|
|
1179
|
+
};
|
|
1180
|
+
PostHogMemoryStorage.prototype.setProperty = function (key, value) {
|
|
1181
|
+
this._memoryStorage[key] = value !== null ? value : undefined;
|
|
1182
|
+
};
|
|
1183
|
+
return PostHogMemoryStorage;
|
|
1184
|
+
}());
|
|
1185
|
+
|
|
1147
1186
|
var getLegacyValues = function () {
|
|
1148
1187
|
return __awaiter(void 0, void 0, void 0, function () {
|
|
1149
1188
|
var posthogFileDirectory, posthogDistinctIdFile, posthogAnonymousIdFile, res, _a, _b, _c, _d, _e, _f;
|
|
@@ -1328,36 +1367,7 @@ var preloadSemiAsyncStorage = function () {
|
|
|
1328
1367
|
return _preloadSemiAsyncStoragePromise;
|
|
1329
1368
|
};
|
|
1330
1369
|
|
|
1331
|
-
var
|
|
1332
|
-
var _OptionalExpoLocalization = undefined;
|
|
1333
|
-
var _OptionalExpoNetwork = undefined;
|
|
1334
|
-
|
|
1335
|
-
var warn = function (name) {
|
|
1336
|
-
console.warn("PostHog: Missing ".concat(name, " optional dependency. Some functions may not work as expected..."));
|
|
1337
|
-
};
|
|
1338
|
-
|
|
1339
|
-
try {
|
|
1340
|
-
_OptionalReactNativeNavigation = require('@react-navigation/native');
|
|
1341
|
-
} catch (e) {
|
|
1342
|
-
warn('@react-navigation/native');
|
|
1343
|
-
}
|
|
1344
|
-
|
|
1345
|
-
try {
|
|
1346
|
-
_OptionalExpoLocalization = require('expo-localization');
|
|
1347
|
-
} catch (e) {
|
|
1348
|
-
warn('expo-localization');
|
|
1349
|
-
}
|
|
1350
|
-
|
|
1351
|
-
try {
|
|
1352
|
-
_OptionalExpoNetwork = require('expo-network');
|
|
1353
|
-
} catch (e) {
|
|
1354
|
-
warn('expo-network');
|
|
1355
|
-
}
|
|
1356
|
-
|
|
1357
|
-
var OptionalReactNativeNavigation = _OptionalReactNativeNavigation;
|
|
1358
|
-
var OptionalExpoLocalization = _OptionalExpoLocalization;
|
|
1359
|
-
|
|
1360
|
-
var version = "2.0.0-alpha7";
|
|
1370
|
+
var version = "2.0.0";
|
|
1361
1371
|
|
|
1362
1372
|
var PostHog =
|
|
1363
1373
|
/** @class */
|
|
@@ -1367,16 +1377,19 @@ function (_super) {
|
|
|
1367
1377
|
function PostHog(apiKey, options) {
|
|
1368
1378
|
var _this = _super.call(this, apiKey, options) || this;
|
|
1369
1379
|
|
|
1380
|
+
_this._memoryStorage = new PostHogMemoryStorage();
|
|
1381
|
+
_this._persistence = options === null || options === void 0 ? void 0 : options.persistence;
|
|
1370
1382
|
reactNative.AppState.addEventListener('change', function () {
|
|
1371
1383
|
_this.flush();
|
|
1372
1384
|
}); // Ensure the async storage has been preloaded (this call is cached)
|
|
1373
1385
|
// It is possible that the old library was used so we try to get the legacy distinctID
|
|
1374
1386
|
|
|
1375
1387
|
void preloadSemiAsyncStorage().then(function () {
|
|
1376
|
-
if (!SemiAsyncStorage.getItem(PostHogPersistedProperty.
|
|
1388
|
+
if (!SemiAsyncStorage.getItem(PostHogPersistedProperty.AnonymousId)) {
|
|
1377
1389
|
getLegacyValues().then(function (legacyValues) {
|
|
1378
1390
|
if (legacyValues === null || legacyValues === void 0 ? void 0 : legacyValues.distinctId) {
|
|
1379
1391
|
SemiAsyncStorage.setItem(PostHogPersistedProperty.DistinctId, legacyValues.distinctId);
|
|
1392
|
+
SemiAsyncStorage.setItem(PostHogPersistedProperty.AnonymousId, legacyValues.anonymousId);
|
|
1380
1393
|
}
|
|
1381
1394
|
});
|
|
1382
1395
|
}
|
|
@@ -1389,10 +1402,18 @@ function (_super) {
|
|
|
1389
1402
|
};
|
|
1390
1403
|
|
|
1391
1404
|
PostHog.prototype.getPersistedProperty = function (key) {
|
|
1405
|
+
if (this._persistence === 'memory') {
|
|
1406
|
+
return this._memoryStorage.getProperty(key);
|
|
1407
|
+
}
|
|
1408
|
+
|
|
1392
1409
|
return SemiAsyncStorage.getItem(key) || undefined;
|
|
1393
1410
|
};
|
|
1394
1411
|
|
|
1395
1412
|
PostHog.prototype.setPersistedProperty = function (key, value) {
|
|
1413
|
+
if (this._persistence === 'memory') {
|
|
1414
|
+
return this._memoryStorage.getProperty(key);
|
|
1415
|
+
}
|
|
1416
|
+
|
|
1396
1417
|
return value !== null ? SemiAsyncStorage.setItem(key, value) : SemiAsyncStorage.removeItem(key);
|
|
1397
1418
|
};
|
|
1398
1419
|
|
|
@@ -1409,29 +1430,24 @@ function (_super) {
|
|
|
1409
1430
|
};
|
|
1410
1431
|
|
|
1411
1432
|
PostHog.prototype.getCustomUserAgent = function () {
|
|
1412
|
-
// TODO
|
|
1413
1433
|
return;
|
|
1414
1434
|
};
|
|
1415
1435
|
|
|
1416
1436
|
PostHog.prototype.getCommonEventProperties = function () {
|
|
1417
1437
|
return __assign(__assign({}, _super.prototype.getCommonEventProperties.call(this)), {
|
|
1418
1438
|
$app_build: '1',
|
|
1419
|
-
$app_name: ExpoApplication__namespace
|
|
1420
|
-
$app_namespace: ExpoApplication__namespace
|
|
1421
|
-
$app_version: ExpoApplication__namespace
|
|
1422
|
-
|
|
1423
|
-
$
|
|
1424
|
-
|
|
1425
|
-
$
|
|
1426
|
-
|
|
1427
|
-
$
|
|
1428
|
-
// "$network_cellular": false,
|
|
1429
|
-
// "$network_wifi": true,
|
|
1430
|
-
$os_name: ExpoDevice__namespace === null || ExpoDevice__namespace === void 0 ? void 0 : ExpoDevice__namespace.osName,
|
|
1431
|
-
$os_version: ExpoDevice__namespace === null || ExpoDevice__namespace === void 0 ? void 0 : ExpoDevice__namespace.osVersion,
|
|
1439
|
+
$app_name: ExpoApplication__namespace.applicationName,
|
|
1440
|
+
$app_namespace: ExpoApplication__namespace.applicationId,
|
|
1441
|
+
$app_version: ExpoApplication__namespace.nativeApplicationVersion,
|
|
1442
|
+
$device_manufacturer: ExpoDevice__namespace.manufacturer,
|
|
1443
|
+
$device_name: ExpoDevice__namespace.modelName,
|
|
1444
|
+
$device_type: reactNative.Platform.OS,
|
|
1445
|
+
$locale: ExpoLocalization__namespace.locale,
|
|
1446
|
+
$os_name: ExpoDevice__namespace.osName,
|
|
1447
|
+
$os_version: ExpoDevice__namespace.osVersion,
|
|
1432
1448
|
$screen_height: reactNative.Dimensions.get('screen').height,
|
|
1433
1449
|
$screen_width: reactNative.Dimensions.get('screen').width,
|
|
1434
|
-
$timezone:
|
|
1450
|
+
$timezone: ExpoLocalization__namespace.timezone
|
|
1435
1451
|
});
|
|
1436
1452
|
}; // Custom methods
|
|
1437
1453
|
|
|
@@ -1489,6 +1505,20 @@ function useLifecycleTracker(client) {
|
|
|
1489
1505
|
}, [posthog]);
|
|
1490
1506
|
}
|
|
1491
1507
|
|
|
1508
|
+
var _OptionalReactNativeNavigation = undefined;
|
|
1509
|
+
|
|
1510
|
+
var warn = function (name) {
|
|
1511
|
+
console.warn("PostHog: Missing ".concat(name, " optional dependency. Some functions may not work as expected..."));
|
|
1512
|
+
};
|
|
1513
|
+
|
|
1514
|
+
try {
|
|
1515
|
+
_OptionalReactNativeNavigation = require('@react-navigation/native');
|
|
1516
|
+
} catch (e) {
|
|
1517
|
+
warn('@react-navigation/native');
|
|
1518
|
+
}
|
|
1519
|
+
|
|
1520
|
+
var OptionalReactNativeNavigation = _OptionalReactNativeNavigation;
|
|
1521
|
+
|
|
1492
1522
|
function _useNavigationTrackerDisabled() {
|
|
1493
1523
|
return;
|
|
1494
1524
|
}
|
|
@@ -1635,7 +1665,9 @@ var autocaptureFromTouchEvent = function (e, posthog, options) {
|
|
|
1635
1665
|
_e = options.maxElementsCaptured,
|
|
1636
1666
|
maxElementsCaptured = _e === void 0 ? 20 : _e,
|
|
1637
1667
|
_f = options.ignoreLabels,
|
|
1638
|
-
ignoreLabels = _f === void 0 ? [] : _f
|
|
1668
|
+
ignoreLabels = _f === void 0 ? [] : _f,
|
|
1669
|
+
_g = options.propsToCapture,
|
|
1670
|
+
propsToCapture = _g === void 0 ? ['style', 'testID', 'accessibilityLabel', 'ph-label'] : _g;
|
|
1639
1671
|
|
|
1640
1672
|
if (!e._targetInst) {
|
|
1641
1673
|
return;
|
|
@@ -1650,8 +1682,19 @@ var autocaptureFromTouchEvent = function (e, posthog, options) {
|
|
|
1650
1682
|
};
|
|
1651
1683
|
var props = currentInst.memoizedProps;
|
|
1652
1684
|
|
|
1685
|
+
if (props === null || props === void 0 ? void 0 : props[noCaptureProp]) {
|
|
1686
|
+
return {
|
|
1687
|
+
value: void 0
|
|
1688
|
+
};
|
|
1689
|
+
}
|
|
1690
|
+
|
|
1653
1691
|
if (props) {
|
|
1692
|
+
// Capture only props we have said to capture. By default this is only "safe" props
|
|
1654
1693
|
Object.keys(props).forEach(function (key) {
|
|
1694
|
+
if (!propsToCapture.includes(key)) {
|
|
1695
|
+
return;
|
|
1696
|
+
}
|
|
1697
|
+
|
|
1655
1698
|
var value = props[key];
|
|
1656
1699
|
|
|
1657
1700
|
if (key === 'style') {
|
|
@@ -1664,12 +1707,6 @@ var autocaptureFromTouchEvent = function (e, posthog, options) {
|
|
|
1664
1707
|
}
|
|
1665
1708
|
}
|
|
1666
1709
|
});
|
|
1667
|
-
}
|
|
1668
|
-
|
|
1669
|
-
if (props === null || props === void 0 ? void 0 : props[noCaptureProp]) {
|
|
1670
|
-
return {
|
|
1671
|
-
value: void 0
|
|
1672
|
-
};
|
|
1673
1710
|
} // Try and find a sensible label
|
|
1674
1711
|
|
|
1675
1712
|
|