posthog-node 5.60.1 → 5.61.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.
Files changed (43) hide show
  1. package/dist/client.d.ts +34 -0
  2. package/dist/client.d.ts.map +1 -1
  3. package/dist/client.js +33 -4
  4. package/dist/client.mjs +33 -4
  5. package/dist/emails/emails.d.ts +45 -0
  6. package/dist/emails/emails.d.ts.map +1 -0
  7. package/dist/emails/emails.js +360 -0
  8. package/dist/emails/emails.mjs +316 -0
  9. package/dist/emails/errors.d.ts +37 -0
  10. package/dist/emails/errors.d.ts.map +1 -0
  11. package/dist/emails/errors.js +79 -0
  12. package/dist/emails/errors.mjs +41 -0
  13. package/dist/emails/types.d.ts +112 -0
  14. package/dist/emails/types.d.ts.map +1 -0
  15. package/dist/emails/types.js +18 -0
  16. package/dist/emails/types.mjs +1 -0
  17. package/dist/exports.d.ts +3 -0
  18. package/dist/exports.d.ts.map +1 -1
  19. package/dist/exports.js +19 -9
  20. package/dist/exports.mjs +1 -0
  21. package/dist/extensions/error-tracking/autocapture.d.ts +32 -2
  22. package/dist/extensions/error-tracking/autocapture.d.ts.map +1 -1
  23. package/dist/extensions/error-tracking/autocapture.js +337 -35
  24. package/dist/extensions/error-tracking/autocapture.mjs +324 -28
  25. package/dist/extensions/error-tracking/index.d.ts +16 -1
  26. package/dist/extensions/error-tracking/index.d.ts.map +1 -1
  27. package/dist/extensions/error-tracking/index.js +23 -8
  28. package/dist/extensions/error-tracking/index.mjs +24 -9
  29. package/dist/types.d.ts +33 -2
  30. package/dist/types.d.ts.map +1 -1
  31. package/dist/version.d.ts +1 -1
  32. package/dist/version.js +1 -1
  33. package/dist/version.mjs +1 -1
  34. package/package.json +2 -2
  35. package/src/client.ts +76 -3
  36. package/src/emails/emails.ts +459 -0
  37. package/src/emails/errors.ts +90 -0
  38. package/src/emails/types.ts +108 -0
  39. package/src/exports.ts +12 -0
  40. package/src/extensions/error-tracking/autocapture.ts +579 -57
  41. package/src/extensions/error-tracking/index.ts +48 -10
  42. package/src/types.ts +34 -2
  43. package/src/version.ts +1 -1
@@ -0,0 +1,37 @@
1
+ /**
2
+ * A coarse category of the failure, for code that branches on the kind of failure rather than the exact `code`.
3
+ */
4
+ export type EmailErrorName = 'validation_error' | 'missing_api_key' | 'invalid_permission' | 'not_found' | 'concurrent_idempotent_requests' | 'invalid_idempotent_request' | 'rate_limit_exceeded' | 'monthly_quota_exceeded' | 'service_unavailable' | 'application_error';
5
+ export interface EmailErrorParams {
6
+ code: string;
7
+ message: string;
8
+ statusCode?: number;
9
+ why?: string;
10
+ fix?: string;
11
+ docsUrl?: string;
12
+ field?: string;
13
+ retryAfterMs?: number;
14
+ cause?: unknown;
15
+ }
16
+ /**
17
+ * PostHog did not queue the email, or the client could not tell whether it did.
18
+ *
19
+ * Branch on `code`, PostHog's stable error code, or on `name`, a coarse category of the
20
+ * failure. The message never contains the secret key or the request body.
21
+ */
22
+ export declare class EmailError extends Error {
23
+ name: EmailErrorName;
24
+ /** PostHog's error code, such as `quota_limited`, or an SDK code such as `network_error`. */
25
+ readonly code: string;
26
+ /** The HTTP status, when PostHog answered. */
27
+ readonly statusCode?: number;
28
+ readonly why?: string;
29
+ readonly fix?: string;
30
+ readonly docsUrl?: string;
31
+ /** The request field the error is about, when PostHog named one. */
32
+ readonly field?: string;
33
+ /** How long PostHog asked the client to wait before it sends again, in milliseconds. */
34
+ readonly retryAfterMs?: number;
35
+ constructor(params: EmailErrorParams);
36
+ }
37
+ //# sourceMappingURL=errors.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../../src/emails/errors.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,MAAM,MAAM,cAAc,GACtB,kBAAkB,GAClB,iBAAiB,GACjB,oBAAoB,GACpB,WAAW,GACX,gCAAgC,GAChC,4BAA4B,GAC5B,qBAAqB,GACrB,wBAAwB,GACxB,qBAAqB,GACrB,mBAAmB,CAAA;AAEvB,MAAM,WAAW,gBAAgB;IAC/B,IAAI,EAAE,MAAM,CAAA;IACZ,OAAO,EAAE,MAAM,CAAA;IACf,UAAU,CAAC,EAAE,MAAM,CAAA;IACnB,GAAG,CAAC,EAAE,MAAM,CAAA;IACZ,GAAG,CAAC,EAAE,MAAM,CAAA;IACZ,OAAO,CAAC,EAAE,MAAM,CAAA;IAChB,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,YAAY,CAAC,EAAE,MAAM,CAAA;IACrB,KAAK,CAAC,EAAE,OAAO,CAAA;CAChB;AAED;;;;;GAKG;AACH,qBAAa,UAAW,SAAQ,KAAK;IAC1B,IAAI,EAAE,cAAc,CAAA;IAC7B,6FAA6F;IAC7F,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAA;IACrB,8CAA8C;IAC9C,QAAQ,CAAC,UAAU,CAAC,EAAE,MAAM,CAAA;IAC5B,QAAQ,CAAC,GAAG,CAAC,EAAE,MAAM,CAAA;IACrB,QAAQ,CAAC,GAAG,CAAC,EAAE,MAAM,CAAA;IACrB,QAAQ,CAAC,OAAO,CAAC,EAAE,MAAM,CAAA;IACzB,oEAAoE;IACpE,QAAQ,CAAC,KAAK,CAAC,EAAE,MAAM,CAAA;IACvB,wFAAwF;IACxF,QAAQ,CAAC,YAAY,CAAC,EAAE,MAAM,CAAA;IAE9B,YAAY,MAAM,EAAE,gBAAgB,EAUnC;CACF"}
@@ -0,0 +1,79 @@
1
+ "use strict";
2
+ var __webpack_require__ = {};
3
+ (()=>{
4
+ __webpack_require__.d = (exports1, getters, values)=>{
5
+ var define = (defs, kind)=>{
6
+ for(var key in defs)if (__webpack_require__.o(defs, key) && !__webpack_require__.o(exports1, key)) Object.defineProperty(exports1, key, {
7
+ enumerable: true,
8
+ [kind]: defs[key]
9
+ });
10
+ };
11
+ define(getters, "get");
12
+ define(values, "value");
13
+ };
14
+ })();
15
+ (()=>{
16
+ __webpack_require__.o = (obj, prop)=>Object.prototype.hasOwnProperty.call(obj, prop);
17
+ })();
18
+ (()=>{
19
+ __webpack_require__.r = (exports1)=>{
20
+ if ("u" > typeof Symbol && Symbol.toStringTag) Object.defineProperty(exports1, Symbol.toStringTag, {
21
+ value: 'Module'
22
+ });
23
+ Object.defineProperty(exports1, '__esModule', {
24
+ value: true
25
+ });
26
+ };
27
+ })();
28
+ var __webpack_exports__ = {};
29
+ __webpack_require__.r(__webpack_exports__);
30
+ class EmailError extends Error {
31
+ constructor(params){
32
+ super(params.message, void 0 === params.cause ? void 0 : {
33
+ cause: params.cause
34
+ });
35
+ this.name = emailErrorName(params.statusCode, params.code);
36
+ this.code = params.code;
37
+ this.statusCode = params.statusCode;
38
+ this.why = params.why;
39
+ this.fix = params.fix;
40
+ this.docsUrl = params.docsUrl;
41
+ this.field = params.field;
42
+ this.retryAfterMs = params.retryAfterMs;
43
+ }
44
+ }
45
+ function emailErrorName(status, code) {
46
+ if ('missing_secret_key' === code || 401 === status) return 'missing_api_key';
47
+ if (void 0 === status) {
48
+ if ('network_error' === code) return 'service_unavailable';
49
+ return code.startsWith('invalid_') ? 'validation_error' : 'application_error';
50
+ }
51
+ switch(status){
52
+ case 400:
53
+ return 'validation_error';
54
+ case 403:
55
+ return 'invalid_permission';
56
+ case 404:
57
+ return 'not_found';
58
+ case 409:
59
+ return 'template_outdated' === code ? 'validation_error' : 'concurrent_idempotent_requests';
60
+ case 422:
61
+ return 'idempotency_key_reused' === code ? 'invalid_idempotent_request' : 'validation_error';
62
+ case 429:
63
+ return 'quota_limited' === code ? 'monthly_quota_exceeded' : 'rate_limit_exceeded';
64
+ case 503:
65
+ return 'service_unavailable';
66
+ default:
67
+ return 'application_error';
68
+ }
69
+ }
70
+ __webpack_require__.d(__webpack_exports__, {
71
+ EmailError: ()=>EmailError
72
+ });
73
+ exports.EmailError = __webpack_exports__.EmailError;
74
+ for(var __rspack_i in __webpack_exports__)if (-1 === [
75
+ "EmailError"
76
+ ].indexOf(__rspack_i)) exports[__rspack_i] = __webpack_exports__[__rspack_i];
77
+ Object.defineProperty(exports, '__esModule', {
78
+ value: true
79
+ });
@@ -0,0 +1,41 @@
1
+ class EmailError extends Error {
2
+ constructor(params){
3
+ super(params.message, void 0 === params.cause ? void 0 : {
4
+ cause: params.cause
5
+ });
6
+ this.name = emailErrorName(params.statusCode, params.code);
7
+ this.code = params.code;
8
+ this.statusCode = params.statusCode;
9
+ this.why = params.why;
10
+ this.fix = params.fix;
11
+ this.docsUrl = params.docsUrl;
12
+ this.field = params.field;
13
+ this.retryAfterMs = params.retryAfterMs;
14
+ }
15
+ }
16
+ function emailErrorName(status, code) {
17
+ if ('missing_secret_key' === code || 401 === status) return 'missing_api_key';
18
+ if (void 0 === status) {
19
+ if ('network_error' === code) return 'service_unavailable';
20
+ return code.startsWith('invalid_') ? 'validation_error' : 'application_error';
21
+ }
22
+ switch(status){
23
+ case 400:
24
+ return 'validation_error';
25
+ case 403:
26
+ return 'invalid_permission';
27
+ case 404:
28
+ return 'not_found';
29
+ case 409:
30
+ return 'template_outdated' === code ? 'validation_error' : 'concurrent_idempotent_requests';
31
+ case 422:
32
+ return 'idempotency_key_reused' === code ? 'invalid_idempotent_request' : 'validation_error';
33
+ case 429:
34
+ return 'quota_limited' === code ? 'monthly_quota_exceeded' : 'rate_limit_exceeded';
35
+ case 503:
36
+ return 'service_unavailable';
37
+ default:
38
+ return 'application_error';
39
+ }
40
+ }
41
+ export { EmailError };
@@ -0,0 +1,112 @@
1
+ import type { EmailError } from './errors';
2
+ /**
3
+ * Options for `posthog.emails.send()`.
4
+ */
5
+ export interface SendEmailOptions {
6
+ /** One recipient email address. */
7
+ to: string;
8
+ /** The UUID of an email template made transactional in PostHog. */
9
+ templateId: string;
10
+ /** Values for the template's `{{ variables.* }}` placeholders. Sent as `message_data`. */
11
+ templateData?: Record<string, unknown>;
12
+ /**
13
+ * The recipient's distinct ID in your product. The email's events go to this person.
14
+ * Without it, they go to a person whose distinct ID is the email address.
15
+ */
16
+ distinctId?: string;
17
+ /**
18
+ * 1 to 255 visible ASCII characters. A send with a key that PostHog has already accepted
19
+ * queues nothing and returns the first send's result. Without it, the client makes a
20
+ * UUID that covers its own retries. Pass a key derived from what the email is for, such
21
+ * as `welcome:user_123`, to cover retries outside this call too.
22
+ */
23
+ idempotencyKey?: string;
24
+ /** Overrides the client's `emailRequestMaxRetries` for this send. `0` turns retries off. */
25
+ maxRetries?: number;
26
+ }
27
+ /** A warning PostHog returned with a queued email. */
28
+ export interface EmailWarning {
29
+ code: string;
30
+ message: string;
31
+ fix?: string;
32
+ }
33
+ /**
34
+ * The queued email. A result means PostHog queued the email, not that it was delivered.
35
+ */
36
+ export interface SendEmailResult {
37
+ /** The queued email's message ID. */
38
+ id: string;
39
+ /** True when PostHog had already accepted this idempotency key and returned the first send's result. */
40
+ replayed: boolean;
41
+ warnings: EmailWarning[];
42
+ }
43
+ /**
44
+ * What `posthog.emails.send()` resolves to. Exactly one of `data` and `error` is set.
45
+ * The promise does not reject.
46
+ */
47
+ export type SendEmailResponse = {
48
+ data: SendEmailResult;
49
+ error: null;
50
+ } | {
51
+ data: null;
52
+ error: EmailError;
53
+ };
54
+ /**
55
+ * What happened to an email. Later SDK versions can see values this list does not have yet.
56
+ *
57
+ * - `queued`: the email waits to go out.
58
+ * - `sent`: PostHog handed the email to the email provider.
59
+ * - `failed`: the email was not sent, and `reason` says why.
60
+ * - `delivered`: the recipient's mail server accepted the email.
61
+ * - `bounced` and `complained`: the recipient's mail provider reported them after delivery.
62
+ */
63
+ export type EmailDeliveryStatus = 'queued' | 'sent' | 'failed' | 'delivered' | 'bounced' | 'complained';
64
+ /** The status of an email that `posthog.emails.send()` queued. */
65
+ export interface EmailStatus {
66
+ /** The message ID that `send()` returned. */
67
+ id: string;
68
+ status: EmailDeliveryStatus | (string & {});
69
+ /** When PostHog queued the email, as an ISO 8601 timestamp. */
70
+ createdAt: string;
71
+ /** When the email reached its current status, as an ISO 8601 timestamp. */
72
+ statusAt: string;
73
+ /**
74
+ * Why a failed email was not sent, such as `provider_error` or `recipient_suppressed`, or the
75
+ * bounce type of a bounced email: `hard`, `soft` or `unknown`. Null otherwise.
76
+ */
77
+ reason: string | null;
78
+ }
79
+ /**
80
+ * What `posthog.emails.get()` resolves to. Exactly one of `data` and `error` is set.
81
+ * The promise does not reject.
82
+ */
83
+ export type GetEmailResponse = {
84
+ data: EmailStatus;
85
+ error: null;
86
+ } | {
87
+ data: null;
88
+ error: EmailError;
89
+ };
90
+ /**
91
+ * The `posthog.emails` API: sends transactional email from PostHog email templates, and reads
92
+ * the status of each email it sent.
93
+ */
94
+ export interface Emails {
95
+ /**
96
+ * Queue one email from a transactional email template.
97
+ *
98
+ * Resolves to `{ data, error }` and does not reject. `data` means PostHog queued the email,
99
+ * not that it was delivered. Network errors, rate limits, an in-flight idempotency key and
100
+ * an unavailable service are retried with the same idempotency key.
101
+ */
102
+ send(options: SendEmailOptions): Promise<SendEmailResponse>;
103
+ /**
104
+ * Read the status of an email that `send()` queued, for 30 days after the send.
105
+ *
106
+ * Resolves to `{ data, error }` and does not reject. The error code is `not_found` when no
107
+ * email of this project has the ID, when the email is older than 30 days, or for a few
108
+ * seconds after the send. Network errors, rate limits and an unavailable service are retried.
109
+ */
110
+ get(id: string): Promise<GetEmailResponse>;
111
+ }
112
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/emails/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,UAAU,CAAA;AAE1C;;GAEG;AACH,MAAM,WAAW,gBAAgB;IAC/B,mCAAmC;IACnC,EAAE,EAAE,MAAM,CAAA;IACV,mEAAmE;IACnE,UAAU,EAAE,MAAM,CAAA;IAClB,0FAA0F;IAC1F,YAAY,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;IACtC;;;OAGG;IACH,UAAU,CAAC,EAAE,MAAM,CAAA;IACnB;;;;;OAKG;IACH,cAAc,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W,MAAM;IACrB;;;;;;OAMG;IACH,IAAI,CAAC,OAAO,EAAE,gBAAgB,GAAG,OAAO,CAAC,iBAAiB,CAAC,CAAA;IAE3D;;;;;;OAMG;IACH,GAAG,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,gBAAgB,CAAC,CAAA;CAC3C"}
@@ -0,0 +1,18 @@
1
+ "use strict";
2
+ var __webpack_require__ = {};
3
+ (()=>{
4
+ __webpack_require__.r = (exports1)=>{
5
+ if ("u" > typeof Symbol && Symbol.toStringTag) Object.defineProperty(exports1, Symbol.toStringTag, {
6
+ value: 'Module'
7
+ });
8
+ Object.defineProperty(exports1, '__esModule', {
9
+ value: true
10
+ });
11
+ };
12
+ })();
13
+ var __webpack_exports__ = {};
14
+ __webpack_require__.r(__webpack_exports__);
15
+ for(var __rspack_i in __webpack_exports__)exports[__rspack_i] = __webpack_exports__[__rspack_i];
16
+ Object.defineProperty(exports, '__esModule', {
17
+ value: true
18
+ });
@@ -0,0 +1 @@
1
+ export { };
package/dist/exports.d.ts CHANGED
@@ -3,6 +3,9 @@ export * from './extensions/express';
3
3
  export * from './types';
4
4
  export { enrichCurrentSpan } from './extensions/context/listeners';
5
5
  export { FeatureFlagEvaluations } from './feature-flag-evaluations';
6
+ export { EmailError } from './emails/errors';
7
+ export type { EmailErrorName } from './emails/errors';
8
+ export type { EmailDeliveryStatus, Emails, EmailStatus, EmailWarning, GetEmailResponse, SendEmailOptions, SendEmailResponse, SendEmailResult, } from './emails/types';
6
9
  export type { FlagDefinitionCacheData, FlagDefinitionCacheInput, FlagDefinitionCacheProvider, } from './extensions/feature-flags/cache';
7
10
  export { FeatureFlagError } from '@posthog/core';
8
11
  export type { FeatureFlagErrorType, UnresolvedFlagReason } from '@posthog/core';
@@ -1 +1 @@
1
- {"version":3,"file":"exports.d.ts","sourceRoot":"","sources":["../src/exports.ts"],"names":[],"mappings":"AAAA,cAAc,iCAAiC,CAAA;AAC/C,cAAc,sBAAsB,CAAA;AACpC,c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,gBAAgB,CAAA;AACvB,YAAY,EACV,uBAAuB,EACvB,wBAAwB,EACxB,2BAA2B,GAC5B,MAAM,kCAAkC,CAAA;AAIzC,OAAO,EAAE,gBAAgB,EAAE,MAAM,eAAe,CAAA;AAChD,YAAY,EAAE,oBAAoB,EAAE,oBAAoB,EAAE,MAAM,eAAe,CAAA;AAI/E,YAAY,EAAE,oBAAoB,EAAE,OAAO,EAAE,aAAa,EAAE,MAAM,eAAe,CAAA;AAIjF,YAAY,EACV,IAAI,EACJ,cAAc,EACd,kBAAkB,EAClB,QAAQ,EACR,cAAc,EACd,aAAa,EACb,gBAAgB,EAChB,UAAU,EACV,gBAAgB,EAChB,YAAY,GACb,MAAM,eAAe,CAAA;AAKtB,OAAO,EACL,uBAAuB,EACvB,qBAAqB,EACrB,oBAAoB,EACpB,kBAAkB,EAClB,iBAAiB,EACjB,sBAAsB,EACtB,MAAM,GACP,MAAM,eAAe,CAAA;AACtB,YAAY,EAAE,WAAW,EAAE,kBAAkB,EAAE,MAAM,eAAe,CAAA"}
package/dist/exports.js CHANGED
@@ -1,5 +1,8 @@
1
1
  "use strict";
2
2
  var __webpack_modules__ = {
3
+ "./emails/errors" (module) {
4
+ module.exports = require("./emails/errors.js");
5
+ },
3
6
  "./extensions/context/listeners" (module) {
4
7
  module.exports = require("./extensions/context/listeners.js");
5
8
  },
@@ -78,6 +81,7 @@ var __webpack_exports__ = {};
78
81
  "cookieStateToProperties",
79
82
  "serializePostHogCookie",
80
83
  "FeatureFlagEvaluations",
84
+ "EmailError",
81
85
  "uuidv7",
82
86
  "FeatureFlagError"
83
87
  ].indexOf(__rspack_import_key) < 0) __rspack_reexport[__rspack_import_key] = ()=>_extensions_sentry_integration__rspack_import_0[__rspack_import_key];
@@ -94,6 +98,7 @@ var __webpack_exports__ = {};
94
98
  "cookieStateToProperties",
95
99
  "serializePostHogCookie",
96
100
  "FeatureFlagEvaluations",
101
+ "EmailError",
97
102
  "uuidv7",
98
103
  "FeatureFlagError"
99
104
  ].indexOf(__rspack_import_key) < 0) __rspack_reexport[__rspack_import_key] = ()=>_extensions_express__rspack_import_1[__rspack_import_key];
@@ -110,26 +115,30 @@ var __webpack_exports__ = {};
110
115
  "cookieStateToProperties",
111
116
  "serializePostHogCookie",
112
117
  "FeatureFlagEvaluations",
118
+ "EmailError",
113
119
  "uuidv7",
114
120
  "FeatureFlagError"
115
121
  ].indexOf(__rspack_import_key) < 0) __rspack_reexport[__rspack_import_key] = ()=>_types__rspack_import_2[__rspack_import_key];
116
122
  __webpack_require__.d(__webpack_exports__, __rspack_reexport);
117
123
  var _extensions_context_listeners__rspack_import_3 = __webpack_require__("./extensions/context/listeners");
118
124
  var _feature_flag_evaluations__rspack_import_4 = __webpack_require__("./feature-flag-evaluations");
119
- var _posthog_core__rspack_import_5 = __webpack_require__("@posthog/core");
125
+ var _emails_errors__rspack_import_5 = __webpack_require__("./emails/errors");
126
+ var _posthog_core__rspack_import_6 = __webpack_require__("@posthog/core");
120
127
  __webpack_require__.d(__webpack_exports__, {
121
- FeatureFlagError: ()=>_posthog_core__rspack_import_5.FeatureFlagError,
128
+ EmailError: ()=>_emails_errors__rspack_import_5.EmailError,
129
+ FeatureFlagError: ()=>_posthog_core__rspack_import_6.FeatureFlagError,
122
130
  FeatureFlagEvaluations: ()=>_feature_flag_evaluations__rspack_import_4.FeatureFlagEvaluations,
123
- cookieStateToProperties: ()=>_posthog_core__rspack_import_5.cookieStateToProperties,
124
- cookieStoreFromHeader: ()=>_posthog_core__rspack_import_5.cookieStoreFromHeader,
131
+ cookieStateToProperties: ()=>_posthog_core__rspack_import_6.cookieStateToProperties,
132
+ cookieStoreFromHeader: ()=>_posthog_core__rspack_import_6.cookieStoreFromHeader,
125
133
  enrichCurrentSpan: ()=>_extensions_context_listeners__rspack_import_3.enrichCurrentSpan,
126
- getPostHogCookieName: ()=>_posthog_core__rspack_import_5.getPostHogCookieName,
127
- parsePostHogCookie: ()=>_posthog_core__rspack_import_5.parsePostHogCookie,
128
- readPostHogCookie: ()=>_posthog_core__rspack_import_5.readPostHogCookie,
129
- serializePostHogCookie: ()=>_posthog_core__rspack_import_5.serializePostHogCookie,
130
- uuidv7: ()=>_posthog_core__rspack_import_5.uuidv7
134
+ getPostHogCookieName: ()=>_posthog_core__rspack_import_6.getPostHogCookieName,
135
+ parsePostHogCookie: ()=>_posthog_core__rspack_import_6.parsePostHogCookie,
136
+ readPostHogCookie: ()=>_posthog_core__rspack_import_6.readPostHogCookie,
137
+ serializePostHogCookie: ()=>_posthog_core__rspack_import_6.serializePostHogCookie,
138
+ uuidv7: ()=>_posthog_core__rspack_import_6.uuidv7
131
139
  });
132
140
  })();
141
+ exports.EmailError = __webpack_exports__.EmailError;
133
142
  exports.FeatureFlagError = __webpack_exports__.FeatureFlagError;
134
143
  exports.FeatureFlagEvaluations = __webpack_exports__.FeatureFlagEvaluations;
135
144
  exports.cookieStateToProperties = __webpack_exports__.cookieStateToProperties;
@@ -141,6 +150,7 @@ exports.readPostHogCookie = __webpack_exports__.readPostHogCookie;
141
150
  exports.serializePostHogCookie = __webpack_exports__.serializePostHogCookie;
142
151
  exports.uuidv7 = __webpack_exports__.uuidv7;
143
152
  for(var __rspack_i in __webpack_exports__)if (-1 === [
153
+ "EmailError",
144
154
  "FeatureFlagError",
145
155
  "FeatureFlagEvaluations",
146
156
  "cookieStateToProperties",
package/dist/exports.mjs CHANGED
@@ -3,4 +3,5 @@ export * from "./extensions/express.mjs";
3
3
  export * from "./types.mjs";
4
4
  export { enrichCurrentSpan } from "./extensions/context/listeners.mjs";
5
5
  export { FeatureFlagEvaluations } from "./feature-flag-evaluations.mjs";
6
+ export { EmailError } from "./emails/errors.mjs";
6
7
  export { FeatureFlagError, cookieStateToProperties, cookieStoreFromHeader, getPostHogCookieName, parsePostHogCookie, readPostHogCookie, serializePostHogCookie, uuidv7 } from "@posthog/core";
@@ -1,7 +1,37 @@
1
1
  import { ErrorTracking as CoreErrorTracking } from '@posthog/core';
2
+ import type { ContextData } from '../context/types';
2
3
  type UnhandledRejectionMode = 'throw' | 'strict' | 'warn' | 'warn-with-error-code' | 'none';
3
4
  export declare function getUnhandledRejectionMode(execArgv?: string[], nodeOptions?: string | undefined): UnhandledRejectionMode;
4
- export declare function addUncaughtExceptionListener(captureFn: (exception: Error, hint: CoreErrorTracking.EventHint) => void, onFatalFn: (exception: Error) => void, mode?: UnhandledRejectionMode): void;
5
- export declare function addUnhandledRejectionListener(captureFn: (exception: unknown, hint: CoreErrorTracking.EventHint) => void, mode?: UnhandledRejectionMode): void;
5
+ /** A client that captures exceptions through the shared process listeners. */
6
+ export type AutocaptureClient = {
7
+ key: string;
8
+ capture: (exception: unknown, hint: CoreErrorTracking.EventHint) => void;
9
+ getContext: () => ContextData | undefined;
10
+ flush: () => Promise<void>;
11
+ shutdown: () => Promise<void>;
12
+ };
13
+ /**
14
+ * Captures uncaught exceptions and unhandled rejections for a client, through one set of process listeners shared by
15
+ * every client in the process. Returns a function the client calls on shutdown. The listeners stay for the life of
16
+ * the process, as they always have, and the last client of a project keeps capturing after it shuts down until
17
+ * another client of the project starts.
18
+ */
19
+ export declare function startExceptionAutocapture(client: AutocaptureClient, mode?: UnhandledRejectionMode): () => void;
20
+ /**
21
+ * Records an error passed to captureException, and reports whether to capture it: false when autocapture already sent
22
+ * this error to the project during this turn. Otherwise the app's capture wins, and autocapture skips the error for the
23
+ * project for the rest of the turn. The same occurrence comes both ways when a framework hands an error from its own
24
+ * process listener to an error hook that calls captureException (Nitro's error hook, which @posthog/nuxt captures),
25
+ * and when an app captures an error and rethrows it. A capture of the same error object in a later turn is a new
26
+ * occurrence.
27
+ */
28
+ export declare function claimExplicitCapture(error: unknown, key: string): boolean;
29
+ /**
30
+ * Captures at once the exceptions waiting for the end of the turn. A flush or shutdown calls this first: an app's
31
+ * crash handler often flushes or shuts the client down and exits before the turn ends.
32
+ */
33
+ export declare function capturePendingExceptions(): Set<AutocaptureClient>;
34
+ /** @internal Removes the shared listeners and forgets every client, for tests. */
35
+ export declare function resetExceptionAutocapture(): void;
6
36
  export {};
7
37
  //# sourceMappingURL=autocapture.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"autocapture.d.ts","sourceRoot":"","sources":["../../../src/extensions/error-tracking/autocapture.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,aAAa,IAAI,iBAAiB,EAAE,MAAM,eAAe,CAAA;AAGlE,KAAK,sBAAsB,GAAG,OAAO,GAAG,QAAQ,GAAG,MAAM,GAAG,sBAAsB,GAAG,MAAM,CAAA;AA+D3F,wBAAgB,yBAAyB,CACvC,QAAQ,GAAE,MAAM,EAAsB,EACtC,WAAW,GAAE,MAAM,GAAG,SAAgC,GACrD,sBAAsB,CAKxB;AA6CD,wBAAgB,4BAA4B,CAC1C,SAAS,EAAE,CAAC,SAAS,EAAE,KAAK,EAAE,IAAI,EAAE,iBAAiB,CAAC,SAAS,KAAK,IAAI,EACxE,SAAS,EAAE,CAAC,SAAS,EAAE,KAAK,KAAK,IAAI,EACrC,IAAI,GAAE,sBAAyD,GAC9D,IAAI,CAYN;AAED,wBAAgB,6BAA6B,CAC3C,SAAS,EAAE,CAAC,SAAS,EAAE,OAAO,EAAE,IAAI,EAAE,iBAAiB,CAAC,SAAS,KAAK,IAAI,EAC1E,IAAI,GAAE,sBAAyD,GAC9D,IAAI,CAiBN"}
1
+ {"version":3,"file":"autocapture.d.ts","sourceRoot":"","sources":["../../../src/extensions/error-tracking/autocapture.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,aAAa,IAAI,iBAAiB,EAAE,MAAM,eAAe,CAAA;AAClE,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAA;AAKnD,KAAK,sBAAsB,GAAG,OAAO,GAAG,QAAQ,GAAG,MAAM,GAAG,sBAAsB,GAAG,MAAM,CAAA;AA+D3F,wBAAgB,yBAAyB,CACvC,QAAQ,GAAE,MAAM,EAAsB,EACtC,WAAW,GAAE,MAAM,GAAG,SAAgC,GACrD,sBAAsB,CAKxB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