posthog-node 5.66.0 → 5.67.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.
- package/dist/client.d.ts +6 -0
- package/dist/client.d.ts.map +1 -1
- package/dist/client.js +7 -0
- package/dist/client.mjs +7 -0
- package/dist/exports.d.ts +1 -0
- package/dist/exports.d.ts.map +1 -1
- package/dist/exports.js +38 -18
- package/dist/exports.mjs +1 -0
- package/dist/extensions/fetch-request.d.ts +65 -0
- package/dist/extensions/fetch-request.d.ts.map +1 -0
- package/dist/extensions/fetch-request.js +237 -0
- package/dist/extensions/fetch-request.mjs +190 -0
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/dist/version.mjs +1 -1
- package/package.json +2 -2
- package/src/client.ts +17 -0
- package/src/exports.ts +1 -0
- package/src/extensions/fetch-request.ts +315 -0
- package/src/version.ts +1 -1
package/dist/client.d.ts
CHANGED
|
@@ -86,6 +86,12 @@ export declare abstract class PostHogBackendClient extends PostHogCoreStateless
|
|
|
86
86
|
protected flushAutomatic(): Promise<void>;
|
|
87
87
|
flush(): Promise<void>;
|
|
88
88
|
private _flushKeepingRuntimeAlive;
|
|
89
|
+
/**
|
|
90
|
+
* Hands a metrics flush to `waitUntil` so a serverless invocation does not end before the flush timer fires.
|
|
91
|
+
* Request-triggered flushes share one queued send and wait out a metrics backoff.
|
|
92
|
+
* @internal
|
|
93
|
+
*/
|
|
94
|
+
_flushMetricsWithinInvocation(): void;
|
|
89
95
|
private scheduleDebouncedFlush;
|
|
90
96
|
private _consumeWaitUntilCycle;
|
|
91
97
|
private resolveWaitUntilFlush;
|
package/dist/client.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"AAEA,OAAO,EAEL,gBAAgB,EAKhB,QAAQ,EAER,qBAAqB,EACrB,oBAAoB,EACpB,sBAAsB,EACtB,mBAAmB,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AAC,EACnD,IAAI,CAAC,EAAE,YAAY,CAAC,MAAM,CAAC,EAC3B,KAAK,CAAC,EAAE,sBAAsB,GAC7B,IAAI,CAcN;IAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OAmCG;IACG,yBAAyB,CAC7B,KAAK,EAAE,OAAO,EACd,UAAU,CAAC,EAAE,MAAM,EACnB,oBAAoB,CAAC,EAAE,MAAM,CAAC,MAAM,GAAG,MAAM,EAAE,GAAG,CAAC,EACnD,KAAK,CAAC,EAAE,sBAAsB,GAC7B,OAAO,CAAC,IAAI,CAAC,CAcf;IAEY,mBAAmB,CAAC,KAAK,EAAE,YAAY,GAAG,OAAO,CAAC;QAC7D,UAAU,EAAE,MAAM,CAAA;QAClB,KAAK,EAAE,MAAM,CAAA;QACb,UAAU,EAAE,sBAAsB,CAAA;QAClC,OAAO,EAAE,qBAAqB,CAAA;KAC/B,CAAC,CAED;IAED;;;;;;;OAOG;IACH,OAAO,CAAC,sBAAsB;IAK9B,yFAAyF;IACzF,OAAO,CAAC,mBAAmB;YAYb,oBAAoB;IA2JlC,OAAO,CAAC,cAAc;CA4BvB"}
|
package/dist/client.js
CHANGED
|
@@ -190,6 +190,13 @@ class PostHogBackendClient extends core_namespaceObject.PostHogCoreStateless {
|
|
|
190
190
|
} catch {}
|
|
191
191
|
return flushPromise;
|
|
192
192
|
}
|
|
193
|
+
_flushMetricsWithinInvocation() {
|
|
194
|
+
const waitUntil = this.options.waitUntil;
|
|
195
|
+
if (!waitUntil || !this._metrics) return;
|
|
196
|
+
try {
|
|
197
|
+
waitUntil(this._metrics.flushCoalesced().catch(()=>{}));
|
|
198
|
+
} catch {}
|
|
199
|
+
}
|
|
193
200
|
scheduleDebouncedFlush() {
|
|
194
201
|
const waitUntil = this.options.waitUntil;
|
|
195
202
|
if (!waitUntil) return;
|
package/dist/client.mjs
CHANGED
|
@@ -147,6 +147,13 @@ class PostHogBackendClient extends PostHogCoreStateless {
|
|
|
147
147
|
} catch {}
|
|
148
148
|
return flushPromise;
|
|
149
149
|
}
|
|
150
|
+
_flushMetricsWithinInvocation() {
|
|
151
|
+
const waitUntil = this.options.waitUntil;
|
|
152
|
+
if (!waitUntil || !this._metrics) return;
|
|
153
|
+
try {
|
|
154
|
+
waitUntil(this._metrics.flushCoalesced().catch(()=>{}));
|
|
155
|
+
} catch {}
|
|
156
|
+
}
|
|
150
157
|
scheduleDebouncedFlush() {
|
|
151
158
|
const waitUntil = this.options.waitUntil;
|
|
152
159
|
if (!waitUntil) return;
|
package/dist/exports.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
export * from './extensions/sentry-integration';
|
|
2
2
|
export * from './extensions/express';
|
|
3
|
+
export * from './extensions/fetch-request';
|
|
3
4
|
export * from './types';
|
|
4
5
|
export { enrichCurrentSpan } from './extensions/context/listeners';
|
|
5
6
|
export { FeatureFlagEvaluations } from './feature-flag-evaluations';
|
package/dist/exports.d.ts.map
CHANGED
|
@@ -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,cAAc,SAAS,CAAA;AACvB,OAAO,EAAE,iBAAiB,EAAE,MAAM,gCAAgC,CAAA;AAElE,OAAO,EAAE,sBAAsB,EAAE,MAAM,4BAA4B,CAAA;AACnE,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAA;AAC5C,YAAY,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAA;AACrD,YAAY,EACV,aAAa,EACb,mBAAmB,EACnB,MAAM,EACN,WAAW,EACX,YAAY,EACZ,gBAAgB,EAChB,oBAAoB,EACpB,aAAa,EACb,gBAAgB,EAChB,iBAAiB,EACjB,eAAe,EACf,wBAAwB,EACxB,iBAAiB,GAClB,MAAM,gBAAgB,CAAA;AACvB,YAAY,EACV,uBAAuB,EACvB,wBAAwB,EACxB,2BA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,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,gBAAgB,EAAE,OAAO,EAAE,aAAa,EAAE,MAAM,eAAe,CAAA;AAInG,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
|
@@ -9,6 +9,9 @@ var __webpack_modules__ = {
|
|
|
9
9
|
"./extensions/express" (module) {
|
|
10
10
|
module.exports = require("./extensions/express.js");
|
|
11
11
|
},
|
|
12
|
+
"./extensions/fetch-request" (module) {
|
|
13
|
+
module.exports = require("./extensions/fetch-request.js");
|
|
14
|
+
},
|
|
12
15
|
"./extensions/sentry-integration" (module) {
|
|
13
16
|
module.exports = require("./extensions/sentry-integration.js");
|
|
14
17
|
},
|
|
@@ -103,9 +106,26 @@ var __webpack_exports__ = {};
|
|
|
103
106
|
"FeatureFlagError"
|
|
104
107
|
].indexOf(__rspack_import_key) < 0) __rspack_reexport[__rspack_import_key] = ()=>_extensions_express__rspack_import_1[__rspack_import_key];
|
|
105
108
|
__webpack_require__.d(__webpack_exports__, __rspack_reexport);
|
|
106
|
-
var
|
|
109
|
+
var _extensions_fetch_request__rspack_import_2 = __webpack_require__("./extensions/fetch-request");
|
|
110
|
+
var __rspack_reexport = {};
|
|
111
|
+
for(const __rspack_import_key in _extensions_fetch_request__rspack_import_2)if ([
|
|
112
|
+
"enrichCurrentSpan",
|
|
113
|
+
"parsePostHogCookie",
|
|
114
|
+
"readPostHogCookie",
|
|
115
|
+
"cookieStoreFromHeader",
|
|
116
|
+
"getPostHogCookieName",
|
|
117
|
+
"default",
|
|
118
|
+
"cookieStateToProperties",
|
|
119
|
+
"serializePostHogCookie",
|
|
120
|
+
"FeatureFlagEvaluations",
|
|
121
|
+
"EmailError",
|
|
122
|
+
"uuidv7",
|
|
123
|
+
"FeatureFlagError"
|
|
124
|
+
].indexOf(__rspack_import_key) < 0) __rspack_reexport[__rspack_import_key] = ()=>_extensions_fetch_request__rspack_import_2[__rspack_import_key];
|
|
125
|
+
__webpack_require__.d(__webpack_exports__, __rspack_reexport);
|
|
126
|
+
var _types__rspack_import_3 = __webpack_require__("./types");
|
|
107
127
|
var __rspack_reexport = {};
|
|
108
|
-
for(const __rspack_import_key in
|
|
128
|
+
for(const __rspack_import_key in _types__rspack_import_3)if ([
|
|
109
129
|
"enrichCurrentSpan",
|
|
110
130
|
"parsePostHogCookie",
|
|
111
131
|
"readPostHogCookie",
|
|
@@ -118,24 +138,24 @@ var __webpack_exports__ = {};
|
|
|
118
138
|
"EmailError",
|
|
119
139
|
"uuidv7",
|
|
120
140
|
"FeatureFlagError"
|
|
121
|
-
].indexOf(__rspack_import_key) < 0) __rspack_reexport[__rspack_import_key] = ()=>
|
|
141
|
+
].indexOf(__rspack_import_key) < 0) __rspack_reexport[__rspack_import_key] = ()=>_types__rspack_import_3[__rspack_import_key];
|
|
122
142
|
__webpack_require__.d(__webpack_exports__, __rspack_reexport);
|
|
123
|
-
var
|
|
124
|
-
var
|
|
125
|
-
var
|
|
126
|
-
var
|
|
143
|
+
var _extensions_context_listeners__rspack_import_4 = __webpack_require__("./extensions/context/listeners");
|
|
144
|
+
var _feature_flag_evaluations__rspack_import_5 = __webpack_require__("./feature-flag-evaluations");
|
|
145
|
+
var _emails_errors__rspack_import_6 = __webpack_require__("./emails/errors");
|
|
146
|
+
var _posthog_core__rspack_import_7 = __webpack_require__("@posthog/core");
|
|
127
147
|
__webpack_require__.d(__webpack_exports__, {
|
|
128
|
-
EmailError: ()=>
|
|
129
|
-
FeatureFlagError: ()=>
|
|
130
|
-
FeatureFlagEvaluations: ()=>
|
|
131
|
-
cookieStateToProperties: ()=>
|
|
132
|
-
cookieStoreFromHeader: ()=>
|
|
133
|
-
enrichCurrentSpan: ()=>
|
|
134
|
-
getPostHogCookieName: ()=>
|
|
135
|
-
parsePostHogCookie: ()=>
|
|
136
|
-
readPostHogCookie: ()=>
|
|
137
|
-
serializePostHogCookie: ()=>
|
|
138
|
-
uuidv7: ()=>
|
|
148
|
+
EmailError: ()=>_emails_errors__rspack_import_6.EmailError,
|
|
149
|
+
FeatureFlagError: ()=>_posthog_core__rspack_import_7.FeatureFlagError,
|
|
150
|
+
FeatureFlagEvaluations: ()=>_feature_flag_evaluations__rspack_import_5.FeatureFlagEvaluations,
|
|
151
|
+
cookieStateToProperties: ()=>_posthog_core__rspack_import_7.cookieStateToProperties,
|
|
152
|
+
cookieStoreFromHeader: ()=>_posthog_core__rspack_import_7.cookieStoreFromHeader,
|
|
153
|
+
enrichCurrentSpan: ()=>_extensions_context_listeners__rspack_import_4.enrichCurrentSpan,
|
|
154
|
+
getPostHogCookieName: ()=>_posthog_core__rspack_import_7.getPostHogCookieName,
|
|
155
|
+
parsePostHogCookie: ()=>_posthog_core__rspack_import_7.parsePostHogCookie,
|
|
156
|
+
readPostHogCookie: ()=>_posthog_core__rspack_import_7.readPostHogCookie,
|
|
157
|
+
serializePostHogCookie: ()=>_posthog_core__rspack_import_7.serializePostHogCookie,
|
|
158
|
+
uuidv7: ()=>_posthog_core__rspack_import_7.uuidv7
|
|
139
159
|
});
|
|
140
160
|
})();
|
|
141
161
|
exports.EmailError = __webpack_exports__.EmailError;
|
package/dist/exports.mjs
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
export * from "./extensions/sentry-integration.mjs";
|
|
2
2
|
export * from "./extensions/express.mjs";
|
|
3
|
+
export * from "./extensions/fetch-request.mjs";
|
|
3
4
|
export * from "./types.mjs";
|
|
4
5
|
export { enrichCurrentSpan } from "./extensions/context/listeners.mjs";
|
|
5
6
|
export { FeatureFlagEvaluations } from "./feature-flag-evaluations.mjs";
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import type { PostHogBackendClient } from '../client';
|
|
2
|
+
/** Duration histogram, in seconds, using the OpenTelemetry HTTP semantic convention name. */
|
|
3
|
+
export declare const HTTP_SERVER_REQUEST_DURATION_METRIC = "http.server.request.duration";
|
|
4
|
+
/** Counter of requests served. */
|
|
5
|
+
export declare const HTTP_SERVER_REQUEST_COUNT_METRIC = "http.server.request.count";
|
|
6
|
+
export interface InstrumentRequestOptions {
|
|
7
|
+
/**
|
|
8
|
+
* The matched route pattern (`/users/:id`), once the handler has run. Used to name the span
|
|
9
|
+
* and as the `http.route` metric attribute. Without it the span is named after the method only,
|
|
10
|
+
* so raw paths never become high-cardinality span names or metric series.
|
|
11
|
+
*/
|
|
12
|
+
getRoute?: (request: Request, response: Response | undefined) => string | undefined;
|
|
13
|
+
/** Skip instrumentation (health checks, for example). The handler still runs, with no span or metrics. */
|
|
14
|
+
ignore?: (request: Request) => boolean;
|
|
15
|
+
}
|
|
16
|
+
type PostHogForRequests = Pick<PostHogBackendClient, 'withContext' | 'withSpan' | 'getContext' | 'metrics' | 'apiKey' | 'options' | '_flushMetricsWithinInvocation'>;
|
|
17
|
+
/**
|
|
18
|
+
* Instruments one request on the fetch API (`Request` in, `Response` out): Hono, Bun, Deno, Next route
|
|
19
|
+
* handlers, Cloudflare Workers, and anything else that works that way.
|
|
20
|
+
*
|
|
21
|
+
* - reads `x-posthog-session-id` / `x-posthog-distinct-id` (or the posthog-js cookie when `readPostHogCookie` is on)
|
|
22
|
+
* and runs the handler inside `withContext`, so events and spans carry the person and the replay
|
|
23
|
+
* - opens a `server` span continuing an inbound `traceparent`, named `METHOD route` once the route is known
|
|
24
|
+
* - marks 5xx responses and thrown errors as span errors (the error is rethrown)
|
|
25
|
+
* - records `http.server.request.duration` (seconds histogram) and `http.server.request.count`,
|
|
26
|
+
* by method, route and status code, and hands their flush to the `waitUntil` client option when set
|
|
27
|
+
*
|
|
28
|
+
* The request context (session and distinct ID on events and spans) needs `withContext`, which the edge
|
|
29
|
+
* entrypoint (Cloudflare Workers, Vercel Edge) does not support: there the span and metrics are still recorded,
|
|
30
|
+
* but captures inside the handler do not pick up the request's IDs. Pass them explicitly on that runtime.
|
|
31
|
+
*
|
|
32
|
+
* @experimental Subject to change in a minor release.
|
|
33
|
+
*
|
|
34
|
+
* @example
|
|
35
|
+
* ```ts
|
|
36
|
+
* export default {
|
|
37
|
+
* fetch: (request: Request) => instrumentRequest(posthog, request, () => app.fetch(request)),
|
|
38
|
+
* }
|
|
39
|
+
* ```
|
|
40
|
+
*/
|
|
41
|
+
export declare function instrumentRequest(posthog: PostHogForRequests, request: Request, handler: () => Response | Promise<Response>, options?: InstrumentRequestOptions): Promise<Response>;
|
|
42
|
+
/** The slice of a Hono `Context` the middleware uses, so `hono` is not a dependency. */
|
|
43
|
+
interface HonoContextLike {
|
|
44
|
+
req: {
|
|
45
|
+
raw: Request;
|
|
46
|
+
routePath: string;
|
|
47
|
+
};
|
|
48
|
+
res: Response;
|
|
49
|
+
/** Set by Hono when a handler threw and its error handler produced the response. */
|
|
50
|
+
error?: unknown;
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* Hono middleware that instruments every request. See {@link instrumentRequest}. The span is named after
|
|
54
|
+
* the matched route (`GET /api/users/:id`), and a thrown error is recorded as a 500.
|
|
55
|
+
*
|
|
56
|
+
* @experimental Subject to change in a minor release.
|
|
57
|
+
*
|
|
58
|
+
* @example
|
|
59
|
+
* ```ts
|
|
60
|
+
* app.use('*', posthogHonoMiddleware(posthog))
|
|
61
|
+
* ```
|
|
62
|
+
*/
|
|
63
|
+
export declare function posthogHonoMiddleware(posthog: PostHogForRequests, options?: Omit<InstrumentRequestOptions, 'getRoute'>): (c: HonoContextLike, next: () => Promise<void>) => Promise<void>;
|
|
64
|
+
export {};
|
|
65
|
+
//# sourceMappingURL=fetch-request.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"fetch-request.d.ts","sourceRoot":"","sources":["../../src/extensions/fetch-request.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,WAAW,CAAA;AAMrD,6FAA6F;AAC7F,eAAO,MAAM,mCAAmC,iCAAiC,CAAA;AACjF,kCAAkC;AAClC,eAAO,MAAM,gCAAgC,8BAA8B,CAAA;AAoB3E,MAAM,WAAW,wBAAwB;IACvC;;;;OAIG;IACH,QAAQ,CAAC,EAAE,CAAC,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,QAAQ,GAAG,SAAS,KAAK,MAAM,GAAG,SAAS,CAAA;IACnF,0GAA0G;IAC1G,MAAM,CAAC,EAAE,CAAC,OAAO,EAAE,OAAO,KAAK,OAAO,CAAA;CACvC;AAED,KAAK,kBAAkB,GAAG,IAAI,CAC5B,oBAAoB,EACpB,aAAa,GAAG,UAAU,GAAG,YAAY,GAAG,SAAS,GAAG,QAAQ,GAAG,SAAS,GAAG,+BAA+B,CAC/G,CAAA;AAkBD;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,wBAAgB,iBAAiB,CAC/B,OAAO,EAAE,kBAAkB,EAC3B,OAAO,EAAE,OAAO,EAChB,OAAO,EAAE,MAAM,QAAQ,GAAG,OAAO,CAAC,QAAQ,CAAC,EAC3C,OAAO,GAAE,wBAA6B,GACrC,OAAO,CAAC,QAAQ,CAAC,CAEnB;AAqLD,wFAAwF;AACxF,UAAU,eAAe;IACvB,GAAG,EAAE;QAAE,GAAG,EAAE,OAAO,CAAC;QAAC,SAAS,EAAE,MAAM,CAAA;KAAE,CAAA;IACxC,GAAG,EAAE,QAAQ,CAAA;IACb,oFAAoF;IACpF,KAAK,CAAC,EAAE,OAAO,CAAA;CAChB;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,qBAAqB,CACnC,OAAO,EAAE,kBAAkB,EAC3B,OAAO,GAAE,IAAI,CAAC,wBAAwB,EAAE,UAAU,CAAM,GACvD,CAAC,CAAC,EAAE,eAAe,EAAE,IAAI,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,KAAK,OAAO,CAAC,IAAI,CAAC,CAmBlE"}
|
|
@@ -0,0 +1,237 @@
|
|
|
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
|
+
__webpack_require__.d(__webpack_exports__, {
|
|
31
|
+
HTTP_SERVER_REQUEST_COUNT_METRIC: ()=>HTTP_SERVER_REQUEST_COUNT_METRIC,
|
|
32
|
+
HTTP_SERVER_REQUEST_DURATION_METRIC: ()=>HTTP_SERVER_REQUEST_DURATION_METRIC,
|
|
33
|
+
instrumentRequest: ()=>instrumentRequest,
|
|
34
|
+
posthogHonoMiddleware: ()=>posthogHonoMiddleware
|
|
35
|
+
});
|
|
36
|
+
const listeners_js_namespaceObject = require("./context/listeners.js");
|
|
37
|
+
const external_tracing_headers_js_namespaceObject = require("./tracing-headers.js");
|
|
38
|
+
const external_url_utils_js_namespaceObject = require("./url-utils.js");
|
|
39
|
+
const HTTP_SERVER_REQUEST_DURATION_METRIC = 'http.server.request.duration';
|
|
40
|
+
const HTTP_SERVER_REQUEST_COUNT_METRIC = 'http.server.request.count';
|
|
41
|
+
const DURATION_BOUNDS_SECONDS = [
|
|
42
|
+
0.005,
|
|
43
|
+
0.01,
|
|
44
|
+
0.025,
|
|
45
|
+
0.05,
|
|
46
|
+
0.075,
|
|
47
|
+
0.1,
|
|
48
|
+
0.25,
|
|
49
|
+
0.5,
|
|
50
|
+
0.75,
|
|
51
|
+
1,
|
|
52
|
+
2.5,
|
|
53
|
+
5,
|
|
54
|
+
7.5,
|
|
55
|
+
10
|
|
56
|
+
];
|
|
57
|
+
const KNOWN_HTTP_METHODS = new Set([
|
|
58
|
+
'CONNECT',
|
|
59
|
+
'DELETE',
|
|
60
|
+
'GET',
|
|
61
|
+
'HEAD',
|
|
62
|
+
'OPTIONS',
|
|
63
|
+
'PATCH',
|
|
64
|
+
'POST',
|
|
65
|
+
'PUT',
|
|
66
|
+
'QUERY',
|
|
67
|
+
'TRACE'
|
|
68
|
+
]);
|
|
69
|
+
function headersToRecord(headers) {
|
|
70
|
+
const record = {};
|
|
71
|
+
headers.forEach((value, key)=>{
|
|
72
|
+
record[key.toLowerCase()] = value;
|
|
73
|
+
});
|
|
74
|
+
return record;
|
|
75
|
+
}
|
|
76
|
+
function safePathname(request) {
|
|
77
|
+
try {
|
|
78
|
+
return new URL(request.url).pathname;
|
|
79
|
+
} catch {
|
|
80
|
+
return;
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
function instrumentRequest(posthog, request, handler, options = {}) {
|
|
84
|
+
return instrument(posthog, request, handler, options);
|
|
85
|
+
}
|
|
86
|
+
async function instrument(posthog, request, handler, options, getHandledError) {
|
|
87
|
+
if (options.ignore?.(request)) return handler();
|
|
88
|
+
const headers = (0, external_tracing_headers_js_namespaceObject.getPostHogTracingHeaderValues)(headersToRecord(request.headers), (0, external_tracing_headers_js_namespaceObject.getPostHogCookieReadOptions)(posthog));
|
|
89
|
+
const existing = posthog.getContext();
|
|
90
|
+
const disableCaptureUrlHashes = true === posthog.options.disable_capture_url_hashes;
|
|
91
|
+
const pathname = safePathname(request);
|
|
92
|
+
const properties = {};
|
|
93
|
+
(0, external_tracing_headers_js_namespaceObject.addProperty)(properties, '$request_method', request.method);
|
|
94
|
+
(0, external_tracing_headers_js_namespaceObject.addProperty)(properties, '$request_path', pathname ? (0, external_url_utils_js_namespaceObject.normalizeRequestPath)(pathname, disableCaptureUrlHashes) : void 0);
|
|
95
|
+
(0, external_tracing_headers_js_namespaceObject.addProperty)(properties, '$user_agent', request.headers.get('user-agent') ?? void 0);
|
|
96
|
+
const sessionId = existing?.sessionId ?? headers.sessionId;
|
|
97
|
+
const distinctId = existing?.distinctId ?? headers.distinctId;
|
|
98
|
+
const contextData = {
|
|
99
|
+
...void 0 !== sessionId ? {
|
|
100
|
+
sessionId
|
|
101
|
+
} : {},
|
|
102
|
+
...void 0 !== distinctId ? {
|
|
103
|
+
distinctId
|
|
104
|
+
} : {},
|
|
105
|
+
properties
|
|
106
|
+
};
|
|
107
|
+
const requestedMethod = request.method.toUpperCase();
|
|
108
|
+
const method = KNOWN_HTTP_METHODS.has(requestedMethod) ? requestedMethod : '_OTHER';
|
|
109
|
+
const spanMethod = '_OTHER' === method ? 'HTTP' : method;
|
|
110
|
+
const startedAt = performance.now();
|
|
111
|
+
const lifetime = new AbortController();
|
|
112
|
+
let streaming = false;
|
|
113
|
+
try {
|
|
114
|
+
return await posthog.withContext(contextData, ()=>{
|
|
115
|
+
(0, listeners_js_namespaceObject.notifyContextListeners)(posthog, true);
|
|
116
|
+
return posthog.withSpan(spanMethod, {
|
|
117
|
+
kind: 'server',
|
|
118
|
+
parent: request.headers.get('traceparent') ?? void 0,
|
|
119
|
+
tracestate: request.headers.get('tracestate') ?? void 0,
|
|
120
|
+
attributes: {
|
|
121
|
+
'http.request.method': method,
|
|
122
|
+
...'_OTHER' === method ? {
|
|
123
|
+
'http.request.method_original': request.method
|
|
124
|
+
} : {},
|
|
125
|
+
...pathname ? {
|
|
126
|
+
'url.path': pathname
|
|
127
|
+
} : {}
|
|
128
|
+
}
|
|
129
|
+
}, async (span)=>{
|
|
130
|
+
let response;
|
|
131
|
+
let thrown;
|
|
132
|
+
let failed = false;
|
|
133
|
+
try {
|
|
134
|
+
response = await handler();
|
|
135
|
+
} catch (error) {
|
|
136
|
+
failed = true;
|
|
137
|
+
thrown = error;
|
|
138
|
+
}
|
|
139
|
+
let route;
|
|
140
|
+
try {
|
|
141
|
+
route = options.getRoute?.(request, response);
|
|
142
|
+
} catch {}
|
|
143
|
+
const statusCode = failed ? 500 : response?.status ?? 500;
|
|
144
|
+
if (route) {
|
|
145
|
+
span.updateName(`${spanMethod} ${route}`);
|
|
146
|
+
span.setAttribute('http.route', route);
|
|
147
|
+
}
|
|
148
|
+
span.setAttribute('http.response.status_code', statusCode);
|
|
149
|
+
if (!failed && statusCode >= 500) {
|
|
150
|
+
let handledError;
|
|
151
|
+
try {
|
|
152
|
+
handledError = getHandledError?.();
|
|
153
|
+
} catch {}
|
|
154
|
+
if (null != handledError) span.recordException(handledError);
|
|
155
|
+
else span.setStatus('error');
|
|
156
|
+
}
|
|
157
|
+
const attributes = {
|
|
158
|
+
'http.request.method': method,
|
|
159
|
+
'http.response.status_code': statusCode,
|
|
160
|
+
...route ? {
|
|
161
|
+
'http.route': route
|
|
162
|
+
} : {}
|
|
163
|
+
};
|
|
164
|
+
posthog.metrics.histogram(HTTP_SERVER_REQUEST_DURATION_METRIC, (performance.now() - startedAt) / 1000, {
|
|
165
|
+
unit: 's',
|
|
166
|
+
attributes,
|
|
167
|
+
bounds: DURATION_BOUNDS_SECONDS
|
|
168
|
+
});
|
|
169
|
+
posthog.metrics.count(HTTP_SERVER_REQUEST_COUNT_METRIC, 1, {
|
|
170
|
+
attributes
|
|
171
|
+
});
|
|
172
|
+
posthog._flushMetricsWithinInvocation();
|
|
173
|
+
if (failed) throw thrown;
|
|
174
|
+
if (response?.body && 'HEAD' !== method) {
|
|
175
|
+
streaming = true;
|
|
176
|
+
return holdUntilBodySettles(response, (fn)=>posthog.withContext(contextData, fn, {
|
|
177
|
+
signal: lifetime.signal
|
|
178
|
+
}), ()=>lifetime.abort());
|
|
179
|
+
}
|
|
180
|
+
return response;
|
|
181
|
+
});
|
|
182
|
+
}, {
|
|
183
|
+
signal: lifetime.signal
|
|
184
|
+
});
|
|
185
|
+
} finally{
|
|
186
|
+
if (!streaming) lifetime.abort();
|
|
187
|
+
}
|
|
188
|
+
}
|
|
189
|
+
function holdUntilBodySettles(response, inContext, settle) {
|
|
190
|
+
const reader = response.body.getReader();
|
|
191
|
+
const body = new ReadableStream({
|
|
192
|
+
async pull (controller) {
|
|
193
|
+
try {
|
|
194
|
+
const { done, value } = await inContext(()=>reader.read());
|
|
195
|
+
if (done) {
|
|
196
|
+
controller.close();
|
|
197
|
+
settle();
|
|
198
|
+
} else controller.enqueue(value);
|
|
199
|
+
} catch (error) {
|
|
200
|
+
settle();
|
|
201
|
+
controller.error(error);
|
|
202
|
+
}
|
|
203
|
+
},
|
|
204
|
+
async cancel (reason) {
|
|
205
|
+
try {
|
|
206
|
+
await inContext(()=>reader.cancel(reason));
|
|
207
|
+
} finally{
|
|
208
|
+
settle();
|
|
209
|
+
}
|
|
210
|
+
}
|
|
211
|
+
});
|
|
212
|
+
return new Response(body, response);
|
|
213
|
+
}
|
|
214
|
+
function posthogHonoMiddleware(posthog, options = {}) {
|
|
215
|
+
return async (c, next)=>{
|
|
216
|
+
c.res = await instrument(posthog, c.req.raw, async ()=>{
|
|
217
|
+
await next();
|
|
218
|
+
return c.res;
|
|
219
|
+
}, {
|
|
220
|
+
...options,
|
|
221
|
+
getRoute: ()=>c.req.routePath && '/*' !== c.req.routePath ? c.req.routePath : void 0
|
|
222
|
+
}, ()=>c.error);
|
|
223
|
+
};
|
|
224
|
+
}
|
|
225
|
+
exports.HTTP_SERVER_REQUEST_COUNT_METRIC = __webpack_exports__.HTTP_SERVER_REQUEST_COUNT_METRIC;
|
|
226
|
+
exports.HTTP_SERVER_REQUEST_DURATION_METRIC = __webpack_exports__.HTTP_SERVER_REQUEST_DURATION_METRIC;
|
|
227
|
+
exports.instrumentRequest = __webpack_exports__.instrumentRequest;
|
|
228
|
+
exports.posthogHonoMiddleware = __webpack_exports__.posthogHonoMiddleware;
|
|
229
|
+
for(var __rspack_i in __webpack_exports__)if (-1 === [
|
|
230
|
+
"HTTP_SERVER_REQUEST_COUNT_METRIC",
|
|
231
|
+
"HTTP_SERVER_REQUEST_DURATION_METRIC",
|
|
232
|
+
"instrumentRequest",
|
|
233
|
+
"posthogHonoMiddleware"
|
|
234
|
+
].indexOf(__rspack_i)) exports[__rspack_i] = __webpack_exports__[__rspack_i];
|
|
235
|
+
Object.defineProperty(exports, '__esModule', {
|
|
236
|
+
value: true
|
|
237
|
+
});
|
|
@@ -0,0 +1,190 @@
|
|
|
1
|
+
import { notifyContextListeners } from "./context/listeners.mjs";
|
|
2
|
+
import { addProperty, getPostHogCookieReadOptions, getPostHogTracingHeaderValues } from "./tracing-headers.mjs";
|
|
3
|
+
import { normalizeRequestPath } from "./url-utils.mjs";
|
|
4
|
+
const HTTP_SERVER_REQUEST_DURATION_METRIC = 'http.server.request.duration';
|
|
5
|
+
const HTTP_SERVER_REQUEST_COUNT_METRIC = 'http.server.request.count';
|
|
6
|
+
const DURATION_BOUNDS_SECONDS = [
|
|
7
|
+
0.005,
|
|
8
|
+
0.01,
|
|
9
|
+
0.025,
|
|
10
|
+
0.05,
|
|
11
|
+
0.075,
|
|
12
|
+
0.1,
|
|
13
|
+
0.25,
|
|
14
|
+
0.5,
|
|
15
|
+
0.75,
|
|
16
|
+
1,
|
|
17
|
+
2.5,
|
|
18
|
+
5,
|
|
19
|
+
7.5,
|
|
20
|
+
10
|
|
21
|
+
];
|
|
22
|
+
const KNOWN_HTTP_METHODS = new Set([
|
|
23
|
+
'CONNECT',
|
|
24
|
+
'DELETE',
|
|
25
|
+
'GET',
|
|
26
|
+
'HEAD',
|
|
27
|
+
'OPTIONS',
|
|
28
|
+
'PATCH',
|
|
29
|
+
'POST',
|
|
30
|
+
'PUT',
|
|
31
|
+
'QUERY',
|
|
32
|
+
'TRACE'
|
|
33
|
+
]);
|
|
34
|
+
function headersToRecord(headers) {
|
|
35
|
+
const record = {};
|
|
36
|
+
headers.forEach((value, key)=>{
|
|
37
|
+
record[key.toLowerCase()] = value;
|
|
38
|
+
});
|
|
39
|
+
return record;
|
|
40
|
+
}
|
|
41
|
+
function safePathname(request) {
|
|
42
|
+
try {
|
|
43
|
+
return new URL(request.url).pathname;
|
|
44
|
+
} catch {
|
|
45
|
+
return;
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
function instrumentRequest(posthog, request, handler, options = {}) {
|
|
49
|
+
return instrument(posthog, request, handler, options);
|
|
50
|
+
}
|
|
51
|
+
async function instrument(posthog, request, handler, options, getHandledError) {
|
|
52
|
+
if (options.ignore?.(request)) return handler();
|
|
53
|
+
const headers = getPostHogTracingHeaderValues(headersToRecord(request.headers), getPostHogCookieReadOptions(posthog));
|
|
54
|
+
const existing = posthog.getContext();
|
|
55
|
+
const disableCaptureUrlHashes = true === posthog.options.disable_capture_url_hashes;
|
|
56
|
+
const pathname = safePathname(request);
|
|
57
|
+
const properties = {};
|
|
58
|
+
addProperty(properties, '$request_method', request.method);
|
|
59
|
+
addProperty(properties, '$request_path', pathname ? normalizeRequestPath(pathname, disableCaptureUrlHashes) : void 0);
|
|
60
|
+
addProperty(properties, '$user_agent', request.headers.get('user-agent') ?? void 0);
|
|
61
|
+
const sessionId = existing?.sessionId ?? headers.sessionId;
|
|
62
|
+
const distinctId = existing?.distinctId ?? headers.distinctId;
|
|
63
|
+
const contextData = {
|
|
64
|
+
...void 0 !== sessionId ? {
|
|
65
|
+
sessionId
|
|
66
|
+
} : {},
|
|
67
|
+
...void 0 !== distinctId ? {
|
|
68
|
+
distinctId
|
|
69
|
+
} : {},
|
|
70
|
+
properties
|
|
71
|
+
};
|
|
72
|
+
const requestedMethod = request.method.toUpperCase();
|
|
73
|
+
const method = KNOWN_HTTP_METHODS.has(requestedMethod) ? requestedMethod : '_OTHER';
|
|
74
|
+
const spanMethod = '_OTHER' === method ? 'HTTP' : method;
|
|
75
|
+
const startedAt = performance.now();
|
|
76
|
+
const lifetime = new AbortController();
|
|
77
|
+
let streaming = false;
|
|
78
|
+
try {
|
|
79
|
+
return await posthog.withContext(contextData, ()=>{
|
|
80
|
+
notifyContextListeners(posthog, true);
|
|
81
|
+
return posthog.withSpan(spanMethod, {
|
|
82
|
+
kind: 'server',
|
|
83
|
+
parent: request.headers.get('traceparent') ?? void 0,
|
|
84
|
+
tracestate: request.headers.get('tracestate') ?? void 0,
|
|
85
|
+
attributes: {
|
|
86
|
+
'http.request.method': method,
|
|
87
|
+
...'_OTHER' === method ? {
|
|
88
|
+
'http.request.method_original': request.method
|
|
89
|
+
} : {},
|
|
90
|
+
...pathname ? {
|
|
91
|
+
'url.path': pathname
|
|
92
|
+
} : {}
|
|
93
|
+
}
|
|
94
|
+
}, async (span)=>{
|
|
95
|
+
let response;
|
|
96
|
+
let thrown;
|
|
97
|
+
let failed = false;
|
|
98
|
+
try {
|
|
99
|
+
response = await handler();
|
|
100
|
+
} catch (error) {
|
|
101
|
+
failed = true;
|
|
102
|
+
thrown = error;
|
|
103
|
+
}
|
|
104
|
+
let route;
|
|
105
|
+
try {
|
|
106
|
+
route = options.getRoute?.(request, response);
|
|
107
|
+
} catch {}
|
|
108
|
+
const statusCode = failed ? 500 : response?.status ?? 500;
|
|
109
|
+
if (route) {
|
|
110
|
+
span.updateName(`${spanMethod} ${route}`);
|
|
111
|
+
span.setAttribute('http.route', route);
|
|
112
|
+
}
|
|
113
|
+
span.setAttribute('http.response.status_code', statusCode);
|
|
114
|
+
if (!failed && statusCode >= 500) {
|
|
115
|
+
let handledError;
|
|
116
|
+
try {
|
|
117
|
+
handledError = getHandledError?.();
|
|
118
|
+
} catch {}
|
|
119
|
+
if (null != handledError) span.recordException(handledError);
|
|
120
|
+
else span.setStatus('error');
|
|
121
|
+
}
|
|
122
|
+
const attributes = {
|
|
123
|
+
'http.request.method': method,
|
|
124
|
+
'http.response.status_code': statusCode,
|
|
125
|
+
...route ? {
|
|
126
|
+
'http.route': route
|
|
127
|
+
} : {}
|
|
128
|
+
};
|
|
129
|
+
posthog.metrics.histogram(HTTP_SERVER_REQUEST_DURATION_METRIC, (performance.now() - startedAt) / 1000, {
|
|
130
|
+
unit: 's',
|
|
131
|
+
attributes,
|
|
132
|
+
bounds: DURATION_BOUNDS_SECONDS
|
|
133
|
+
});
|
|
134
|
+
posthog.metrics.count(HTTP_SERVER_REQUEST_COUNT_METRIC, 1, {
|
|
135
|
+
attributes
|
|
136
|
+
});
|
|
137
|
+
posthog._flushMetricsWithinInvocation();
|
|
138
|
+
if (failed) throw thrown;
|
|
139
|
+
if (response?.body && 'HEAD' !== method) {
|
|
140
|
+
streaming = true;
|
|
141
|
+
return holdUntilBodySettles(response, (fn)=>posthog.withContext(contextData, fn, {
|
|
142
|
+
signal: lifetime.signal
|
|
143
|
+
}), ()=>lifetime.abort());
|
|
144
|
+
}
|
|
145
|
+
return response;
|
|
146
|
+
});
|
|
147
|
+
}, {
|
|
148
|
+
signal: lifetime.signal
|
|
149
|
+
});
|
|
150
|
+
} finally{
|
|
151
|
+
if (!streaming) lifetime.abort();
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
function holdUntilBodySettles(response, inContext, settle) {
|
|
155
|
+
const reader = response.body.getReader();
|
|
156
|
+
const body = new ReadableStream({
|
|
157
|
+
async pull (controller) {
|
|
158
|
+
try {
|
|
159
|
+
const { done, value } = await inContext(()=>reader.read());
|
|
160
|
+
if (done) {
|
|
161
|
+
controller.close();
|
|
162
|
+
settle();
|
|
163
|
+
} else controller.enqueue(value);
|
|
164
|
+
} catch (error) {
|
|
165
|
+
settle();
|
|
166
|
+
controller.error(error);
|
|
167
|
+
}
|
|
168
|
+
},
|
|
169
|
+
async cancel (reason) {
|
|
170
|
+
try {
|
|
171
|
+
await inContext(()=>reader.cancel(reason));
|
|
172
|
+
} finally{
|
|
173
|
+
settle();
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
});
|
|
177
|
+
return new Response(body, response);
|
|
178
|
+
}
|
|
179
|
+
function posthogHonoMiddleware(posthog, options = {}) {
|
|
180
|
+
return async (c, next)=>{
|
|
181
|
+
c.res = await instrument(posthog, c.req.raw, async ()=>{
|
|
182
|
+
await next();
|
|
183
|
+
return c.res;
|
|
184
|
+
}, {
|
|
185
|
+
...options,
|
|
186
|
+
getRoute: ()=>c.req.routePath && '/*' !== c.req.routePath ? c.req.routePath : void 0
|
|
187
|
+
}, ()=>c.error);
|
|
188
|
+
};
|
|
189
|
+
}
|
|
190
|
+
export { HTTP_SERVER_REQUEST_COUNT_METRIC, HTTP_SERVER_REQUEST_DURATION_METRIC, instrumentRequest, posthogHonoMiddleware };
|
package/dist/version.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export declare const version = "5.
|
|
1
|
+
export declare const version = "5.67.1";
|
|
2
2
|
//# sourceMappingURL=version.d.ts.map
|
package/dist/version.js
CHANGED
package/dist/version.mjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
const version = "5.
|
|
1
|
+
const version = "5.67.1";
|
|
2
2
|
export { version };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "posthog-node",
|
|
3
|
-
"version": "5.
|
|
3
|
+
"version": "5.67.1",
|
|
4
4
|
"bugs": {
|
|
5
5
|
"url": "https://github.com/PostHog/posthog-js/issues"
|
|
6
6
|
},
|
|
@@ -29,7 +29,7 @@
|
|
|
29
29
|
"module": "dist/entrypoints/index.node.mjs",
|
|
30
30
|
"types": "dist/entrypoints/index.node.d.ts",
|
|
31
31
|
"dependencies": {
|
|
32
|
-
"@posthog/core": "^1.
|
|
32
|
+
"@posthog/core": "^1.67.1"
|
|
33
33
|
},
|
|
34
34
|
"devDependencies": {
|
|
35
35
|
"@edge-runtime/vm": "^5.0.0",
|
package/src/client.ts
CHANGED
|
@@ -399,6 +399,23 @@ export abstract class PostHogBackendClient extends PostHogCoreStateless implemen
|
|
|
399
399
|
return flushPromise
|
|
400
400
|
}
|
|
401
401
|
|
|
402
|
+
/**
|
|
403
|
+
* Hands a metrics flush to `waitUntil` so a serverless invocation does not end before the flush timer fires.
|
|
404
|
+
* Request-triggered flushes share one queued send and wait out a metrics backoff.
|
|
405
|
+
* @internal
|
|
406
|
+
*/
|
|
407
|
+
_flushMetricsWithinInvocation(): void {
|
|
408
|
+
const waitUntil = this.options.waitUntil
|
|
409
|
+
if (!waitUntil || !this._metrics) {
|
|
410
|
+
return
|
|
411
|
+
}
|
|
412
|
+
try {
|
|
413
|
+
waitUntil(this._metrics.flushCoalesced().catch(() => {}))
|
|
414
|
+
} catch {
|
|
415
|
+
// waitUntil may throw outside request context
|
|
416
|
+
}
|
|
417
|
+
}
|
|
418
|
+
|
|
402
419
|
private scheduleDebouncedFlush(): void {
|
|
403
420
|
// `waitUntil` is a serverless construct
|
|
404
421
|
// if it doesn't exist, we can skip all the debounce logic and flush as normal
|
package/src/exports.ts
CHANGED
|
@@ -0,0 +1,315 @@
|
|
|
1
|
+
import type { PostHogBackendClient } from '../client'
|
|
2
|
+
import type { ContextData } from './context/types'
|
|
3
|
+
import { notifyContextListeners } from './context/listeners'
|
|
4
|
+
import { addProperty, getPostHogCookieReadOptions, getPostHogTracingHeaderValues } from './tracing-headers'
|
|
5
|
+
import { normalizeRequestPath } from './url-utils'
|
|
6
|
+
|
|
7
|
+
/** Duration histogram, in seconds, using the OpenTelemetry HTTP semantic convention name. */
|
|
8
|
+
export const HTTP_SERVER_REQUEST_DURATION_METRIC = 'http.server.request.duration'
|
|
9
|
+
/** Counter of requests served. */
|
|
10
|
+
export const HTTP_SERVER_REQUEST_COUNT_METRIC = 'http.server.request.count'
|
|
11
|
+
|
|
12
|
+
// Seconds, the boundaries the OpenTelemetry HTTP semantic conventions recommend for this histogram.
|
|
13
|
+
const DURATION_BOUNDS_SECONDS = [0.005, 0.01, 0.025, 0.05, 0.075, 0.1, 0.25, 0.5, 0.75, 1, 2.5, 5, 7.5, 10]
|
|
14
|
+
|
|
15
|
+
// Any other method token becomes `_OTHER`, as the OpenTelemetry HTTP conventions say, so clients sending
|
|
16
|
+
// made-up methods cannot mint span names or metric series.
|
|
17
|
+
const KNOWN_HTTP_METHODS = new Set([
|
|
18
|
+
'CONNECT',
|
|
19
|
+
'DELETE',
|
|
20
|
+
'GET',
|
|
21
|
+
'HEAD',
|
|
22
|
+
'OPTIONS',
|
|
23
|
+
'PATCH',
|
|
24
|
+
'POST',
|
|
25
|
+
'PUT',
|
|
26
|
+
'QUERY',
|
|
27
|
+
'TRACE',
|
|
28
|
+
])
|
|
29
|
+
|
|
30
|
+
export interface InstrumentRequestOptions {
|
|
31
|
+
/**
|
|
32
|
+
* The matched route pattern (`/users/:id`), once the handler has run. Used to name the span
|
|
33
|
+
* and as the `http.route` metric attribute. Without it the span is named after the method only,
|
|
34
|
+
* so raw paths never become high-cardinality span names or metric series.
|
|
35
|
+
*/
|
|
36
|
+
getRoute?: (request: Request, response: Response | undefined) => string | undefined
|
|
37
|
+
/** Skip instrumentation (health checks, for example). The handler still runs, with no span or metrics. */
|
|
38
|
+
ignore?: (request: Request) => boolean
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
type PostHogForRequests = Pick<
|
|
42
|
+
PostHogBackendClient,
|
|
43
|
+
'withContext' | 'withSpan' | 'getContext' | 'metrics' | 'apiKey' | 'options' | '_flushMetricsWithinInvocation'
|
|
44
|
+
>
|
|
45
|
+
|
|
46
|
+
function headersToRecord(headers: Headers): Record<string, string> {
|
|
47
|
+
const record: Record<string, string> = {}
|
|
48
|
+
headers.forEach((value, key) => {
|
|
49
|
+
record[key.toLowerCase()] = value
|
|
50
|
+
})
|
|
51
|
+
return record
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
function safePathname(request: Request): string | undefined {
|
|
55
|
+
try {
|
|
56
|
+
return new URL(request.url).pathname
|
|
57
|
+
} catch {
|
|
58
|
+
return undefined
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
/**
|
|
63
|
+
* Instruments one request on the fetch API (`Request` in, `Response` out): Hono, Bun, Deno, Next route
|
|
64
|
+
* handlers, Cloudflare Workers, and anything else that works that way.
|
|
65
|
+
*
|
|
66
|
+
* - reads `x-posthog-session-id` / `x-posthog-distinct-id` (or the posthog-js cookie when `readPostHogCookie` is on)
|
|
67
|
+
* and runs the handler inside `withContext`, so events and spans carry the person and the replay
|
|
68
|
+
* - opens a `server` span continuing an inbound `traceparent`, named `METHOD route` once the route is known
|
|
69
|
+
* - marks 5xx responses and thrown errors as span errors (the error is rethrown)
|
|
70
|
+
* - records `http.server.request.duration` (seconds histogram) and `http.server.request.count`,
|
|
71
|
+
* by method, route and status code, and hands their flush to the `waitUntil` client option when set
|
|
72
|
+
*
|
|
73
|
+
* The request context (session and distinct ID on events and spans) needs `withContext`, which the edge
|
|
74
|
+
* entrypoint (Cloudflare Workers, Vercel Edge) does not support: there the span and metrics are still recorded,
|
|
75
|
+
* but captures inside the handler do not pick up the request's IDs. Pass them explicitly on that runtime.
|
|
76
|
+
*
|
|
77
|
+
* @experimental Subject to change in a minor release.
|
|
78
|
+
*
|
|
79
|
+
* @example
|
|
80
|
+
* ```ts
|
|
81
|
+
* export default {
|
|
82
|
+
* fetch: (request: Request) => instrumentRequest(posthog, request, () => app.fetch(request)),
|
|
83
|
+
* }
|
|
84
|
+
* ```
|
|
85
|
+
*/
|
|
86
|
+
export function instrumentRequest(
|
|
87
|
+
posthog: PostHogForRequests,
|
|
88
|
+
request: Request,
|
|
89
|
+
handler: () => Response | Promise<Response>,
|
|
90
|
+
options: InstrumentRequestOptions = {}
|
|
91
|
+
): Promise<Response> {
|
|
92
|
+
return instrument(posthog, request, handler, options)
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
async function instrument(
|
|
96
|
+
posthog: PostHogForRequests,
|
|
97
|
+
request: Request,
|
|
98
|
+
handler: () => Response | Promise<Response>,
|
|
99
|
+
options: InstrumentRequestOptions,
|
|
100
|
+
// An error the framework caught and turned into a response, so it never reaches us as a rejection.
|
|
101
|
+
getHandledError?: () => unknown
|
|
102
|
+
): Promise<Response> {
|
|
103
|
+
if (options.ignore?.(request)) {
|
|
104
|
+
return handler()
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
const headers = getPostHogTracingHeaderValues(headersToRecord(request.headers), getPostHogCookieReadOptions(posthog))
|
|
108
|
+
const existing = posthog.getContext()
|
|
109
|
+
const disableCaptureUrlHashes = posthog.options.disable_capture_url_hashes === true
|
|
110
|
+
const pathname = safePathname(request)
|
|
111
|
+
const properties: Record<string, any> = {}
|
|
112
|
+
addProperty(properties, '$request_method', request.method)
|
|
113
|
+
addProperty(
|
|
114
|
+
properties,
|
|
115
|
+
'$request_path',
|
|
116
|
+
pathname ? normalizeRequestPath(pathname, disableCaptureUrlHashes) : undefined
|
|
117
|
+
)
|
|
118
|
+
addProperty(properties, '$user_agent', request.headers.get('user-agent') ?? undefined)
|
|
119
|
+
|
|
120
|
+
const sessionId = existing?.sessionId ?? headers.sessionId
|
|
121
|
+
const distinctId = existing?.distinctId ?? headers.distinctId
|
|
122
|
+
const contextData: Partial<ContextData> = {
|
|
123
|
+
...(sessionId !== undefined ? { sessionId } : {}),
|
|
124
|
+
...(distinctId !== undefined ? { distinctId } : {}),
|
|
125
|
+
properties,
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
const requestedMethod = request.method.toUpperCase()
|
|
129
|
+
const method = KNOWN_HTTP_METHODS.has(requestedMethod) ? requestedMethod : '_OTHER'
|
|
130
|
+
const spanMethod = method === '_OTHER' ? 'HTTP' : method
|
|
131
|
+
const startedAt = performance.now()
|
|
132
|
+
// Ends the request context once the response settles, so detached work started by the handler
|
|
133
|
+
// does not keep attributing later events and spans to this request.
|
|
134
|
+
const lifetime = new AbortController()
|
|
135
|
+
// Streaming bodies keep the context and the metrics open until they settle, so work the
|
|
136
|
+
// framework does while streaming stays attributed to this request.
|
|
137
|
+
let streaming = false
|
|
138
|
+
|
|
139
|
+
try {
|
|
140
|
+
return await posthog.withContext(
|
|
141
|
+
contextData,
|
|
142
|
+
() => {
|
|
143
|
+
notifyContextListeners(posthog as unknown as PostHogBackendClient, true)
|
|
144
|
+
return posthog.withSpan(
|
|
145
|
+
spanMethod,
|
|
146
|
+
{
|
|
147
|
+
kind: 'server',
|
|
148
|
+
parent: request.headers.get('traceparent') ?? undefined,
|
|
149
|
+
tracestate: request.headers.get('tracestate') ?? undefined,
|
|
150
|
+
attributes: {
|
|
151
|
+
'http.request.method': method,
|
|
152
|
+
...(method === '_OTHER' ? { 'http.request.method_original': request.method } : {}),
|
|
153
|
+
...(pathname ? { 'url.path': pathname } : {}),
|
|
154
|
+
},
|
|
155
|
+
},
|
|
156
|
+
async (span) => {
|
|
157
|
+
let response: Response | undefined
|
|
158
|
+
let thrown: unknown
|
|
159
|
+
let failed = false
|
|
160
|
+
try {
|
|
161
|
+
response = await handler()
|
|
162
|
+
} catch (error) {
|
|
163
|
+
failed = true
|
|
164
|
+
thrown = error
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
let route: string | undefined
|
|
168
|
+
try {
|
|
169
|
+
route = options.getRoute?.(request, response)
|
|
170
|
+
} catch {
|
|
171
|
+
// A broken route resolver must not break the request.
|
|
172
|
+
}
|
|
173
|
+
const statusCode = failed ? 500 : (response?.status ?? 500)
|
|
174
|
+
if (route) {
|
|
175
|
+
span.updateName(`${spanMethod} ${route}`)
|
|
176
|
+
span.setAttribute('http.route', route)
|
|
177
|
+
}
|
|
178
|
+
span.setAttribute('http.response.status_code', statusCode)
|
|
179
|
+
// A thrown error is recorded by `withSpan` when it is rethrown below.
|
|
180
|
+
if (!failed && statusCode >= 500) {
|
|
181
|
+
let handledError: unknown
|
|
182
|
+
try {
|
|
183
|
+
handledError = getHandledError?.()
|
|
184
|
+
} catch {
|
|
185
|
+
// Reading the framework's error must not break the request.
|
|
186
|
+
}
|
|
187
|
+
if (handledError !== undefined && handledError !== null) {
|
|
188
|
+
span.recordException(handledError)
|
|
189
|
+
} else {
|
|
190
|
+
span.setStatus('error')
|
|
191
|
+
}
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
const attributes: Record<string, string | number> = {
|
|
195
|
+
'http.request.method': method,
|
|
196
|
+
'http.response.status_code': statusCode,
|
|
197
|
+
...(route ? { 'http.route': route } : {}),
|
|
198
|
+
}
|
|
199
|
+
posthog.metrics.histogram(HTTP_SERVER_REQUEST_DURATION_METRIC, (performance.now() - startedAt) / 1000, {
|
|
200
|
+
unit: 's',
|
|
201
|
+
attributes,
|
|
202
|
+
bounds: DURATION_BOUNDS_SECONDS,
|
|
203
|
+
})
|
|
204
|
+
posthog.metrics.count(HTTP_SERVER_REQUEST_COUNT_METRIC, 1, {
|
|
205
|
+
attributes,
|
|
206
|
+
})
|
|
207
|
+
// Serverless hosts can end the invocation before the metrics flush timer fires.
|
|
208
|
+
posthog._flushMetricsWithinInvocation()
|
|
209
|
+
|
|
210
|
+
if (failed) {
|
|
211
|
+
throw thrown
|
|
212
|
+
}
|
|
213
|
+
// The duration covers the time to the response, not the body. The context stays open
|
|
214
|
+
// until the body ends, so work done while streaming stays attributed to this request.
|
|
215
|
+
// A HEAD response sends no content (frameworks such as Hono drop the GET route's body
|
|
216
|
+
// without reading it), so it is complete once returned.
|
|
217
|
+
if (response?.body && method !== 'HEAD') {
|
|
218
|
+
streaming = true
|
|
219
|
+
return holdUntilBodySettles(
|
|
220
|
+
response,
|
|
221
|
+
// The server reads the body outside this scope, so each read re-enters the request
|
|
222
|
+
// context: the handler's stream producer runs with the request's IDs.
|
|
223
|
+
(fn) => posthog.withContext(contextData, fn, { signal: lifetime.signal }),
|
|
224
|
+
() => lifetime.abort()
|
|
225
|
+
)
|
|
226
|
+
}
|
|
227
|
+
return response as Response
|
|
228
|
+
}
|
|
229
|
+
)
|
|
230
|
+
},
|
|
231
|
+
{ signal: lifetime.signal }
|
|
232
|
+
)
|
|
233
|
+
} finally {
|
|
234
|
+
if (!streaming) {
|
|
235
|
+
lifetime.abort()
|
|
236
|
+
}
|
|
237
|
+
}
|
|
238
|
+
}
|
|
239
|
+
|
|
240
|
+
/**
|
|
241
|
+
* Returns a copy of `response` whose body is passed through unchanged, and calls `settle` once the
|
|
242
|
+
* body ends, errors or is cancelled by the consumer. Reads and cancellation run through `inContext`.
|
|
243
|
+
*/
|
|
244
|
+
function holdUntilBodySettles(response: Response, inContext: <T>(fn: () => T) => T, settle: () => void): Response {
|
|
245
|
+
const reader = (response.body as ReadableStream<Uint8Array>).getReader()
|
|
246
|
+
const body = new ReadableStream<Uint8Array>({
|
|
247
|
+
async pull(controller) {
|
|
248
|
+
try {
|
|
249
|
+
const { done, value } = await inContext(() => reader.read())
|
|
250
|
+
if (done) {
|
|
251
|
+
controller.close()
|
|
252
|
+
settle()
|
|
253
|
+
} else {
|
|
254
|
+
controller.enqueue(value)
|
|
255
|
+
}
|
|
256
|
+
} catch (error) {
|
|
257
|
+
settle()
|
|
258
|
+
controller.error(error)
|
|
259
|
+
}
|
|
260
|
+
},
|
|
261
|
+
async cancel(reason) {
|
|
262
|
+
try {
|
|
263
|
+
await inContext(() => reader.cancel(reason))
|
|
264
|
+
} finally {
|
|
265
|
+
settle()
|
|
266
|
+
}
|
|
267
|
+
},
|
|
268
|
+
})
|
|
269
|
+
// The original response as the initializer keeps runtime-specific state, such as Workers'
|
|
270
|
+
// `encodeBody: 'manual'` for precompressed bodies, that a status/headers copy drops.
|
|
271
|
+
return new Response(body, response)
|
|
272
|
+
}
|
|
273
|
+
|
|
274
|
+
/** The slice of a Hono `Context` the middleware uses, so `hono` is not a dependency. */
|
|
275
|
+
interface HonoContextLike {
|
|
276
|
+
req: { raw: Request; routePath: string }
|
|
277
|
+
res: Response
|
|
278
|
+
/** Set by Hono when a handler threw and its error handler produced the response. */
|
|
279
|
+
error?: unknown
|
|
280
|
+
}
|
|
281
|
+
|
|
282
|
+
/**
|
|
283
|
+
* Hono middleware that instruments every request. See {@link instrumentRequest}. The span is named after
|
|
284
|
+
* the matched route (`GET /api/users/:id`), and a thrown error is recorded as a 500.
|
|
285
|
+
*
|
|
286
|
+
* @experimental Subject to change in a minor release.
|
|
287
|
+
*
|
|
288
|
+
* @example
|
|
289
|
+
* ```ts
|
|
290
|
+
* app.use('*', posthogHonoMiddleware(posthog))
|
|
291
|
+
* ```
|
|
292
|
+
*/
|
|
293
|
+
export function posthogHonoMiddleware(
|
|
294
|
+
posthog: PostHogForRequests,
|
|
295
|
+
options: Omit<InstrumentRequestOptions, 'getRoute'> = {}
|
|
296
|
+
): (c: HonoContextLike, next: () => Promise<void>) => Promise<void> {
|
|
297
|
+
return async (c, next) => {
|
|
298
|
+
// Hono's `next()` resolves with the response on `c.res` (error handlers set it too), so wrap that.
|
|
299
|
+
// A streamed body is wrapped, so the wrapper has to replace `c.res` for Hono to send the live stream.
|
|
300
|
+
c.res = await instrument(
|
|
301
|
+
posthog,
|
|
302
|
+
c.req.raw,
|
|
303
|
+
async () => {
|
|
304
|
+
await next()
|
|
305
|
+
return c.res
|
|
306
|
+
},
|
|
307
|
+
{
|
|
308
|
+
...options,
|
|
309
|
+
// routePath is the last matched route; the catch-all `/*` means nothing matched.
|
|
310
|
+
getRoute: () => (c.req.routePath && c.req.routePath !== '/*' ? c.req.routePath : undefined),
|
|
311
|
+
},
|
|
312
|
+
() => c.error
|
|
313
|
+
)
|
|
314
|
+
}
|
|
315
|
+
}
|
package/src/version.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export const version = "5.
|
|
1
|
+
export const version = "5.67.1"
|