posthog-node 5.57.2 → 5.58.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.
- package/README.md +39 -0
- package/dist/client.d.ts.map +1 -1
- package/dist/client.js +10 -4
- package/dist/client.mjs +10 -4
- package/dist/entrypoints/otel.d.ts +18 -0
- package/dist/entrypoints/otel.d.ts.map +1 -0
- package/dist/entrypoints/otel.js +99 -0
- package/dist/entrypoints/otel.mjs +58 -0
- package/dist/exports.d.ts +1 -0
- package/dist/exports.d.ts.map +1 -1
- package/dist/exports.js +30 -20
- package/dist/exports.mjs +1 -0
- package/dist/extensions/context/context.d.ts.map +1 -1
- package/dist/extensions/context/context.js +12 -8
- package/dist/extensions/context/context.mjs +12 -8
- package/dist/extensions/context/event-context.d.ts +5 -0
- package/dist/extensions/context/event-context.d.ts.map +1 -0
- package/dist/extensions/context/event-context.js +57 -0
- package/dist/extensions/context/event-context.mjs +16 -0
- package/dist/extensions/context/lifetime.d.ts +8 -0
- package/dist/extensions/context/lifetime.d.ts.map +1 -0
- package/dist/extensions/context/lifetime.js +60 -0
- package/dist/extensions/context/lifetime.mjs +19 -0
- package/dist/extensions/context/listeners.d.ts +11 -0
- package/dist/extensions/context/listeners.d.ts.map +1 -0
- package/dist/extensions/context/listeners.js +65 -0
- package/dist/extensions/context/listeners.mjs +21 -0
- package/dist/extensions/context/types.d.ts +5 -0
- package/dist/extensions/context/types.d.ts.map +1 -1
- package/dist/extensions/error-tracking/index.d.ts +2 -1
- package/dist/extensions/error-tracking/index.d.ts.map +1 -1
- package/dist/extensions/error-tracking/index.js +6 -4
- package/dist/extensions/error-tracking/index.mjs +6 -4
- package/dist/extensions/express.d.ts.map +1 -1
- package/dist/extensions/express.js +10 -3
- package/dist/extensions/express.mjs +10 -3
- package/dist/extensions/nestjs.d.ts.map +1 -1
- package/dist/extensions/nestjs.js +2 -0
- package/dist/extensions/nestjs.mjs +2 -0
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/dist/version.mjs +1 -1
- package/package.json +13 -6
- package/src/client.ts +16 -4
- package/src/entrypoints/otel.ts +75 -0
- package/src/exports.ts +1 -0
- package/src/extensions/context/context.ts +16 -10
- package/src/extensions/context/event-context.ts +14 -0
- package/src/extensions/context/lifetime.ts +28 -0
- package/src/extensions/context/listeners.ts +36 -0
- package/src/extensions/context/types.ts +5 -0
- package/src/extensions/error-tracking/index.ts +11 -4
- package/src/extensions/express.ts +11 -3
- package/src/extensions/nestjs.ts +2 -0
- package/src/version.ts +1 -1
package/src/client.ts
CHANGED
|
@@ -72,6 +72,8 @@ import ErrorTracking from './extensions/error-tracking'
|
|
|
72
72
|
import { getActiveTraceProperties } from './extensions/error-tracking/trace-context'
|
|
73
73
|
import { PostHogMemoryStorage } from './storage-memory'
|
|
74
74
|
import { ContextData, ContextOptions, IPostHogContext } from './extensions/context/types'
|
|
75
|
+
import { notifyContextListeners } from './extensions/context/listeners'
|
|
76
|
+
import { getEventContext } from './extensions/context/event-context'
|
|
75
77
|
import { type CaptureMode, resolveCaptureMode } from './capture-v1/config'
|
|
76
78
|
import { AI_ROUTE, ANALYTICS_ROUTE, isLegacyOnlyEvent } from './capture-v1/routing'
|
|
77
79
|
import { V1CaptureSender } from './capture-v1/sender'
|
|
@@ -2843,7 +2845,14 @@ export abstract class PostHogBackendClient extends PostHogCoreStateless implemen
|
|
|
2843
2845
|
return fn()
|
|
2844
2846
|
}
|
|
2845
2847
|
|
|
2846
|
-
return this.context.run(
|
|
2848
|
+
return this.context.run(
|
|
2849
|
+
data,
|
|
2850
|
+
() => {
|
|
2851
|
+
notifyContextListeners(this)
|
|
2852
|
+
return fn()
|
|
2853
|
+
},
|
|
2854
|
+
options
|
|
2855
|
+
)
|
|
2847
2856
|
}
|
|
2848
2857
|
|
|
2849
2858
|
/**
|
|
@@ -2882,6 +2891,7 @@ export abstract class PostHogBackendClient extends PostHogCoreStateless implemen
|
|
|
2882
2891
|
*/
|
|
2883
2892
|
enterContext(data: Partial<ContextData>, options?: ContextOptions): void {
|
|
2884
2893
|
this.context?.enter(data as ContextData, options)
|
|
2894
|
+
notifyContextListeners(this)
|
|
2885
2895
|
}
|
|
2886
2896
|
|
|
2887
2897
|
/**
|
|
@@ -3176,7 +3186,8 @@ export abstract class PostHogBackendClient extends PostHogCoreStateless implemen
|
|
|
3176
3186
|
error,
|
|
3177
3187
|
{ syntheticException },
|
|
3178
3188
|
distinctId,
|
|
3179
|
-
additionalProperties
|
|
3189
|
+
additionalProperties,
|
|
3190
|
+
this.getContext()
|
|
3180
3191
|
).then((msg) => this._capturePreparedEvent({ ...msg, uuid, flags }, false))
|
|
3181
3192
|
)
|
|
3182
3193
|
}
|
|
@@ -3232,7 +3243,8 @@ export abstract class PostHogBackendClient extends PostHogCoreStateless implemen
|
|
|
3232
3243
|
error,
|
|
3233
3244
|
{ syntheticException },
|
|
3234
3245
|
distinctId,
|
|
3235
|
-
additionalProperties
|
|
3246
|
+
additionalProperties,
|
|
3247
|
+
this.getContext()
|
|
3236
3248
|
).then((msg) => this.captureImmediate({ ...msg, flags }))
|
|
3237
3249
|
)
|
|
3238
3250
|
}
|
|
@@ -3268,7 +3280,7 @@ export abstract class PostHogBackendClient extends PostHogCoreStateless implemen
|
|
|
3268
3280
|
uuid,
|
|
3269
3281
|
}: EventMessage = props
|
|
3270
3282
|
|
|
3271
|
-
const contextData = this.context?.get()
|
|
3283
|
+
const contextData = getEventContext(props, this.context?.get())
|
|
3272
3284
|
const includeContextProperties = options.includeContextProperties ?? true
|
|
3273
3285
|
|
|
3274
3286
|
let mergedDistinctId = distinctId || contextData?.distinctId
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
import { trace, SpanKind, type Attributes, type Context, type Span } from '@opentelemetry/api'
|
|
2
|
+
import type { PostHogBackendClient } from '../client'
|
|
3
|
+
import { addContextListener } from '../extensions/context/listeners'
|
|
4
|
+
|
|
5
|
+
export { enrichCurrentSpan } from '../extensions/context/listeners'
|
|
6
|
+
|
|
7
|
+
type ReadableSpan = Span & { readonly attributes: Attributes }
|
|
8
|
+
|
|
9
|
+
function hasReadableAttributes(span: Span | undefined): span is ReadableSpan {
|
|
10
|
+
return !!span && 'attributes' in span && typeof span.attributes === 'object' && span.attributes !== null
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export class PostHogContextSpanProcessor {
|
|
14
|
+
private active = true
|
|
15
|
+
private readonly snapshots = new WeakSet<Span>()
|
|
16
|
+
private readonly parents = new WeakMap<Span, WeakRef<Span>>()
|
|
17
|
+
private readonly unsubscribe: () => void
|
|
18
|
+
|
|
19
|
+
constructor(private readonly posthog: PostHogBackendClient) {
|
|
20
|
+
this.unsubscribe = addContextListener(posthog, (requestEntry) => {
|
|
21
|
+
const span = trace.getActiveSpan()
|
|
22
|
+
this.enrich(span, requestEntry)
|
|
23
|
+
if (requestEntry) this.enrichNearestServerSpan(span)
|
|
24
|
+
})
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
private enrich(span: Span | undefined, requestEntry = false): void {
|
|
28
|
+
if (!this.active) return
|
|
29
|
+
try {
|
|
30
|
+
if (this.posthog.isDisabled || this.posthog.optedOut) return
|
|
31
|
+
if (!hasReadableAttributes(span) || !span.isRecording() || (this.snapshots.has(span) && !requestEntry)) return
|
|
32
|
+
const context = this.posthog.getContext()
|
|
33
|
+
if (!context) return
|
|
34
|
+
this.snapshots.add(span)
|
|
35
|
+
if (context.sessionId && span.attributes.sessionId === undefined) {
|
|
36
|
+
span.setAttribute('sessionId', context.sessionId)
|
|
37
|
+
}
|
|
38
|
+
if (context.distinctId && span.attributes.posthogDistinctId === undefined) {
|
|
39
|
+
span.setAttribute('posthogDistinctId', context.distinctId)
|
|
40
|
+
}
|
|
41
|
+
} catch {}
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
private enrichNearestServerSpan(current: Span | undefined): void {
|
|
45
|
+
let span = current
|
|
46
|
+
while (span) {
|
|
47
|
+
if ('kind' in span && span.kind === SpanKind.SERVER && span.isRecording()) {
|
|
48
|
+
if (span !== current) this.enrich(span, true)
|
|
49
|
+
return
|
|
50
|
+
}
|
|
51
|
+
span = this.parents.get(span)?.deref()
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
onStart(span: Span, parentContext?: Context): void {
|
|
56
|
+
if (!this.active) return
|
|
57
|
+
const parent = parentContext && trace.getSpan(parentContext)
|
|
58
|
+
if (parent && parent !== span) this.parents.set(span, new WeakRef(parent))
|
|
59
|
+
this.enrich(span)
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
onEnd(): void {}
|
|
63
|
+
|
|
64
|
+
forceFlush(): Promise<void> {
|
|
65
|
+
return Promise.resolve()
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
shutdown(): Promise<void> {
|
|
69
|
+
if (this.active) {
|
|
70
|
+
this.active = false
|
|
71
|
+
this.unsubscribe()
|
|
72
|
+
}
|
|
73
|
+
return Promise.resolve()
|
|
74
|
+
}
|
|
75
|
+
}
|
package/src/exports.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
export * from './extensions/sentry-integration'
|
|
2
2
|
export * from './extensions/express'
|
|
3
3
|
export * from './types'
|
|
4
|
+
export { enrichCurrentSpan } from './extensions/context/listeners'
|
|
4
5
|
|
|
5
6
|
export { FeatureFlagEvaluations } from './feature-flag-evaluations'
|
|
6
7
|
export type {
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { AsyncLocalStorage } from 'node:async_hooks'
|
|
2
2
|
import { ContextData, ContextOptions, IPostHogContext } from './types'
|
|
3
|
+
import { inheritContextLifetime, isContextActive } from './lifetime'
|
|
3
4
|
|
|
4
5
|
export class PostHogContext implements IPostHogContext {
|
|
5
6
|
private storage: AsyncLocalStorage<ContextData>
|
|
@@ -9,7 +10,8 @@ export class PostHogContext implements IPostHogContext {
|
|
|
9
10
|
}
|
|
10
11
|
|
|
11
12
|
get(): ContextData | undefined {
|
|
12
|
-
|
|
13
|
+
const context = this.storage.getStore()
|
|
14
|
+
return context && isContextActive(context) ? context : undefined
|
|
13
15
|
}
|
|
14
16
|
|
|
15
17
|
run<T>(context: ContextData, fn: () => T, options?: ContextOptions): T {
|
|
@@ -21,18 +23,22 @@ export class PostHogContext implements IPostHogContext {
|
|
|
21
23
|
}
|
|
22
24
|
|
|
23
25
|
private resolve(context: ContextData, options?: ContextOptions): ContextData {
|
|
26
|
+
const current = this.get()
|
|
24
27
|
if (options?.fresh === true) {
|
|
25
|
-
return context
|
|
28
|
+
return inheritContextLifetime(undefined, { ...context }, options.signal)
|
|
26
29
|
}
|
|
27
30
|
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
31
|
+
return inheritContextLifetime(
|
|
32
|
+
current,
|
|
33
|
+
{
|
|
34
|
+
distinctId: context.distinctId ?? current?.distinctId,
|
|
35
|
+
sessionId: context.sessionId ?? current?.sessionId,
|
|
36
|
+
properties: {
|
|
37
|
+
...(current?.properties || {}),
|
|
38
|
+
...(context.properties || {}),
|
|
39
|
+
},
|
|
35
40
|
},
|
|
36
|
-
|
|
41
|
+
options?.signal
|
|
42
|
+
)
|
|
37
43
|
}
|
|
38
44
|
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { EventMessage } from '../../types'
|
|
2
|
+
import type { ContextData } from './types'
|
|
3
|
+
|
|
4
|
+
const capturedContext = Symbol('capturedContext')
|
|
5
|
+
type ContextEvent = EventMessage & { [capturedContext]?: ContextData | null }
|
|
6
|
+
|
|
7
|
+
export function snapshotEventContext(context: ContextData | undefined): (event: EventMessage) => EventMessage {
|
|
8
|
+
const snapshot = context ? { ...context, properties: { ...context.properties } } : null
|
|
9
|
+
return (event) => Object.assign(event, { [capturedContext]: snapshot })
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export function getEventContext(event: EventMessage, fallback: ContextData | undefined): ContextData | undefined {
|
|
13
|
+
return capturedContext in event ? ((event as ContextEvent)[capturedContext] ?? undefined) : fallback
|
|
14
|
+
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import type { ContextData } from './types'
|
|
2
|
+
|
|
3
|
+
export interface ContextLifetime {
|
|
4
|
+
signal: AbortSignal
|
|
5
|
+
parent?: ContextLifetime
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
const lifetimes = new WeakMap<ContextData, ContextLifetime>()
|
|
9
|
+
|
|
10
|
+
export function inheritContextLifetime(
|
|
11
|
+
parent: ContextData | undefined,
|
|
12
|
+
child: ContextData,
|
|
13
|
+
signal?: AbortSignal
|
|
14
|
+
): ContextData {
|
|
15
|
+
const lifetime = parent && lifetimes.get(parent)
|
|
16
|
+
if (signal) lifetimes.set(child, { signal, parent: lifetime })
|
|
17
|
+
else if (lifetime) lifetimes.set(child, lifetime)
|
|
18
|
+
return child
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export function isContextActive(context: ContextData): boolean {
|
|
22
|
+
let lifetime = lifetimes.get(context)
|
|
23
|
+
while (lifetime) {
|
|
24
|
+
if (lifetime.signal.aborted) return false
|
|
25
|
+
lifetime = lifetime.parent
|
|
26
|
+
}
|
|
27
|
+
return true
|
|
28
|
+
}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import type { PostHogBackendClient } from '../../client'
|
|
2
|
+
|
|
3
|
+
type ContextListener = (requestEntry: boolean) => void
|
|
4
|
+
|
|
5
|
+
type ContextListenerRegistry = WeakMap<PostHogBackendClient, Set<ContextListener>>
|
|
6
|
+
|
|
7
|
+
// The CommonJS and ESM builds are separate module copies, so they share one registry through a global.
|
|
8
|
+
const REGISTRY_KEY = Symbol.for('posthog-node.context-listeners')
|
|
9
|
+
const registryHolder = globalThis as typeof globalThis & { [REGISTRY_KEY]?: ContextListenerRegistry }
|
|
10
|
+
const listeners = (registryHolder[REGISTRY_KEY] ??= new WeakMap())
|
|
11
|
+
|
|
12
|
+
export function addContextListener(client: PostHogBackendClient, listener: ContextListener): () => void {
|
|
13
|
+
const callbacks = listeners.get(client) ?? new Set<ContextListener>()
|
|
14
|
+
listeners.set(client, callbacks)
|
|
15
|
+
callbacks.add(listener)
|
|
16
|
+
return () => {
|
|
17
|
+
callbacks.delete(listener)
|
|
18
|
+
if (!callbacks.size) listeners.delete(client)
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
export function notifyContextListeners(client: PostHogBackendClient, requestEntry = false): void {
|
|
23
|
+
for (const listener of listeners.get(client) ?? []) {
|
|
24
|
+
try {
|
|
25
|
+
listener(requestEntry)
|
|
26
|
+
} catch {}
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* Notify installed span processors after request IDs become available.
|
|
32
|
+
* This entry point does not load OpenTelemetry; without a processor it does nothing.
|
|
33
|
+
*/
|
|
34
|
+
export function enrichCurrentSpan(client: PostHogBackendClient): void {
|
|
35
|
+
notifyContextListeners(client, true)
|
|
36
|
+
}
|
|
@@ -11,6 +11,11 @@ export interface ContextOptions {
|
|
|
11
11
|
* @default false
|
|
12
12
|
*/
|
|
13
13
|
fresh?: boolean
|
|
14
|
+
/**
|
|
15
|
+
* Ends this context and its inherited scopes when aborted, without cancelling the callback.
|
|
16
|
+
* An already aborted signal starts no active context. A fresh context has an independent lifetime.
|
|
17
|
+
*/
|
|
18
|
+
signal?: AbortSignal
|
|
14
19
|
}
|
|
15
20
|
|
|
16
21
|
export interface IPostHogContext {
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import { addUncaughtExceptionListener, addUnhandledRejectionListener } from './autocapture'
|
|
2
2
|
import { PostHogBackendClient } from '@/client'
|
|
3
|
+
import type { ContextData } from '../context/types'
|
|
4
|
+
import { snapshotEventContext } from '../context/event-context'
|
|
3
5
|
import { isObject } from '@posthog/core'
|
|
4
6
|
import { EventMessage, PostHogOptions } from '@/types'
|
|
5
7
|
import type { Logger } from '@posthog/core'
|
|
@@ -47,8 +49,10 @@ export default class ErrorTracking {
|
|
|
47
49
|
error: unknown,
|
|
48
50
|
hint: CoreErrorTracking.EventHint,
|
|
49
51
|
distinctId?: string,
|
|
50
|
-
additionalProperties?: Record<string | number, any
|
|
52
|
+
additionalProperties?: Record<string | number, any>,
|
|
53
|
+
context?: ContextData
|
|
51
54
|
): Promise<EventMessage> {
|
|
55
|
+
const applyContextSnapshot = snapshotEventContext(context)
|
|
52
56
|
const properties: EventMessage['properties'] = { ...additionalProperties }
|
|
53
57
|
|
|
54
58
|
const exceptionProperties = builder.buildFromUnknown(error, hint)
|
|
@@ -59,7 +63,7 @@ export default class ErrorTracking {
|
|
|
59
63
|
properties.$release_id = injectedReleaseId
|
|
60
64
|
}
|
|
61
65
|
|
|
62
|
-
return {
|
|
66
|
+
return applyContextSnapshot({
|
|
63
67
|
event: '$exception',
|
|
64
68
|
// Leave distinctId resolution to prepareEventMessage which checks request context
|
|
65
69
|
// and falls back to a random UUID with $process_person_profile = false
|
|
@@ -69,7 +73,7 @@ export default class ErrorTracking {
|
|
|
69
73
|
...properties,
|
|
70
74
|
},
|
|
71
75
|
_originatedFromCaptureException: true,
|
|
72
|
-
}
|
|
76
|
+
})
|
|
73
77
|
}
|
|
74
78
|
|
|
75
79
|
private startAutocaptureIfEnabled(): void {
|
|
@@ -86,7 +90,10 @@ export default class ErrorTracking {
|
|
|
86
90
|
const eventMessage = await ErrorTracking.buildEventMessage(
|
|
87
91
|
this.client.getErrorPropertiesBuilder(),
|
|
88
92
|
exception,
|
|
89
|
-
hint
|
|
93
|
+
hint,
|
|
94
|
+
undefined,
|
|
95
|
+
undefined,
|
|
96
|
+
this.client.getContext()
|
|
90
97
|
)
|
|
91
98
|
const exceptionProperties = eventMessage.properties
|
|
92
99
|
const exceptionType = exceptionProperties?.$exception_list[0]?.type ?? 'Exception'
|
|
@@ -5,6 +5,7 @@ import { addProperty, getFirstHeaderValue, getPostHogTracingHeaderValues } from
|
|
|
5
5
|
import { normalizeRequestCurrentUrl, normalizeRequestPath } from './url-utils'
|
|
6
6
|
import type { Request, Response } from 'express'
|
|
7
7
|
import type { ContextData } from './context/types'
|
|
8
|
+
import { notifyContextListeners } from './context/listeners'
|
|
8
9
|
|
|
9
10
|
type ExpressMiddleware = (req: Request, res: Response, next: () => void) => void
|
|
10
11
|
|
|
@@ -34,7 +35,10 @@ function getClientIp(req: Request): string | undefined {
|
|
|
34
35
|
}
|
|
35
36
|
|
|
36
37
|
function buildRequestContextData(posthog: PostHogBackendClient, req: Request): Partial<ContextData> {
|
|
37
|
-
const
|
|
38
|
+
const headers = getPostHogTracingHeaderValues(req.headers)
|
|
39
|
+
const context = posthog.getContext()
|
|
40
|
+
const sessionId = context?.sessionId ?? headers.sessionId
|
|
41
|
+
const distinctId = context?.distinctId ?? headers.distinctId
|
|
38
42
|
const properties: Record<string, any> = {}
|
|
39
43
|
const disableCaptureUrlHashes = posthog.options.disable_capture_url_hashes === true
|
|
40
44
|
|
|
@@ -66,7 +70,10 @@ export function setupExpressRequestContext(
|
|
|
66
70
|
|
|
67
71
|
function posthogRequestContext(posthog: PostHogBackendClient): ExpressMiddleware {
|
|
68
72
|
return (req, _res, next): void => {
|
|
69
|
-
posthog.withContext(buildRequestContextData(posthog, req), () =>
|
|
73
|
+
posthog.withContext(buildRequestContextData(posthog, req), () => {
|
|
74
|
+
notifyContextListeners(posthog, true)
|
|
75
|
+
next()
|
|
76
|
+
})
|
|
70
77
|
}
|
|
71
78
|
}
|
|
72
79
|
|
|
@@ -122,7 +129,8 @@ function posthogErrorHandler(posthog: PostHogBackendClient): ExpressErrorMiddlew
|
|
|
122
129
|
error,
|
|
123
130
|
hint,
|
|
124
131
|
contextData.distinctId,
|
|
125
|
-
additionalProperties
|
|
132
|
+
additionalProperties,
|
|
133
|
+
posthog.getContext()
|
|
126
134
|
),
|
|
127
135
|
// Downstream error handlers can choose a different status, even asynchronously.
|
|
128
136
|
getResponseStatusCode(res),
|
package/src/extensions/nestjs.ts
CHANGED
|
@@ -5,6 +5,7 @@ import { catchError } from 'rxjs/operators'
|
|
|
5
5
|
import ErrorTracking from './error-tracking'
|
|
6
6
|
import { addProperty, getFirstHeaderValue, getPostHogTracingHeaderValues } from './tracing-headers'
|
|
7
7
|
import { normalizeRequestCurrentUrl, normalizeRequestPath } from './url-utils'
|
|
8
|
+
import { notifyContextListeners } from './context/listeners'
|
|
8
9
|
import { PostHogBackendClient } from '../client'
|
|
9
10
|
|
|
10
11
|
// Local interfaces to avoid runtime dependency on @nestjs/common
|
|
@@ -99,6 +100,7 @@ export class PostHogInterceptor implements NestInterceptor {
|
|
|
99
100
|
this.posthog.withContext(
|
|
100
101
|
contextData,
|
|
101
102
|
() => {
|
|
103
|
+
notifyContextListeners(this.posthog, true)
|
|
102
104
|
let source = next.handle()
|
|
103
105
|
|
|
104
106
|
if (this.captureExceptions) {
|
package/src/version.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export const version = "5.
|
|
1
|
+
export const version = "5.58.0"
|