@posthog/core 1.29.12 → 1.29.13
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/error-tracking/coercers/error-event-coercer.d.ts +8 -3
- package/dist/error-tracking/coercers/error-event-coercer.d.ts.map +1 -1
- package/dist/error-tracking/coercers/promise-rejection-event.d.ts +9 -5
- package/dist/error-tracking/coercers/promise-rejection-event.d.ts.map +1 -1
- package/dist/posthog-core-stateless.d.ts +18 -0
- package/dist/posthog-core-stateless.d.ts.map +1 -1
- package/dist/posthog-core-stateless.js +13 -0
- package/dist/posthog-core-stateless.mjs +13 -0
- package/dist/posthog-core.d.ts +2 -1
- package/dist/posthog-core.d.ts.map +1 -1
- package/dist/posthog-core.js +12 -18
- package/dist/posthog-core.mjs +13 -19
- package/package.json +2 -2
- package/src/error-tracking/coercers/error-event-coercer.ts +13 -4
- package/src/error-tracking/coercers/promise-rejection-event.ts +16 -8
- package/src/posthog-core-stateless.ts +37 -0
- package/src/posthog-core.ts +12 -17
|
@@ -1,7 +1,12 @@
|
|
|
1
1
|
import { CoercingContext, ErrorTrackingCoercer, ExceptionLike } from '../types';
|
|
2
|
-
|
|
2
|
+
interface ErrorEventLike {
|
|
3
|
+
message: string;
|
|
4
|
+
error?: unknown;
|
|
5
|
+
}
|
|
6
|
+
export declare class ErrorEventCoercer implements ErrorTrackingCoercer<ErrorEventLike> {
|
|
3
7
|
constructor();
|
|
4
|
-
match(err: unknown): err is
|
|
5
|
-
coerce(err:
|
|
8
|
+
match(err: unknown): err is ErrorEventLike;
|
|
9
|
+
coerce(err: ErrorEventLike, ctx: CoercingContext): ExceptionLike;
|
|
6
10
|
}
|
|
11
|
+
export {};
|
|
7
12
|
//# sourceMappingURL=error-event-coercer.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"error-event-coercer.d.ts","sourceRoot":"","sources":["../../../src/error-tracking/coercers/error-event-coercer.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,oBAAoB,EAAE,aAAa,EAAE,MAAM,UAAU,CAAA;
|
|
1
|
+
{"version":3,"file":"error-event-coercer.d.ts","sourceRoot":"","sources":["../../../src/error-tracking/coercers/error-event-coercer.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,oBAAoB,EAAE,aAAa,EAAE,MAAM,UAAU,CAAA;AAO/E,UAAU,cAAc;IACtB,OAAO,EAAE,MAAM,CAAA;IACf,KAAK,CAAC,EAAE,OAAO,CAAA;CAChB;AAED,qBAAa,iBAAkB,YAAW,oBAAoB,CAAC,cAAc,CAAC;;IAG5E,KAAK,CAAC,GAAG,EAAE,OAAO,GAAG,GAAG,IAAI,cAAc;IAI1C,MAAM,CAAC,GAAG,EAAE,cAAc,EAAE,GAAG,EAAE,eAAe,GAAG,aAAa;CAajE"}
|
|
@@ -1,13 +1,17 @@
|
|
|
1
1
|
import { CoercingContext, ErrorTrackingCoercer, ExceptionLike } from '../types';
|
|
2
|
-
|
|
2
|
+
interface PromiseRejectionEventLike {
|
|
3
|
+
reason: unknown;
|
|
4
|
+
}
|
|
5
|
+
interface EventWithDetailReason {
|
|
3
6
|
detail: {
|
|
4
7
|
reason: unknown;
|
|
5
8
|
};
|
|
6
|
-
}
|
|
7
|
-
|
|
8
|
-
|
|
9
|
+
}
|
|
10
|
+
type RejectionLike = PromiseRejectionEventLike | EventWithDetailReason;
|
|
11
|
+
export declare class PromiseRejectionEventCoercer implements ErrorTrackingCoercer<RejectionLike> {
|
|
12
|
+
match(err: unknown): err is RejectionLike;
|
|
9
13
|
private isCustomEventWrappingRejection;
|
|
10
|
-
coerce(err:
|
|
14
|
+
coerce(err: RejectionLike, ctx: CoercingContext): ExceptionLike | undefined;
|
|
11
15
|
private getUnhandledRejectionReason;
|
|
12
16
|
}
|
|
13
17
|
export {};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"promise-rejection-event.d.ts","sourceRoot":"","sources":["../../../src/error-tracking/coercers/promise-rejection-event.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,eAAe,EAAE,oBAAoB,EAAE,aAAa,EAAE,MAAM,UAAU,CAAA;
|
|
1
|
+
{"version":3,"file":"promise-rejection-event.d.ts","sourceRoot":"","sources":["../../../src/error-tracking/coercers/promise-rejection-event.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,eAAe,EAAE,oBAAoB,EAAE,aAAa,EAAE,MAAM,UAAU,CAAA;AAM/E,UAAU,yBAAyB;IACjC,MAAM,EAAE,OAAO,CAAA;CAChB;AACD,UAAU,qBAAqB;IAC7B,MAAM,EAAE;QAAE,MAAM,EAAE,OAAO,CAAA;KAAE,CAAA;CAC5B;AACD,KAAK,aAAa,GAAG,yBAAyB,GAAG,qBAAqB,CAAA;AAGtE,qBAAa,4BAA6B,YAAW,oBAAoB,CAAC,aAAa,CAAC;IACtF,KAAK,CAAC,GAAG,EAAE,OAAO,GAAG,GAAG,IAAI,aAAa;IAIzC,OAAO,CAAC,8BAA8B;IAYtC,MAAM,CAAC,GAAG,EAAE,aAAa,EAAE,GAAG,EAAE,eAAe,GAAG,aAAa,GAAG,SAAS;IAc3E,OAAO,CAAC,2BAA2B;CAsBpC"}
|
|
@@ -2,6 +2,7 @@ import type { OtlpLogsPayload } from '@posthog/types';
|
|
|
2
2
|
import { SimpleEventEmitter } from './eventemitter';
|
|
3
3
|
import { PostHogFlagsResponse, PostHogCoreOptions, PostHogEventProperties, PostHogCaptureOptions, JsonType, PostHogRemoteConfig, FeatureFlagValue, PostHogFeatureFlagDetails, FeatureFlagDetail, SurveyResponse, PostHogFetchResponse, PostHogFetchOptions, PostHogPersistedProperty, Logger, GetFlagsResult } from './types';
|
|
4
4
|
import { RetriableOptions } from './utils';
|
|
5
|
+
import { ErrorPropertiesBuilder } from './error-tracking';
|
|
5
6
|
declare class PostHogFetchNetworkError extends Error {
|
|
6
7
|
error: unknown;
|
|
7
8
|
name: string;
|
|
@@ -73,6 +74,23 @@ export declare abstract class PostHogCoreStateless {
|
|
|
73
74
|
protected _isInitialized: boolean;
|
|
74
75
|
protected _remoteConfigResponsePromise?: Promise<PostHogRemoteConfig | undefined>;
|
|
75
76
|
protected _logger: Logger;
|
|
77
|
+
private _errorPropertiesBuilder?;
|
|
78
|
+
/**
|
|
79
|
+
* Returns the builder used by `captureException` to coerce arbitrary inputs into a
|
|
80
|
+
* structured `$exception_list` (with parsed stack frames).
|
|
81
|
+
*
|
|
82
|
+
* @internal Exposed for cross-package use within this SDK; not part of the stable public API.
|
|
83
|
+
*/
|
|
84
|
+
getErrorPropertiesBuilder(): ErrorPropertiesBuilder;
|
|
85
|
+
/**
|
|
86
|
+
* Override in subclasses to plug in platform-specific stack parsers (e.g. node, hermes),
|
|
87
|
+
* additional coercers (DOMException, ErrorEvent, PromiseRejectionEvent), or async frame
|
|
88
|
+
* modifiers (source maps, context lines).
|
|
89
|
+
*
|
|
90
|
+
* The default is intentionally JS-runtime-agnostic — no DOM-typed coercers — so any SDK
|
|
91
|
+
* that just extends core gets parsed stack frames out of the box.
|
|
92
|
+
*/
|
|
93
|
+
protected createErrorPropertiesBuilder(): ErrorPropertiesBuilder;
|
|
76
94
|
abstract fetch(url: string, options: PostHogFetchOptions): Promise<PostHogFetchResponse>;
|
|
77
95
|
abstract getLibraryId(): string;
|
|
78
96
|
abstract getLibraryVersion(): string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"posthog-core-stateless.d.ts","sourceRoot":"","sources":["../src/posthog-core-stateless.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAA;AACrD,OAAO,EAAE,kBAAkB,EAAE,MAAM,gBAAgB,CAAA;AAGnD,OAAO,EACL,oBAAoB,EACpB,kBAAkB,EAClB,sBAAsB,EACtB,qBAAqB,EACrB,QAAQ,EACR,mBAAmB,EACnB,gBAAgB,EAGhB,yBAAyB,EACzB,iBAAiB,EACjB,cAAc,EACd,oBAAoB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,SAAS,CAAC,iBAAiB,GAAE,MAAc,GAAG,OAAO,CAAC,IAAI,CAAC;IA0DjE;;;;;;;;;;;;;;;;;;;;;;OAsBG;IACG,QAAQ,CAAC,iBAAiB,GAAE,MAAc,GAAG,OAAO,CAAC,IAAI,CAAC;CAYjE"}
|
|
@@ -36,6 +36,7 @@ const external_gzip_js_namespaceObject = require("./gzip.js");
|
|
|
36
36
|
const external_types_js_namespaceObject = require("./types.js");
|
|
37
37
|
const index_js_namespaceObject = require("./utils/index.js");
|
|
38
38
|
const uuidv7_js_namespaceObject = require("./vendor/uuidv7.js");
|
|
39
|
+
const external_error_tracking_index_js_namespaceObject = require("./error-tracking/index.js");
|
|
39
40
|
class PostHogFetchHttpError extends Error {
|
|
40
41
|
constructor(response, reqByteLength){
|
|
41
42
|
super('HTTP error while fetching PostHog: status=' + response.status + ', reqByteLength=' + reqByteLength), this.response = response, this.reqByteLength = reqByteLength, this.name = 'PostHogFetchHttpError';
|
|
@@ -85,6 +86,18 @@ var posthog_core_stateless_QuotaLimitedFeature = /*#__PURE__*/ function(QuotaLim
|
|
|
85
86
|
return QuotaLimitedFeature;
|
|
86
87
|
}({});
|
|
87
88
|
class PostHogCoreStateless {
|
|
89
|
+
getErrorPropertiesBuilder() {
|
|
90
|
+
if (!this._errorPropertiesBuilder) this._errorPropertiesBuilder = this.createErrorPropertiesBuilder();
|
|
91
|
+
return this._errorPropertiesBuilder;
|
|
92
|
+
}
|
|
93
|
+
createErrorPropertiesBuilder() {
|
|
94
|
+
return new external_error_tracking_index_js_namespaceObject.ErrorPropertiesBuilder([
|
|
95
|
+
new external_error_tracking_index_js_namespaceObject.ErrorCoercer(),
|
|
96
|
+
new external_error_tracking_index_js_namespaceObject.ObjectCoercer(),
|
|
97
|
+
new external_error_tracking_index_js_namespaceObject.StringCoercer(),
|
|
98
|
+
new external_error_tracking_index_js_namespaceObject.PrimitiveCoercer()
|
|
99
|
+
], (0, external_error_tracking_index_js_namespaceObject.createDefaultStackParser)());
|
|
100
|
+
}
|
|
88
101
|
constructor(apiKey, options = {}){
|
|
89
102
|
this.flushPromise = null;
|
|
90
103
|
this.shutdownPromise = null;
|
|
@@ -4,6 +4,7 @@ import { gzipCompress, isGzipSupported } from "./gzip.mjs";
|
|
|
4
4
|
import { PostHogPersistedProperty } from "./types.mjs";
|
|
5
5
|
import { PromiseQueue, STRING_FORMAT, allSettled, createLogger, currentISOTime, removeTrailingSlash, retriable, safeSetTimeout } from "./utils/index.mjs";
|
|
6
6
|
import { uuidv7 } from "./vendor/uuidv7.mjs";
|
|
7
|
+
import { ErrorCoercer, ErrorPropertiesBuilder, ObjectCoercer, PrimitiveCoercer, StringCoercer, createDefaultStackParser } from "./error-tracking/index.mjs";
|
|
7
8
|
class PostHogFetchHttpError extends Error {
|
|
8
9
|
constructor(response, reqByteLength){
|
|
9
10
|
super('HTTP error while fetching PostHog: status=' + response.status + ', reqByteLength=' + reqByteLength), this.response = response, this.reqByteLength = reqByteLength, this.name = 'PostHogFetchHttpError';
|
|
@@ -53,6 +54,18 @@ var posthog_core_stateless_QuotaLimitedFeature = /*#__PURE__*/ function(QuotaLim
|
|
|
53
54
|
return QuotaLimitedFeature;
|
|
54
55
|
}({});
|
|
55
56
|
class PostHogCoreStateless {
|
|
57
|
+
getErrorPropertiesBuilder() {
|
|
58
|
+
if (!this._errorPropertiesBuilder) this._errorPropertiesBuilder = this.createErrorPropertiesBuilder();
|
|
59
|
+
return this._errorPropertiesBuilder;
|
|
60
|
+
}
|
|
61
|
+
createErrorPropertiesBuilder() {
|
|
62
|
+
return new ErrorPropertiesBuilder([
|
|
63
|
+
new ErrorCoercer(),
|
|
64
|
+
new ObjectCoercer(),
|
|
65
|
+
new StringCoercer(),
|
|
66
|
+
new PrimitiveCoercer()
|
|
67
|
+
], createDefaultStackParser());
|
|
68
|
+
}
|
|
56
69
|
constructor(apiKey, options = {}){
|
|
57
70
|
this.flushPromise = null;
|
|
58
71
|
this.shutdownPromise = null;
|
package/dist/posthog-core.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import type { PostHogAutocaptureElement, PostHogFlagsResponse, PostHogFeatureFlagsResponse, PostHogCoreOptions, PostHogEventProperties, PostHogCaptureOptions, JsonType, PostHogRemoteConfig, FeatureFlagValue, FeatureFlagResult, FeatureFlagResultOptions, PostHogFeatureFlagDetails, PostHogGroupProperties } from './types';
|
|
2
2
|
import { PostHogPersistedProperty } from './types';
|
|
3
3
|
import { PostHogCoreStateless } from './posthog-core-stateless';
|
|
4
|
+
import { EventHint } from './error-tracking';
|
|
4
5
|
interface FlagsAsyncOptions {
|
|
5
6
|
sendAnonDistinctId?: boolean;
|
|
6
7
|
fetchConfig?: boolean;
|
|
@@ -195,7 +196,7 @@ export declare abstract class PostHogCore extends PostHogCoreStateless {
|
|
|
195
196
|
* @param {Object} [additionalProperties] Any additional properties to add to the error event
|
|
196
197
|
* @returns {CaptureResult} The result of the capture
|
|
197
198
|
*/
|
|
198
|
-
captureException(error: unknown, additionalProperties?: PostHogEventProperties): void;
|
|
199
|
+
captureException(error: unknown, additionalProperties?: PostHogEventProperties, hint?: EventHint): void;
|
|
199
200
|
/**
|
|
200
201
|
* Capture written user feedback for a LLM trace. Numeric values are converted to strings.
|
|
201
202
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"posthog-core.d.ts","sourceRoot":"","sources":["../src/posthog-core.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,yBAAyB,EACzB,oBAAoB,EACpB,2BAA2B,EAC3B,kBAAkB,EAClB,sBAAsB,EACtB,qBAAqB,EACrB,QAAQ,EACR,mBAAmB,EACnB,gBAAgB,EAChB,iBAAiB,EACjB,wBAAwB,EAGxB,yBAAyB,EAKzB,sBAAsB,EAGvB,MAAM,SAAS,CAAA;AAYhB,OAAO,EAAiC,wBAAwB,EAAE,MAAM,SAAS,CAAA;AACjF,OAAO,EAAY,oBAAoB,EAAuB,MAAM,0BAA0B,CAAA;
|
|
1
|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AAG,IAAI;IA+C9F;;;;;;OAMG;IACH,OAAO,CAAC,cAAc;CAsBvB"}
|
package/dist/posthog-core.js
CHANGED
|
@@ -665,24 +665,18 @@ class PostHogCore extends external_posthog_core_stateless_js_namespaceObject.Pos
|
|
|
665
665
|
return this.setPersistedProperty(external_types_js_namespaceObject.PostHogPersistedProperty.OverrideFeatureFlags, flags);
|
|
666
666
|
});
|
|
667
667
|
}
|
|
668
|
-
captureException(error, additionalProperties) {
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
$
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
],
|
|
681
|
-
...additionalProperties
|
|
682
|
-
};
|
|
683
|
-
this.capture('$exception', properties, {
|
|
684
|
-
_originatedFromCaptureException: true
|
|
685
|
-
});
|
|
668
|
+
captureException(error, additionalProperties, hint) {
|
|
669
|
+
try {
|
|
670
|
+
const exceptionProperties = this.getErrorPropertiesBuilder().buildFromUnknown(error, hint);
|
|
671
|
+
this.capture('$exception', {
|
|
672
|
+
...exceptionProperties,
|
|
673
|
+
...additionalProperties
|
|
674
|
+
}, {
|
|
675
|
+
_originatedFromCaptureException: true
|
|
676
|
+
});
|
|
677
|
+
} catch (e) {
|
|
678
|
+
this._logger.error('Error while capturing $exception:', e);
|
|
679
|
+
}
|
|
686
680
|
}
|
|
687
681
|
captureTraceFeedback(traceId, userFeedback) {
|
|
688
682
|
this.capture('$ai_feedback', {
|
package/dist/posthog-core.mjs
CHANGED
|
@@ -2,7 +2,7 @@ import { createFlagsResponseFromFlagsAndPayloads, getEnabledFromValue, getFeatur
|
|
|
2
2
|
import { Compression, FeatureFlagError, PostHogPersistedProperty } from "./types.mjs";
|
|
3
3
|
import { PostHogCoreStateless, QuotaLimitedFeature, maybeAdd } from "./posthog-core-stateless.mjs";
|
|
4
4
|
import { uuidv7 } from "./vendor/uuidv7.mjs";
|
|
5
|
-
import { getPersonPropertiesHash, isEmptyObject, isNullish, isObject
|
|
5
|
+
import { getPersonPropertiesHash, isEmptyObject, isNullish, isObject } from "./utils/index.mjs";
|
|
6
6
|
class PostHogCore extends PostHogCoreStateless {
|
|
7
7
|
constructor(apiKey, options){
|
|
8
8
|
const disableGeoipOption = options?.disableGeoip ?? false;
|
|
@@ -637,24 +637,18 @@ class PostHogCore extends PostHogCoreStateless {
|
|
|
637
637
|
return this.setPersistedProperty(PostHogPersistedProperty.OverrideFeatureFlags, flags);
|
|
638
638
|
});
|
|
639
639
|
}
|
|
640
|
-
captureException(error, additionalProperties) {
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
$
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
],
|
|
653
|
-
...additionalProperties
|
|
654
|
-
};
|
|
655
|
-
this.capture('$exception', properties, {
|
|
656
|
-
_originatedFromCaptureException: true
|
|
657
|
-
});
|
|
640
|
+
captureException(error, additionalProperties, hint) {
|
|
641
|
+
try {
|
|
642
|
+
const exceptionProperties = this.getErrorPropertiesBuilder().buildFromUnknown(error, hint);
|
|
643
|
+
this.capture('$exception', {
|
|
644
|
+
...exceptionProperties,
|
|
645
|
+
...additionalProperties
|
|
646
|
+
}, {
|
|
647
|
+
_originatedFromCaptureException: true
|
|
648
|
+
});
|
|
649
|
+
} catch (e) {
|
|
650
|
+
this._logger.error('Error while capturing $exception:', e);
|
|
651
|
+
}
|
|
658
652
|
}
|
|
659
653
|
captureTraceFeedback(traceId, userFeedback) {
|
|
660
654
|
this.capture('$ai_feedback', {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@posthog/core",
|
|
3
|
-
"version": "1.29.
|
|
3
|
+
"version": "1.29.13",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"module": "dist/index.mjs",
|
|
@@ -67,7 +67,7 @@
|
|
|
67
67
|
}
|
|
68
68
|
},
|
|
69
69
|
"dependencies": {
|
|
70
|
-
"@posthog/types": "1.376.
|
|
70
|
+
"@posthog/types": "1.376.4"
|
|
71
71
|
},
|
|
72
72
|
"devDependencies": {
|
|
73
73
|
"@rslib/core": "0.10.6",
|
|
@@ -1,14 +1,23 @@
|
|
|
1
1
|
import { CoercingContext, ErrorTrackingCoercer, ExceptionLike } from '../types'
|
|
2
2
|
import { isErrorEvent } from '@/utils'
|
|
3
3
|
|
|
4
|
-
|
|
4
|
+
// Structural subset of the DOM `ErrorEvent`. Avoids leaking a DOM-only global
|
|
5
|
+
// into the public type surface so non-DOM consumers (e.g. React Native, whose
|
|
6
|
+
// tsconfig lib excludes DOM) can still consume `@posthog/core` types via tools
|
|
7
|
+
// like api-extractor that resolve symbols transitively.
|
|
8
|
+
interface ErrorEventLike {
|
|
9
|
+
message: string
|
|
10
|
+
error?: unknown
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export class ErrorEventCoercer implements ErrorTrackingCoercer<ErrorEventLike> {
|
|
5
14
|
constructor() {}
|
|
6
15
|
|
|
7
|
-
match(err: unknown): err is
|
|
8
|
-
return isErrorEvent(err) && (err as
|
|
16
|
+
match(err: unknown): err is ErrorEventLike {
|
|
17
|
+
return isErrorEvent(err) && (err as ErrorEventLike).error != undefined
|
|
9
18
|
}
|
|
10
19
|
|
|
11
|
-
coerce(err:
|
|
20
|
+
coerce(err: ErrorEventLike, ctx: CoercingContext): ExceptionLike {
|
|
12
21
|
const exceptionLike = ctx.apply(err.error)
|
|
13
22
|
if (!exceptionLike) {
|
|
14
23
|
return {
|
|
@@ -1,13 +1,21 @@
|
|
|
1
1
|
import { isBuiltin, isEvent, isPrimitive } from '@/utils'
|
|
2
2
|
import { CoercingContext, ErrorTrackingCoercer, ExceptionLike } from '../types'
|
|
3
3
|
|
|
4
|
-
|
|
4
|
+
// Structural subsets of the DOM `PromiseRejectionEvent` / `Event`. Avoids leaking
|
|
5
|
+
// DOM-only globals into the public type surface so non-DOM consumers (e.g. React
|
|
6
|
+
// Native, whose tsconfig lib excludes DOM) can still consume `@posthog/core`
|
|
7
|
+
// types via tools like api-extractor that resolve symbols transitively.
|
|
8
|
+
interface PromiseRejectionEventLike {
|
|
9
|
+
reason: unknown
|
|
10
|
+
}
|
|
11
|
+
interface EventWithDetailReason {
|
|
12
|
+
detail: { reason: unknown }
|
|
13
|
+
}
|
|
14
|
+
type RejectionLike = PromiseRejectionEventLike | EventWithDetailReason
|
|
5
15
|
|
|
6
16
|
// Web only
|
|
7
|
-
export class PromiseRejectionEventCoercer implements ErrorTrackingCoercer<
|
|
8
|
-
|
|
9
|
-
> {
|
|
10
|
-
match(err: unknown): err is PromiseRejectionEvent | EventWithDetailReason {
|
|
17
|
+
export class PromiseRejectionEventCoercer implements ErrorTrackingCoercer<RejectionLike> {
|
|
18
|
+
match(err: unknown): err is RejectionLike {
|
|
11
19
|
return isBuiltin(err, 'PromiseRejectionEvent') || this.isCustomEventWrappingRejection(err)
|
|
12
20
|
}
|
|
13
21
|
|
|
@@ -16,14 +24,14 @@ export class PromiseRejectionEventCoercer implements ErrorTrackingCoercer<
|
|
|
16
24
|
return false
|
|
17
25
|
}
|
|
18
26
|
try {
|
|
19
|
-
const detail = (err as EventWithDetailReason).detail
|
|
27
|
+
const detail = (err as unknown as EventWithDetailReason).detail
|
|
20
28
|
return detail != null && typeof detail === 'object' && 'reason' in detail
|
|
21
29
|
} catch {
|
|
22
30
|
return false
|
|
23
31
|
}
|
|
24
32
|
}
|
|
25
33
|
|
|
26
|
-
coerce(err:
|
|
34
|
+
coerce(err: RejectionLike, ctx: CoercingContext): ExceptionLike | undefined {
|
|
27
35
|
const reason = this.getUnhandledRejectionReason(err)
|
|
28
36
|
if (isPrimitive(reason)) {
|
|
29
37
|
return {
|
|
@@ -37,7 +45,7 @@ export class PromiseRejectionEventCoercer implements ErrorTrackingCoercer<
|
|
|
37
45
|
}
|
|
38
46
|
}
|
|
39
47
|
|
|
40
|
-
private getUnhandledRejectionReason(error:
|
|
48
|
+
private getUnhandledRejectionReason(error: RejectionLike): unknown {
|
|
41
49
|
try {
|
|
42
50
|
// PromiseRejectionEvents store the object of the rejection under 'reason'
|
|
43
51
|
// see https://developer.mozilla.org/en-US/docs/Web/API/PromiseRejectionEvent
|
|
@@ -35,6 +35,14 @@ import {
|
|
|
35
35
|
createLogger,
|
|
36
36
|
} from './utils'
|
|
37
37
|
import { uuidv7 } from './vendor/uuidv7'
|
|
38
|
+
import {
|
|
39
|
+
ErrorPropertiesBuilder,
|
|
40
|
+
ErrorCoercer,
|
|
41
|
+
ObjectCoercer,
|
|
42
|
+
StringCoercer,
|
|
43
|
+
PrimitiveCoercer,
|
|
44
|
+
createDefaultStackParser,
|
|
45
|
+
} from './error-tracking'
|
|
38
46
|
|
|
39
47
|
class PostHogFetchHttpError extends Error {
|
|
40
48
|
name = 'PostHogFetchHttpError'
|
|
@@ -162,6 +170,35 @@ export abstract class PostHogCoreStateless {
|
|
|
162
170
|
protected _isInitialized: boolean = false
|
|
163
171
|
protected _remoteConfigResponsePromise?: Promise<PostHogRemoteConfig | undefined>
|
|
164
172
|
protected _logger: Logger
|
|
173
|
+
private _errorPropertiesBuilder?: ErrorPropertiesBuilder
|
|
174
|
+
|
|
175
|
+
/**
|
|
176
|
+
* Returns the builder used by `captureException` to coerce arbitrary inputs into a
|
|
177
|
+
* structured `$exception_list` (with parsed stack frames).
|
|
178
|
+
*
|
|
179
|
+
* @internal Exposed for cross-package use within this SDK; not part of the stable public API.
|
|
180
|
+
*/
|
|
181
|
+
getErrorPropertiesBuilder(): ErrorPropertiesBuilder {
|
|
182
|
+
if (!this._errorPropertiesBuilder) {
|
|
183
|
+
this._errorPropertiesBuilder = this.createErrorPropertiesBuilder()
|
|
184
|
+
}
|
|
185
|
+
return this._errorPropertiesBuilder
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
/**
|
|
189
|
+
* Override in subclasses to plug in platform-specific stack parsers (e.g. node, hermes),
|
|
190
|
+
* additional coercers (DOMException, ErrorEvent, PromiseRejectionEvent), or async frame
|
|
191
|
+
* modifiers (source maps, context lines).
|
|
192
|
+
*
|
|
193
|
+
* The default is intentionally JS-runtime-agnostic — no DOM-typed coercers — so any SDK
|
|
194
|
+
* that just extends core gets parsed stack frames out of the box.
|
|
195
|
+
*/
|
|
196
|
+
protected createErrorPropertiesBuilder(): ErrorPropertiesBuilder {
|
|
197
|
+
return new ErrorPropertiesBuilder(
|
|
198
|
+
[new ErrorCoercer(), new ObjectCoercer(), new StringCoercer(), new PrimitiveCoercer()],
|
|
199
|
+
createDefaultStackParser()
|
|
200
|
+
)
|
|
201
|
+
}
|
|
165
202
|
|
|
166
203
|
// Abstract methods to be overridden by implementations
|
|
167
204
|
abstract fetch(url: string, options: PostHogFetchOptions): Promise<PostHogFetchResponse>
|
package/src/posthog-core.ts
CHANGED
|
@@ -35,7 +35,8 @@ import {
|
|
|
35
35
|
import { Compression, FeatureFlagError, PostHogPersistedProperty } from './types'
|
|
36
36
|
import { maybeAdd, PostHogCoreStateless, QuotaLimitedFeature } from './posthog-core-stateless'
|
|
37
37
|
import { uuidv7 } from './vendor/uuidv7'
|
|
38
|
-
import { isEmptyObject, isNullish,
|
|
38
|
+
import { isEmptyObject, isNullish, getPersonPropertiesHash, isObject } from './utils'
|
|
39
|
+
import { EventHint } from './error-tracking'
|
|
39
40
|
|
|
40
41
|
// Stores the parameters for a pending feature flags reload request
|
|
41
42
|
interface FlagsAsyncOptions {
|
|
@@ -1169,23 +1170,17 @@ export abstract class PostHogCore extends PostHogCoreStateless {
|
|
|
1169
1170
|
* @param {Object} [additionalProperties] Any additional properties to add to the error event
|
|
1170
1171
|
* @returns {CaptureResult} The result of the capture
|
|
1171
1172
|
*/
|
|
1172
|
-
captureException(error: unknown, additionalProperties?: PostHogEventProperties): void {
|
|
1173
|
-
|
|
1174
|
-
|
|
1175
|
-
|
|
1176
|
-
|
|
1177
|
-
|
|
1178
|
-
|
|
1179
|
-
|
|
1180
|
-
|
|
1181
|
-
|
|
1182
|
-
},
|
|
1183
|
-
},
|
|
1184
|
-
],
|
|
1185
|
-
...additionalProperties,
|
|
1173
|
+
captureException(error: unknown, additionalProperties?: PostHogEventProperties, hint?: EventHint): void {
|
|
1174
|
+
try {
|
|
1175
|
+
const exceptionProperties = this.getErrorPropertiesBuilder().buildFromUnknown(error, hint)
|
|
1176
|
+
this.capture(
|
|
1177
|
+
'$exception',
|
|
1178
|
+
{ ...exceptionProperties, ...additionalProperties } as unknown as PostHogEventProperties,
|
|
1179
|
+
{ _originatedFromCaptureException: true }
|
|
1180
|
+
)
|
|
1181
|
+
} catch (e) {
|
|
1182
|
+
this._logger.error('Error while capturing $exception:', e)
|
|
1186
1183
|
}
|
|
1187
|
-
|
|
1188
|
-
this.capture('$exception', properties, { _originatedFromCaptureException: true })
|
|
1189
1184
|
}
|
|
1190
1185
|
|
|
1191
1186
|
/**
|