posthog-js 1.275.2 → 1.275.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/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/lazy-recorder.js +1 -1
- package/dist/main.js +1 -1
- package/dist/main.js.map +1 -1
- package/dist/module.d.ts +1 -0
- package/dist/module.full.d.ts +1 -0
- package/dist/module.full.js +1 -1
- package/dist/module.full.js.map +1 -1
- package/dist/module.full.no-external.d.ts +1 -0
- 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.d.ts +1 -0
- package/dist/module.no-external.js +1 -1
- package/dist/module.no-external.js.map +1 -1
- package/dist/posthog-recorder.js +1 -1
- package/dist/src/posthog-core.d.ts +1 -0
- package/dist/surveys-preview.d.ts +1 -0
- package/lib/package.json +1 -1
- package/lib/src/posthog-core.d.ts +1 -0
- package/lib/src/posthog-core.js +26 -12
- package/lib/src/posthog-core.js.map +1 -1
- package/package.json +1 -1
|
@@ -1541,6 +1541,7 @@ export declare class PostHog {
|
|
|
1541
1541
|
* @param metricValue The value of the metric to capture.
|
|
1542
1542
|
*/
|
|
1543
1543
|
captureTraceMetric(traceId: string | number, metricName: string, metricValue: string | number | boolean): void;
|
|
1544
|
+
private _checkLocalStorageForDebug;
|
|
1544
1545
|
}
|
|
1545
1546
|
export declare function init_from_snippet(): void;
|
|
1546
1547
|
export declare function init_as_module(): PostHog;
|
|
@@ -4212,6 +4212,7 @@ declare class PostHog {
|
|
|
4212
4212
|
* @param metricValue The value of the metric to capture.
|
|
4213
4213
|
*/
|
|
4214
4214
|
captureTraceMetric(traceId: string | number, metricName: string, metricValue: string | number | boolean): void;
|
|
4215
|
+
private _checkLocalStorageForDebug;
|
|
4215
4216
|
}
|
|
4216
4217
|
|
|
4217
4218
|
declare function getNextSurveyStep(survey: Survey, currentQuestionIndex: number, response: string | string[] | number | null): any;
|
package/lib/package.json
CHANGED
|
@@ -1541,6 +1541,7 @@ export declare class PostHog {
|
|
|
1541
1541
|
* @param metricValue The value of the metric to capture.
|
|
1542
1542
|
*/
|
|
1543
1543
|
captureTraceMetric(traceId: string | number, metricName: string, metricValue: string | number | boolean): void;
|
|
1544
|
+
private _checkLocalStorageForDebug;
|
|
1544
1545
|
}
|
|
1545
1546
|
export declare function init_from_snippet(): void;
|
|
1546
1547
|
export declare function init_as_module(): PostHog;
|
package/lib/src/posthog-core.js
CHANGED
|
@@ -394,11 +394,14 @@ var PostHog = /** @class */ (function () {
|
|
|
394
394
|
return this;
|
|
395
395
|
}
|
|
396
396
|
if (this.__loaded) {
|
|
397
|
-
|
|
397
|
+
// need to be able to log before having processed debug config
|
|
398
|
+
// eslint-disable-next-line no-console
|
|
399
|
+
console.warn('[PostHog.js]', 'You have already initialized PostHog! Re-initializing is a no-op');
|
|
398
400
|
return this;
|
|
399
401
|
}
|
|
400
402
|
this.__loaded = true;
|
|
401
403
|
this.config = {}; // will be set right below
|
|
404
|
+
config.debug = this._checkLocalStorageForDebug(config.debug);
|
|
402
405
|
this._originalUserConfig = config; // Store original user config for migration
|
|
403
406
|
this._triggered_notifs = [];
|
|
404
407
|
if (config.person_profiles) {
|
|
@@ -2210,16 +2213,24 @@ var PostHog = /** @class */ (function () {
|
|
|
2210
2213
|
this.config.persistence === 'sessionStorage' || this.config.persistence === 'memory'
|
|
2211
2214
|
? this.persistence
|
|
2212
2215
|
: new posthog_persistence_1.PostHogPersistence(__assign(__assign({}, this.config), { persistence: 'sessionStorage' }), isPersistenceDisabled);
|
|
2213
|
-
|
|
2214
|
-
|
|
2216
|
+
var debugConfigFromLocalStorage = this._checkLocalStorageForDebug(this.config.debug);
|
|
2217
|
+
if ((0, core_1.isBoolean)(debugConfigFromLocalStorage)) {
|
|
2218
|
+
this.config.debug = debugConfigFromLocalStorage;
|
|
2215
2219
|
}
|
|
2216
|
-
if (this.config.debug) {
|
|
2217
|
-
|
|
2218
|
-
|
|
2219
|
-
|
|
2220
|
-
|
|
2221
|
-
|
|
2222
|
-
|
|
2220
|
+
if ((0, core_1.isBoolean)(this.config.debug)) {
|
|
2221
|
+
if (this.config.debug) {
|
|
2222
|
+
config_1.default.DEBUG = true;
|
|
2223
|
+
storage_1.localStore._is_supported() && storage_1.localStore._set('ph_debug', 'true');
|
|
2224
|
+
logger_1.logger.info('set_config', {
|
|
2225
|
+
config: config,
|
|
2226
|
+
oldConfig: oldConfig,
|
|
2227
|
+
newConfig: __assign({}, this.config),
|
|
2228
|
+
});
|
|
2229
|
+
}
|
|
2230
|
+
else {
|
|
2231
|
+
config_1.default.DEBUG = false;
|
|
2232
|
+
storage_1.localStore._is_supported() && storage_1.localStore._remove('ph_debug');
|
|
2233
|
+
}
|
|
2223
2234
|
}
|
|
2224
2235
|
(_b = this.sessionRecording) === null || _b === void 0 ? void 0 : _b.startIfEnabledOrStop();
|
|
2225
2236
|
(_c = this.autocapture) === null || _c === void 0 ? void 0 : _c.startIfEnabled();
|
|
@@ -2810,12 +2821,10 @@ var PostHog = /** @class */ (function () {
|
|
|
2810
2821
|
PostHog.prototype.debug = function (debug) {
|
|
2811
2822
|
if (debug === false) {
|
|
2812
2823
|
globals_1.window === null || globals_1.window === void 0 ? void 0 : globals_1.window.console.log("You've disabled debug mode.");
|
|
2813
|
-
localStorage && localStorage.removeItem('ph_debug');
|
|
2814
2824
|
this.set_config({ debug: false });
|
|
2815
2825
|
}
|
|
2816
2826
|
else {
|
|
2817
2827
|
globals_1.window === null || globals_1.window === void 0 ? void 0 : globals_1.window.console.log("You're now in debug mode. All calls to PostHog will be logged in your console.\nYou can disable this with `posthog.debug(false)`.");
|
|
2818
|
-
localStorage && localStorage.setItem('ph_debug', 'true');
|
|
2819
2828
|
this.set_config({ debug: true });
|
|
2820
2829
|
}
|
|
2821
2830
|
};
|
|
@@ -2924,6 +2933,11 @@ var PostHog = /** @class */ (function () {
|
|
|
2924
2933
|
$ai_metric_value: String(metricValue),
|
|
2925
2934
|
});
|
|
2926
2935
|
};
|
|
2936
|
+
PostHog.prototype._checkLocalStorageForDebug = function (debugConfig) {
|
|
2937
|
+
var explicitlyFalse = (0, core_1.isBoolean)(debugConfig) && !debugConfig;
|
|
2938
|
+
var isTrueInLocalStorage = storage_1.localStore._is_supported() && storage_1.localStore._get('ph_debug') === 'true';
|
|
2939
|
+
return explicitlyFalse ? false : isTrueInLocalStorage ? true : debugConfig;
|
|
2940
|
+
};
|
|
2927
2941
|
return PostHog;
|
|
2928
2942
|
}());
|
|
2929
2943
|
exports.PostHog = PostHog;
|