posthog-js 1.32.1 → 1.32.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/dist/module.d.ts CHANGED
@@ -166,7 +166,7 @@ interface PostHogConfig {
166
166
  opt_out_persistence_by_default: boolean;
167
167
  opt_out_capturing_persistence_type: 'localStorage' | 'cookie';
168
168
  opt_out_capturing_cookie_prefix: string | null;
169
- opt_in_web_app_injection: boolean;
169
+ opt_in_site_apps: boolean;
170
170
  respect_dnt: boolean;
171
171
  property_blacklist: string[];
172
172
  xhr_headers: {
@@ -278,10 +278,9 @@ interface DecideResponse {
278
278
  editorParams: EditorParams;
279
279
  toolbarVersion: 'toolbar'; /** deprecated, moved to editorParams */
280
280
  isAuthenticated: boolean;
281
- inject: {
281
+ siteApps: {
282
282
  id: number;
283
- source: string;
284
- config?: Record<string, any>;
283
+ url: string;
285
284
  }[];
286
285
  }
287
286
  declare type FeatureFlagsCallback = (flags: string[], variants: Record<string, string | boolean>) => void;
package/dist/module.js CHANGED
@@ -885,7 +885,7 @@ var LZString = {
885
885
  }
886
886
  };
887
887
 
888
- var version = "1.32.1";
888
+ var version = "1.32.3";
889
889
 
890
890
  // e.g. Config.DEBUG = Config.DEBUG || instance.get_config('debug')
891
891
 
@@ -4060,33 +4060,39 @@ var Decide = /*#__PURE__*/function () {
4060
4060
  this.instance['compression'] = {};
4061
4061
  }
4062
4062
 
4063
- if (response['inject'] && this.instance.get_config('opt_in_web_app_injection')) {
4064
- var _iterator2 = _createForOfIteratorHelper(response['inject']),
4065
- _step2;
4063
+ if (response['siteApps']) {
4064
+ if (this.instance.get_config('opt_in_site_apps')) {
4065
+ var apiHost = this.instance.get_config('api_host');
4066
4066
 
4067
- try {
4068
- for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
4069
- var _step2$value = _step2.value,
4070
- id = _step2$value.id,
4071
- source = _step2$value.source,
4072
- config = _step2$value.config;
4073
-
4074
- try {
4075
- var _window$eval, _window$eval2, _window$eval2$inject;
4076
-
4077
- var apiHost = this.instance.get_config('api_host');
4078
- (_window$eval = window.eval(source)) === null || _window$eval === void 0 ? void 0 : (_window$eval2 = _window$eval(apiHost)) === null || _window$eval2 === void 0 ? void 0 : (_window$eval2$inject = _window$eval2.inject) === null || _window$eval2$inject === void 0 ? void 0 : _window$eval2$inject.call(_window$eval2, {
4079
- config: config,
4080
- posthog: this.instance
4081
- });
4082
- } catch (e) {
4083
- console.error("[POSTHOG-JS] Error while initializing PostHog app with config id ".concat(id), e);
4067
+ var _iterator2 = _createForOfIteratorHelper(response['siteApps']),
4068
+ _step2;
4069
+
4070
+ try {
4071
+ var _loop = function _loop() {
4072
+ var _step2$value = _step2.value,
4073
+ id = _step2$value.id,
4074
+ url = _step2$value.url;
4075
+ var script = document.createElement('script');
4076
+ script.src = [apiHost, apiHost[apiHost.length - 1] === '/' && url[0] === '/' ? url.substring(1) : url].join('');
4077
+
4078
+ script.onerror = function (e) {
4079
+ console.error("Error while initializing PostHog app with config id ".concat(id), e);
4080
+ };
4081
+
4082
+ window["__$$ph_web_js_".concat(id)] = _this2.instance;
4083
+ document.body.appendChild(script);
4084
+ };
4085
+
4086
+ for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
4087
+ _loop();
4084
4088
  }
4089
+ } catch (err) {
4090
+ _iterator2.e(err);
4091
+ } finally {
4092
+ _iterator2.f();
4085
4093
  }
4086
- } catch (err) {
4087
- _iterator2.e(err);
4088
- } finally {
4089
- _iterator2.f();
4094
+ } else if (response['siteApps'].length > 0) {
4095
+ console.error('PostHog site apps are disabled. Enable the "opt_in_site_apps" config to proceed.');
4090
4096
  }
4091
4097
  }
4092
4098
  }
@@ -6004,7 +6010,7 @@ var defaultConfig = function defaultConfig() {
6004
6010
  opt_out_persistence_by_default: false,
6005
6011
  opt_out_capturing_persistence_type: 'localStorage',
6006
6012
  opt_out_capturing_cookie_prefix: null,
6007
- opt_in_web_app_injection: false,
6013
+ opt_in_site_apps: false,
6008
6014
  property_blacklist: [],
6009
6015
  respect_dnt: false,
6010
6016
  sanitize_properties: null,