posthog-react-native 2.1.1 → 2.1.3
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 +12 -45
- package/lib/index.cjs.js.map +1 -1
- package/lib/index.d.ts +1 -11
- package/lib/index.esm.js +12 -45
- package/lib/index.esm.js.map +1 -1
- package/lib/posthog-core/src/index.d.ts +0 -2
- package/lib/posthog-core/src/types.d.ts +1 -7
- package/lib/posthog-react-native/src/posthog.d.ts +14 -0
- package/lib/posthog-react-native/src/types.d.ts +0 -2
- package/package.json +1 -1
- package/CHANGELOG.md +0 -8
- package/lib/node_modules/tslib/tslib.es6.d.ts +0 -35
package/lib/index.cjs.js
CHANGED
|
@@ -772,26 +772,6 @@ var PostHogCore = /** @class */ (function () {
|
|
|
772
772
|
}
|
|
773
773
|
return __assign({ $lib: this.getLibraryId(), $lib_version: this.getLibraryVersion(), $active_feature_flags: featureFlags ? Object.keys(featureFlags) : undefined }, featureVariantProperties);
|
|
774
774
|
};
|
|
775
|
-
PostHogCore.prototype.setupBootstrap = function (options) {
|
|
776
|
-
var _a, _b, _c, _d;
|
|
777
|
-
if ((_a = options === null || options === void 0 ? void 0 : options.bootstrap) === null || _a === void 0 ? void 0 : _a.distinctId) {
|
|
778
|
-
if ((_b = options === null || options === void 0 ? void 0 : options.bootstrap) === null || _b === void 0 ? void 0 : _b.isIdentifiedId) {
|
|
779
|
-
this.setPersistedProperty(PostHogPersistedProperty.DistinctId, options.bootstrap.distinctId);
|
|
780
|
-
}
|
|
781
|
-
else {
|
|
782
|
-
this.setPersistedProperty(PostHogPersistedProperty.AnonymousId, options.bootstrap.distinctId);
|
|
783
|
-
}
|
|
784
|
-
}
|
|
785
|
-
if ((_c = options === null || options === void 0 ? void 0 : options.bootstrap) === null || _c === void 0 ? void 0 : _c.featureFlags) {
|
|
786
|
-
var activeFlags = Object.keys(((_d = options.bootstrap) === null || _d === void 0 ? void 0 : _d.featureFlags) || {})
|
|
787
|
-
.filter(function (flag) { var _a, _b; return !!((_b = (_a = options.bootstrap) === null || _a === void 0 ? void 0 : _a.featureFlags) === null || _b === void 0 ? void 0 : _b[flag]); })
|
|
788
|
-
.reduce(function (res, key) {
|
|
789
|
-
var _a, _b;
|
|
790
|
-
return ((res[key] = ((_b = (_a = options.bootstrap) === null || _a === void 0 ? void 0 : _a.featureFlags) === null || _b === void 0 ? void 0 : _b[key]) || false), res);
|
|
791
|
-
}, {});
|
|
792
|
-
this.setKnownFeatureFlags(activeFlags);
|
|
793
|
-
}
|
|
794
|
-
};
|
|
795
775
|
Object.defineProperty(PostHogCore.prototype, "props", {
|
|
796
776
|
// NOTE: Props are lazy loaded from localstorage hence the complex getter setter logic
|
|
797
777
|
get: function () {
|
|
@@ -1035,7 +1015,8 @@ var PostHogCore = /** @class */ (function () {
|
|
|
1035
1015
|
.then(function (r) { return r.json(); })
|
|
1036
1016
|
.then(function (res) {
|
|
1037
1017
|
if (res.featureFlags) {
|
|
1038
|
-
_this.
|
|
1018
|
+
_this.setPersistedProperty(PostHogPersistedProperty.FeatureFlags, res.featureFlags);
|
|
1019
|
+
_this._events.emit('featureflags', res.featureFlags);
|
|
1039
1020
|
}
|
|
1040
1021
|
return res;
|
|
1041
1022
|
})
|
|
@@ -1046,10 +1027,6 @@ var PostHogCore = /** @class */ (function () {
|
|
|
1046
1027
|
});
|
|
1047
1028
|
});
|
|
1048
1029
|
};
|
|
1049
|
-
PostHogCore.prototype.setKnownFeatureFlags = function (featureFlags) {
|
|
1050
|
-
this.setPersistedProperty(PostHogPersistedProperty.FeatureFlags, featureFlags);
|
|
1051
|
-
this._events.emit('featureflags', featureFlags);
|
|
1052
|
-
};
|
|
1053
1030
|
PostHogCore.prototype.getFeatureFlag = function (key) {
|
|
1054
1031
|
var featureFlags = this.getFeatureFlags();
|
|
1055
1032
|
if (!featureFlags) {
|
|
@@ -1361,7 +1338,7 @@ var loadStorageAsync = function () {
|
|
|
1361
1338
|
return __generator(this, function (_a) {
|
|
1362
1339
|
switch (_a.label) {
|
|
1363
1340
|
case 0:
|
|
1364
|
-
uri =
|
|
1341
|
+
uri = FileSystem__namespace.documentDirectory + POSTHOG_STORAGE_KEY;
|
|
1365
1342
|
_a.label = 1;
|
|
1366
1343
|
|
|
1367
1344
|
case 1:
|
|
@@ -1398,7 +1375,7 @@ var persitStorageAsync = function (content) {
|
|
|
1398
1375
|
return __generator(this, function (_a) {
|
|
1399
1376
|
switch (_a.label) {
|
|
1400
1377
|
case 0:
|
|
1401
|
-
uri =
|
|
1378
|
+
uri = FileSystem__namespace.documentDirectory + POSTHOG_STORAGE_KEY;
|
|
1402
1379
|
data = {
|
|
1403
1380
|
version: POSTHOG_STORAGE_VERSION,
|
|
1404
1381
|
content: content
|
|
@@ -1461,7 +1438,7 @@ var preloadSemiAsyncStorage = function () {
|
|
|
1461
1438
|
return _preloadSemiAsyncStoragePromise;
|
|
1462
1439
|
};
|
|
1463
1440
|
|
|
1464
|
-
var version = "2.
|
|
1441
|
+
var version = "2.0.0";
|
|
1465
1442
|
|
|
1466
1443
|
var PostHog =
|
|
1467
1444
|
/** @class */
|
|
@@ -1479,8 +1456,6 @@ function (_super) {
|
|
|
1479
1456
|
// It is possible that the old library was used so we try to get the legacy distinctID
|
|
1480
1457
|
|
|
1481
1458
|
void preloadSemiAsyncStorage().then(function () {
|
|
1482
|
-
_this.setupBootstrap(options);
|
|
1483
|
-
|
|
1484
1459
|
if (!SemiAsyncStorage.getItem(PostHogPersistedProperty.AnonymousId)) {
|
|
1485
1460
|
getLegacyValues().then(function (legacyValues) {
|
|
1486
1461
|
if (legacyValues === null || legacyValues === void 0 ? void 0 : legacyValues.distinctId) {
|
|
@@ -1507,7 +1482,7 @@ function (_super) {
|
|
|
1507
1482
|
|
|
1508
1483
|
PostHog.prototype.setPersistedProperty = function (key, value) {
|
|
1509
1484
|
if (this._persistence === 'memory') {
|
|
1510
|
-
return this._memoryStorage.
|
|
1485
|
+
return this._memoryStorage.getProperty(key);
|
|
1511
1486
|
}
|
|
1512
1487
|
|
|
1513
1488
|
return value !== null ? SemiAsyncStorage.setItem(key, value) : SemiAsyncStorage.removeItem(key);
|
|
@@ -1831,20 +1806,14 @@ var autocaptureFromTouchEvent = function (e, posthog, options) {
|
|
|
1831
1806
|
}
|
|
1832
1807
|
};
|
|
1833
1808
|
|
|
1834
|
-
function
|
|
1809
|
+
function PostHogHooks(_a) {
|
|
1835
1810
|
var options = _a.options;
|
|
1836
1811
|
useNavigationTracker(options === null || options === void 0 ? void 0 : options.navigation);
|
|
1837
|
-
return null;
|
|
1838
|
-
}
|
|
1839
|
-
|
|
1840
|
-
function PostHogLifecycleHook() {
|
|
1841
1812
|
useLifecycleTracker();
|
|
1842
1813
|
return null;
|
|
1843
1814
|
}
|
|
1844
1815
|
|
|
1845
1816
|
var PostHogProvider = function (_a) {
|
|
1846
|
-
var _b, _c;
|
|
1847
|
-
|
|
1848
1817
|
var children = _a.children,
|
|
1849
1818
|
client = _a.client,
|
|
1850
1819
|
options = _a.options,
|
|
@@ -1857,13 +1826,10 @@ var PostHogProvider = function (_a) {
|
|
|
1857
1826
|
posthogRef.current = client ? client : apiKey ? new PostHog(apiKey, options) : undefined;
|
|
1858
1827
|
}
|
|
1859
1828
|
|
|
1829
|
+
var autocaptureEnabled = !!autocapture;
|
|
1860
1830
|
var autocaptureOptions = autocapture && typeof autocapture !== 'boolean' ? autocapture : {};
|
|
1861
1831
|
var posthog = posthogRef.current;
|
|
1862
1832
|
var captureTouches = posthog && (autocapture === true || (autocaptureOptions === null || autocaptureOptions === void 0 ? void 0 : autocaptureOptions.captureTouches));
|
|
1863
|
-
var captureScreens = posthog && (autocapture === true || ((_b = autocaptureOptions === null || autocaptureOptions === void 0 ? void 0 : autocaptureOptions.captureScreens) !== null && _b !== void 0 ? _b : true)); // Default to true if not set
|
|
1864
|
-
|
|
1865
|
-
var captureLifecycle = posthog && (autocapture === true || ((_c = autocaptureOptions === null || autocaptureOptions === void 0 ? void 0 : autocaptureOptions.captureLifecycleEvents) !== null && _c !== void 0 ? _c : true)); // Default to true if not set
|
|
1866
|
-
|
|
1867
1833
|
var onTouch = React.useCallback(function (type, e) {
|
|
1868
1834
|
// TODO: Improve this to ensure we only capture presses and not just ends of a drag for example
|
|
1869
1835
|
if (!captureTouches) {
|
|
@@ -1873,7 +1839,8 @@ var PostHogProvider = function (_a) {
|
|
|
1873
1839
|
if (type === 'end') {
|
|
1874
1840
|
autocaptureFromTouchEvent(e, posthog, autocaptureOptions);
|
|
1875
1841
|
}
|
|
1876
|
-
}, [posthog, autocapture]);
|
|
1842
|
+
}, [posthog, autocapture]); // TODO: Improve this to ensure we only capture presses and not just ends of a drag for example
|
|
1843
|
+
|
|
1877
1844
|
return /*#__PURE__*/React__default["default"].createElement(reactNative.View, {
|
|
1878
1845
|
"ph-label": "PostHogProvider",
|
|
1879
1846
|
style: style || {
|
|
@@ -1886,9 +1853,9 @@ var PostHogProvider = function (_a) {
|
|
|
1886
1853
|
value: {
|
|
1887
1854
|
client: posthogRef.current
|
|
1888
1855
|
}
|
|
1889
|
-
},
|
|
1856
|
+
}, autocaptureEnabled ? /*#__PURE__*/React__default["default"].createElement(PostHogHooks, {
|
|
1890
1857
|
options: autocaptureOptions
|
|
1891
|
-
}) : null,
|
|
1858
|
+
}) : null, children));
|
|
1892
1859
|
};
|
|
1893
1860
|
|
|
1894
1861
|
exports.PostHog = PostHog;
|