posthog-js 1.29.3 → 1.30.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/CHANGELOG.md +4 -0
- package/dist/array.js +1 -1
- package/dist/array.js.map +1 -1
- package/dist/es.js +48 -7
- package/dist/es.js.map +1 -1
- package/dist/module.d.ts +7 -1
- package/dist/module.js +48 -7
- package/dist/module.js.map +1 -1
- package/lib/package.json +1 -1
- package/package.json +1 -1
package/dist/es.js
CHANGED
|
@@ -881,7 +881,7 @@ var LZString = {
|
|
|
881
881
|
}
|
|
882
882
|
};
|
|
883
883
|
|
|
884
|
-
var version = "1.
|
|
884
|
+
var version = "1.30.0";
|
|
885
885
|
|
|
886
886
|
// e.g. Config.DEBUG = Config.DEBUG || instance.get_config('debug')
|
|
887
887
|
|
|
@@ -3290,6 +3290,7 @@ var PostHogFeatureFlags = /*#__PURE__*/function () {
|
|
|
3290
3290
|
}, {
|
|
3291
3291
|
key: "receivedFeatureFlags",
|
|
3292
3292
|
value: function receivedFeatureFlags(response) {
|
|
3293
|
+
this.instance.decideEndpointWasHit = true;
|
|
3293
3294
|
parseFeatureFlagDecideResponse(response, this.instance.persistence);
|
|
3294
3295
|
var flags = this.getFlags();
|
|
3295
3296
|
var variants = this.getFlagVariants();
|
|
@@ -3967,8 +3968,9 @@ var Decide = /*#__PURE__*/function () {
|
|
|
3967
3968
|
function Decide(instance) {
|
|
3968
3969
|
_classCallCheck(this, Decide);
|
|
3969
3970
|
|
|
3970
|
-
this.instance = instance;
|
|
3971
|
-
|
|
3971
|
+
this.instance = instance; // don't need to wait for `decide` to return if flags were provided on initialisation
|
|
3972
|
+
|
|
3973
|
+
this.instance.decideEndpointWasHit = this.instance._hasBootstrappedFeatureFlags();
|
|
3972
3974
|
}
|
|
3973
3975
|
|
|
3974
3976
|
_createClass(Decide, [{
|
|
@@ -5954,7 +5956,8 @@ var defaultConfig = function defaultConfig() {
|
|
|
5954
5956
|
_capture_metrics: false,
|
|
5955
5957
|
_capture_performance: false,
|
|
5956
5958
|
name: 'posthog',
|
|
5957
|
-
callback_fn: 'posthog._jsc'
|
|
5959
|
+
callback_fn: 'posthog._jsc',
|
|
5960
|
+
bootstrap: {}
|
|
5958
5961
|
};
|
|
5959
5962
|
};
|
|
5960
5963
|
/**
|
|
@@ -6103,6 +6106,8 @@ var PostHog = /*#__PURE__*/function () {
|
|
|
6103
6106
|
}, {
|
|
6104
6107
|
key: "_init",
|
|
6105
6108
|
value: function _init(token) {
|
|
6109
|
+
var _config$bootstrap;
|
|
6110
|
+
|
|
6106
6111
|
var config = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
6107
6112
|
var name = arguments.length > 2 ? arguments[2] : undefined;
|
|
6108
6113
|
this.__loaded = true;
|
|
@@ -6127,14 +6132,43 @@ var PostHog = /*#__PURE__*/function () {
|
|
|
6127
6132
|
|
|
6128
6133
|
this._gdpr_init();
|
|
6129
6134
|
|
|
6135
|
+
if (((_config$bootstrap = config.bootstrap) === null || _config$bootstrap === void 0 ? void 0 : _config$bootstrap.distinctID) !== undefined) {
|
|
6136
|
+
var _config$bootstrap2;
|
|
6137
|
+
|
|
6138
|
+
var uuid = this.get_config('get_device_id')(_UUID());
|
|
6139
|
+
var deviceID = (_config$bootstrap2 = config.bootstrap) !== null && _config$bootstrap2 !== void 0 && _config$bootstrap2.isIdentifiedID ? uuid : config.bootstrap.distinctID;
|
|
6140
|
+
this.register({
|
|
6141
|
+
distinct_id: config.bootstrap.distinctID,
|
|
6142
|
+
$device_id: deviceID
|
|
6143
|
+
});
|
|
6144
|
+
}
|
|
6145
|
+
|
|
6146
|
+
if (this._hasBootstrappedFeatureFlags()) {
|
|
6147
|
+
var _config$bootstrap3;
|
|
6148
|
+
|
|
6149
|
+
var activeFlags = Object.keys(((_config$bootstrap3 = config.bootstrap) === null || _config$bootstrap3 === void 0 ? void 0 : _config$bootstrap3.featureFlags) || {}).filter(function (flag) {
|
|
6150
|
+
var _config$bootstrap4, _config$bootstrap4$fe;
|
|
6151
|
+
|
|
6152
|
+
return !!((_config$bootstrap4 = config.bootstrap) !== null && _config$bootstrap4 !== void 0 && (_config$bootstrap4$fe = _config$bootstrap4.featureFlags) !== null && _config$bootstrap4$fe !== void 0 && _config$bootstrap4$fe[flag]);
|
|
6153
|
+
}).reduce(function (res, key) {
|
|
6154
|
+
var _config$bootstrap5, _config$bootstrap5$fe;
|
|
6155
|
+
|
|
6156
|
+
return res[key] = ((_config$bootstrap5 = config.bootstrap) === null || _config$bootstrap5 === void 0 ? void 0 : (_config$bootstrap5$fe = _config$bootstrap5.featureFlags) === null || _config$bootstrap5$fe === void 0 ? void 0 : _config$bootstrap5$fe[key]) || false, res;
|
|
6157
|
+
}, {});
|
|
6158
|
+
this.featureFlags.receivedFeatureFlags({
|
|
6159
|
+
featureFlags: activeFlags
|
|
6160
|
+
});
|
|
6161
|
+
}
|
|
6162
|
+
|
|
6130
6163
|
if (!this.get_distinct_id()) {
|
|
6131
6164
|
// There is no need to set the distinct id
|
|
6132
6165
|
// or the device id if something was already stored
|
|
6133
6166
|
// in the persitence
|
|
6134
|
-
var
|
|
6167
|
+
var _uuid = this.get_config('get_device_id')(_UUID());
|
|
6168
|
+
|
|
6135
6169
|
this.register_once({
|
|
6136
|
-
distinct_id:
|
|
6137
|
-
$device_id:
|
|
6170
|
+
distinct_id: _uuid,
|
|
6171
|
+
$device_id: _uuid
|
|
6138
6172
|
}, '');
|
|
6139
6173
|
} // Set up event handler for pageleave
|
|
6140
6174
|
// Use `onpagehide` if available, see https://calendar.perfplanet.com/2020/beaconing-in-practice/#beaconing-reliability-avoiding-abandons
|
|
@@ -6415,6 +6449,13 @@ var PostHog = /*#__PURE__*/function () {
|
|
|
6415
6449
|
execute(other_calls, this);
|
|
6416
6450
|
execute(capturing_calls, this);
|
|
6417
6451
|
}
|
|
6452
|
+
}, {
|
|
6453
|
+
key: "_hasBootstrappedFeatureFlags",
|
|
6454
|
+
value: function _hasBootstrappedFeatureFlags() {
|
|
6455
|
+
var _this$config$bootstra, _this$config$bootstra2;
|
|
6456
|
+
|
|
6457
|
+
return ((_this$config$bootstra = this.config.bootstrap) === null || _this$config$bootstra === void 0 ? void 0 : _this$config$bootstra.featureFlags) && Object.keys((_this$config$bootstra2 = this.config.bootstrap) === null || _this$config$bootstra2 === void 0 ? void 0 : _this$config$bootstra2.featureFlags).length > 0 || false;
|
|
6458
|
+
}
|
|
6418
6459
|
/**
|
|
6419
6460
|
* push() keeps the standard async-array-push
|
|
6420
6461
|
* behavior around after the lib is loaded.
|