posthog-node 5.38.2 → 5.38.4
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/extensions/express.d.ts.map +1 -1
- package/dist/extensions/express.js +7 -5
- package/dist/extensions/express.mjs +7 -5
- package/dist/extensions/nestjs.d.ts.map +1 -1
- package/dist/extensions/nestjs.js +4 -2
- package/dist/extensions/nestjs.mjs +4 -2
- package/dist/extensions/sentry-integration.d.ts +21 -0
- package/dist/extensions/sentry-integration.d.ts.map +1 -1
- package/dist/extensions/url-utils.d.ts +3 -0
- package/dist/extensions/url-utils.d.ts.map +1 -0
- package/dist/extensions/url-utils.js +53 -0
- package/dist/extensions/url-utils.mjs +16 -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/extensions/express.ts +11 -5
- package/src/extensions/nestjs.ts +8 -2
- package/src/extensions/sentry-integration.ts +21 -0
- package/src/extensions/url-utils.ts +27 -0
- package/src/version.ts +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"express.d.ts","sourceRoot":"","sources":["../../src/extensions/express.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,oBAAoB,EAAE,MAAM,WAAW,CAAA;
|
|
1
|
+
{"version":3,"file":"express.d.ts","sourceRoot":"","sources":["../../src/extensions/express.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,oBAAoB,EAAE,MAAM,WAAW,CAAA;AAIhD,OAAO,KAAK,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAA;AAGhD,KAAK,iBAAiB,GAAG,CAAC,GAAG,EAAE,OAAO,EAAE,GAAG,EAAE,QAAQ,EAAE,IAAI,EAAE,MAAM,IAAI,KAAK,IAAI,CAAA;AAEhF,KAAK,sBAAsB,GAAG,CAC5B,KAAK,EAAE,eAAe,EACtB,GAAG,EAAE,OAAO,EACZ,GAAG,EAAE,QAAQ,EACb,IAAI,EAAE,CAAC,KAAK,EAAE,eAAe,KAAK,IAAI,KACnC,IAAI,CAAA;AAET,UAAU,eAAgB,SAAQ,KAAK;IACrC,MAAM,CAAC,EAAE,MAAM,GAAG,MAAM,CAAA;IACxB,UAAU,CAAC,EAAE,MAAM,GAAG,MAAM,CAAA;IAC5B,WAAW,CAAC,EAAE,MAAM,GAAG,MAAM,CAAA;IAC7B,MAAM,CAAC,EAAE;QACP,UAAU,CAAC,EAAE,MAAM,GAAG,MAAM,CAAA;KAC7B,CAAA;CACF;AAiCD,wBAAgB,0BAA0B,CACxC,QAAQ,EAAE,oBAAoB,EAC9B,GAAG,EAAE;IACH,GAAG,EAAE,CAAC,UAAU,EAAE,iBAAiB,KAAK,OAAO,CAAA;CAChD,GACA,IAAI,CAEN;AAQD,wBAAgB,wBAAwB,CACtC,QAAQ,EAAE,oBAAoB,EAC9B,GAAG,EAAE;IACH,GAAG,EAAE,CAAC,UAAU,EAAE,iBAAiB,GAAG,sBAAsB,KAAK,OAAO,CAAA;CACzE,GACA,IAAI,CAEN"}
|
|
@@ -39,6 +39,7 @@ __webpack_require__.d(__webpack_exports__, {
|
|
|
39
39
|
const index_js_namespaceObject = require("./error-tracking/index.js");
|
|
40
40
|
var index_js_default = /*#__PURE__*/ __webpack_require__.n(index_js_namespaceObject);
|
|
41
41
|
const external_tracing_headers_js_namespaceObject = require("./tracing-headers.js");
|
|
42
|
+
const external_url_utils_js_namespaceObject = require("./url-utils.js");
|
|
42
43
|
function getClientIp(req) {
|
|
43
44
|
const forwarded = (0, external_tracing_headers_js_namespaceObject.getFirstHeaderValue)(req.headers['x-forwarded-for']);
|
|
44
45
|
if (forwarded) {
|
|
@@ -47,12 +48,13 @@ function getClientIp(req) {
|
|
|
47
48
|
}
|
|
48
49
|
return req.socket?.remoteAddress;
|
|
49
50
|
}
|
|
50
|
-
function buildRequestContextData(req) {
|
|
51
|
+
function buildRequestContextData(posthog, req) {
|
|
51
52
|
const { sessionId, distinctId } = (0, external_tracing_headers_js_namespaceObject.getPostHogTracingHeaderValues)(req.headers);
|
|
52
53
|
const properties = {};
|
|
53
|
-
|
|
54
|
+
const disableCaptureUrlHashes = true === posthog.options.disable_capture_url_hashes;
|
|
55
|
+
(0, external_tracing_headers_js_namespaceObject.addProperty)(properties, '$current_url', (0, external_url_utils_js_namespaceObject.normalizeRequestCurrentUrl)(req.originalUrl || req.url, disableCaptureUrlHashes));
|
|
54
56
|
(0, external_tracing_headers_js_namespaceObject.addProperty)(properties, '$request_method', req.method);
|
|
55
|
-
(0, external_tracing_headers_js_namespaceObject.addProperty)(properties, '$request_path', req.path);
|
|
57
|
+
(0, external_tracing_headers_js_namespaceObject.addProperty)(properties, '$request_path', (0, external_url_utils_js_namespaceObject.normalizeRequestPath)(req.path, disableCaptureUrlHashes));
|
|
56
58
|
(0, external_tracing_headers_js_namespaceObject.addProperty)(properties, '$user_agent', (0, external_tracing_headers_js_namespaceObject.getFirstHeaderValue)(req.headers['user-agent']));
|
|
57
59
|
(0, external_tracing_headers_js_namespaceObject.addProperty)(properties, '$ip', getClientIp(req));
|
|
58
60
|
return {
|
|
@@ -70,7 +72,7 @@ function setupExpressRequestContext(_posthog, app) {
|
|
|
70
72
|
}
|
|
71
73
|
function posthogRequestContext(posthog) {
|
|
72
74
|
return (req, _res, next)=>{
|
|
73
|
-
posthog.withContext(buildRequestContextData(req), ()=>next());
|
|
75
|
+
posthog.withContext(buildRequestContextData(posthog, req), ()=>next());
|
|
74
76
|
};
|
|
75
77
|
}
|
|
76
78
|
function setupExpressErrorHandler(_posthog, app) {
|
|
@@ -79,7 +81,7 @@ function setupExpressErrorHandler(_posthog, app) {
|
|
|
79
81
|
function posthogErrorHandler(posthog) {
|
|
80
82
|
return (error, req, res, next)=>{
|
|
81
83
|
if (index_js_default().isPreviouslyCapturedError(error)) return void next(error);
|
|
82
|
-
const contextData = buildRequestContextData(req);
|
|
84
|
+
const contextData = buildRequestContextData(posthog, req);
|
|
83
85
|
const syntheticException = new Error('Synthetic exception');
|
|
84
86
|
const hint = {
|
|
85
87
|
mechanism: {
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import error_tracking from "./error-tracking/index.mjs";
|
|
2
2
|
import { addProperty, getFirstHeaderValue, getPostHogTracingHeaderValues } from "./tracing-headers.mjs";
|
|
3
|
+
import { normalizeRequestCurrentUrl, normalizeRequestPath } from "./url-utils.mjs";
|
|
3
4
|
function getClientIp(req) {
|
|
4
5
|
const forwarded = getFirstHeaderValue(req.headers['x-forwarded-for']);
|
|
5
6
|
if (forwarded) {
|
|
@@ -8,12 +9,13 @@ function getClientIp(req) {
|
|
|
8
9
|
}
|
|
9
10
|
return req.socket?.remoteAddress;
|
|
10
11
|
}
|
|
11
|
-
function buildRequestContextData(req) {
|
|
12
|
+
function buildRequestContextData(posthog, req) {
|
|
12
13
|
const { sessionId, distinctId } = getPostHogTracingHeaderValues(req.headers);
|
|
13
14
|
const properties = {};
|
|
14
|
-
|
|
15
|
+
const disableCaptureUrlHashes = true === posthog.options.disable_capture_url_hashes;
|
|
16
|
+
addProperty(properties, '$current_url', normalizeRequestCurrentUrl(req.originalUrl || req.url, disableCaptureUrlHashes));
|
|
15
17
|
addProperty(properties, '$request_method', req.method);
|
|
16
|
-
addProperty(properties, '$request_path', req.path);
|
|
18
|
+
addProperty(properties, '$request_path', normalizeRequestPath(req.path, disableCaptureUrlHashes));
|
|
17
19
|
addProperty(properties, '$user_agent', getFirstHeaderValue(req.headers['user-agent']));
|
|
18
20
|
addProperty(properties, '$ip', getClientIp(req));
|
|
19
21
|
return {
|
|
@@ -31,7 +33,7 @@ function setupExpressRequestContext(_posthog, app) {
|
|
|
31
33
|
}
|
|
32
34
|
function posthogRequestContext(posthog) {
|
|
33
35
|
return (req, _res, next)=>{
|
|
34
|
-
posthog.withContext(buildRequestContextData(req), ()=>next());
|
|
36
|
+
posthog.withContext(buildRequestContextData(posthog, req), ()=>next());
|
|
35
37
|
};
|
|
36
38
|
}
|
|
37
39
|
function setupExpressErrorHandler(_posthog, app) {
|
|
@@ -40,7 +42,7 @@ function setupExpressErrorHandler(_posthog, app) {
|
|
|
40
42
|
function posthogErrorHandler(posthog) {
|
|
41
43
|
return (error, req, res, next)=>{
|
|
42
44
|
if (error_tracking.isPreviouslyCapturedError(error)) return void next(error);
|
|
43
|
-
const contextData = buildRequestContextData(req);
|
|
45
|
+
const contextData = buildRequestContextData(posthog, req);
|
|
44
46
|
const syntheticException = new Error('Synthetic exception');
|
|
45
47
|
const hint = {
|
|
46
48
|
mechanism: {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"nestjs.d.ts","sourceRoot":"","sources":["../../src/extensions/nestjs.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,UAAU,EAAc,MAAM,MAAM,CAAA;
|
|
1
|
+
{"version":3,"file":"nestjs.d.ts","sourceRoot":"","sources":["../../src/extensions/nestjs.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,UAAU,EAAc,MAAM,MAAM,CAAA;AAM7C,OAAO,EAAE,oBAAoB,EAAE,MAAM,WAAW,CAAA;AAGhD,UAAU,iBAAiB;IACzB,UAAU,CAAC,CAAC,GAAG,GAAG,KAAK,CAAC,CAAA;IACxB,WAAW,CAAC,CAAC,GAAG,GAAG,KAAK,CAAC,CAAA;CAC1B;AAED,UAAU,gBAAgB;IACxB,YAAY,IAAI,iBAAiB,CAAA;CAClC;AAED,UAAU,WAAW,CAAC,CAAC,GAAG,GAAG;IAC3B,MAAM,IAAI,UAAU,CAAC,CAAC,CAAC,CAAA;CACxB;AAED,UAAU,eAAe,CAAC,CAAC,GAAG,GAAG,EAAE,CAAC,GAAG,GAAG;IACxC,SAAS,CAAC,OAAO,EAAE,gBAAgB,EAAE,IAAI,EAAE,WAAW,CAAC,CAAC,CAAC,GAAG,UAAU,CAAC,CAAC,CAAC,CAAA;CAC1E;AAED,MAAM,WAAW,uBAAuB;IACtC,+GAA+G;IAC/G,kBAAkB,CAAC,EAAE,MAAM,CAAA;CAC5B;AAED,MAAM,WAAW,yBAAyB;IACxC,mGAAmG;IACnG,iBAAiB,CAAC,EAAE,OAAO,GAAG,uBAAuB,CAAA;CACtD;AAwBD,qBAAa,kBAAmB,YAAW,eAAe;IACxD,OAAO,CAAC,OAAO,CAAsB;IACrC,OAAO,CAAC,iBAAiB,CAAS;IAClC,OAAO,CAAC,kBAAkB,CAAQ;gBAEtB,OAAO,EAAE,oBAAoB,EAAE,OAAO,CAAC,EAAE,yBAAyB;IAO9E,SAAS,CAAC,OAAO,EAAE,gBAAgB,EAAE,IAAI,EAAE,WAAW,GAAG,UAAU,CAAC,GAAG,CAAC;CAoDzE"}
|
|
@@ -40,6 +40,7 @@ const operators_namespaceObject = require("rxjs/operators");
|
|
|
40
40
|
const index_js_namespaceObject = require("./error-tracking/index.js");
|
|
41
41
|
var index_js_default = /*#__PURE__*/ __webpack_require__.n(index_js_namespaceObject);
|
|
42
42
|
const external_tracing_headers_js_namespaceObject = require("./tracing-headers.js");
|
|
43
|
+
const external_url_utils_js_namespaceObject = require("./url-utils.js");
|
|
43
44
|
function getClientIp(headers, request) {
|
|
44
45
|
const forwarded = (0, external_tracing_headers_js_namespaceObject.getFirstHeaderValue)(headers['x-forwarded-for']);
|
|
45
46
|
if (forwarded) {
|
|
@@ -68,9 +69,10 @@ class PostHogInterceptor {
|
|
|
68
69
|
const headers = request?.headers ?? {};
|
|
69
70
|
const { sessionId, distinctId } = (0, external_tracing_headers_js_namespaceObject.getPostHogTracingHeaderValues)(headers);
|
|
70
71
|
const properties = {};
|
|
71
|
-
|
|
72
|
+
const disableCaptureUrlHashes = true === this.posthog.options.disable_capture_url_hashes;
|
|
73
|
+
(0, external_tracing_headers_js_namespaceObject.addProperty)(properties, '$current_url', (0, external_url_utils_js_namespaceObject.normalizeRequestCurrentUrl)(request?.url, disableCaptureUrlHashes));
|
|
72
74
|
(0, external_tracing_headers_js_namespaceObject.addProperty)(properties, '$request_method', request?.method);
|
|
73
|
-
(0, external_tracing_headers_js_namespaceObject.addProperty)(properties, '$request_path', request?.path ?? request?.url);
|
|
75
|
+
(0, external_tracing_headers_js_namespaceObject.addProperty)(properties, '$request_path', (0, external_url_utils_js_namespaceObject.normalizeRequestPath)(request?.path ?? request?.url, disableCaptureUrlHashes));
|
|
74
76
|
(0, external_tracing_headers_js_namespaceObject.addProperty)(properties, '$user_agent', (0, external_tracing_headers_js_namespaceObject.getFirstHeaderValue)(headers['user-agent']));
|
|
75
77
|
(0, external_tracing_headers_js_namespaceObject.addProperty)(properties, '$ip', getClientIp(headers, request));
|
|
76
78
|
const contextData = {
|
|
@@ -2,6 +2,7 @@ import { throwError } from "rxjs";
|
|
|
2
2
|
import { catchError } from "rxjs/operators";
|
|
3
3
|
import error_tracking from "./error-tracking/index.mjs";
|
|
4
4
|
import { addProperty, getFirstHeaderValue, getPostHogTracingHeaderValues } from "./tracing-headers.mjs";
|
|
5
|
+
import { normalizeRequestCurrentUrl, normalizeRequestPath } from "./url-utils.mjs";
|
|
5
6
|
function getClientIp(headers, request) {
|
|
6
7
|
const forwarded = getFirstHeaderValue(headers['x-forwarded-for']);
|
|
7
8
|
if (forwarded) {
|
|
@@ -30,9 +31,10 @@ class PostHogInterceptor {
|
|
|
30
31
|
const headers = request?.headers ?? {};
|
|
31
32
|
const { sessionId, distinctId } = getPostHogTracingHeaderValues(headers);
|
|
32
33
|
const properties = {};
|
|
33
|
-
|
|
34
|
+
const disableCaptureUrlHashes = true === this.posthog.options.disable_capture_url_hashes;
|
|
35
|
+
addProperty(properties, '$current_url', normalizeRequestCurrentUrl(request?.url, disableCaptureUrlHashes));
|
|
34
36
|
addProperty(properties, '$request_method', request?.method);
|
|
35
|
-
addProperty(properties, '$request_path', request?.path ?? request?.url);
|
|
37
|
+
addProperty(properties, '$request_path', normalizeRequestPath(request?.path ?? request?.url, disableCaptureUrlHashes));
|
|
36
38
|
addProperty(properties, '$user_agent', getFirstHeaderValue(headers['user-agent']));
|
|
37
39
|
addProperty(properties, '$ip', getClientIp(headers, request));
|
|
38
40
|
const contextData = {
|
|
@@ -4,6 +4,9 @@
|
|
|
4
4
|
/**
|
|
5
5
|
* Integrate Sentry with PostHog. This will add a direct link to the person in Sentry, and an $exception event in PostHog.
|
|
6
6
|
*
|
|
7
|
+
* @deprecated This integration is deprecated and will be removed in a future major version. Use PostHog Error Tracking for Node instead:
|
|
8
|
+
* https://posthog.com/docs/error-tracking/installation/node
|
|
9
|
+
*
|
|
7
10
|
* ### Usage
|
|
8
11
|
*
|
|
9
12
|
* Sentry.init({
|
|
@@ -42,8 +45,26 @@ export type SentryIntegrationOptions = {
|
|
|
42
45
|
severityAllowList?: CoreErrorTracking.SeverityLevel[] | '*';
|
|
43
46
|
sendExceptionsToPostHog?: boolean;
|
|
44
47
|
};
|
|
48
|
+
/**
|
|
49
|
+
* Creates an event processor for the deprecated Sentry integration.
|
|
50
|
+
*
|
|
51
|
+
* @deprecated This integration is deprecated and will be removed in a future major version. Use PostHog Error Tracking for Node instead:
|
|
52
|
+
* https://posthog.com/docs/error-tracking/installation/node
|
|
53
|
+
*/
|
|
45
54
|
export declare function createEventProcessor(_posthog: PostHogBackendClient, { organization, projectId, prefix, severityAllowList, sendExceptionsToPostHog, }?: SentryIntegrationOptions): (event: _SentryEvent) => _SentryEvent;
|
|
55
|
+
/**
|
|
56
|
+
* Creates the function-based Sentry integration.
|
|
57
|
+
*
|
|
58
|
+
* @deprecated This integration is deprecated and will be removed in a future major version. Use PostHog Error Tracking for Node instead:
|
|
59
|
+
* https://posthog.com/docs/error-tracking/installation/node
|
|
60
|
+
*/
|
|
46
61
|
export declare function sentryIntegration(_posthog: PostHogBackendClient, options?: SentryIntegrationOptions): _SentryIntegration;
|
|
62
|
+
/**
|
|
63
|
+
* Class-based Sentry integration.
|
|
64
|
+
*
|
|
65
|
+
* @deprecated This integration is deprecated and will be removed in a future major version. Use PostHog Error Tracking for Node instead:
|
|
66
|
+
* https://posthog.com/docs/error-tracking/installation/node
|
|
67
|
+
*/
|
|
47
68
|
export declare class PostHogSentryIntegration implements _SentryIntegrationClass {
|
|
48
69
|
readonly name = "posthog-node";
|
|
49
70
|
static readonly POSTHOG_ID_TAG = "posthog_distinct_id";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sentry-integration.d.ts","sourceRoot":"","sources":["../../src/extensions/sentry-integration.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH
|
|
1
|
+
{"version":3,"file":"sentry-integration.d.ts","sourceRoot":"","sources":["../../src/extensions/sentry-integration.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AAEH,OAAO,EAAE,aAAa,IAAI,iBAAiB,EAAE,MAAM,eAAe,CAAA;AAClE,OAAO,EAAE,KAAK,oBAAoB,EAAE,MAAM,WAAW,CAAA;AAiBrD,KAAK,YAAY,GAAG,GAAG,CAAA;AACvB,KAAK,qBAAqB,GAAG,GAAG,CAAA;AAEhC,KAAK,UAAU,GAAG,GAAG,CAAA;AAGrB,UAAU,kBAAkB;IAC1B,IAAI,EAAE,MAAM,CAAA;IACZ,YAAY,CAAC,KAAK,EAAE,YAAY,GAAG,YAAY,CAAA;CAChD;AAED,UAAU,uBAAuB;IAC/B,IAAI,EAAE,MAAM,CAAA;IACZ,SAAS,CAAC,uBAAuB,EAAE,CAAC,QAAQ,EAAE,qBAAqB,KAAK,IAAI,EAAE,aAAa,EAAE,MAAM,UAAU,GAAG,IAAI,CAAA;CACrH;AAWD,MAAM,MAAM,wBAAwB,GAAG;IACrC,YAAY,CAAC,EAAE,MAAM,CAAA;IACrB,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,iBAAiB,CAAC,EAAE,iBAAiB,CAAC,aAAa,EAAE,GAAG,GAAG,CAAA;IAC3D,uBAAuB,CAAC,EAAE,OAAO,CAAA;CAClC,CAAA;AAID;;;;;GAKG;AACH,wBAAgB,oBAAoB,CAClC,QAAQ,EAAE,oBAAoB,EAC9B,EACE,YAAY,EACZ,SAAS,EACT,MAAM,EACN,iBAA6B,EAC7B,uBAA8B,GAC/B,GAAE,wBAA6B,GAC/B,CAAC,KAAK,EAAE,YAAY,KAAK,YAAY,CA0EvC;AAGD;;;;;GAKG;AACH,wBAAgB,iBAAiB,CAC/B,QAAQ,EAAE,oBAAoB,EAC9B,OAAO,CAAC,EAAE,wBAAwB,GACjC,kBAAkB,CAQpB;AAGD;;;;;GAKG;AACH,qBAAa,wBAAyB,YAAW,uBAAuB;IACtE,SAAgB,IAAI,kBAAO;IAE3B,gBAAuB,cAAc,yBAAwB;IAEtD,SAAS,EAAE,CAChB,uBAAuB,EAAE,CAAC,QAAQ,EAAE,qBAAqB,KAAK,IAAI,EAClE,aAAa,EAAE,MAAM,UAAU,KAC5B,IAAI,CAAA;gBAGP,QAAQ,EAAE,oBAAoB,EAC9B,YAAY,CAAC,EAAE,MAAM,EACrB,MAAM,CAAC,EAAE,MAAM,EACf,iBAAiB,CAAC,EAAE,iBAAiB,CAAC,aAAa,EAAE,GAAG,GAAG,EAC3D,uBAAuB,CAAC,EAAE,OAAO;CAoBpC"}
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
export declare function normalizeRequestCurrentUrl(currentUrl: string | undefined, disableCaptureUrlHashes: boolean): string | undefined;
|
|
2
|
+
export declare function normalizeRequestPath(path: string | undefined, disableCaptureUrlHashes: boolean): string | undefined;
|
|
3
|
+
//# sourceMappingURL=url-utils.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"url-utils.d.ts","sourceRoot":"","sources":["../../src/extensions/url-utils.ts"],"names":[],"mappings":"AAEA,wBAAgB,0BAA0B,CACxC,UAAU,EAAE,MAAM,GAAG,SAAS,EAC9B,uBAAuB,EAAE,OAAO,GAC/B,MAAM,GAAG,SAAS,CAEpB;AAED,wBAAgB,oBAAoB,CAAC,IAAI,EAAE,MAAM,GAAG,SAAS,EAAE,uBAAuB,EAAE,OAAO,GAAG,MAAM,GAAG,SAAS,CAGnH"}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __webpack_require__ = {};
|
|
3
|
+
(()=>{
|
|
4
|
+
__webpack_require__.d = (exports1, definition)=>{
|
|
5
|
+
for(var key in definition)if (__webpack_require__.o(definition, key) && !__webpack_require__.o(exports1, key)) Object.defineProperty(exports1, key, {
|
|
6
|
+
enumerable: true,
|
|
7
|
+
get: definition[key]
|
|
8
|
+
});
|
|
9
|
+
};
|
|
10
|
+
})();
|
|
11
|
+
(()=>{
|
|
12
|
+
__webpack_require__.o = (obj, prop)=>Object.prototype.hasOwnProperty.call(obj, prop);
|
|
13
|
+
})();
|
|
14
|
+
(()=>{
|
|
15
|
+
__webpack_require__.r = (exports1)=>{
|
|
16
|
+
if ('undefined' != typeof Symbol && Symbol.toStringTag) Object.defineProperty(exports1, Symbol.toStringTag, {
|
|
17
|
+
value: 'Module'
|
|
18
|
+
});
|
|
19
|
+
Object.defineProperty(exports1, '__esModule', {
|
|
20
|
+
value: true
|
|
21
|
+
});
|
|
22
|
+
};
|
|
23
|
+
})();
|
|
24
|
+
var __webpack_exports__ = {};
|
|
25
|
+
__webpack_require__.r(__webpack_exports__);
|
|
26
|
+
__webpack_require__.d(__webpack_exports__, {
|
|
27
|
+
normalizeRequestPath: ()=>normalizeRequestPath,
|
|
28
|
+
normalizeRequestCurrentUrl: ()=>normalizeRequestCurrentUrl
|
|
29
|
+
});
|
|
30
|
+
const core_namespaceObject = require("@posthog/core");
|
|
31
|
+
function normalizeRequestCurrentUrl(currentUrl, disableCaptureUrlHashes) {
|
|
32
|
+
return disableCaptureUrlHashes ? (0, core_namespaceObject.stripUrlHash)(currentUrl) : currentUrl;
|
|
33
|
+
}
|
|
34
|
+
function normalizeRequestPath(path, disableCaptureUrlHashes) {
|
|
35
|
+
const pathWithoutSearch = stripUrlSearch(path);
|
|
36
|
+
return disableCaptureUrlHashes ? (0, core_namespaceObject.stripUrlHash)(pathWithoutSearch) : pathWithoutSearch;
|
|
37
|
+
}
|
|
38
|
+
function stripUrlSearch(url) {
|
|
39
|
+
if (!url) return url;
|
|
40
|
+
const searchIndex = url.indexOf('?');
|
|
41
|
+
const hashIndex = url.indexOf('#');
|
|
42
|
+
if (-1 === searchIndex || -1 !== hashIndex && hashIndex < searchIndex) return url;
|
|
43
|
+
return `${url.slice(0, searchIndex)}${-1 === hashIndex ? '' : url.slice(hashIndex)}`;
|
|
44
|
+
}
|
|
45
|
+
exports.normalizeRequestCurrentUrl = __webpack_exports__.normalizeRequestCurrentUrl;
|
|
46
|
+
exports.normalizeRequestPath = __webpack_exports__.normalizeRequestPath;
|
|
47
|
+
for(var __webpack_i__ in __webpack_exports__)if (-1 === [
|
|
48
|
+
"normalizeRequestCurrentUrl",
|
|
49
|
+
"normalizeRequestPath"
|
|
50
|
+
].indexOf(__webpack_i__)) exports[__webpack_i__] = __webpack_exports__[__webpack_i__];
|
|
51
|
+
Object.defineProperty(exports, '__esModule', {
|
|
52
|
+
value: true
|
|
53
|
+
});
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { stripUrlHash } from "@posthog/core";
|
|
2
|
+
function normalizeRequestCurrentUrl(currentUrl, disableCaptureUrlHashes) {
|
|
3
|
+
return disableCaptureUrlHashes ? stripUrlHash(currentUrl) : currentUrl;
|
|
4
|
+
}
|
|
5
|
+
function normalizeRequestPath(path, disableCaptureUrlHashes) {
|
|
6
|
+
const pathWithoutSearch = stripUrlSearch(path);
|
|
7
|
+
return disableCaptureUrlHashes ? stripUrlHash(pathWithoutSearch) : pathWithoutSearch;
|
|
8
|
+
}
|
|
9
|
+
function stripUrlSearch(url) {
|
|
10
|
+
if (!url) return url;
|
|
11
|
+
const searchIndex = url.indexOf('?');
|
|
12
|
+
const hashIndex = url.indexOf('#');
|
|
13
|
+
if (-1 === searchIndex || -1 !== hashIndex && hashIndex < searchIndex) return url;
|
|
14
|
+
return `${url.slice(0, searchIndex)}${-1 === hashIndex ? '' : url.slice(hashIndex)}`;
|
|
15
|
+
}
|
|
16
|
+
export { normalizeRequestCurrentUrl, normalizeRequestPath };
|
package/dist/version.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export declare const version = "5.38.
|
|
1
|
+
export declare const version = "5.38.4";
|
|
2
2
|
//# sourceMappingURL=version.d.ts.map
|
package/dist/version.js
CHANGED
|
@@ -26,7 +26,7 @@ __webpack_require__.r(__webpack_exports__);
|
|
|
26
26
|
__webpack_require__.d(__webpack_exports__, {
|
|
27
27
|
version: ()=>version
|
|
28
28
|
});
|
|
29
|
-
const version = '5.38.
|
|
29
|
+
const version = '5.38.4';
|
|
30
30
|
exports.version = __webpack_exports__.version;
|
|
31
31
|
for(var __webpack_i__ in __webpack_exports__)if (-1 === [
|
|
32
32
|
"version"
|
package/dist/version.mjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
const version = '5.38.
|
|
1
|
+
const version = '5.38.4';
|
|
2
2
|
export { version };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "posthog-node",
|
|
3
|
-
"version": "5.38.
|
|
3
|
+
"version": "5.38.4",
|
|
4
4
|
"bugs": {
|
|
5
5
|
"url": "https://github.com/PostHog/posthog-js/issues"
|
|
6
6
|
},
|
|
@@ -28,7 +28,7 @@
|
|
|
28
28
|
"module": "dist/entrypoints/index.node.mjs",
|
|
29
29
|
"types": "dist/entrypoints/index.node.d.ts",
|
|
30
30
|
"dependencies": {
|
|
31
|
-
"@posthog/core": "^1.
|
|
31
|
+
"@posthog/core": "^1.37.1"
|
|
32
32
|
},
|
|
33
33
|
"devDependencies": {
|
|
34
34
|
"@edge-runtime/jest-environment": "^4.0.0",
|
|
@@ -2,6 +2,7 @@ import ErrorTracking from './error-tracking'
|
|
|
2
2
|
import { PostHogBackendClient } from '../client'
|
|
3
3
|
import { ErrorTracking as CoreErrorTracking } from '@posthog/core'
|
|
4
4
|
import { addProperty, getFirstHeaderValue, getPostHogTracingHeaderValues } from './tracing-headers'
|
|
5
|
+
import { normalizeRequestCurrentUrl, normalizeRequestPath } from './url-utils'
|
|
5
6
|
import type { Request, Response } from 'express'
|
|
6
7
|
import type { ContextData } from './context/types'
|
|
7
8
|
|
|
@@ -32,13 +33,18 @@ function getClientIp(req: Request): string | undefined {
|
|
|
32
33
|
return req.socket?.remoteAddress
|
|
33
34
|
}
|
|
34
35
|
|
|
35
|
-
function buildRequestContextData(req: Request): Partial<ContextData> {
|
|
36
|
+
function buildRequestContextData(posthog: PostHogBackendClient, req: Request): Partial<ContextData> {
|
|
36
37
|
const { sessionId, distinctId } = getPostHogTracingHeaderValues(req.headers)
|
|
37
38
|
const properties: Record<string, any> = {}
|
|
39
|
+
const disableCaptureUrlHashes = posthog.options.disable_capture_url_hashes === true
|
|
38
40
|
|
|
39
|
-
addProperty(
|
|
41
|
+
addProperty(
|
|
42
|
+
properties,
|
|
43
|
+
'$current_url',
|
|
44
|
+
normalizeRequestCurrentUrl(req.originalUrl || req.url, disableCaptureUrlHashes)
|
|
45
|
+
)
|
|
40
46
|
addProperty(properties, '$request_method', req.method)
|
|
41
|
-
addProperty(properties, '$request_path', req.path)
|
|
47
|
+
addProperty(properties, '$request_path', normalizeRequestPath(req.path, disableCaptureUrlHashes))
|
|
42
48
|
addProperty(properties, '$user_agent', getFirstHeaderValue(req.headers['user-agent']))
|
|
43
49
|
addProperty(properties, '$ip', getClientIp(req))
|
|
44
50
|
|
|
@@ -60,7 +66,7 @@ export function setupExpressRequestContext(
|
|
|
60
66
|
|
|
61
67
|
function posthogRequestContext(posthog: PostHogBackendClient): ExpressMiddleware {
|
|
62
68
|
return (req, _res, next): void => {
|
|
63
|
-
posthog.withContext(buildRequestContextData(req), () => next())
|
|
69
|
+
posthog.withContext(buildRequestContextData(posthog, req), () => next())
|
|
64
70
|
}
|
|
65
71
|
}
|
|
66
72
|
|
|
@@ -80,7 +86,7 @@ function posthogErrorHandler(posthog: PostHogBackendClient): ExpressErrorMiddlew
|
|
|
80
86
|
return
|
|
81
87
|
}
|
|
82
88
|
|
|
83
|
-
const contextData = buildRequestContextData(req)
|
|
89
|
+
const contextData = buildRequestContextData(posthog, req)
|
|
84
90
|
const syntheticException = new Error('Synthetic exception')
|
|
85
91
|
const hint: CoreErrorTracking.EventHint = { mechanism: { type: 'middleware', handled: false }, syntheticException }
|
|
86
92
|
const additionalProperties: Record<string, any> = {
|
package/src/extensions/nestjs.ts
CHANGED
|
@@ -4,6 +4,7 @@ import { catchError } from 'rxjs/operators'
|
|
|
4
4
|
|
|
5
5
|
import ErrorTracking from './error-tracking'
|
|
6
6
|
import { addProperty, getFirstHeaderValue, getPostHogTracingHeaderValues } from './tracing-headers'
|
|
7
|
+
import { normalizeRequestCurrentUrl, normalizeRequestPath } from './url-utils'
|
|
7
8
|
import { PostHogBackendClient } from '../client'
|
|
8
9
|
|
|
9
10
|
// Local interfaces to avoid runtime dependency on @nestjs/common
|
|
@@ -77,9 +78,14 @@ export class PostHogInterceptor implements NestInterceptor {
|
|
|
77
78
|
const { sessionId, distinctId } = getPostHogTracingHeaderValues(headers)
|
|
78
79
|
|
|
79
80
|
const properties: Record<string, any> = {}
|
|
80
|
-
|
|
81
|
+
const disableCaptureUrlHashes = this.posthog.options.disable_capture_url_hashes === true
|
|
82
|
+
addProperty(properties, '$current_url', normalizeRequestCurrentUrl(request?.url, disableCaptureUrlHashes))
|
|
81
83
|
addProperty(properties, '$request_method', request?.method)
|
|
82
|
-
addProperty(
|
|
84
|
+
addProperty(
|
|
85
|
+
properties,
|
|
86
|
+
'$request_path',
|
|
87
|
+
normalizeRequestPath(request?.path ?? request?.url, disableCaptureUrlHashes)
|
|
88
|
+
)
|
|
83
89
|
addProperty(properties, '$user_agent', getFirstHeaderValue(headers['user-agent']))
|
|
84
90
|
addProperty(properties, '$ip', getClientIp(headers, request))
|
|
85
91
|
|
|
@@ -4,6 +4,9 @@
|
|
|
4
4
|
/**
|
|
5
5
|
* Integrate Sentry with PostHog. This will add a direct link to the person in Sentry, and an $exception event in PostHog.
|
|
6
6
|
*
|
|
7
|
+
* @deprecated This integration is deprecated and will be removed in a future major version. Use PostHog Error Tracking for Node instead:
|
|
8
|
+
* https://posthog.com/docs/error-tracking/installation/node
|
|
9
|
+
*
|
|
7
10
|
* ### Usage
|
|
8
11
|
*
|
|
9
12
|
* Sentry.init({
|
|
@@ -76,6 +79,12 @@ export type SentryIntegrationOptions = {
|
|
|
76
79
|
|
|
77
80
|
const NAME = 'posthog-node'
|
|
78
81
|
|
|
82
|
+
/**
|
|
83
|
+
* Creates an event processor for the deprecated Sentry integration.
|
|
84
|
+
*
|
|
85
|
+
* @deprecated This integration is deprecated and will be removed in a future major version. Use PostHog Error Tracking for Node instead:
|
|
86
|
+
* https://posthog.com/docs/error-tracking/installation/node
|
|
87
|
+
*/
|
|
79
88
|
export function createEventProcessor(
|
|
80
89
|
_posthog: PostHogBackendClient,
|
|
81
90
|
{
|
|
@@ -162,6 +171,12 @@ export function createEventProcessor(
|
|
|
162
171
|
}
|
|
163
172
|
|
|
164
173
|
// V8 integration - function based
|
|
174
|
+
/**
|
|
175
|
+
* Creates the function-based Sentry integration.
|
|
176
|
+
*
|
|
177
|
+
* @deprecated This integration is deprecated and will be removed in a future major version. Use PostHog Error Tracking for Node instead:
|
|
178
|
+
* https://posthog.com/docs/error-tracking/installation/node
|
|
179
|
+
*/
|
|
165
180
|
export function sentryIntegration(
|
|
166
181
|
_posthog: PostHogBackendClient,
|
|
167
182
|
options?: SentryIntegrationOptions
|
|
@@ -176,6 +191,12 @@ export function sentryIntegration(
|
|
|
176
191
|
}
|
|
177
192
|
|
|
178
193
|
// V7 integration - class based
|
|
194
|
+
/**
|
|
195
|
+
* Class-based Sentry integration.
|
|
196
|
+
*
|
|
197
|
+
* @deprecated This integration is deprecated and will be removed in a future major version. Use PostHog Error Tracking for Node instead:
|
|
198
|
+
* https://posthog.com/docs/error-tracking/installation/node
|
|
199
|
+
*/
|
|
179
200
|
export class PostHogSentryIntegration implements _SentryIntegrationClass {
|
|
180
201
|
public readonly name = NAME
|
|
181
202
|
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { stripUrlHash } from '@posthog/core'
|
|
2
|
+
|
|
3
|
+
export function normalizeRequestCurrentUrl(
|
|
4
|
+
currentUrl: string | undefined,
|
|
5
|
+
disableCaptureUrlHashes: boolean
|
|
6
|
+
): string | undefined {
|
|
7
|
+
return disableCaptureUrlHashes ? stripUrlHash(currentUrl) : currentUrl
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
export function normalizeRequestPath(path: string | undefined, disableCaptureUrlHashes: boolean): string | undefined {
|
|
11
|
+
const pathWithoutSearch = stripUrlSearch(path)
|
|
12
|
+
return disableCaptureUrlHashes ? stripUrlHash(pathWithoutSearch) : pathWithoutSearch
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
function stripUrlSearch<T extends string | undefined>(url: T): T extends string ? string : undefined {
|
|
16
|
+
if (!url) {
|
|
17
|
+
return url as any
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
const searchIndex = url.indexOf('?')
|
|
21
|
+
const hashIndex = url.indexOf('#')
|
|
22
|
+
if (searchIndex === -1 || (hashIndex !== -1 && hashIndex < searchIndex)) {
|
|
23
|
+
return url as any
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
return `${url.slice(0, searchIndex)}${hashIndex === -1 ? '' : url.slice(hashIndex)}` as any
|
|
27
|
+
}
|
package/src/version.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export const version = '5.38.
|
|
1
|
+
export const version = '5.38.4'
|