posthog-js 1.201.0 → 1.201.1
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/array.full.es5.js +1 -1
- package/dist/array.full.es5.js.map +1 -1
- package/dist/array.full.js +1 -1
- package/dist/array.full.js.map +1 -1
- package/dist/array.full.no-external.js +1 -1
- package/dist/array.full.no-external.js.map +1 -1
- package/dist/array.js +1 -1
- package/dist/array.js.map +1 -1
- package/dist/array.no-external.js +1 -1
- package/dist/array.no-external.js.map +1 -1
- package/dist/customizations.full.js +1 -1
- package/dist/main.js +1 -1
- package/dist/main.js.map +1 -1
- package/dist/module.full.js +1 -1
- package/dist/module.full.js.map +1 -1
- package/dist/module.full.no-external.js +1 -1
- package/dist/module.full.no-external.js.map +1 -1
- package/dist/module.js +1 -1
- package/dist/module.js.map +1 -1
- package/dist/module.no-external.js +1 -1
- package/dist/module.no-external.js.map +1 -1
- package/lib/package.json +1 -1
- package/lib/src/remote-config.js +30 -27
- package/lib/src/remote-config.js.map +1 -1
- package/package.json +1 -1
package/lib/package.json
CHANGED
package/lib/src/remote-config.js
CHANGED
|
@@ -27,36 +27,35 @@ var RemoteConfigLoader = /** @class */ (function () {
|
|
|
27
27
|
});
|
|
28
28
|
};
|
|
29
29
|
RemoteConfigLoader.prototype.load = function () {
|
|
30
|
-
// Call decide to get what features are enabled and other settings.
|
|
31
|
-
// As a reminder, if the /decide endpoint is disabled, feature flags, toolbar, session recording, autocapture,
|
|
32
|
-
// and compression will not be available.
|
|
33
30
|
var _this = this;
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
logger.info('Using preloaded remote config', assignableWindow._POSTHOG_CONFIG);
|
|
40
|
-
this.onRemoteConfig(assignableWindow._POSTHOG_CONFIG);
|
|
41
|
-
return;
|
|
42
|
-
}
|
|
43
|
-
if (this.instance.config.advanced_disable_decide) {
|
|
44
|
-
// This setting is essentially saying "dont call external APIs" hence we respect it here
|
|
45
|
-
logger.warn('Remote config is disabled. Falling back to local config.');
|
|
46
|
-
return;
|
|
47
|
-
}
|
|
48
|
-
// Attempt 2 - if we have the external deps loader then lets load the script version of the config that includes site apps
|
|
49
|
-
this._loadRemoteConfigJs(function (config) {
|
|
50
|
-
if (!config) {
|
|
51
|
-
logger.info('No config found after loading remote JS config. Falling back to JSON.');
|
|
52
|
-
// Attempt 3 Load the config json instead of the script - we won't get site apps etc. but we will get the config
|
|
53
|
-
_this._loadRemoteConfigJSON(function (config) {
|
|
54
|
-
_this.onRemoteConfig(config);
|
|
55
|
-
});
|
|
31
|
+
try {
|
|
32
|
+
// Attempt 1 - use the pre-loaded config if it came as part of the token-specific array.js
|
|
33
|
+
if (assignableWindow._POSTHOG_CONFIG) {
|
|
34
|
+
logger.info('Using preloaded remote config', assignableWindow._POSTHOG_CONFIG);
|
|
35
|
+
this.onRemoteConfig(assignableWindow._POSTHOG_CONFIG);
|
|
56
36
|
return;
|
|
57
37
|
}
|
|
58
|
-
|
|
59
|
-
|
|
38
|
+
if (this.instance.config.advanced_disable_decide) {
|
|
39
|
+
// This setting is essentially saying "dont call external APIs" hence we respect it here
|
|
40
|
+
logger.warn('Remote config is disabled. Falling back to local config.');
|
|
41
|
+
return;
|
|
42
|
+
}
|
|
43
|
+
// Attempt 2 - if we have the external deps loader then lets load the script version of the config that includes site apps
|
|
44
|
+
this._loadRemoteConfigJs(function (config) {
|
|
45
|
+
if (!config) {
|
|
46
|
+
logger.info('No config found after loading remote JS config. Falling back to JSON.');
|
|
47
|
+
// Attempt 3 Load the config json instead of the script - we won't get site apps etc. but we will get the config
|
|
48
|
+
_this._loadRemoteConfigJSON(function (config) {
|
|
49
|
+
_this.onRemoteConfig(config);
|
|
50
|
+
});
|
|
51
|
+
return;
|
|
52
|
+
}
|
|
53
|
+
_this.onRemoteConfig(config);
|
|
54
|
+
});
|
|
55
|
+
}
|
|
56
|
+
catch (error) {
|
|
57
|
+
logger.error('Error loading remote config', error);
|
|
58
|
+
}
|
|
60
59
|
};
|
|
61
60
|
RemoteConfigLoader.prototype.onRemoteConfig = function (config) {
|
|
62
61
|
// NOTE: Once this is rolled out we will remove the "decide" related code above. Until then the code duplication is fine.
|
|
@@ -64,6 +63,10 @@ var RemoteConfigLoader = /** @class */ (function () {
|
|
|
64
63
|
logger.error('Failed to fetch remote config from PostHog.');
|
|
65
64
|
return;
|
|
66
65
|
}
|
|
66
|
+
if (!this.instance.config.__preview_remote_config) {
|
|
67
|
+
logger.info('__preview_remote_config is disabled. Logging config instead', config);
|
|
68
|
+
return;
|
|
69
|
+
}
|
|
67
70
|
this.instance._onRemoteConfig(config);
|
|
68
71
|
// We only need to reload if we haven't already loaded the flags or if the request is in flight
|
|
69
72
|
if (config.hasFeatureFlags !== false) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"remote-config.js","sourceRoot":"","sources":["../../src/remote-config.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAA;AAC7C,OAAO,EAAE,gBAAgB,EAAE,MAAM,iBAAiB,CAAA;AAElD,IAAM,MAAM,GAAG,YAAY,CAAC,UAAU,CAAC,CAAA;AAEvC;IACI,4BAA6B,QAAiB;QAAjB,aAAQ,GAAR,QAAQ,CAAS;IAAG,CAAC;IAE1C,gDAAmB,GAA3B,UAA4B,EAAmC;;QAC3D,IAAI,MAAA,gBAAgB,CAAC,qBAAqB,0CAAE,sBAAsB,EAAE,CAAC;YACjE,MAAA,MAAA,gBAAgB,CAAC,qBAAqB,0CAAE,sBAAsB,mDAAG,IAAI,CAAC,QAAQ,EAAE,eAAe,EAAE;gBAC7F,OAAO,EAAE,CAAC,gBAAgB,CAAC,eAAe,CAAC,CAAA;YAC/C,CAAC,CAAC,CAAA;QACN,CAAC;aAAM,CAAC;YACJ,MAAM,CAAC,KAAK,CAAC,0DAA0D,CAAC,CAAA;YACxE,EAAE,EAAE,CAAA;QACR,CAAC;IACL,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B,MAAqB;QACxC,yHAAyH;QACzH,IAAI,CAAC,MAAM,EAAE,CAAC;YACV,MAAM,CAAC,KAAK,CAAC,6CAA6C,CAAC,CAAA;YAC3D,OAAM;QACV,CAAC;QAED,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC,MAAM,CAAC,uBAAuB,EAAE,CAAC;YAChD,MAAM,CAAC,IAAI,CAAC,6DAA6D,EAAE,MAAM,CAAC,CAAA;YAClF,OAAM;QACV,CAAC;QAED,IAAI,CAAC,QAAQ,CAAC,eAAe,CAAC,MAAM,CAAC,CAAA;QAErC,+FAA+F;QAC/F,IAAI,MAAM,CAAC,eAAe,KAAK,KAAK,EAAE,CAAC;YACnC,mFAAmF;YACnF,sGAAsG;YACtG,IAAI,CAAC,QAAQ,CAAC,YAAY,CAAC,iBAAiB,EAAE,CAAA;QAClD,CAAC;IACL,CAAC;IACL,yBAAC;AAAD,CAAC,AA9ED,IA8EC","sourcesContent":["import { PostHog } from './posthog-core'\nimport { RemoteConfig } from './types'\n\nimport { createLogger } from './utils/logger'\nimport { assignableWindow } from './utils/globals'\n\nconst logger = createLogger('[Decide]')\n\nexport class RemoteConfigLoader {\n constructor(private readonly instance: PostHog) {}\n\n private _loadRemoteConfigJs(cb: (config?: RemoteConfig) => void): void {\n if (assignableWindow.__PosthogExtensions__?.loadExternalDependency) {\n assignableWindow.__PosthogExtensions__?.loadExternalDependency?.(this.instance, 'remote-config', () => {\n return cb(assignableWindow._POSTHOG_CONFIG)\n })\n } else {\n logger.error('PostHog Extensions not found. Cannot load remote config.')\n cb()\n }\n }\n\n private _loadRemoteConfigJSON(cb: (config?: RemoteConfig) => void): void {\n this.instance._send_request({\n method: 'GET',\n url: this.instance.requestRouter.endpointFor('assets', `/array/${this.instance.config.token}/config`),\n callback: (response) => {\n cb(response.json as RemoteConfig | undefined)\n },\n })\n }\n\n load(): void {\n try {\n // Attempt 1 - use the pre-loaded config if it came as part of the token-specific array.js\n if (assignableWindow._POSTHOG_CONFIG) {\n logger.info('Using preloaded remote config', assignableWindow._POSTHOG_CONFIG)\n this.onRemoteConfig(assignableWindow._POSTHOG_CONFIG)\n return\n }\n\n if (this.instance.config.advanced_disable_decide) {\n // This setting is essentially saying \"dont call external APIs\" hence we respect it here\n logger.warn('Remote config is disabled. Falling back to local config.')\n return\n }\n\n // Attempt 2 - if we have the external deps loader then lets load the script version of the config that includes site apps\n this._loadRemoteConfigJs((config) => {\n if (!config) {\n logger.info('No config found after loading remote JS config. Falling back to JSON.')\n // Attempt 3 Load the config json instead of the script - we won't get site apps etc. but we will get the config\n this._loadRemoteConfigJSON((config) => {\n this.onRemoteConfig(config)\n })\n return\n }\n\n this.onRemoteConfig(config)\n })\n } catch (error) {\n logger.error('Error loading remote config', error)\n }\n }\n\n private onRemoteConfig(config?: RemoteConfig): void {\n // NOTE: Once this is rolled out we will remove the \"decide\" related code above. Until then the code duplication is fine.\n if (!config) {\n logger.error('Failed to fetch remote config from PostHog.')\n return\n }\n\n if (!this.instance.config.__preview_remote_config) {\n logger.info('__preview_remote_config is disabled. Logging config instead', config)\n return\n }\n\n this.instance._onRemoteConfig(config)\n\n // We only need to reload if we haven't already loaded the flags or if the request is in flight\n if (config.hasFeatureFlags !== false) {\n // If the config has feature flags, we need to call decide to get the feature flags\n // This completely separates it from the config logic which is good in terms of separation of concerns\n this.instance.featureFlags.ensureFlagsLoaded()\n }\n }\n}\n"]}
|
package/package.json
CHANGED