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.
@@ -0,0 +1,14 @@
1
+ import { PostHog } from './posthog-core';
2
+ import { DecideResponse, Properties } from './types';
3
+ export declare const BASE_ERROR_ENDPOINT_SUFFIX = "/e/";
4
+ export declare class PostHogExceptions {
5
+ private readonly instance;
6
+ private _endpointSuffix;
7
+ constructor(instance: PostHog);
8
+ get endpoint(): string;
9
+ afterDecideResponse(response: DecideResponse): void;
10
+ /**
11
+ * :TRICKY: Make sure we batch these requests
12
+ */
13
+ sendExceptionEvent(properties: Properties): void;
14
+ }
@@ -0,0 +1,49 @@
1
+ import { EXCEPTION_CAPTURE_ENDPOINT_SUFFIX } from './constants';
2
+ import { isObject } from './utils/type-utils';
3
+ // TODO: move this to /x/ as default
4
+ export var BASE_ERROR_ENDPOINT_SUFFIX = '/e/';
5
+ var PostHogExceptions = /** @class */ (function () {
6
+ function PostHogExceptions(instance) {
7
+ var _a;
8
+ this.instance = instance;
9
+ // TODO: once BASE_ERROR_ENDPOINT_SUFFIX is no longer /e/ this can be removed
10
+ this._endpointSuffix =
11
+ ((_a = this.instance.persistence) === null || _a === void 0 ? void 0 : _a.props[EXCEPTION_CAPTURE_ENDPOINT_SUFFIX]) || BASE_ERROR_ENDPOINT_SUFFIX;
12
+ }
13
+ Object.defineProperty(PostHogExceptions.prototype, "endpoint", {
14
+ get: function () {
15
+ // Always respect any api_host set by the client config
16
+ return this.instance.requestRouter.endpointFor('api', this._endpointSuffix);
17
+ },
18
+ enumerable: false,
19
+ configurable: true
20
+ });
21
+ PostHogExceptions.prototype.afterDecideResponse = function (response) {
22
+ var _a;
23
+ var autocaptureExceptionsResponse = response.autocaptureExceptions;
24
+ this._endpointSuffix = isObject(autocaptureExceptionsResponse)
25
+ ? autocaptureExceptionsResponse.endpoint || BASE_ERROR_ENDPOINT_SUFFIX
26
+ : BASE_ERROR_ENDPOINT_SUFFIX;
27
+ if (this.instance.persistence) {
28
+ // when we come to moving the endpoint to not /e/
29
+ // we'll want that to persist between startup and decide response
30
+ // TODO: once BASE_ENDPOINT is no longer /e/ this can be removed
31
+ this.instance.persistence.register((_a = {},
32
+ _a[EXCEPTION_CAPTURE_ENDPOINT_SUFFIX] = this._endpointSuffix,
33
+ _a));
34
+ }
35
+ };
36
+ /**
37
+ * :TRICKY: Make sure we batch these requests
38
+ */
39
+ PostHogExceptions.prototype.sendExceptionEvent = function (properties) {
40
+ this.instance.capture('$exception', properties, {
41
+ _noTruncate: true,
42
+ _batchKey: 'exceptionEvent',
43
+ _url: this.endpoint,
44
+ });
45
+ };
46
+ return PostHogExceptions;
47
+ }());
48
+ export { PostHogExceptions };
49
+ //# sourceMappingURL=posthog-exceptions.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"posthog-exceptions.js","sourceRoot":"","sources":["../../src/posthog-exceptions.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iCAAiC,EAAE,MAAM,aAAa,CAAA;AAG/D,OAAO,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAA;AAE7C,oCAAoC;AACpC,MAAM,CAAC,IAAM,0BAA0B,GAAG,KAAK,CAAA;AAE/C;IAGI,2BAA6B,QAAiB;;QAAjB,aAAQ,GAAR,QAAQ,CAAS;QAC1C,6EAA6E;QAC7E,IAAI,CAAC,eAAe;YAChB,CAAA,MAAA,IAAI,CAAC,QAAQ,CAAC,WAAW,0CAAE,KAAK,CAAC,iCAAiC,CAAC,KAAI,0BAA0B,CAAA;IACzG,CAAC;IAED,sBAAI,uCAAQ;aAAZ;YACI,uDAAuD;YACvD,OAAO,IAAI,CAAC,QAAQ,CAAC,aAAa,CAAC,WAAW,CAAC,KAAK,EAAE,IAAI,CAAC,eAAe,CAAC,CAAA;QAC/E,CAAC;;;OAAA;IAED,+CAAmB,GAAnB,UAAoB,QAAwB;;QACxC,IAAM,6BAA6B,GAAG,QAAQ,CAAC,qBAAqB,CAAA;QAEpE,IAAI,CAAC,eAAe,GAAG,QAAQ,CAAC,6BAA6B,CAAC;YAC1D,CAAC,CAAC,6BAA6B,CAAC,QAAQ,IAAI,0BAA0B;YACtE,CAAC,CAAC,0BAA0B,CAAA;QAEhC,IAAI,IAAI,CAAC,QAAQ,CAAC,WAAW,EAAE,CAAC;YAC5B,iDAAiD;YACjD,iEAAiE;YACjE,gEAAgE;YAChE,IAAI,CAAC,QAAQ,CAAC,WAAW,CAAC,QAAQ;gBAC9B,GAAC,iCAAiC,IAAG,IAAI,CAAC,eAAe;oBAC3D,CAAA;QACN,CAAC;IACL,CAAC;IAED;;OAEG;IACH,8CAAkB,GAAlB,UAAmB,UAAsB;QACrC,IAAI,CAAC,QAAQ,CAAC,OAAO,CAAC,YAAY,EAAE,UAAU,EAAE;YAC5C,WAAW,EAAE,IAAI;YACjB,SAAS,EAAE,gBAAgB;YAC3B,IAAI,EAAE,IAAI,CAAC,QAAQ;SACtB,CAAC,CAAA;IACN,CAAC;IACL,wBAAC;AAAD,CAAC,AAzCD,IAyCC","sourcesContent":["import { EXCEPTION_CAPTURE_ENDPOINT_SUFFIX } from './constants'\nimport { PostHog } from './posthog-core'\nimport { DecideResponse, Properties } from './types'\nimport { isObject } from './utils/type-utils'\n\n// TODO: move this to /x/ as default\nexport const BASE_ERROR_ENDPOINT_SUFFIX = '/e/'\n\nexport class PostHogExceptions {\n private _endpointSuffix: string\n\n constructor(private readonly instance: PostHog) {\n // TODO: once BASE_ERROR_ENDPOINT_SUFFIX is no longer /e/ this can be removed\n this._endpointSuffix =\n this.instance.persistence?.props[EXCEPTION_CAPTURE_ENDPOINT_SUFFIX] || BASE_ERROR_ENDPOINT_SUFFIX\n }\n\n get endpoint() {\n // Always respect any api_host set by the client config\n return this.instance.requestRouter.endpointFor('api', this._endpointSuffix)\n }\n\n afterDecideResponse(response: DecideResponse) {\n const autocaptureExceptionsResponse = response.autocaptureExceptions\n\n this._endpointSuffix = isObject(autocaptureExceptionsResponse)\n ? autocaptureExceptionsResponse.endpoint || BASE_ERROR_ENDPOINT_SUFFIX\n : BASE_ERROR_ENDPOINT_SUFFIX\n\n if (this.instance.persistence) {\n // when we come to moving the endpoint to not /e/\n // we'll want that to persist between startup and decide response\n // TODO: once BASE_ENDPOINT is no longer /e/ this can be removed\n this.instance.persistence.register({\n [EXCEPTION_CAPTURE_ENDPOINT_SUFFIX]: this._endpointSuffix,\n })\n }\n }\n\n /**\n * :TRICKY: Make sure we batch these requests\n */\n sendExceptionEvent(properties: Properties) {\n this.instance.capture('$exception', properties, {\n _noTruncate: true,\n _batchKey: 'exceptionEvent',\n _url: this.endpoint,\n })\n }\n}\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "posthog-js",
3
- "version": "1.158.3",
3
+ "version": "1.160.0",
4
4
  "description": "Posthog-js allows you to automatically capture usage and send events to PostHog.",
5
5
  "repository": "https://github.com/PostHog/posthog-js",
6
6
  "author": "hey@posthog.com",