apple.tsx 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190
  1. import ExternalLink from 'sentry/components/links/externalLink';
  2. import {Layout, LayoutProps} from 'sentry/components/onboarding/gettingStartedDoc/layout';
  3. import {ModuleProps} from 'sentry/components/onboarding/gettingStartedDoc/sdkDocumentation';
  4. import {StepType} from 'sentry/components/onboarding/gettingStartedDoc/step';
  5. import {t, tct} from 'sentry/locale';
  6. // Configuration Start
  7. export const steps = ({
  8. dsn,
  9. }: {
  10. dsn?: string;
  11. } = {}): LayoutProps['steps'] => [
  12. {
  13. type: StepType.INSTALL,
  14. description: (
  15. <p>
  16. {tct(
  17. '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:',
  18. {
  19. alternateMethods: (
  20. <ExternalLink href="https://docs.sentry.io/platforms/apple/install/" />
  21. ),
  22. addPackage: <strong />,
  23. }
  24. )}
  25. </p>
  26. ),
  27. configurations: [
  28. {
  29. language: 'text',
  30. code: `
  31. https://github.com/getsentry/sentry-cocoa.git
  32. `,
  33. },
  34. {
  35. description: (
  36. <p>
  37. {tct(
  38. 'Alternatively, when your project uses a [packageSwift: Package.swift] file to manage dependencies, you can specify the target with:',
  39. {
  40. packageSwift: <code />,
  41. }
  42. )}
  43. </p>
  44. ),
  45. language: 'swift',
  46. code: `
  47. .package(url: "https://github.com/getsentry/sentry-cocoa", from: "8.9.3"),
  48. `,
  49. },
  50. ],
  51. },
  52. {
  53. type: StepType.CONFIGURE,
  54. description: (
  55. <p>
  56. {tct(
  57. 'Make sure you initialize the SDK as soon as possible in your application lifecycle e.g. in your AppDelegate [appDelegate: application:didFinishLaunchingWithOptions] method:',
  58. {
  59. appDelegate: <code />,
  60. }
  61. )}
  62. </p>
  63. ),
  64. configurations: [
  65. {
  66. language: 'swift',
  67. code: `
  68. import Sentry
  69. // ....
  70. func application(_ application: UIApplication,
  71. didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
  72. SentrySDK.start { options in
  73. options.dsn = "${dsn}"
  74. options.debug = true // Enabled debug when first installing is always helpful
  75. // Set tracesSampleRate to 1.0 to capture 100% of transactions for performance monitoring.
  76. // We recommend adjusting this value in production.
  77. options.tracesSampleRate = 1.0
  78. }
  79. return true
  80. }
  81. `,
  82. },
  83. {
  84. description: (
  85. <p>
  86. {tct(
  87. "When using SwiftUI and your app doesn't implement an app delegate, initialize the SDK within the [initializer: App conformer's initializer]:",
  88. {
  89. initializer: (
  90. <ExternalLink href="https://developer.apple.com/documentation/swiftui/app/main()" />
  91. ),
  92. }
  93. )}
  94. </p>
  95. ),
  96. language: 'swift',
  97. code: `
  98. import Sentry
  99. @main
  100. struct SwiftUIApp: App {
  101. init() {
  102. SentrySDK.start { options in
  103. options.dsn = "${dsn}"
  104. options.debug = true // Enabled debug when first installing is always helpful
  105. // Set tracesSampleRate to 1.0 to capture 100% of transactions for performance monitoring.
  106. // We recommend adjusting this value in production.
  107. options.tracesSampleRate = 1.0
  108. }
  109. }
  110. }
  111. `,
  112. },
  113. ],
  114. },
  115. {
  116. type: StepType.VERIFY,
  117. description: (
  118. <p>
  119. {tct(
  120. '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].',
  121. {
  122. viewController: <code />,
  123. }
  124. )}
  125. </p>
  126. ),
  127. configurations: [
  128. {
  129. language: 'swift',
  130. code: `
  131. let button = UIButton(type: .roundedRect)
  132. button.frame = CGRect(x: 20, y: 50, width: 100, height: 30)
  133. button.setTitle("Break the world", for: [])
  134. button.addTarget(self, action: #selector(self.breakTheWorld(_:)), for: .touchUpInside)
  135. view.addSubview(button)
  136. @IBAction func breakTheWorld(_ sender: AnyObject) {
  137. fatalError("Break the world")
  138. }
  139. `,
  140. },
  141. ],
  142. },
  143. ];
  144. export const nextSteps = [
  145. {
  146. id: 'cocoapods-carthage',
  147. name: t('CocoaPods/Carthage'),
  148. description: t(
  149. 'Learn about integrating Sentry into your project using CocoaPods or Carthage.'
  150. ),
  151. link: 'https://docs.sentry.io/platforms/apple/install/',
  152. },
  153. {
  154. id: 'debug-symbols',
  155. name: t('Debug Symbols'),
  156. description: t('Symbolicate and get readable stacktraces in your Sentry errors.'),
  157. link: 'https://docs.sentry.io/platforms/apple/dsym/',
  158. },
  159. {
  160. id: 'swiftui',
  161. name: t('SwiftUI'),
  162. description: t('Learn about our first class integration with SwiftUI.'),
  163. link: 'https://docs.sentry.io/platforms/apple/performance/instrumentation/swiftui-instrumentation/',
  164. },
  165. {
  166. id: 'profiling',
  167. name: t('Profiling'),
  168. description: t(
  169. 'Collect and analyze performance profiles from real user devices in production.'
  170. ),
  171. link: 'https://docs.sentry.io/platforms/apple/profiling/',
  172. },
  173. ];
  174. // Configuration End
  175. export function GettingStartedWithApple({dsn, ...props}: ModuleProps) {
  176. return <Layout steps={steps({dsn})} nextSteps={nextSteps} {...props} />;
  177. }
  178. export default GettingStartedWithApple;