Skip to content

Conversation

@Mercy811
Copy link
Contributor

@Mercy811 Mercy811 commented Nov 28, 2025

Summary

https://amplitude.atlassian.net/wiki/spaces/GOV/pages/3501359165/Diagnostics+track+uncaught+SDK+errors#3.-Runtime-stack-trace-filtering-%E2%AD%90%EF%B8%8F

Auto capture uncaught errors originated from Amplitude SDK including Amplitude plugins by comparing the error stack trace. Errors in event callbacks in Amplitude plugins will be captured too. This only works for installing by <script> tag. If any stack frame contains the the script filename, it's considered as a SDK error.

Checklist

  • Does your PR title have the correct title format?
  • Does your PR have a breaking change?:

Note

Add global listeners to capture uncaught SDK/plugin errors when loaded via <script>, wiring into DiagnosticsClient and snippet to register script URL, plus exports and tests.

  • Diagnostics (core)
    • Uncaught Error Capture: Add diagnostics/uncaught-sdk-errors.ts with registerSdkLoaderMetadata and enableSdkErrorListeners to record sdk.error.uncaught via global error/unhandledrejection listeners when errors originate from the SDK script.
    • DiagnosticsClient Integration: Invoke enableSdkErrorListeners(this) when diagnostics sampling is enabled in DiagnosticsClient.
    • Exports: Re-export registerSdkLoaderMetadata from src/index.ts.
    • Tests: Add comprehensive unit tests for URL registration/normalization and error/rejection handling in uncaught-sdk-errors.test.ts, and index export test updates.
  • Browser Snippet
    • Script URL Registration: In snippet-index.ts, resolve current script URL and call registerSdkLoaderMetadata to enable origin detection.
  • Test Server
    • Manual Validation Page: Update test-server/diagnostics.html to load SDK via script and include buttons/workflows to trigger SDK and non-SDK errors for diagnostics verification.

Written by Cursor Bugbot for commit 24d0bde. Configure here.

@Mercy811 Mercy811 marked this pull request as ready for review November 28, 2025 22:49
@Mercy811
Copy link
Contributor Author

bugbot run

Copy link

@cursor cursor bot left a comment

Choose a reason for hiding this comment

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

Comment @cursor review or bugbot run to trigger another review on this PR

@Mercy811
Copy link
Contributor Author

bugbot run

Copy link

@cursor cursor bot left a comment

Choose a reason for hiding this comment

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

✅ Bugbot reviewed your changes and found no bugs!


Comment @cursor review or bugbot run to trigger another review on this PR

@Mercy811 Mercy811 merged commit dc0b3cc into main Dec 9, 2025
8 checks passed
@Mercy811 Mercy811 deleted the AMP-143673-diagnostics-uncaught-error-script-auto branch December 9, 2025 04:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants