posthog-js 1.158.3 → 1.160.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/dist/array.full.js +1 -1
- package/dist/array.full.js.map +1 -1
- package/dist/array.js +1 -1
- package/dist/array.js.map +1 -1
- package/dist/exception-autocapture.js +1 -1
- package/dist/exception-autocapture.js.map +1 -1
- package/dist/lib/src/constants.d.ts +1 -1
- package/dist/lib/src/extensions/exception-autocapture/index.d.ts +0 -9
- package/dist/lib/src/posthog-core.d.ts +6 -0
- package/dist/lib/src/posthog-exceptions.d.ts +14 -0
- package/dist/main.js +1 -1
- package/dist/main.js.map +1 -1
- package/dist/module.d.ts +17 -8
- package/dist/module.js +1 -1
- package/dist/module.js.map +1 -1
- package/lib/package.json +1 -1
- package/lib/src/constants.d.ts +1 -1
- package/lib/src/constants.js +1 -1
- package/lib/src/constants.js.map +1 -1
- package/lib/src/entrypoints/exception-autocapture.js +1 -0
- package/lib/src/entrypoints/exception-autocapture.js.map +1 -1
- package/lib/src/extensions/exception-autocapture/index.d.ts +0 -9
- package/lib/src/extensions/exception-autocapture/index.js +6 -39
- package/lib/src/extensions/exception-autocapture/index.js.map +1 -1
- package/lib/src/extensions/sentry-integration.js +2 -8
- package/lib/src/extensions/sentry-integration.js.map +1 -1
- package/lib/src/posthog-core.d.ts +6 -0
- package/lib/src/posthog-core.js +27 -8
- package/lib/src/posthog-core.js.map +1 -1
- package/lib/src/posthog-exceptions.d.ts +14 -0
- package/lib/src/posthog-exceptions.js +49 -0
- package/lib/src/posthog-exceptions.js.map +1 -0
- package/package.json +1 -1
package/lib/package.json
CHANGED
package/lib/src/constants.d.ts
CHANGED
|
@@ -6,7 +6,7 @@ export declare const EVENT_TIMERS_KEY = "__timers";
|
|
|
6
6
|
export declare const AUTOCAPTURE_DISABLED_SERVER_SIDE = "$autocapture_disabled_server_side";
|
|
7
7
|
export declare const HEATMAPS_ENABLED_SERVER_SIDE = "$heatmaps_enabled_server_side";
|
|
8
8
|
export declare const EXCEPTION_CAPTURE_ENABLED_SERVER_SIDE = "$exception_capture_enabled_server_side";
|
|
9
|
-
export declare const
|
|
9
|
+
export declare const EXCEPTION_CAPTURE_ENDPOINT_SUFFIX = "$exception_capture_endpoint_suffix";
|
|
10
10
|
export declare const WEB_VITALS_ENABLED_SERVER_SIDE = "$web_vitals_enabled_server_side";
|
|
11
11
|
export declare const SESSION_RECORDING_ENABLED_SERVER_SIDE = "$session_recording_enabled_server_side";
|
|
12
12
|
export declare const CONSOLE_LOG_RECORDING_ENABLED_SERVER_SIDE = "$console_log_recording_enabled_server_side";
|
package/lib/src/constants.js
CHANGED
|
@@ -11,7 +11,7 @@ export var EVENT_TIMERS_KEY = '__timers';
|
|
|
11
11
|
export var AUTOCAPTURE_DISABLED_SERVER_SIDE = '$autocapture_disabled_server_side';
|
|
12
12
|
export var HEATMAPS_ENABLED_SERVER_SIDE = '$heatmaps_enabled_server_side';
|
|
13
13
|
export var EXCEPTION_CAPTURE_ENABLED_SERVER_SIDE = '$exception_capture_enabled_server_side';
|
|
14
|
-
export var
|
|
14
|
+
export var EXCEPTION_CAPTURE_ENDPOINT_SUFFIX = '$exception_capture_endpoint_suffix';
|
|
15
15
|
export var WEB_VITALS_ENABLED_SERVER_SIDE = '$web_vitals_enabled_server_side';
|
|
16
16
|
export var SESSION_RECORDING_ENABLED_SERVER_SIDE = '$session_recording_enabled_server_side';
|
|
17
17
|
export var CONSOLE_LOG_RECORDING_ENABLED_SERVER_SIDE = '$console_log_recording_enabled_server_side';
|
package/lib/src/constants.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"constants.js","sourceRoot":"","sources":["../../src/constants.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,mBAAmB;AAEnB,0FAA0F;AAC1F,MAAM,CAAC,IAAM,sBAAsB,GAAG,qBAAqB,CAAA;AAC3D,MAAM,CAAC,IAAM,WAAW,GAAG,aAAa,CAAA;AACxC,M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oB;IACpB,kBAAkB;IAClB,uBAAuB;IACvB,qBAAqB;IACrB,wBAAwB;CAC3B,CAAA","sourcesContent":["/*\n * Constants\n */\n\n/* PROPERTY KEYS */\n\n// This key is deprecated, but we want to check for it to see whether aliasing is allowed.\nexport const PEOPLE_DISTINCT_ID_KEY = '$people_distinct_id'\nexport const DISTINCT_ID = 'distinct_id'\nexport const ALIAS_ID_KEY = '__alias'\nexport const CAMPAIGN_IDS_KEY = '__cmpns'\nexport const EVENT_TIMERS_KEY = '__timers'\nexport const AUTOCAPTURE_DISABLED_SERVER_SIDE = '$autocapture_disabled_server_side'\nexport const HEATMAPS_ENABLED_SERVER_SIDE = '$heatmaps_enabled_server_side'\nexport const EXCEPTION_CAPTURE_ENABLED_SERVER_SIDE = '$exception_capture_enabled_server_side'\nexport const EXCEPTION_CAPTURE_ENDPOINT_SUFFIX = '$exception_capture_endpoint_suffix'\nexport const WEB_VITALS_ENABLED_SERVER_SIDE = '$web_vitals_enabled_server_side'\nexport const SESSION_RECORDING_ENABLED_SERVER_SIDE = '$session_recording_enabled_server_side'\nexport const CONSOLE_LOG_RECORDING_ENABLED_SERVER_SIDE = '$console_log_recording_enabled_server_side'\nexport const SESSION_RECORDING_NETWORK_PAYLOAD_CAPTURE = '$session_recording_network_payload_capture'\nexport const SESSION_RECORDING_CANVAS_RECORDING = '$session_recording_canvas_recording'\nexport const SESSION_RECORDING_SAMPLE_RATE = '$replay_sample_rate'\nexport const SESSION_RECORDING_MINIMUM_DURATION = '$replay_minimum_duration'\nexport const SESSION_ID = '$sesid'\nexport const SESSION_RECORDING_IS_SAMPLED = '$session_is_sampled'\nexport const ENABLED_FEATURE_FLAGS = '$enabled_feature_flags'\nexport const PERSISTENCE_EARLY_ACCESS_FEATURES = '$early_access_features'\nexport const STORED_PERSON_PROPERTIES_KEY = '$stored_person_properties'\nexport const STORED_GROUP_PROPERTIES_KEY = '$stored_group_properties'\nexport const SURVEYS = '$surveys'\nexport const SURVEYS_ACTIVATED = '$surveys_activated'\nexport const FLAG_CALL_REPORTED = '$flag_call_reported'\nexport const USER_STATE = '$user_state'\nexport const CLIENT_SESSION_PROPS = '$client_session_props'\nexport const CAPTURE_RATE_LIMIT = '$capture_rate_limit'\n\n/** @deprecated Delete this when INITIAL_PERSON_INFO has been around for long enough to ignore backwards compat */\nexport const INITIAL_CAMPAIGN_PARAMS = '$initial_campaign_params'\n/** @deprecated Delete this when INITIAL_PERSON_INFO has been around for long enough to ignore backwards compat */\nexport const INITIAL_REFERRER_INFO = '$initial_referrer_info'\nexport const INITIAL_PERSON_INFO = '$initial_person_info'\nexport const ENABLE_PERSON_PROCESSING = '$epp'\nexport const TOOLBAR_ID = '__POSTHOG_TOOLBAR__'\n\n// These are properties that are reserved and will not be automatically included in events\nexport const PERSISTENCE_RESERVED_PROPERTIES = [\n PEOPLE_DISTINCT_ID_KEY,\n ALIAS_ID_KEY,\n CAMPAIGN_IDS_KEY,\n EVENT_TIMERS_KEY,\n SESSION_RECORDING_ENABLED_SERVER_SIDE,\n HEATMAPS_ENABLED_SERVER_SIDE,\n SESSION_ID,\n ENABLED_FEATURE_FLAGS,\n USER_STATE,\n PERSISTENCE_EARLY_ACCESS_FEATURES,\n STORED_GROUP_PROPERTIES_KEY,\n STORED_PERSON_PROPERTIES_KEY,\n SURVEYS,\n FLAG_CALL_REPORTED,\n CLIENT_SESSION_PROPS,\n CAPTURE_RATE_LIMIT,\n INITIAL_CAMPAIGN_PARAMS,\n INITIAL_REFERRER_INFO,\n ENABLE_PERSON_PROCESSING,\n]\n"]}
|
|
@@ -79,6 +79,7 @@ var posthogErrorWrappingFunctions = {
|
|
|
79
79
|
if (window) {
|
|
80
80
|
;
|
|
81
81
|
window.posthogErrorWrappingFunctions = posthogErrorWrappingFunctions;
|
|
82
|
+
window.parseErrorAsProperties = errorToProperties;
|
|
82
83
|
}
|
|
83
84
|
export default posthogErrorWrappingFunctions;
|
|
84
85
|
//# sourceMappingURL=exception-autocapture.js.map
|
|
@@ -1 +1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AC,oBAAoB,CAAA;IAE7D,GAAG,CAAC,oBAAoB,GAAG;;QAAU,cAAoC;aAApC,UAAoC,EAApC,qBAAoC,EAApC,IAAoC;YAApC,yBAAoC;;QACrE,IAAM,eAAe,GAAG,8BAA8B,CAAC,IAAI,CAAC,CAAA;QAC5D,SAAS,CAAC,eAAe,CAAC,CAAA;QAC1B,OAAO,MAAA,4BAA4B,aAA5B,4BAA4B,uBAA5B,4BAA4B,CAAE,KAAK,CAAC,GAAG,EAAE,IAAI,CAAC,mCAAI,KAAK,CAAA;IAClE,CAAC,CAAA;IACD,GAAG,CAAC,oBAAoB,CAAC,wBAAwB,GAAG,IAAI,CAAA;IAExD,OAAO;;QACI,MAAA,GAAG,CAAC,oBAAoB,+CAAE,wBAAwB,CAAA;QACzD,GAAG,CAAC,oBAAoB,GAAG,4BAA4B,CAAA;IAC3D,CAAC,CAAA;AACL,CAAC,CAAA;AAED,IAAM,6BAA6B,GAAG;IAClC,WAAW,aAAA;IACX,sBAAsB,wBAAA;CACzB,CAAA;AAED,IAAI,MAAM,EAAE,CAAC;IACT,CAAC;IAAC,MAAc,CAAC,6BAA6B,GAAG,6BAA6B,CAAA;
|
|
1
|
+
{"version":3,"file":"exception-autocapture.js","sourceRoot":"","sources":["../../../src/entrypoints/exception-autocapture.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAAA,OAAO,EAAE,iBAAiB,EAAE,8BAA8B,EAAE,MAAM,sDAAsD,CAAA;AACxH,OAAO,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAA;AAEzC,OAAO,EAAE,MAAM,EAAE,MAAM,iBAAiB,CAAA;AAExC,IAAM,WAAW,GAAG,UAAC,SAAsC;IACvD,IAAM,GAAG,GAAG,MAAa,CAAA;IACzB,IAAI,CAAC,GAAG,EAAE,CAAC;QACP,MAAM,CAAC,IAAI,CAAC,2CAA2C,CAAC,CAAA;IAC5D,CAAC;IACD,IAAM,eAAe,GAAG,GAAG,CAAC,OAAO,C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4BAA4B,CAAA;IAC3D,CAAC,CAAA;AACL,CAAC,CAAA;AAED,IAAM,6BAA6B,GAAG;IAClC,WAAW,aAAA;IACX,sBAAsB,wBAAA;CACzB,CAAA;AAED,IAAI,MAAM,EAAE,CAAC;IACT,CAAC;IAAC,MAAc,CAAC,6BAA6B,GAAG,6BAA6B,CAC7E;IAAC,MAAc,CAAC,sBAAsB,GAAG,iBAAiB,CAAA;AAC/D,CAAC;AAED,eAAe,6BAA6B,CAAA","sourcesContent":["import { errorToProperties, unhandledRejectionToProperties } from '../extensions/exception-autocapture/error-conversion'\nimport { window } from '../utils/globals'\nimport { ErrorEventArgs, Properties } from '../types'\nimport { logger } from '../utils/logger'\n\nconst wrapOnError = (captureFn: (props: Properties) => void) => {\n const win = window as any\n if (!win) {\n logger.info('window not available, cannot wrap onerror')\n }\n const originalOnError = win.onerror\n\n win.onerror = function (...args: ErrorEventArgs): boolean {\n const errorProperties = errorToProperties(args)\n captureFn(errorProperties)\n return originalOnError?.(...args) ?? false\n }\n win.onerror.__POSTHOG_INSTRUMENTED__ = true\n\n return () => {\n delete win.onerror?.__POSTHOG_INSTRUMENTED__\n win.onerror = originalOnError\n }\n}\n\nconst wrapUnhandledRejection = (captureFn: (props: Properties) => void) => {\n const win = window as any\n if (!win) {\n logger.info('window not available, cannot wrap onUnhandledRejection')\n }\n\n const originalOnUnhandledRejection = win.onunhandledrejection\n\n win.onunhandledrejection = function (...args: [ev: PromiseRejectionEvent]): boolean {\n const errorProperties = unhandledRejectionToProperties(args)\n captureFn(errorProperties)\n return originalOnUnhandledRejection?.apply(win, args) ?? false\n }\n win.onunhandledrejection.__POSTHOG_INSTRUMENTED__ = true\n\n return () => {\n delete win.onunhandledrejection?.__POSTHOG_INSTRUMENTED__\n win.onunhandledrejection = originalOnUnhandledRejection\n }\n}\n\nconst posthogErrorWrappingFunctions = {\n wrapOnError,\n wrapUnhandledRejection,\n}\n\nif (window) {\n ;(window as any).posthogErrorWrappingFunctions = posthogErrorWrappingFunctions\n ;(window as any).parseErrorAsProperties = errorToProperties\n}\n\nexport default posthogErrorWrappingFunctions\n"]}
|
|
@@ -1,15 +1,12 @@
|
|
|
1
1
|
import { PostHog } from '../../posthog-core';
|
|
2
2
|
import { DecideResponse, Properties } from '../../types';
|
|
3
|
-
export declare const BASE_ERROR_ENDPOINT = "/e/";
|
|
4
3
|
export declare class ExceptionObserver {
|
|
5
|
-
private _endpointSuffix;
|
|
6
4
|
instance: PostHog;
|
|
7
5
|
remoteEnabled: boolean | undefined;
|
|
8
6
|
private originalOnUnhandledRejectionHandler;
|
|
9
7
|
private unwrapOnError;
|
|
10
8
|
private unwrapUnhandledRejection;
|
|
11
9
|
constructor(instance: PostHog);
|
|
12
|
-
get endpoint(): string;
|
|
13
10
|
get isEnabled(): boolean;
|
|
14
11
|
get isCapturing(): boolean;
|
|
15
12
|
get hasHandlers(): ((this: WindowEventHandlers, ev: PromiseRejectionEvent) => any) | undefined;
|
|
@@ -19,10 +16,4 @@ export declare class ExceptionObserver {
|
|
|
19
16
|
private stopCapturing;
|
|
20
17
|
afterDecideResponse(response: DecideResponse): void;
|
|
21
18
|
captureException(errorProperties: Properties): void;
|
|
22
|
-
/**
|
|
23
|
-
* :TRICKY: Make sure we batch these requests
|
|
24
|
-
*/
|
|
25
|
-
sendExceptionEvent(properties: {
|
|
26
|
-
[key: string]: any;
|
|
27
|
-
}): void;
|
|
28
19
|
}
|
|
@@ -1,19 +1,15 @@
|
|
|
1
1
|
import { window } from '../../utils/globals';
|
|
2
|
-
import { isObject } from '../../utils/type-utils';
|
|
3
2
|
import { logger } from '../../utils/logger';
|
|
4
|
-
import { EXCEPTION_CAPTURE_ENABLED_SERVER_SIDE
|
|
3
|
+
import { EXCEPTION_CAPTURE_ENABLED_SERVER_SIDE } from '../../constants';
|
|
5
4
|
import Config from '../../config';
|
|
6
|
-
|
|
7
|
-
export var BASE_ERROR_ENDPOINT = '/e/';
|
|
8
|
-
var LOGGER_PREFIX = '[Exception Capture]';
|
|
5
|
+
var LOGGER_PREFIX = '[Exception Autocapture]';
|
|
9
6
|
var ExceptionObserver = /** @class */ (function () {
|
|
10
7
|
function ExceptionObserver(instance) {
|
|
11
8
|
var _this = this;
|
|
12
|
-
var _a
|
|
9
|
+
var _a;
|
|
13
10
|
this.originalOnUnhandledRejectionHandler = undefined;
|
|
14
11
|
this.startCapturing = function () {
|
|
15
|
-
|
|
16
|
-
if (!window || !_this.isEnabled || _this.hasHandlers || ((_a = window.onerror) === null || _a === void 0 ? void 0 : _a.__POSTHOG_INSTRUMENTED__)) {
|
|
12
|
+
if (!window || !_this.isEnabled || _this.hasHandlers || _this.isCapturing) {
|
|
17
13
|
return;
|
|
18
14
|
}
|
|
19
15
|
var wrapOnError = window.posthogErrorWrappingFunctions.wrapOnError;
|
|
@@ -33,18 +29,8 @@ var ExceptionObserver = /** @class */ (function () {
|
|
|
33
29
|
};
|
|
34
30
|
this.instance = instance;
|
|
35
31
|
this.remoteEnabled = !!((_a = this.instance.persistence) === null || _a === void 0 ? void 0 : _a.props[EXCEPTION_CAPTURE_ENABLED_SERVER_SIDE]);
|
|
36
|
-
// TODO: once BASE_ERROR_ENDPOINT is no longer /e/ this can be removed
|
|
37
|
-
this._endpointSuffix = ((_b = this.instance.persistence) === null || _b === void 0 ? void 0 : _b.props[EXCEPTION_CAPTURE_ENDPOINT]) || BASE_ERROR_ENDPOINT;
|
|
38
32
|
this.startIfEnabled();
|
|
39
33
|
}
|
|
40
|
-
Object.defineProperty(ExceptionObserver.prototype, "endpoint", {
|
|
41
|
-
get: function () {
|
|
42
|
-
// Always respect any api_host set by the client config
|
|
43
|
-
return this.instance.requestRouter.endpointFor('api', this._endpointSuffix);
|
|
44
|
-
},
|
|
45
|
-
enumerable: false,
|
|
46
|
-
configurable: true
|
|
47
|
-
});
|
|
48
34
|
Object.defineProperty(ExceptionObserver.prototype, "isEnabled", {
|
|
49
35
|
get: function () {
|
|
50
36
|
var _a;
|
|
@@ -92,40 +78,21 @@ var ExceptionObserver = /** @class */ (function () {
|
|
|
92
78
|
(_b = this.unwrapUnhandledRejection) === null || _b === void 0 ? void 0 : _b.call(this);
|
|
93
79
|
};
|
|
94
80
|
ExceptionObserver.prototype.afterDecideResponse = function (response) {
|
|
95
|
-
var _a
|
|
81
|
+
var _a;
|
|
96
82
|
var autocaptureExceptionsResponse = response.autocaptureExceptions;
|
|
97
83
|
// store this in-memory in case persistence is disabled
|
|
98
84
|
this.remoteEnabled = !!autocaptureExceptionsResponse || false;
|
|
99
|
-
this._endpointSuffix = isObject(autocaptureExceptionsResponse)
|
|
100
|
-
? autocaptureExceptionsResponse.endpoint || BASE_ERROR_ENDPOINT
|
|
101
|
-
: BASE_ERROR_ENDPOINT;
|
|
102
85
|
if (this.instance.persistence) {
|
|
103
86
|
this.instance.persistence.register((_a = {},
|
|
104
87
|
_a[EXCEPTION_CAPTURE_ENABLED_SERVER_SIDE] = this.remoteEnabled,
|
|
105
88
|
_a));
|
|
106
|
-
// when we come to moving the endpoint to not /e/
|
|
107
|
-
// we'll want that to persist between startup and decide response
|
|
108
|
-
// TODO: once BASE_ENDPOINT is no longer /e/ this can be removed
|
|
109
|
-
this.instance.persistence.register((_b = {},
|
|
110
|
-
_b[EXCEPTION_CAPTURE_ENDPOINT] = this._endpointSuffix,
|
|
111
|
-
_b));
|
|
112
89
|
}
|
|
113
90
|
this.startIfEnabled();
|
|
114
91
|
};
|
|
115
92
|
ExceptionObserver.prototype.captureException = function (errorProperties) {
|
|
116
93
|
var posthogHost = this.instance.requestRouter.endpointFor('ui');
|
|
117
94
|
errorProperties.$exception_personURL = "".concat(posthogHost, "/project/").concat(this.instance.config.token, "/person/").concat(this.instance.get_distinct_id());
|
|
118
|
-
this.sendExceptionEvent(errorProperties);
|
|
119
|
-
};
|
|
120
|
-
/**
|
|
121
|
-
* :TRICKY: Make sure we batch these requests
|
|
122
|
-
*/
|
|
123
|
-
ExceptionObserver.prototype.sendExceptionEvent = function (properties) {
|
|
124
|
-
this.instance.capture('$exception', properties, {
|
|
125
|
-
_noTruncate: true,
|
|
126
|
-
_batchKey: 'exceptionEvent',
|
|
127
|
-
_url: this.endpoint,
|
|
128
|
-
});
|
|
95
|
+
this.instance.exceptions.sendExceptionEvent(errorProperties);
|
|
129
96
|
};
|
|
130
97
|
return ExceptionObserver;
|
|
131
98
|
}());
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/extensions/exception-autocapture/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAA;AAI5C,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/extensions/exception-autocapture/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAA;AAI5C,OAAO,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAA;AAC3C,OAAO,EAAE,qCAAqC,EAAE,MAAM,iBAAiB,CAAA;AACvE,OAAO,MAAM,MAAM,cAAc,CAAA;AAEjC,IAAM,aAAa,GAAG,yBAAyB,CAAA;AAE/C;IAOI,2BAAY,QAAiB;QAA7B,iBAKC;;QATO,wCAAmC,GAAsD,SAAS,CAAA;QA4ClG,mBAAc,GAAG;YACrB,IAAI,CAAC,MAAM,IAAI,CAAC,KAAI,CAAC,SAAS,IAAI,KAAI,CAAC,WAAW,IAAI,KAAI,CAAC,WAAW,EAAE,CAAC;gBACrE,OAAM;YACV,CAAC;YAED,IAAM,WAAW,GAAI,MAAc,CAAC,6BAA6B,CAAC,WAAW,CAAA;YAC7E,IAAM,sBAAsB,GAAI,MAAc,CAAC,6BAA6B,CAAC,sBAAsB,CAAA;YAEnG,IAAI,CAAC,WAAW,IAAI,CAAC,sBAAsB,EAAE,CAAC;gBAC1C,MAAM,CAAC,KAAK,CAAC,aAAa,GAAG,yDAAyD,CAAC,CAAA;gBACvF,OAAM;YACV,CAAC;YAED,IAAI,CAAC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AAC,UAAU,CAAC,kBAAkB,CAAC,eAAe,CAAC,CAAA;IAChE,CAAC;IACL,wBAAC;AAAD,CAAC,AAlGD,IAkGC","sourcesContent":["import { window } from '../../utils/globals'\nimport { PostHog } from '../../posthog-core'\nimport { DecideResponse, Properties } from '../../types'\n\nimport { logger } from '../../utils/logger'\nimport { EXCEPTION_CAPTURE_ENABLED_SERVER_SIDE } from '../../constants'\nimport Config from '../../config'\n\nconst LOGGER_PREFIX = '[Exception Autocapture]'\n\nexport class ExceptionObserver {\n instance: PostHog\n remoteEnabled: boolean | undefined\n private originalOnUnhandledRejectionHandler: Window['onunhandledrejection'] | null | undefined = undefined\n private unwrapOnError: (() => void) | undefined\n private unwrapUnhandledRejection: (() => void) | undefined\n\n constructor(instance: PostHog) {\n this.instance = instance\n this.remoteEnabled = !!this.instance.persistence?.props[EXCEPTION_CAPTURE_ENABLED_SERVER_SIDE]\n\n this.startIfEnabled()\n }\n\n get isEnabled() {\n return this.remoteEnabled ?? false\n }\n\n get isCapturing() {\n return !!(window?.onerror as any)?.__POSTHOG_INSTRUMENTED__\n }\n\n get hasHandlers() {\n return this.originalOnUnhandledRejectionHandler || this.unwrapOnError\n }\n\n startIfEnabled(): void {\n if (this.isEnabled && !this.isCapturing) {\n logger.info(LOGGER_PREFIX + ' enabled, starting...')\n this.loadScript(this.startCapturing)\n }\n }\n\n private loadScript(cb: () => void): void {\n if (this.hasHandlers) {\n // already loaded\n cb()\n }\n\n this.instance.requestRouter.loadScript(`/static/exception-autocapture.js?v=${Config.LIB_VERSION}`, (err) => {\n if (err) {\n return logger.error(LOGGER_PREFIX + ' failed to load script', err)\n }\n cb()\n })\n }\n\n private startCapturing = () => {\n if (!window || !this.isEnabled || this.hasHandlers || this.isCapturing) {\n return\n }\n\n const wrapOnError = (window as any).posthogErrorWrappingFunctions.wrapOnError\n const wrapUnhandledRejection = (window as any).posthogErrorWrappingFunctions.wrapUnhandledRejection\n\n if (!wrapOnError || !wrapUnhandledRejection) {\n logger.error(LOGGER_PREFIX + ' failed to load error wrapping functions - cannot start')\n return\n }\n\n try {\n this.unwrapOnError = wrapOnError(this.captureException.bind(this))\n this.unwrapUnhandledRejection = wrapUnhandledRejection(this.captureException.bind(this))\n } catch (e) {\n logger.error(LOGGER_PREFIX + ' failed to start', e)\n this.stopCapturing()\n }\n }\n\n private stopCapturing() {\n this.unwrapOnError?.()\n this.unwrapUnhandledRejection?.()\n }\n\n afterDecideResponse(response: DecideResponse) {\n const autocaptureExceptionsResponse = response.autocaptureExceptions\n\n // store this in-memory in case persistence is disabled\n this.remoteEnabled = !!autocaptureExceptionsResponse || false\n\n if (this.instance.persistence) {\n this.instance.persistence.register({\n [EXCEPTION_CAPTURE_ENABLED_SERVER_SIDE]: this.remoteEnabled,\n })\n }\n\n this.startIfEnabled()\n }\n\n captureException(errorProperties: Properties) {\n const posthogHost = this.instance.requestRouter.endpointFor('ui')\n\n errorProperties.$exception_personURL = `${posthogHost}/project/${\n this.instance.config.token\n }/person/${this.instance.get_distinct_id()}`\n\n this.instance.exceptions.sendExceptionEvent(errorProperties)\n }\n}\n"]}
|
|
@@ -15,12 +15,11 @@
|
|
|
15
15
|
* @param {Number} [projectId] Optional: The Sentry project id, used to send a direct link from PostHog to Sentry
|
|
16
16
|
* @param {string} [prefix] Optional: Url of a self-hosted sentry instance (default: https://sentry.io/organizations/)
|
|
17
17
|
*/
|
|
18
|
-
import { BASE_ERROR_ENDPOINT } from './exception-autocapture';
|
|
19
18
|
var NAME = 'posthog-js';
|
|
20
19
|
export function createEventProcessor(_posthog, _a) {
|
|
21
20
|
var _b = _a === void 0 ? {} : _a, organization = _b.organization, projectId = _b.projectId, prefix = _b.prefix, _c = _b.severityAllowList, severityAllowList = _c === void 0 ? ['error'] : _c;
|
|
22
21
|
return function (event) {
|
|
23
|
-
var _a, _b, _c, _d, _e
|
|
22
|
+
var _a, _b, _c, _d, _e;
|
|
24
23
|
var shouldProcessLevel = severityAllowList === '*' || severityAllowList.includes(event.level);
|
|
25
24
|
if (!shouldProcessLevel || !_posthog.__loaded)
|
|
26
25
|
return event;
|
|
@@ -55,12 +54,7 @@ export function createEventProcessor(_posthog, _a) {
|
|
|
55
54
|
'&query=' +
|
|
56
55
|
event.event_id;
|
|
57
56
|
}
|
|
58
|
-
|
|
59
|
-
// so that when we add error specific URL for ingestion
|
|
60
|
-
// these errors are sent there too
|
|
61
|
-
_posthog.capture('$exception', data, {
|
|
62
|
-
_url: ((_f = _posthog.exceptionObserver) === null || _f === void 0 ? void 0 : _f.endpoint) || _posthog.requestRouter.endpointFor('api', BASE_ERROR_ENDPOINT),
|
|
63
|
-
});
|
|
57
|
+
_posthog.exceptions.sendExceptionEvent(data);
|
|
64
58
|
return event;
|
|
65
59
|
};
|
|
66
60
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sentry-integration.js","sourceRoot":"","sources":["../../../src/extensions/sentry-integration.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;
|
|
1
|
+
{"version":3,"file":"sentry-integration.js","sourceRoot":"","sources":["../../../src/extensions/sentry-integration.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAwDH,IAAM,IAAI,GAAG,YAAY,CAAA;AAEzB,MAAM,UAAU,oBAAoB,CAChC,QAAiB,EACjB,EAAiG;QAAjG,qBAA+F,EAAE,KAAA,EAA/F,YAAY,kBAAA,EAAE,SAAS,eAAA,EAAE,MAAM,YAAA,EAAE,yBAA6B,EAA7B,iBAAiB,mBAAG,CAAC,OAAO,CAAC,KAAA;IAEhE,OAAO,UAAC,KAAK;;QACT,IAAM,kBAAkB,GAAG,iBAAiB,KAAK,GAAG,IAAI,iBAAiB,CAAC,QAAQ,CAAC,KAAK,CAAC,KAAsB,CAAC,CAAA;QAChH,IAAI,CAAC,kBAAkB,IAAI,CAAC,QAAQ,CAAC,QAAQ;YAAE,OAAO,KAAK,CAAA;QAC3D,IAAI,CAAC,KAAK,CAAC,IAAI;YA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AAkC,CAAC;oBAC9C,YAAY;oBACZ,mBAAmB;oBACnB,SAAS;oBACT,SAAS;oBACT,KAAK,CAAC,QAAQ,CAAA;QACtB,CAAC;QAED,QAAQ,CAAC,UAAU,CAAC,kBAAkB,CAAC,IAAI,CAAC,CAAA;QAE5C,OAAO,KAAK,CAAA;IAChB,CAAC,CAAA;AACL,CAAC;AAED,kCAAkC;AAClC,MAAM,UAAU,iBAAiB,CAAC,QAAiB,EAAE,OAAkC;IACnF,IAAM,SAAS,GAAG,oBAAoB,CAAC,QAAQ,EAAE,OAAO,CAAC,CAAA;IACzD,OAAO;QACH,IAAI,EAAE,IAAI;QACV,YAAY,YAAC,KAAK;YACd,OAAO,SAAS,CAAC,KAAK,CAAC,CAAA;QAC3B,CAAC;KACJ,CAAA;AACL,CAAC;AACD,+BAA+B;AAC/B;IAQI,2BACI,QAAiB,EACjB,YAAqB,EACrB,SAAkB,EAClB,MAAe;IACf;;;;;;OAMG;IACH,iBAAyC;QAEzC,gEAAgE;QAChE,IAAI,CAAC,IAAI,GAAG,IAAI,CAAA;QAChB,IAAI,CAAC,SAAS,GAAG,UAAU,uBAAkE;YACzF,uBAAuB,CACnB,oBAAoB,CAAC,QAAQ,EAAE,EAAE,YAAY,cAAA,EAAE,SAAS,WAAA,EAAE,MAAM,QAAA,EAAE,iBAAiB,mBAAA,EAAE,CAAC,CACzF,CAAA;QACL,CAAC,CAAA;IACL,CAAC;IACL,wBAAC;AAAD,CAAC,AA9BD,IA8BC","sourcesContent":["/**\n * Integrate Sentry with PostHog. This will add a direct link to the person in Sentry, and an $exception event in PostHog\n *\n * ### Usage\n *\n * Sentry.init({\n * dsn: 'https://example',\n * integrations: [\n * new posthog.SentryIntegration(posthog)\n * ]\n * })\n *\n * @param {Object} [posthog] The posthog object\n * @param {string} [organization] Optional: The Sentry organization, used to send a direct link from PostHog to Sentry\n * @param {Number} [projectId] Optional: The Sentry project id, used to send a direct link from PostHog to Sentry\n * @param {string} [prefix] Optional: Url of a self-hosted sentry instance (default: https://sentry.io/organizations/)\n */\n\nimport { PostHog } from '../posthog-core'\nimport { SeverityLevel } from '../types'\n\n// NOTE - we can't import from @sentry/types because it changes frequently and causes clashes\n// We only use a small subset of the types, so we can just define the integration overall and use any for the rest\n\n// import {\n// Event as _SentryEvent,\n// EventProcessor as _SentryEventProcessor,\n// Hub as _SentryHub,\n// Integration as _SentryIntegration,\n// SeverityLevel as _SeverityLevel,\n// IntegrationClass as _SentryIntegrationClass,\n// } from '@sentry/types'\n\n// Uncomment the above and comment the below to get type checking for development\n\ntype _SentryEvent = any\ntype _SentryEventProcessor = any\ntype _SentryHub = any\n\ninterface _SentryIntegrationClass {\n name: string\n setupOnce(addGlobalEventProcessor: (callback: _SentryEventProcessor) => void, getCurrentHub: () => _SentryHub): void\n}\n\ninterface _SentryIntegration {\n name: string\n processEvent(event: _SentryEvent): _SentryEvent\n}\n\ninterface SentryExceptionProperties {\n $sentry_event_id: any\n $sentry_exception: any\n $sentry_exception_message: any\n $sentry_exception_type: any\n $sentry_tags: any\n $sentry_url?: string\n}\n\nexport type SentryIntegrationOptions = {\n organization?: string\n projectId?: number\n prefix?: string\n /**\n * By default, only errors are sent to PostHog. You can set this to '*' to send all events.\n * Or to an error of SeverityLevel to only send events matching the provided levels.\n * e.g. ['error', 'fatal'] to send only errors and fatals\n * e.g. ['error'] to send only errors -- the default when omitted\n * e.g. '*' to send all events\n */\n severityAllowList?: SeverityLevel[] | '*'\n}\n\nconst NAME = 'posthog-js'\n\nexport function createEventProcessor(\n _posthog: PostHog,\n { organization, projectId, prefix, severityAllowList = ['error'] }: SentryIntegrationOptions = {}\n): (event: _SentryEvent) => _SentryEvent {\n return (event) => {\n const shouldProcessLevel = severityAllowList === '*' || severityAllowList.includes(event.level as SeverityLevel)\n if (!shouldProcessLevel || !_posthog.__loaded) return event\n if (!event.tags) event.tags = {}\n\n const personUrl = _posthog.requestRouter.endpointFor(\n 'ui',\n `/project/${_posthog.config.token}/person/${_posthog.get_distinct_id()}`\n )\n event.tags['PostHog Person URL'] = personUrl\n if (_posthog.sessionRecordingStarted()) {\n event.tags['PostHog Recording URL'] = _posthog.get_session_replay_url({ withTimestamp: true })\n }\n\n const exceptions = event.exception?.values || []\n\n const data: SentryExceptionProperties & {\n // two properties added to match any exception auto-capture\n // added manually to avoid any dependency on the lazily loaded content\n $exception_message: any\n $exception_type: any\n $exception_personURL: string\n $exception_level: SeverityLevel\n $level: SeverityLevel\n } = {\n // PostHog Exception Properties,\n $exception_message: exceptions[0]?.value || event.message,\n $exception_type: exceptions[0]?.type,\n $exception_personURL: personUrl,\n $exception_level: event.level,\n // Sentry Exception Properties\n $sentry_event_id: event.event_id,\n $sentry_exception: event.exception,\n $sentry_exception_message: exceptions[0]?.value || event.message,\n $sentry_exception_type: exceptions[0]?.type,\n $sentry_tags: event.tags,\n $level: event.level,\n }\n\n if (organization && projectId) {\n data['$sentry_url'] =\n (prefix || 'https://sentry.io/organizations/') +\n organization +\n '/issues/?project=' +\n projectId +\n '&query=' +\n event.event_id\n }\n\n _posthog.exceptions.sendExceptionEvent(data)\n\n return event\n }\n}\n\n// V8 integration - function based\nexport function sentryIntegration(_posthog: PostHog, options?: SentryIntegrationOptions): _SentryIntegration {\n const processor = createEventProcessor(_posthog, options)\n return {\n name: NAME,\n processEvent(event) {\n return processor(event)\n },\n }\n}\n// V7 integration - class based\nexport class SentryIntegration implements _SentryIntegrationClass {\n name: string\n\n setupOnce: (\n addGlobalEventProcessor: (callback: _SentryEventProcessor) => void,\n getCurrentHub: () => _SentryHub\n ) => void\n\n constructor(\n _posthog: PostHog,\n organization?: string,\n projectId?: number,\n prefix?: string,\n /**\n * By default, only errors are sent to PostHog. You can set this to '*' to send all events.\n * Or to an error of SeverityLevel to only send events matching the provided levels.\n * e.g. ['error', 'fatal'] to send only errors and fatals\n * e.g. ['error'] to send only errors -- the default when omitted\n * e.g. '*' to send all events\n */\n severityAllowList?: SeverityLevel[] | '*'\n ) {\n // setupOnce gets called by Sentry when it intializes the plugin\n this.name = NAME\n this.setupOnce = function (addGlobalEventProcessor: (callback: _SentryEventProcessor) => void) {\n addGlobalEventProcessor(\n createEventProcessor(_posthog, { organization, projectId, prefix, severityAllowList })\n )\n }\n }\n}\n"]}
|
|
@@ -19,6 +19,7 @@ import { Autocapture } from './autocapture';
|
|
|
19
19
|
import { ConsentManager } from './consent';
|
|
20
20
|
import { ExceptionObserver } from './extensions/exception-autocapture';
|
|
21
21
|
import { WebVitalsAutocapture } from './extensions/web-vitals';
|
|
22
|
+
import { PostHogExceptions } from './posthog-exceptions';
|
|
22
23
|
type OnlyValidKeys<T, Shape> = T extends Shape ? (Exclude<keyof T, keyof Shape> extends never ? T : never) : never;
|
|
23
24
|
export declare const defaultConfig: () => PostHogConfig;
|
|
24
25
|
export declare const configRenames: (origConfig: Partial<PostHogConfig>) => Partial<PostHogConfig>;
|
|
@@ -40,6 +41,7 @@ export declare class PostHog {
|
|
|
40
41
|
featureFlags: PostHogFeatureFlags;
|
|
41
42
|
surveys: PostHogSurveys;
|
|
42
43
|
toolbar: Toolbar;
|
|
44
|
+
exceptions: PostHogExceptions;
|
|
43
45
|
consent: ConsentManager;
|
|
44
46
|
persistence?: PostHogPersistence;
|
|
45
47
|
sessionPersistence?: PostHogPersistence;
|
|
@@ -54,6 +56,7 @@ export declare class PostHog {
|
|
|
54
56
|
_retryQueue?: RetryQueue;
|
|
55
57
|
sessionRecording?: SessionRecording;
|
|
56
58
|
webPerformance: DeprecatedWebPerformanceObserver;
|
|
59
|
+
_initialPageviewCaptured: boolean;
|
|
57
60
|
_triggered_notifs: any;
|
|
58
61
|
compression?: Compression;
|
|
59
62
|
__request_queue: QueuedRequestOptions[];
|
|
@@ -567,6 +570,8 @@ export declare class PostHog {
|
|
|
567
570
|
* is currently running
|
|
568
571
|
*/
|
|
569
572
|
sessionRecordingStarted(): boolean;
|
|
573
|
+
/** Capture a caught exception manually */
|
|
574
|
+
captureException(error: Error, additionalProperties?: Properties): void;
|
|
570
575
|
/**
|
|
571
576
|
* returns a boolean indicating whether the toolbar loaded
|
|
572
577
|
* @param toolbarParams
|
|
@@ -702,6 +707,7 @@ export declare class PostHog {
|
|
|
702
707
|
*/
|
|
703
708
|
clear_opt_in_out_capturing(): void;
|
|
704
709
|
_is_bot(): boolean | undefined;
|
|
710
|
+
_captureInitialPageview(): void;
|
|
705
711
|
debug(debug?: boolean): void;
|
|
706
712
|
}
|
|
707
713
|
export declare function init_from_snippet(): void;
|
package/lib/src/posthog-core.js
CHANGED
|
@@ -69,6 +69,7 @@ import { TracingHeaders } from './extensions/tracing-headers';
|
|
|
69
69
|
import { ConsentManager } from './consent';
|
|
70
70
|
import { ExceptionObserver } from './extensions/exception-autocapture';
|
|
71
71
|
import { WebVitalsAutocapture } from './extensions/web-vitals';
|
|
72
|
+
import { PostHogExceptions } from './posthog-exceptions';
|
|
72
73
|
var instances = {};
|
|
73
74
|
// some globals for comparisons
|
|
74
75
|
var __NOOP = function () { };
|
|
@@ -213,11 +214,13 @@ var PostHog = /** @class */ (function () {
|
|
|
213
214
|
this.__request_queue = [];
|
|
214
215
|
this.__loaded = false;
|
|
215
216
|
this.analyticsDefaultEndpoint = '/e/';
|
|
217
|
+
this._initialPageviewCaptured = false;
|
|
216
218
|
this.featureFlags = new PostHogFeatureFlags(this);
|
|
217
219
|
this.toolbar = new Toolbar(this);
|
|
218
220
|
this.scrollManager = new ScrollManager(this);
|
|
219
221
|
this.pageViewManager = new PageViewManager(this);
|
|
220
222
|
this.surveys = new PostHogSurveys(this);
|
|
223
|
+
this.exceptions = new PostHogExceptions(this);
|
|
221
224
|
this.rateLimiter = new RateLimiter(this);
|
|
222
225
|
this.requestRouter = new RequestRouter(this);
|
|
223
226
|
this.consent = new ConsentManager(this);
|
|
@@ -403,7 +406,7 @@ var PostHog = /** @class */ (function () {
|
|
|
403
406
|
};
|
|
404
407
|
// Private methods
|
|
405
408
|
PostHog.prototype._afterDecideResponse = function (response) {
|
|
406
|
-
var _a, _b, _c, _d, _e, _f, _g;
|
|
409
|
+
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
407
410
|
this.compression = undefined;
|
|
408
411
|
if (response.supportedCompression && !this.config.disable_compression) {
|
|
409
412
|
this.compression = includes(response['supportedCompression'], Compression.GZipJS)
|
|
@@ -420,7 +423,8 @@ var PostHog = /** @class */ (function () {
|
|
|
420
423
|
(_d = this.heatmaps) === null || _d === void 0 ? void 0 : _d.afterDecideResponse(response);
|
|
421
424
|
(_e = this.surveys) === null || _e === void 0 ? void 0 : _e.afterDecideResponse(response);
|
|
422
425
|
(_f = this.webVitalsAutocapture) === null || _f === void 0 ? void 0 : _f.afterDecideResponse(response);
|
|
423
|
-
(_g = this.
|
|
426
|
+
(_g = this.exceptions) === null || _g === void 0 ? void 0 : _g.afterDecideResponse(response);
|
|
427
|
+
(_h = this.exceptionObserver) === null || _h === void 0 ? void 0 : _h.afterDecideResponse(response);
|
|
424
428
|
};
|
|
425
429
|
PostHog.prototype._loaded = function () {
|
|
426
430
|
var _this = this;
|
|
@@ -443,8 +447,8 @@ var PostHog = /** @class */ (function () {
|
|
|
443
447
|
// NOTE: We want to fire this on the next tick as the previous implementation had this side effect
|
|
444
448
|
// and some clients may rely on it
|
|
445
449
|
setTimeout(function () {
|
|
446
|
-
if (
|
|
447
|
-
_this.
|
|
450
|
+
if (_this.consent.isOptedIn()) {
|
|
451
|
+
_this._captureInitialPageview();
|
|
448
452
|
}
|
|
449
453
|
}, 1);
|
|
450
454
|
}
|
|
@@ -1565,6 +1569,13 @@ var PostHog = /** @class */ (function () {
|
|
|
1565
1569
|
var _a;
|
|
1566
1570
|
return !!((_a = this.sessionRecording) === null || _a === void 0 ? void 0 : _a.started);
|
|
1567
1571
|
};
|
|
1572
|
+
/** Capture a caught exception manually */
|
|
1573
|
+
PostHog.prototype.captureException = function (error, additionalProperties) {
|
|
1574
|
+
var properties = isFunction(assignableWindow.parseErrorAsProperties)
|
|
1575
|
+
? assignableWindow.parseErrorAsProperties([error.message, undefined, undefined, undefined, error])
|
|
1576
|
+
: __assign({ $exception_type: error.name, $exception_message: error.message, $exception_level: 'error' }, additionalProperties);
|
|
1577
|
+
this.exceptions.sendExceptionEvent(properties);
|
|
1578
|
+
};
|
|
1568
1579
|
/**
|
|
1569
1580
|
* returns a boolean indicating whether the toolbar loaded
|
|
1570
1581
|
* @param toolbarParams
|
|
@@ -1715,11 +1726,13 @@ var PostHog = /** @class */ (function () {
|
|
|
1715
1726
|
var _a;
|
|
1716
1727
|
this.consent.optInOut(true);
|
|
1717
1728
|
this._sync_opt_out_with_persistence();
|
|
1718
|
-
|
|
1719
|
-
|
|
1720
|
-
|
|
1729
|
+
// Don't capture if captureEventName is null or false
|
|
1730
|
+
if (isUndefined(options === null || options === void 0 ? void 0 : options.captureEventName) || (options === null || options === void 0 ? void 0 : options.captureEventName)) {
|
|
1731
|
+
this.capture((_a = options === null || options === void 0 ? void 0 : options.captureEventName) !== null && _a !== void 0 ? _a : '$opt_in', options === null || options === void 0 ? void 0 : options.captureProperties, { send_instantly: true });
|
|
1732
|
+
}
|
|
1733
|
+
if (this.config.capture_pageview) {
|
|
1734
|
+
this._captureInitialPageview();
|
|
1721
1735
|
}
|
|
1722
|
-
this.capture((_a = options === null || options === void 0 ? void 0 : options.captureEventName) !== null && _a !== void 0 ? _a : '$opt_in', options === null || options === void 0 ? void 0 : options.captureProperties, { send_instantly: true });
|
|
1723
1736
|
};
|
|
1724
1737
|
/**
|
|
1725
1738
|
* Opt the user out of data capturing and cookies/localstorage for this PostHog instance.
|
|
@@ -1782,6 +1795,12 @@ var PostHog = /** @class */ (function () {
|
|
|
1782
1795
|
return undefined;
|
|
1783
1796
|
}
|
|
1784
1797
|
};
|
|
1798
|
+
PostHog.prototype._captureInitialPageview = function () {
|
|
1799
|
+
if (document && !this._initialPageviewCaptured) {
|
|
1800
|
+
this._initialPageviewCaptured = true;
|
|
1801
|
+
this.capture('$pageview', { title: document.title }, { send_instantly: true });
|
|
1802
|
+
}
|
|
1803
|
+
};
|
|
1785
1804
|
PostHog.prototype.debug = function (debug) {
|
|
1786
1805
|
if (debug === false) {
|
|
1787
1806
|
window === null || window === void 0 ? void 0 : window.console.log("You've disabled debug mode.");
|