posthog-node 5.57.1 → 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.
Files changed (59) hide show
  1. package/README.md +39 -0
  2. package/dist/client.d.ts.map +1 -1
  3. package/dist/client.js +10 -4
  4. package/dist/client.mjs +10 -4
  5. package/dist/entrypoints/otel.d.ts +18 -0
  6. package/dist/entrypoints/otel.d.ts.map +1 -0
  7. package/dist/entrypoints/otel.js +99 -0
  8. package/dist/entrypoints/otel.mjs +58 -0
  9. package/dist/exports.d.ts +1 -0
  10. package/dist/exports.d.ts.map +1 -1
  11. package/dist/exports.js +30 -20
  12. package/dist/exports.mjs +1 -0
  13. package/dist/extensions/context/context.d.ts.map +1 -1
  14. package/dist/extensions/context/context.js +12 -8
  15. package/dist/extensions/context/context.mjs +12 -8
  16. package/dist/extensions/context/event-context.d.ts +5 -0
  17. package/dist/extensions/context/event-context.d.ts.map +1 -0
  18. package/dist/extensions/context/event-context.js +57 -0
  19. package/dist/extensions/context/event-context.mjs +16 -0
  20. package/dist/extensions/context/lifetime.d.ts +8 -0
  21. package/dist/extensions/context/lifetime.d.ts.map +1 -0
  22. package/dist/extensions/context/lifetime.js +60 -0
  23. package/dist/extensions/context/lifetime.mjs +19 -0
  24. package/dist/extensions/context/listeners.d.ts +11 -0
  25. package/dist/extensions/context/listeners.d.ts.map +1 -0
  26. package/dist/extensions/context/listeners.js +65 -0
  27. package/dist/extensions/context/listeners.mjs +21 -0
  28. package/dist/extensions/context/types.d.ts +5 -0
  29. package/dist/extensions/context/types.d.ts.map +1 -1
  30. package/dist/extensions/error-tracking/index.d.ts +2 -1
  31. package/dist/extensions/error-tracking/index.d.ts.map +1 -1
  32. package/dist/extensions/error-tracking/index.js +6 -4
  33. package/dist/extensions/error-tracking/index.mjs +6 -4
  34. package/dist/extensions/error-tracking/trace-context.d.ts.map +1 -1
  35. package/dist/extensions/error-tracking/trace-context.js +5 -3
  36. package/dist/extensions/error-tracking/trace-context.mjs +5 -3
  37. package/dist/extensions/express.d.ts.map +1 -1
  38. package/dist/extensions/express.js +10 -3
  39. package/dist/extensions/express.mjs +10 -3
  40. package/dist/extensions/nestjs.d.ts.map +1 -1
  41. package/dist/extensions/nestjs.js +2 -0
  42. package/dist/extensions/nestjs.mjs +2 -0
  43. package/dist/version.d.ts +1 -1
  44. package/dist/version.js +1 -1
  45. package/dist/version.mjs +1 -1
  46. package/package.json +13 -5
  47. package/src/client.ts +16 -4
  48. package/src/entrypoints/otel.ts +75 -0
  49. package/src/exports.ts +1 -0
  50. package/src/extensions/context/context.ts +16 -10
  51. package/src/extensions/context/event-context.ts +14 -0
  52. package/src/extensions/context/lifetime.ts +28 -0
  53. package/src/extensions/context/listeners.ts +36 -0
  54. package/src/extensions/context/types.ts +5 -0
  55. package/src/extensions/error-tracking/index.ts +11 -4
  56. package/src/extensions/error-tracking/trace-context.ts +12 -3
  57. package/src/extensions/express.ts +11 -3
  58. package/src/extensions/nestjs.ts +2 -0
  59. package/src/version.ts +1 -1
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "posthog-node",
3
- "version": "5.57.1",
3
+ "version": "5.58.0",
4
4
  "bugs": {
5
5
  "url": "https://github.com/PostHog/posthog-js/issues"
6
6
  },
@@ -29,21 +29,23 @@
29
29
  "module": "dist/entrypoints/index.node.mjs",
30
30
  "types": "dist/entrypoints/index.node.d.ts",
31
31
  "dependencies": {
32
- "@posthog/core": "^1.60.1"
32
+ "@posthog/core": "^1.61.1"
33
33
  },
34
34
  "devDependencies": {
35
35
  "@edge-runtime/vm": "^5.0.0",
36
36
  "@opentelemetry/api": "^1.9.0",
37
37
  "@opentelemetry/context-async-hooks": "^2.2.0",
38
+ "@opentelemetry/sdk-trace-base": "^2.10.0",
38
39
  "@rslib/core": "0.23.2",
39
40
  "@types/express": "^5.0.6",
40
41
  "@types/node": "^20.0.0",
41
- "rxjs": "^7.8.0",
42
+ "esbuild": "^0.25.0",
42
43
  "@vitest/coverage-v8": "^1.6.1",
43
- "vitest": "^1.6.1",
44
+ "rxjs": "^7.8.0",
44
45
  "typescript": "7.0.2",
46
+ "vitest": "^1.6.1",
45
47
  "@posthog-tooling/tsconfig-base": "1.1.1",
46
- "@posthog/types": "^1.416.0"
48
+ "@posthog/types": "^1.418.0"
47
49
  },
48
50
  "peerDependencies": {
49
51
  "@opentelemetry/api": "^1.2.0",
@@ -105,6 +107,12 @@
105
107
  "import": "./dist/experimental.mjs",
106
108
  "require": "./dist/experimental.js",
107
109
  "default": "./dist/experimental.js"
110
+ },
111
+ "./otel": {
112
+ "types": "./dist/entrypoints/otel.d.ts",
113
+ "import": "./dist/entrypoints/otel.mjs",
114
+ "require": "./dist/entrypoints/otel.js",
115
+ "default": "./dist/entrypoints/otel.js"
108
116
  }
109
117
  },
110
118
  "scripts": {
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(data, fn, options)
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
- return this.storage.getStore()
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
- const current = this.get() || {}
29
- return {
30
- distinctId: context.distinctId ?? current.distinctId,
31
- sessionId: context.sessionId ?? current.sessionId,
32
- properties: {
33
- ...(current.properties || {}),
34
- ...(context.properties || {}),
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'
@@ -1,12 +1,21 @@
1
1
  const TRACE_ID_PATTERN = /^[0-9a-f]{32}$/i
2
2
  const SPAN_ID_PATTERN = /^[0-9a-f]{16}$/i
3
3
 
4
- let otelApi: Promise<typeof import('@opentelemetry/api')> | undefined
4
+ // `@opentelemetry/api` v1 keeps its registered context manager on this global, so that all copies of the API share it.
5
+ // We read it here and do not import the optional peer: bundlers such as esbuild fail the build when an imported
6
+ // module is not installed, and an import from a variable makes webpack warn and drop the module.
7
+ const OTEL_API_GLOBAL_KEY = Symbol.for('opentelemetry.js.api.1')
8
+ const SPAN_CONTEXT_KEY = Symbol.for('OpenTelemetry Context Key SPAN')
9
+
10
+ type OtelSpan = { spanContext(): { traceId?: unknown; spanId?: unknown } }
11
+ type OtelContext = { getValue(key: symbol): unknown }
12
+ type OtelApiGlobal = { context?: { active(): OtelContext } }
5
13
 
6
14
  export async function getActiveTraceProperties(): Promise<Record<string, string>> {
7
15
  try {
8
- const api = await (otelApi ??= import('@opentelemetry/api'))
9
- const spanContext = api.trace.getActiveSpan()?.spanContext()
16
+ const otelApi = (globalThis as Record<symbol, OtelApiGlobal | undefined>)[OTEL_API_GLOBAL_KEY]
17
+ const span = otelApi?.context?.active().getValue(SPAN_CONTEXT_KEY) as OtelSpan | undefined
18
+ const spanContext = span?.spanContext()
10
19
  const traceId = spanContext?.traceId
11
20
  const spanId = spanContext?.spanId
12
21
 
@@ -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 { sessionId, distinctId } = getPostHogTracingHeaderValues(req.headers)
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), () => next())
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),
@@ -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.57.1"
1
+ export const version = "5.58.0"