feat(js): Offer dataCollection setup step SDK v11 that writes a PII-reducing preset into Sentry.init - #1359
Conversation
Adds src/utils/data-collection.ts: a v11 gate (sdkSupportsDataCollection), a yes/no prompt with telemetry (askShouldReduceDataCollection), and a renderer for the PII-reducing dataCollection preset with deny lists (getDataCollectionSnippet). Also hoists the duplicated private getMajor helpers from sveltekit and react-router into src/utils/semver.ts as getMajorVersion.
Prompts after install when the installed major is >= 11 and threads the decision through ProjectInfo into the hooks templates, the instrumentation.server template, and both magicast init-insert paths. When accepted, the commented-out dataCollection hint is replaced by the active preset; when declined, output is unchanged. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Threads the decision into the server/edge config templates, the instrumentation-client file, and the copy-paste snippets. When accepted, the commented-out dataCollection hint is replaced by the active preset; when declined, output is unchanged. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Re-reads the installed SDK version after install and threads the decision into the client and server config templates. When accepted, the commented-out dataCollection hint is replaced by the active preset; when declined, output is unchanged. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Re-reads the installed SDK version after install and splices the active preset (with its comment block) into the magicast-generated client and server init calls when accepted. When declined, output is unchanged. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Threads the decision into the server instrumentation template, the manual copy-paste snippets, and the client entry codemod. When accepted, the commented-out dataCollection hint is replaced by the active preset; when declined, output is unchanged. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Re-reads the installed SDK version after install and splices the active preset (with its comment block) into the magicast-generated Sentry.init call when accepted. When declined, output is unchanged. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Re-reads the installed SDK version after install and threads the decision into the worker template and the recast withSentry config builder (preset comment attached as leading comments). When declined, output is unchanged. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
…-reducing preset into `Sentry.init`
| const reduceDataCollection = | ||
| sdkSupportsDataCollection(installedSdkVersion, '^10.73.0') && | ||
| (await askShouldReduceDataCollection()); |
There was a problem hiding this comment.
Bug: The data collection prompt is never shown because the sdkSupportsDataCollection check requires SDK version 11+, but the wizard installs version 10.
Severity: LOW
Suggested Fix
Update the sdkSupportsDataCollection check to be compatible with the installed SDK version, or update the wizard to install version 11 or greater of the @sentry/nextjs package to ensure the data collection prompt is shown.
Prompt for AI Agent
Review the code at the location below. A potential bug has been identified by an AI
agent. Verify if this is a real issue. If it is, propose a fix; if not, explain why it's
not valid.
Location: src/nextjs/nextjs-wizard.ts#L171-L173
Potential issue: The data collection prompt, controlled by
`askShouldReduceDataCollection`, is never shown to users of the Next.js wizard. The
function `sdkSupportsDataCollection` checks if the installed `@sentry/nextjs` SDK major
version is 11 or greater to determine if the prompt should be displayed. However, the
wizard installs version `^10.73.0`, which always resolves to a major version of 10. As a
result, the condition `sdkMajor >= 11` is always false, preventing the prompt from ever
appearing.
Did we get this right? 👍 / 👎 to inform future reviews.
|
bugbot run |
There was a problem hiding this comment.
✅ Bugbot reviewed your changes and found no new issues!
Comment @cursor review or bugbot run to trigger another review on this PR
Reviewed by Cursor Bugbot for commit d08bf2c. Configure here.
JPeer264
left a comment
There was a problem hiding this comment.
Should we maybe add a link into the terminal with "More info: "?
Adds a "More info: <docs link>" line to the reduce-data-collection prompt so users can read up on the categories before deciding. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
…-setup-2-wizard-usage # Conflicts: # src/nuxt/nuxt-wizard.ts
Every framework change lives in its own commit (easier reviewing).
Depends on (merged) #1358
Closes getsentry/sentry-javascript#24551