import ExternalLink from 'sentry/components/links/externalLink'; import {StepType} from 'sentry/components/onboarding/gettingStartedDoc/step'; import type { Docs, DocsParams, OnboardingConfig, } from 'sentry/components/onboarding/gettingStartedDoc/types'; import { getCrashReportApiIntroduction, getCrashReportInstallDescription, } from 'sentry/components/onboarding/gettingStartedDoc/utils/feedbackOnboarding'; import {t, tct} from 'sentry/locale'; import {getPackageVersion} from 'sentry/utils/gettingStartedDocs/getPackageVersion'; type Params = DocsParams; const getInstallSnippet = (params: Params) => ` .package(url: "https://github.com/getsentry/sentry-cocoa", from: "${getPackageVersion( params, 'sentry.cocoa', '8.9.3' )}"),`; const getConfigurationSnippet = (params: Params) => ` import Sentry // .... func applicationDidFinishLaunching(_ aNotification: Notification) { SentrySDK.start { options in options.dsn = "${params.dsn}" options.debug = true // Enabling debug when first installing is always helpful${ params.isPerformanceSelected ? ` // Set tracesSampleRate to 1.0 to capture 100% of transactions for performance monitoring. // We recommend adjusting this value in production. options.tracesSampleRate = 1.0` : '' }${ params.isProfilingSelected ? ` // Sample rate for profiling, applied on top of TracesSampleRate. // We recommend adjusting this value in production. options.profilesSampleRate = 1.0` : '' } } return true }`; const getConfigurationSnippetSwiftUi = (params: Params) => ` import Sentry @main struct SwiftUIApp: App { init() { SentrySDK.start { options in options.dsn = "${params.dsn}" options.debug = true // Enabling debug when first installing is always helpful${ params.isPerformanceSelected ? ` // Set tracesSampleRate to 1.0 to capture 100% of transactions for performance monitoring. // We recommend adjusting this value in production. options.tracesSampleRate = 1.0` : '' }${ params.isProfilingSelected ? ` // Sample rate for profiling, applied on top of TracesSampleRate. // We recommend adjusting this value in production. options.profilesSampleRate = 1.0` : '' } } } }`; const getVerifySnippet = () => ` let button = UIButton(type: .roundedRect) button.frame = CGRect(x: 20, y: 50, width: 100, height: 30) button.setTitle("Break the world", for: []) button.addTarget(self, action: #selector(self.breakTheWorld(_:)), for: .touchUpInside) view.addSubview(button) @IBAction func breakTheWorld(_ sender: AnyObject) { fatalError("Break the world") }`; const onboarding: OnboardingConfig = { install: params => [ { type: StepType.INSTALL, description: (
{tct(
'We recommend installing the SDK with Swift Package Manager (SPM), but we also support [alternateMethods: alternate installation methods]. To integrate Sentry into your Xcode project using SPM, open your App in Xcode and open [addPackage: File > Add Packages]. Then add the SDK by entering the Git repo url in the top right search field:',
{
alternateMethods: (
{tct(
'Alternatively, when your project uses a [packageSwift: Package.swift] file to manage dependencies, you can specify the target with:',
{
packageSwift: ,
}
)}
{tct(
'Make sure you initialize the SDK as soon as possible in your application lifecycle e.g. in your [appDelegate:] method:',
{
appDelegate: (
- [NSAppDelegate applicationDidFinishLaunchingWithNotification:]
),
}
)}
{tct(
"When using SwiftUI and your app doesn't implement an app delegate, initialize the SDK within the [initializer: App conformer's initializer]:",
{
initializer: (
{tct(
'This snippet contains an intentional error you can use to test that errors are uploaded to Sentry correctly. You can add it to your main [viewController: ViewController].',
{
viewController: ,
}
)}
}
),
code: [
{
label: 'Swift',
value: 'swift',
language: 'swift',
code: `import Sentry
SentrySDK.start { options in
options.dsn = "${params.dsn}"
options.onCrashedLastRun = { event in
// capture user feedback
}
}
`,
},
{
label: 'Objective-C',
value: 'c',
language: 'c',
code: `@import Sentry;
[SentrySDK startWithConfigureOptions:^(SentryOptions *options) {
options.dsn = @"${params.dsn}";
options.onCrashedLastRun = ^void(SentryEvent * _Nonnull event) {
// capture user feedback
};
}];`,
},
],
},
],
},
],
configure: () => [],
verify: () => [],
nextSteps: () => [],
};
const docs: Docs = {
onboarding,
feedbackOnboardingCrashApi: appleFeedbackOnboarding,
crashReportOnboarding: appleFeedbackOnboarding,
};
export default docs;