Skip to content

Conversation

@daibhin
Copy link
Contributor

@daibhin daibhin commented Nov 18, 2025

Problem

Inspired by this thread: https://posthog.slack.com/archives/C07AA937K9A/p1759356822031919

Changes

  • Add LLMA trace_id (for starters, could add other properties too) to exceptions and set exception_id on trace events
  • Add ability to Node SDK to skip previously captured exceptions (so we don't double capture)
  • Remove unnecessary isError check given we have the error

Release info Sub-libraries affected

Libraries affected

  • All of them
  • posthog-js (web)
  • posthog-js-lite (web lite)
  • posthog-node
  • posthog-react-native
  • @posthog/react
  • @posthog/ai
  • @posthog/nextjs-config
  • @posthog/nuxt

@daibhin daibhin requested review from a team as code owners November 18, 2025 16:41
@vercel
Copy link

vercel bot commented Nov 18, 2025

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Review Updated (UTC)
posthog-js Ready Ready Preview Jan 7, 2026 3:34pm
posthog-nextjs-config Ready Ready Preview Jan 7, 2026 3:34pm

@wiz-7ad640923b
Copy link

wiz-7ad640923b bot commented Nov 18, 2025

Wiz Scan Summary

Scanner Findings
Vulnerability Finding Vulnerabilities 14 High 7 Medium 6 Low
Data Finding Sensitive Data -
Secret Finding Secrets -
IaC Misconfiguration IaC Misconfigurations -
SAST Finding SAST Findings -
Software Supply Chain Finding Software Supply Chain Findings -
Total 14 High 7 Medium 6 Low

View scan details in Wiz

To detect these findings earlier in the dev lifecycle, try using Wiz Code VS Code Extension.

@github-actions
Copy link
Contributor

github-actions bot commented Nov 18, 2025

Copy link
Contributor

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Additional Comments (8)

  1. packages/ai/src/openai/index.ts, line 312-336 (link)

    logic: inconsistent error handling - still using old pattern

    This error handler wasn't updated to use sendEventWithErrorToPosthog like the streaming paths were. This means it won't link exceptions to trace events and won't prevent double-capturing.

  2. packages/ai/src/openai/index.ts, line 504-529 (link)

    logic: inconsistent error handling - still using old pattern

    Same as other non-streaming path, needs to be updated to sendEventWithErrorToPosthog

  3. packages/ai/src/openai/index.ts, line 644-665 (link)

    logic: inconsistent error handling - still using old pattern

    Same issue in embeddings error handler

  4. packages/ai/src/anthropic/index.ts, line 285-304 (link)

    logic: inconsistent error handling - still using old pattern

    This non-streaming error handler wasn't updated to use sendEventWithErrorToPosthog

  5. packages/ai/src/openai/azure.ts, line 277-302 (link)

    logic: inconsistent error handling - still using old pattern

    Azure OpenAI non-streaming error handlers also need the same update

  6. packages/ai/src/openai/azure.ts, line 448-474 (link)

    logic: inconsistent error handling - still using old pattern

    Another Azure OpenAI error handler that needs updating

  7. packages/ai/src/openai/azure.ts, line 513-532 (link)

    logic: inconsistent error handling - still using old pattern

    Another Azure OpenAI error handler that needs updating

  8. packages/ai/src/openai/azure.ts, line 576-600 (link)

    logic: inconsistent error handling - still using old pattern

    Azure embeddings error handler also needs updating

12 files reviewed, 9 comments

Edit Code Review Agent Settings | Greptile
React with 👍 or 👎 to share your feedback on this new summary format

@github-actions
Copy link
Contributor

github-actions bot commented Nov 18, 2025

Size Change: +5.19 kB (+0.1%)

Total Size: 5.42 MB

Filename Size Change
packages/ai/dist/anthropic/index.cjs 18.7 kB +782 B (+4.36%)
packages/ai/dist/anthropic/index.mjs 18.4 kB +780 B (+4.43%)
packages/ai/dist/gemini/index.cjs 24.2 kB +800 B (+3.42%)
packages/ai/dist/gemini/index.mjs 24 kB +798 B (+3.44%)
packages/ai/dist/index.cjs 145 kB -509 B (-0.35%)
packages/ai/dist/index.mjs 144 kB -511 B (-0.35%)
packages/ai/dist/langchain/index.cjs 44.4 kB +26 B (+0.06%)
packages/ai/dist/langchain/index.mjs 43.8 kB +24 B (+0.05%)
packages/ai/dist/openai/index.cjs 42.9 kB +167 B (+0.39%)
packages/ai/dist/openai/index.mjs 42.6 kB +165 B (+0.39%)
packages/ai/dist/vercel/index.cjs 31.2 kB +744 B (+2.44%)
packages/ai/dist/vercel/index.mjs 31.1 kB +742 B (+2.44%)
packages/core/dist/utils/type-utils.js 6.82 kB -113 B (-1.63%)
packages/core/dist/utils/type-utils.mjs 3.01 kB -14 B (-0.46%)
packages/node/dist/client.js 28 kB +263 B (+0.95%)
packages/node/dist/client.mjs 26 kB +255 B (+0.99%)
packages/node/dist/extensions/error-tracking/index.js 4.2 kB +315 B (+8.11%) 🔍
packages/node/dist/extensions/error-tracking/index.mjs 2.91 kB +299 B (+11.46%) ⚠️
packages/node/dist/extensions/express.js 2.84 kB +90 B (+3.28%)
packages/node/dist/extensions/express.mjs 1.25 kB +86 B (+7.39%) 🔍
ℹ️ View Unchanged
Filename Size Change
packages/browser/dist/all-external-dependencies.js 229 kB 0 B
packages/browser/dist/array.full.es5.js 310 kB 0 B
packages/browser/dist/array.full.js 377 kB 0 B
packages/browser/dist/array.full.no-external.js 393 kB 0 B
packages/browser/dist/array.js 171 kB 0 B
packages/browser/dist/array.no-external.js 185 kB 0 B
packages/browser/dist/conversations.js 38.4 kB 0 B
packages/browser/dist/crisp-chat-integration.js 2.11 kB 0 B
packages/browser/dist/customizations.full.js 18 kB 0 B
packages/browser/dist/dead-clicks-autocapture.js 13.1 kB 0 B
packages/browser/dist/exception-autocapture.js 11.8 kB 0 B
packages/browser/dist/external-scripts-loader.js 2.95 kB 0 B
packages/browser/dist/intercom-integration.js 2.16 kB 0 B
packages/browser/dist/lazy-recorder.js 150 kB 0 B
packages/browser/dist/main.js 172 kB 0 B
packages/browser/dist/module.full.js 378 kB 0 B
packages/browser/dist/module.full.no-external.js 394 kB 0 B
packages/browser/dist/module.js 172 kB 0 B
packages/browser/dist/module.no-external.js 186 kB 0 B
packages/browser/dist/posthog-recorder.js 248 kB 0 B
packages/browser/dist/product-tours-preview.js 45.1 kB 0 B
packages/browser/dist/product-tours.js 69.9 kB 0 B
packages/browser/dist/recorder-v2.js 113 kB 0 B
packages/browser/dist/recorder.js 113 kB 0 B
packages/browser/dist/surveys-preview.js 73.1 kB 0 B
packages/browser/dist/surveys.js 85.4 kB 0 B
packages/browser/dist/tracing-headers.js 1.93 kB 0 B
packages/browser/dist/web-vitals.js 10.5 kB 0 B
packages/browser/react/dist/esm/index.js 19.3 kB 0 B
packages/browser/react/dist/umd/index.js 22.4 kB 0 B
packages/core/dist/error-tracking/chunk-ids.js 2.54 kB 0 B
packages/core/dist/error-tracking/chunk-ids.mjs 1.31 kB 0 B
packages/core/dist/error-tracking/coercers/dom-exception-coercer.js 2.3 kB 0 B
packages/core/dist/error-tracking/coercers/dom-exception-coercer.mjs 993 B 0 B
packages/core/dist/error-tracking/coercers/error-coercer.js 2.02 kB 0 B
packages/core/dist/error-tracking/coercers/error-coercer.mjs 794 B 0 B
packages/core/dist/error-tracking/coercers/error-event-coercer.js 1.76 kB 0 B
packages/core/dist/error-tracking/coercers/error-event-coercer.mjs 513 B 0 B
packages/core/dist/error-tracking/coercers/event-coercer.js 1.82 kB 0 B
packages/core/dist/error-tracking/coercers/event-coercer.mjs 548 B 0 B
packages/core/dist/error-tracking/coercers/index.js 6.79 kB 0 B
packages/core/dist/error-tracking/coercers/index.mjs 326 B 0 B
packages/core/dist/error-tracking/coercers/object-coercer.js 3.46 kB 0 B
packages/core/dist/error-tracking/coercers/object-coercer.mjs 2.07 kB 0 B
packages/core/dist/error-tracking/coercers/primitive-coercer.js 1.67 kB 0 B
packages/core/dist/error-tracking/coercers/primitive-coercer.mjs 419 B 0 B
packages/core/dist/error-tracking/coercers/promise-rejection-event.js 2.25 kB 0 B
packages/core/dist/error-tracking/coercers/promise-rejection-event.mjs 904 B 0 B
packages/core/dist/error-tracking/coercers/string-coercer.js 2.01 kB 0 B
packages/core/dist/error-tracking/coercers/string-coercer.mjs 820 B 0 B
packages/core/dist/error-tracking/coercers/utils.js 2.06 kB 0 B
packages/core/dist/error-tracking/coercers/utils.mjs 716 B 0 B
packages/core/dist/error-tracking/error-properties-builder.js 5.49 kB 0 B
packages/core/dist/error-tracking/error-properties-builder.mjs 4.15 kB 0 B
packages/core/dist/error-tracking/index.js 4.11 kB 0 B
packages/core/dist/error-tracking/index.mjs 152 B 0 B
packages/core/dist/error-tracking/parsers/base.js 1.83 kB 0 B
packages/core/dist/error-tracking/parsers/base.mjs 464 B 0 B
packages/core/dist/error-tracking/parsers/chrome.js 2.73 kB 0 B
packages/core/dist/error-tracking/parsers/chrome.mjs 1.32 kB 0 B
packages/core/dist/error-tracking/parsers/gecko.js 2.47 kB 0 B
packages/core/dist/error-tracking/parsers/gecko.mjs 1.13 kB 0 B
packages/core/dist/error-tracking/parsers/index.js 4.38 kB 0 B
packages/core/dist/error-tracking/parsers/index.mjs 1.94 kB 0 B
packages/core/dist/error-tracking/parsers/node.js 3.94 kB 0 B
packages/core/dist/error-tracking/parsers/node.mjs 2.68 kB 0 B
packages/core/dist/error-tracking/parsers/opera.js 2.26 kB 0 B
packages/core/dist/error-tracking/parsers/opera.mjs 746 B 0 B
packages/core/dist/error-tracking/parsers/safari.js 1.88 kB 0 B
packages/core/dist/error-tracking/parsers/safari.mjs 574 B 0 B
packages/core/dist/error-tracking/parsers/winjs.js 1.72 kB 0 B
packages/core/dist/error-tracking/parsers/winjs.mjs 426 B 0 B
packages/core/dist/error-tracking/types.js 1.33 kB 0 B
packages/core/dist/error-tracking/types.mjs 131 B 0 B
packages/core/dist/error-tracking/utils.js 1.8 kB 0 B
packages/core/dist/error-tracking/utils.mjs 604 B 0 B
packages/core/dist/eventemitter.js 1.78 kB 0 B
packages/core/dist/eventemitter.mjs 571 B 0 B
packages/core/dist/featureFlagUtils.js 6.5 kB 0 B
packages/core/dist/featureFlagUtils.mjs 4.28 kB 0 B
packages/core/dist/gzip.js 1.88 kB 0 B
packages/core/dist/gzip.mjs 577 B 0 B
packages/core/dist/index.js 5.7 kB 0 B
packages/core/dist/index.mjs 485 B 0 B
packages/core/dist/posthog-core-stateless.js 29.7 kB 0 B
packages/core/dist/posthog-core-stateless.mjs 27.2 kB 0 B
packages/core/dist/posthog-core.js 28.2 kB 0 B
packages/core/dist/posthog-core.mjs 24 kB 0 B
packages/core/dist/process/index.js 2.77 kB 0 B
packages/core/dist/process/index.mjs 114 B 0 B
packages/core/dist/process/spawn-local.js 1.82 kB 0 B
packages/core/dist/process/spawn-local.mjs 568 B 0 B
packages/core/dist/process/utils.js 3.12 kB 0 B
packages/core/dist/process/utils.mjs 1.15 kB 0 B
packages/core/dist/testing/index.js 2.93 kB 0 B
packages/core/dist/testing/index.mjs 79 B 0 B
packages/core/dist/testing/PostHogCoreTestClient.js 3.15 kB 0 B
packages/core/dist/testing/PostHogCoreTestClient.mjs 1.74 kB 0 B
packages/core/dist/testing/test-utils.js 2.77 kB 0 B
packages/core/dist/testing/test-utils.mjs 1.09 kB 0 B
packages/core/dist/types.js 8.2 kB 0 B
packages/core/dist/types.mjs 5.93 kB 0 B
packages/core/dist/utils/bot-detection.js 3.28 kB 0 B
packages/core/dist/utils/bot-detection.mjs 1.95 kB 0 B
packages/core/dist/utils/bucketed-rate-limiter.js 3 kB 0 B
packages/core/dist/utils/bucketed-rate-limiter.mjs 1.62 kB 0 B
packages/core/dist/utils/index.js 11.9 kB 0 B
packages/core/dist/utils/index.mjs 1.98 kB 0 B
packages/core/dist/utils/logger.js 2.5 kB 0 B
packages/core/dist/utils/logger.mjs 1.22 kB 0 B
packages/core/dist/utils/number-utils.js 2 kB 0 B
packages/core/dist/utils/number-utils.mjs 735 B 0 B
packages/core/dist/utils/promise-queue.js 2 kB 0 B
packages/core/dist/utils/promise-queue.mjs 768 B 0 B
packages/core/dist/utils/string-utils.js 1.91 kB 0 B
packages/core/dist/utils/string-utils.mjs 414 B 0 B
packages/core/dist/utils/user-agent-utils.js 14.9 kB 0 B
packages/core/dist/utils/user-agent-utils.mjs 11.9 kB 0 B
packages/core/dist/vendor/uuidv7.js 8.29 kB 0 B
packages/core/dist/vendor/uuidv7.mjs 6.72 kB 0 B
packages/nextjs-config/dist/config.js 4.97 kB 0 B
packages/nextjs-config/dist/config.mjs 3.48 kB 0 B
packages/nextjs-config/dist/index.js 2.24 kB 0 B
packages/nextjs-config/dist/index.mjs 30 B 0 B
packages/nextjs-config/dist/utils.js 3.96 kB 0 B
packages/nextjs-config/dist/utils.mjs 1.85 kB 0 B
packages/node/dist/entrypoints/index.edge.js 4.25 kB 0 B
packages/node/dist/entrypoints/index.edge.mjs 723 B 0 B
packages/node/dist/entrypoints/index.node.js 5.55 kB 0 B
packages/node/dist/entrypoints/index.node.mjs 1.08 kB 0 B
packages/node/dist/experimental.js 603 B 0 B
packages/node/dist/experimental.mjs 0 B 0 B 🆕
packages/node/dist/exports.js 3.6 kB 0 B
packages/node/dist/exports.mjs 124 B 0 B
packages/node/dist/extensions/context/context.js 2.12 kB 0 B
packages/node/dist/extensions/context/context.mjs 862 B 0 B
packages/node/dist/extensions/context/types.js 603 B 0 B
packages/node/dist/extensions/context/types.mjs 0 B 0 B 🆕
packages/node/dist/extensions/error-tracking/autocapture.js 2.66 kB 0 B
packages/node/dist/extensions/error-tracking/autocapture.mjs 1.24 kB 0 B
packages/node/dist/extensions/error-tracking/modifiers/context-lines.node.js 8.81 kB 0 B
packages/node/dist/extensions/error-tracking/modifiers/context-lines.node.mjs 7.15 kB 0 B
packages/node/dist/extensions/error-tracking/modifiers/module.node.js 2.78 kB 0 B
packages/node/dist/extensions/error-tracking/modifiers/module.node.mjs 1.45 kB 0 B
packages/node/dist/extensions/feature-flags/cache.js 603 B 0 B
packages/node/dist/extensions/feature-flags/cache.mjs 0 B 0 B 🆕
packages/node/dist/extensions/feature-flags/crypto.js 1.57 kB 0 B
packages/node/dist/extensions/feature-flags/crypto.mjs 395 B 0 B
packages/node/dist/extensions/feature-flags/feature-flags.js 31.1 kB 0 B
packages/node/dist/extensions/feature-flags/feature-flags.mjs 29.1 kB 0 B
packages/node/dist/extensions/sentry-integration.js 4.66 kB 0 B
packages/node/dist/extensions/sentry-integration.mjs 3.17 kB 0 B
packages/node/dist/storage-memory.js 1.52 kB 0 B
packages/node/dist/storage-memory.mjs 297 B 0 B
packages/node/dist/types.js 1.43 kB 0 B
packages/node/dist/types.mjs 224 B 0 B
packages/node/dist/version.js 1.21 kB 0 B
packages/node/dist/version.mjs 46 B 0 B
packages/nuxt/dist/module.mjs 4.39 kB 0 B
packages/nuxt/dist/runtime/composables/useFeatureFlagEnabled.js 566 B 0 B
packages/nuxt/dist/runtime/composables/useFeatureFlagPayload.js 597 B 0 B
packages/nuxt/dist/runtime/composables/useFeatureFlagVariantKey.js 591 B 0 B
packages/nuxt/dist/runtime/composables/usePostHog.js 128 B 0 B
packages/nuxt/dist/runtime/nitro-plugin.js 1.08 kB 0 B
packages/nuxt/dist/runtime/vue-plugin.js 1.14 kB 0 B
packages/react-native/dist/autocapture.js 5.05 kB 0 B
packages/react-native/dist/error-tracking/index.js 6.77 kB 0 B
packages/react-native/dist/error-tracking/utils.js 2.58 kB 0 B
packages/react-native/dist/frameworks/wix-navigation.js 1.3 kB 0 B
packages/react-native/dist/hooks/useFeatureFlag.js 1.49 kB 0 B
packages/react-native/dist/hooks/useFeatureFlags.js 821 B 0 B
packages/react-native/dist/hooks/useNavigationTracker.js 2.46 kB 0 B
packages/react-native/dist/hooks/usePostHog.js 467 B 0 B
packages/react-native/dist/index.js 3.12 kB 0 B
packages/react-native/dist/native-deps.js 8.16 kB 0 B
packages/react-native/dist/optional/OptionalAsyncStorage.js 299 B 0 B
packages/react-native/dist/optional/OptionalExpoApplication.js 377 B 0 B
packages/react-native/dist/optional/OptionalExpoDevice.js 347 B 0 B
packages/react-native/dist/optional/OptionalExpoFileSystem.js 386 B 0 B
packages/react-native/dist/optional/OptionalExpoFileSystemLegacy.js 423 B 0 B
packages/react-native/dist/optional/OptionalExpoLocalization.js 383 B 0 B
packages/react-native/dist/optional/OptionalReactNativeDeviceInfo.js 415 B 0 B
packages/react-native/dist/optional/OptionalReactNativeLocalize.js 303 B 0 B
packages/react-native/dist/optional/OptionalReactNativeNavigation.js 415 B 0 B
packages/react-native/dist/optional/OptionalReactNativeNavigationWix.js 443 B 0 B
packages/react-native/dist/optional/OptionalReactNativeSafeArea.js 644 B 0 B
packages/react-native/dist/optional/OptionalSessionReplay.js 455 B 0 B
packages/react-native/dist/posthog-rn.js 30.5 kB 0 B
packages/react-native/dist/PostHogContext.js 329 B 0 B
packages/react-native/dist/PostHogProvider.js 4.77 kB 0 B
packages/react-native/dist/storage.js 3.39 kB 0 B
packages/react-native/dist/surveys/components/BottomSection.js 1.34 kB 0 B
packages/react-native/dist/surveys/components/Cancel.js 909 B 0 B
packages/react-native/dist/surveys/components/ConfirmationMessage.js 1.65 kB 0 B
packages/react-native/dist/surveys/components/QuestionHeader.js 1.37 kB 0 B
packages/react-native/dist/surveys/components/QuestionTypes.js 11.3 kB 0 B
packages/react-native/dist/surveys/components/SurveyModal.js 4.01 kB 0 B
packages/react-native/dist/surveys/components/Surveys.js 7.22 kB 0 B
packages/react-native/dist/surveys/getActiveMatchingSurveys.js 2.64 kB 0 B
packages/react-native/dist/surveys/icons.js 7.76 kB 0 B
packages/react-native/dist/surveys/index.js 600 B 0 B
packages/react-native/dist/surveys/PostHogSurveyProvider.js 5.71 kB 0 B
packages/react-native/dist/surveys/surveys-utils.js 12.7 kB 0 B
packages/react-native/dist/surveys/useActivatedSurveys.js 3.67 kB 0 B
packages/react-native/dist/surveys/useSurveyStorage.js 2.16 kB 0 B
packages/react-native/dist/tooling/expoconfig.js 2.63 kB 0 B
packages/react-native/dist/tooling/metroconfig.js 2.2 kB 0 B
packages/react-native/dist/tooling/posthogMetroSerializer.js 4.78 kB 0 B
packages/react-native/dist/tooling/utils.js 4.05 kB 0 B
packages/react-native/dist/tooling/vendor/expo/expoconfig.js 70 B 0 B
packages/react-native/dist/tooling/vendor/metro/countLines.js 237 B 0 B
packages/react-native/dist/tooling/vendor/metro/utils.js 3.35 kB 0 B
packages/react-native/dist/types.js 70 B 0 B
packages/react-native/dist/utils.js 719 B 0 B
packages/react-native/dist/version.js 130 B 0 B
packages/react/dist/esm/index.js 19.3 kB 0 B
packages/react/dist/umd/index.js 22.4 kB 0 B
packages/rollup-plugin/dist/index.js 3.62 kB 0 B
packages/types/dist/capture.js 603 B 0 B
packages/types/dist/capture.mjs 0 B 0 B 🆕
packages/types/dist/common.js 603 B 0 B
packages/types/dist/common.mjs 0 B 0 B 🆕
packages/types/dist/feature-flags.js 603 B 0 B
packages/types/dist/feature-flags.mjs 0 B 0 B 🆕
packages/types/dist/index.js 603 B 0 B
packages/types/dist/index.mjs 0 B 0 B 🆕
packages/types/dist/posthog-config.js 603 B 0 B
packages/types/dist/posthog-config.mjs 0 B 0 B 🆕
packages/types/dist/posthog.js 603 B 0 B
packages/types/dist/posthog.mjs 0 B 0 B 🆕
packages/types/dist/request.js 603 B 0 B
packages/types/dist/request.mjs 0 B 0 B 🆕
packages/types/dist/segment.js 603 B 0 B
packages/types/dist/segment.mjs 0 B 0 B 🆕
packages/types/dist/session-recording.js 603 B 0 B
packages/types/dist/session-recording.mjs 0 B 0 B 🆕
packages/web/dist/index.cjs 13.8 kB 0 B
packages/web/dist/index.mjs 13.7 kB 0 B
packages/webpack-plugin/dist/config.js 2.69 kB 0 B
packages/webpack-plugin/dist/config.mjs 1.69 kB 0 B
packages/webpack-plugin/dist/index.js 6.47 kB 0 B
packages/webpack-plugin/dist/index.mjs 3.05 kB 0 B
tooling/changelog/dist/index.js 3.31 kB 0 B
tooling/rollup-utils/dist/index.js 1.17 kB 0 B

compressed-size-action

Copy link
Member

@andrewm4894 andrewm4894 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks! was thinking there should be better integration between LLMA and Error tracking. We added an Errors tab recently but i think this SDK approach also opens up much deeper/native linkage that will be great for users of both products.

@andrewm4894
Copy link
Member

@daibhin i think just a couple of CI failures maybe

@marandaneto marandaneto removed the request for review from a team December 10, 2025 09:04
@posthog-bot
Copy link
Contributor

This PR hasn't seen activity in a week! Should it be merged, closed, or further worked on? If you want to keep it open, post a comment or remove the stale label – otherwise this will be closed in another week.

@github-actions
Copy link
Contributor

github-actions bot commented Jan 5, 2026

This PR was closed due to lack of activity. Feel free to reopen if it's still relevant.

@github-actions github-actions bot closed this Jan 5, 2026
@andrewm4894
Copy link
Member

Hmm I think we want to try get this over the line, reopening

@andrewm4894 andrewm4894 reopened this Jan 5, 2026
Copy link
Contributor

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Additional Comments (8)

  1. packages/ai/src/anthropic/index.ts, line 286-303 (link)

    logic: inconsistent error enrichment - should use sendEventWithErrorToPosthog

    this promise rejection handler still uses the old pattern - it sends the event but throws the original error instead of the enriched one. This means the error won't be marked as previously captured and could be double-captured by autocapture.

  2. packages/ai/src/openai/index.ts, line 312-336 (link)

    logic: inconsistent error enrichment - should use sendEventWithErrorToPosthog

    same issue as anthropic - this handler doesn't enrich the error or throw the enriched version, so the error could be double-captured.

  3. packages/ai/src/openai/index.ts, line 511-529 (link)

    logic: inconsistent error enrichment - should use sendEventWithErrorToPosthog

    same pattern issue - not enriching/throwing enriched error

    Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!

  4. packages/ai/src/openai/index.ts, line 654-665 (link)

    logic: inconsistent error enrichment - should use sendEventWithErrorToPosthog

    Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!

  5. packages/ai/src/openai/azure.ts, line 278-302 (link)

    logic: inconsistent error enrichment - should use sendEventWithErrorToPosthog

    Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!

  6. packages/ai/src/openai/azure.ts, line 457-474 (link)

    logic: inconsistent error enrichment - should use sendEventWithErrorToPosthog

    Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!

  7. packages/ai/src/openai/azure.ts, line 522-532 (link)

    logic: inconsistent error enrichment - should use sendEventWithErrorToPosthog

    Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!

  8. packages/ai/src/openai/azure.ts, line 590-600 (link)

    logic: inconsistent error enrichment - should use sendEventWithErrorToPosthog

    Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!

12 files reviewed, 8 comments

Edit Code Review Agent Settings | Greptile

@Radu-Raicea
Copy link
Member

@andrewm4894 thank you for taking this!

@github-actions github-actions bot removed the stale label Jan 6, 2026
🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
andrewm4894 and others added 2 commits January 7, 2026 12:01
…capture

The mock PostHog clients in tests don't have the options property,
causing tests to fail when accessing client.options.enableExceptionAutocapture.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
@andrewm4894
Copy link
Member

Current State Summary

This PR links LLM observability (LLMA) traces with error tracking exceptions, enabling bi-directional navigation between AI traces and their associated errors in PostHog.

How it works

  1. When an AI SDK wrapper (OpenAI, Anthropic, Gemini, Vercel) catches an error:

    • If enableExceptionAutocapture is enabled on the PostHog client, it generates a UUID (exceptionId)
    • Calls client.captureException() with $ai_trace_id property linking to the trace
    • Marks the error with __posthog_previously_captured_error = true to prevent double-capture
    • Adds $exception_event_id to the trace event
  2. The Node SDK's error tracking extension checks for __posthog_previously_captured_error before capturing, avoiding duplicates when errors bubble up through middleware (e.g., Express error handler).

Key changes by package

  • @posthog/ai: All provider wrappers now call sendEventWithErrorToPosthog() which handles the linking logic
  • posthog-node: captureException() accepts optional exceptionId parameter; error tracking checks for previously captured errors
  • @posthog/core: Added PreviouslyCapturedError type with __posthog_previously_captured_error flag

Recent fixes

  • Merged main to resolve conflicts with the new @posthog/types package
  • Fixed test failures by adding optional chaining for client.options?.enableExceptionAutocapture (mock clients in tests don't have options)

CI Status

Unit tests and build pass. Playwright integration test failures are pre-existing on main (ingestion lag flakiness), not related to this PR.

@andrewm4894 andrewm4894 requested a review from hpouillot January 7, 2026 13:12
Resolved conflicts in packages/ai/package.json (kept @posthog/core dependency
with updated package versions from main) and regenerated pnpm-lock.yaml
@andrewm4894
Copy link
Member

@PostHog/team-mobile for some reason this pr seems to want a review from someone on your team - assuming a codeowners thing maybe?

@andrewm4894 andrewm4894 requested a review from a team January 8, 2026 13:26
@marandaneto
Copy link
Member

@PostHog/team-mobile for some reason this pr seems to want a review from someone on your team - assuming a codeowners thing maybe?

i think we should remove this yeah
#2858

@andrewm4894 andrewm4894 merged commit fba9fb2 into main Jan 8, 2026
41 of 46 checks passed
@andrewm4894 andrewm4894 deleted the dn-feat/link-exceptions-traces branch January 8, 2026 14:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

llmo This issue is related to LLM Observability. team/llm-analytics LLM Analytics

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants