Repository navigation
fix(cli): Send the iOS wizard's test event only in Debug builds - #2798
Merged
Merged
Conversation
The snippet that sentry wizard ios writes captured a test message right after SentrySDK.start. Apps that kept the line sent that event on every launch in production. Wrap it in #if DEBUG so Release builds leave it out. Co-Authored-By: Antonis Lilis <antonis.lilis@sentry.io>
|
The latest updates on your projects. Learn more about Vercel for GitHub.
1 Skipped Deployment
|
antonis
marked this pull request as ready for review
December 2, 2026 14:47
antonis
approved these changes
Dec 2, 2026
antonis
enabled auto-merge
December 2, 2026 14:47
antonis
added a commit
that referenced
this pull request
Dec 2, 2026
…est event #2798 wraps the test event at the end of both snippets in #if DEBUG. Update the expected snippets for the tracing and profiling answers, and check for the profiling #if line instead of any #if, since every snippet now has one. Pass options to the snippet functions in #2798's test. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
github-actions Bot
pushed a commit
to Fields-Education/sentry-mcp
that referenced
this pull request
Dec 3, 2026
…ilds (getsentry#2803) This comes from testing `sentry wizard android` on fresh Android Studio projects (getsentry/sentry-java#6797). The wizard adds a test error to the main Activity's `onCreate` through an `OnGlobalLayoutListener` that it never removes. A global layout listener fires on every layout pass, not just the first: rotation, the keyboard, insets, any view change. So the app sends a stream of test errors, and keeps doing it in Release builds if the snippet ships. The test error is now sent once per Activity creation, in debuggable builds only, like the iOS wizard's `#if DEBUG` (getsentry#2798): - The Java and Kotlin snippets use an anonymous `ViewTreeObserver.OnGlobalLayoutListener` that calls `removeOnGlobalLayoutListener(this)` first in `onGlobalLayout()`. It still waits for the first layout, so the error's screenshot shows the UI. It removes itself through `contentView.getViewTreeObserver()` rather than a saved observer, because the observer you get in `onCreate`, before the view is attached, is merged into the window's observer later, and removing from the old one would throw. - The snippet runs only when `ApplicationInfo.FLAG_DEBUGGABLE` is set. It doesn't use `BuildConfig.DEBUG`, because AGP 8 and later don't generate `BuildConfig` unless `buildFeatures.buildConfig` is on. - `android.content.pm.ApplicationInfo` and `android.view.ViewTreeObserver` are fully qualified, like `android.R.id.content`, so the wizard still adds only the `io.sentry.Sentry` import. - The comment now says what the snippet does and to remove it after confirming the integration works. - The snippet indents each nesting level by 4 spaces, matching Android Studio's default for Java and Kotlin and the `sentry {}` block the wizard already writes. It used to start at 4 spaces but nest by 2. The first line stays at 4 spaces, in line with `onCreate`'s body. `code-tools.ts` is unchanged and still inserts the snippet right after `super.onCreate(...)`. `@sentry/wizard` has the same snippet and needs the same fix. Open decision: whether this is ready for review. It stays a draft until then. <!-- junior-request-attribution:start --> via **Antonis Lilis**. <!-- junior-request-attribution:end --> <!-- junior-session-footer:start --> <!-- junior-conversation-id:slack%3AD0CAPGCFLSC%3A1796224967.137949 --> -- [View Session](https://junior-prod.sentry.dev/conversations/slack%3AD0CAPGCFLSC%3A1796224967.137949) [[Sentry]](https://sentry.sentry.io/explore/conversations/slack%3AD0CAPGCFLSC%3A1796224967.137949/?project=4510944073809921) <!-- junior-session-footer:end --> --------- Co-authored-by: sentry-junior[bot] <264270552+sentry-junior[bot]@users.noreply.github.com> Co-authored-by: Antonis Lilis <antonis.lilis@sentry.io>
5 tasks
14 of 16 tasks
This branch was successfully deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Testing
sentry wizard ioson real projects showed that the snippet it writes ends with a test event right afterSentrySDK.start. A comment asks people to remove it once the integration works, but when they don't, every launch of the shipped app sends that event to Sentry, using quota and adding noise.@sentry/wizardbehaves the same.The capture line is now wrapped in
#if DEBUG…#endifin both the Swift and Objective-C snippets. Xcode's templates defineDEBUGfor the Debug configuration in both languages, so the test event still arrives from Debug builds but not from Release builds. The#if/#endiflines use the capture line's indentation, like the profiling guard in #2791, and the comment now says the event is Debug-only (the Objective-C comment also gets its missing space after//).Detection of an existing
SentrySDK.start/[SentrySDK startincode-tools.tsis unaffected, since the start call is unchanged.via Antonis Lilis.
--
View Session [Sentry]