sentry-wizard icon indicating copy to clipboard operation
sentry-wizard copied to clipboard

Apple: Step for adding sample error

Open philipphofmann opened this issue 4 months ago • 3 comments

Replace the default captureMessage with a step in the wizard that asks the user if they want to add a captureMessage call, so users don't leave it in by accident, which could send loads of test messages to our servers and burn the users' quota.

https://github.com/getsentry/sentry-wizard/blob/4d6445c119da142b7da3f3b131feba5fa7d6582d/src/apple/templates.ts#L67

Related to https://github.com/getsentry/sentry-wizard/issues/1093

philipphofmann avatar Oct 14 '25 12:10 philipphofmann

WIZARD-104

linear[bot] avatar Oct 14 '25 12:10 linear[bot]

@cursor implement this feature and look how the angular wizard does this, but instead of a button click keep the SentrySDK.capture(message: "This app uses Sentry! :)")\n after the SentrySDK.start, because on iOS adding a button can be a bit tricky.

philipphofmann avatar Oct 14 '25 12:10 philipphofmann

Create PR

Excellent! All tests are passing. Let me create a summary of what I implemented:

Summary

I've successfully implemented the feature to add a wizard step that asks users if they want to include a sample error in the Apple/iOS Sentry setup, similar to how the Angular wizard does it.

Changes Made:

  1. Added new prompt function (src/utils/clack/index.ts):

    • Created askShouldAddSampleError() function that asks users if they want to add a sample error to verify their Sentry setup
    • The prompt suggests "Yes" as recommended but reminds users to remove it later
  2. Updated templates (src/apple/templates.ts):

    • Modified getSwiftSnippet() to accept an optional addSampleError parameter (defaults to true)
    • Modified getObjcSnippet() to accept an optional addSampleError parameter (defaults to true)
    • Both functions now conditionally include the SentrySDK.capture(message:) call based on the parameter
  3. Updated code injection (src/apple/code-tools.ts):

    • Modified addCodeSnippetToProject() to accept the addSampleError parameter and pass it to template functions
  4. Updated injection wrapper (src/apple/inject-code-snippet.ts):

    • Modified injectCodeSnippet() to accept and pass through the addSampleError parameter
  5. Updated wizard flow (src/apple/apple-wizard.ts):

    • Added import for askShouldAddSampleError and Sentry for telemetry
    • Added step to ask users about including sample error
    • Added telemetry tracking for the user's choice
    • Pass the user's choice to the code injection function
  6. Updated tests (test/apple/templates.test.ts):

    • Added test cases for Swift and Objective-C snippets without the sample error
    • All existing tests pass with backward compatibility

Key Design Decisions:

  • The addSampleError parameter defaults to true to maintain backward compatibility with existing code
  • The sample error code is kept right after SentrySDK.start (not tied to a button), as requested for iOS
  • The implementation follows the same pattern as the Angular wizard for consistency
  • Telemetry tracking is included to monitor feature adoption

All 190 tests pass successfully! ✅


Open in Cursor Open in Web

Learn more about Cursor Agents

cursor[bot] avatar Oct 14 '25 12:10 cursor[bot]