Repository navigation
Conversation
daniel-graham-amplitude
left a comment
There was a problem hiding this comment.
Looks good. Thanks for the contribution!
|
bugbot run |
Mercy811
left a comment
There was a problem hiding this comment.
please fix the bugbot issue
Thanks for flagging this. I've addressed the SSR issue in the latest commits by preventing initial page-view tracking when browser APIs are unavailable, and added a regression test to cover it. Could you please take another look when you get a chance? I also noticed that five CI workflows are awaiting maintainer approval. |
Codex Review Summary: ✅ CompletedThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
|
bugbot run |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: c12c835631
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
|
overall lgtm! @sshnox could you fix the failing test and add more test for 100% test coverage? Notes for myself: we cannot have a shared helper function because different plugins requires different APIs. Page view plugin requires history and addEventListener while file download only needs addEventListener. |
|
bugbot run |
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
Reviewed by Cursor Bugbot for commit e3d7538. Configure here.

Summary
Fixes #942.
The file-download and form-interaction tracking plugins assume a global returned by
getGlobalScope()implements browser event listeners, and readdocument.readyStateduring setup. In SSR and server-like environments these assumptions can throw during SDK initialization. The page-view plugin similarly assumes a browserhistoryandaddEventListener.documentis unavailable.loadlisteners when the global does not implementaddEventListener.addEventListenerin file-download and form-interaction plugins.Validation
main: only the five intended source and test files differ.No changes to browser tracking behavior when DOM APIs are present.
Note
Low Risk
Defensive environment checks with no intended behavior change when browser APIs exist; broad test coverage for SSR paths.
Overview
Adds SSR and server-like environment guards so Amplitude browser tracking plugins no longer throw during SDK init when
document,location,history, oraddEventListenerare missing.File download and form interaction plugins now return early from
setupwhendocumentis undefined, and only register the windowloadlistener whenaddEventListeneris actually a function.The page view plugin introduces an
isServerEnvironmentflag:setupbails out (no initial page view, no history/popstatehooks),executepasses events through without attribution-to-page-view conversion, andteardownonly callsremoveEventListenerwhen it exists.Regression tests simulate missing
document, undefined global scope, globals withoutaddEventListenerorhistory, and related edge cases across all three plugins.Reviewed by Cursor Bugbot for commit e3d7538. Configure here.