apple-ios.tsx 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355
  1. import ExternalLink from 'sentry/components/links/externalLink';
  2. import Link from 'sentry/components/links/link';
  3. import List from 'sentry/components/list/';
  4. import ListItem from 'sentry/components/list/listItem';
  5. import {StepType} from 'sentry/components/onboarding/gettingStartedDoc/step';
  6. import type {
  7. Docs,
  8. DocsParams,
  9. OnboardingConfig,
  10. } from 'sentry/components/onboarding/gettingStartedDoc/types';
  11. import {appleFeedbackOnboarding} from 'sentry/gettingStartedDocs/apple/apple-macos';
  12. import {t, tct} from 'sentry/locale';
  13. type Params = DocsParams;
  14. const getInstallSnippet = () =>
  15. `brew install getsentry/tools/sentry-wizard && sentry-wizard -i ios`;
  16. const getExperimentalFeaturesSnippetSwift = () => `
  17. import Sentry
  18. SentrySDK.start { options in
  19. // ...
  20. // Enable all experimental features
  21. options.attachViewHierarchy = true
  22. options.enableMetricKit = true
  23. options.enableTimeToFullDisplayTracing = true
  24. options.swiftAsyncStacktraces = true
  25. options.enableAppLaunchProfiling = true
  26. }`;
  27. const getExperimentalFeaturesSnippetObjC = () => `
  28. @import Sentry;
  29. [SentrySDK startWithConfigureOptions:^(SentryOptions *options) {
  30. // ...
  31. // Enable all experimental features
  32. options.attachViewHierarchy = YES;
  33. options.enableMetricKit = YES;
  34. options.enableTimeToFullDisplayTracing = YES;
  35. options.swiftAsyncStacktraces = YES;
  36. options.enableAppLaunchProfiling = YES;
  37. }];`;
  38. const getConfigureMetricsSnippetSwift = (params: Params) => `
  39. import Sentry
  40. SentrySDK.start { options in
  41. options.dsn = "${params.dsn}"
  42. options.enableMetrics = true
  43. }`;
  44. const getConfigureMetricsSnippetObjC = (params: Params) => `
  45. @import Sentry;
  46. [SentrySDK startWithConfigureOptions:^(SentryOptions * options) {
  47. options.Dsn = @"${params.dsn}";
  48. options.enableMetrics = YES;
  49. }];`;
  50. const getVerifyMetricsSnippetSwift = () => `
  51. import Sentry
  52. SentrySDK.metrics
  53. .increment(key: "button_login_click",
  54. value: 1.0,
  55. tags: ["screen": "login"]
  56. )`;
  57. const getVerifyMetricsSnippetObjC = () => `
  58. @import Sentry;
  59. [SentrySDK.metrics
  60. incrementWithKey :@"button_login_click"
  61. value: 1.0
  62. unit: SentryMeasurementUnit.none
  63. tags: @{ @"screen" : @"login" }
  64. ];`;
  65. const onboarding: OnboardingConfig = {
  66. install: () => [
  67. {
  68. type: StepType.INSTALL,
  69. description: (
  70. <p>
  71. {tct(
  72. 'Add Sentry automatically to your app with the [wizardLink:Sentry wizard] (call this inside your project directory).',
  73. {
  74. wizardLink: (
  75. <ExternalLink href="https://docs.sentry.io/platforms/apple/guides/ios/#install" />
  76. ),
  77. }
  78. )}
  79. </p>
  80. ),
  81. configurations: [
  82. {
  83. language: 'bash',
  84. code: getInstallSnippet(),
  85. },
  86. ],
  87. },
  88. ],
  89. configure: () => [
  90. {
  91. type: StepType.CONFIGURE,
  92. description: t('The Sentry wizard will automatically patch your application:'),
  93. configurations: [
  94. {
  95. description: (
  96. <List symbol="bullet">
  97. <ListItem>
  98. {t('Install the Sentry SDK via Swift Package Manager or Cocoapods')}
  99. </ListItem>
  100. <ListItem>
  101. {tct(
  102. 'Update your [appDelegate: AppDelegate] or SwiftUI App Initializer with the default Sentry configuration and an example error',
  103. {
  104. appDelegate: <code />,
  105. }
  106. )}
  107. </ListItem>
  108. <ListItem>
  109. {tct(
  110. 'Add a new [phase: Upload Debug Symbols] phase to your [xcodebuild: xcodebuild] build script',
  111. {
  112. phase: <code />,
  113. xcodebuild: <code />,
  114. }
  115. )}
  116. </ListItem>
  117. <ListItem>
  118. {tct(
  119. 'Create [sentryclirc: .sentryclirc] with an auth token to upload debug symbols (this file is automatically added to [gitignore: .gitignore])',
  120. {
  121. sentryclirc: <code />,
  122. gitignore: <code />,
  123. }
  124. )}
  125. </ListItem>
  126. <ListItem>
  127. {t(
  128. "When you're using Fastlane, it will add a Sentry lane for uploading debug symbols"
  129. )}
  130. </ListItem>
  131. </List>
  132. ),
  133. additionalInfo: tct(
  134. 'Alternatively, you can also [manualSetupLink:set up the SDK manually].',
  135. {
  136. manualSetupLink: (
  137. <ExternalLink href="https://docs.sentry.io/platforms/apple/guides/ios/manual-setup/" />
  138. ),
  139. stepsBelow: <strong />,
  140. }
  141. ),
  142. },
  143. ],
  144. },
  145. ],
  146. verify: () => [
  147. {
  148. type: StepType.VERIFY,
  149. description: t(
  150. 'The Sentry wizard automatically adds a code snippet that captures a message to your project. Simply run your app and you should see this message in your Sentry project.'
  151. ),
  152. },
  153. {
  154. title: t('Experimental Features'),
  155. description: tct(
  156. 'Want to play with some new features? Try out our experimental features for [vh: View Hierarchy], [ttfd: Time to Full Display (TTFD)], [metricKit: MetricKit], [prewarmedAppStart: Prewarmed App Start Tracing], and [asyncStacktraces: Swift Async Stacktraces]. Experimental features are still a work-in-progress and may have bugs. We recognize the irony. [break] Let us know if you have feedback through [gh: GitHub issues].',
  157. {
  158. vh: (
  159. <ExternalLink href="https://docs.sentry.io/platforms/apple/guides/ios/enriching-events/viewhierarchy/" />
  160. ),
  161. ttfd: (
  162. <ExternalLink href="https://docs.sentry.io/platforms/apple/guides/ios/performance/instrumentation/automatic-instrumentation/#time-to-full-display" />
  163. ),
  164. metricKit: (
  165. <ExternalLink href="https://docs.sentry.io/platforms/apple/guides/watchos/configuration/metric-kit/" />
  166. ),
  167. prewarmedAppStart: (
  168. <ExternalLink href="https://docs.sentry.io/platforms/apple/performance/instrumentation/automatic-instrumentation/#prewarmed-app-start-tracing" />
  169. ),
  170. asyncStacktraces: (
  171. <ExternalLink href="https://docs.sentry.io/platforms/apple/guides/ios/#stitch-together-swift-concurrency-stack-traces" />
  172. ),
  173. gh: <ExternalLink href="https://github.com/getsentry/sentry-cocoa/issues" />,
  174. break: <br />,
  175. }
  176. ),
  177. configurations: [
  178. {
  179. code: [
  180. {
  181. label: 'Swift',
  182. value: 'swift',
  183. language: 'swift',
  184. code: getExperimentalFeaturesSnippetSwift(),
  185. },
  186. {
  187. label: 'Objective-C',
  188. value: 'c',
  189. language: 'c',
  190. code: getExperimentalFeaturesSnippetObjC(),
  191. },
  192. ],
  193. },
  194. ],
  195. },
  196. ],
  197. nextSteps: () => [
  198. {
  199. id: 'cocoapods-carthage',
  200. name: t('CocoaPods/Carthage'),
  201. description: t(
  202. 'Learn about integrating Sentry into your project using CocoaPods or Carthage.'
  203. ),
  204. link: 'https://docs.sentry.io/platforms/apple/install/',
  205. },
  206. {
  207. id: 'debug-symbols',
  208. name: t('Debug Symbols'),
  209. description: t('Symbolicate and get readable stacktraces in your Sentry errors.'),
  210. link: 'https://docs.sentry.io/platforms/apple/dsym/',
  211. },
  212. {
  213. id: 'swiftui',
  214. name: t('SwiftUI'),
  215. description: t('Learn about our first class integration with SwiftUI.'),
  216. link: 'https://docs.sentry.io/platforms/apple/performance/instrumentation/swiftui-instrumentation/',
  217. },
  218. {
  219. id: 'profiling',
  220. name: t('Profiling'),
  221. description: t(
  222. 'Collect and analyze performance profiles from real user devices in production.'
  223. ),
  224. link: 'https://docs.sentry.io/platforms/apple/profiling/',
  225. },
  226. ],
  227. };
  228. const metricsOnboarding: OnboardingConfig = {
  229. install: (params: DocsParams) => [
  230. {
  231. type: StepType.INSTALL,
  232. description: tct(
  233. 'You need Sentry Cocoa SDK version [codeVersion:8.23.0] or higher. Learn more about installation methods in our [docsLink:full documentation].',
  234. {
  235. codeVersion: <code />,
  236. docsLink: <Link to={`/projects/${params.projectSlug}/getting-started/`} />,
  237. }
  238. ),
  239. configurations: [
  240. {
  241. language: 'yml',
  242. partialLoading: params.sourcePackageRegistries?.isLoading,
  243. code: getInstallSnippet(),
  244. },
  245. ],
  246. },
  247. ],
  248. configure: (params: DocsParams) => [
  249. {
  250. type: StepType.CONFIGURE,
  251. description: t(
  252. 'To enable capturing metrics, you need to enable the metrics feature.'
  253. ),
  254. configurations: [
  255. {
  256. code: [
  257. {
  258. label: 'Swift',
  259. value: 'swift',
  260. language: 'swift',
  261. code: getConfigureMetricsSnippetSwift(params),
  262. },
  263. {
  264. label: 'Objective-C',
  265. value: 'c',
  266. language: 'c',
  267. code: getConfigureMetricsSnippetObjC(params),
  268. },
  269. ],
  270. },
  271. ],
  272. },
  273. ],
  274. verify: () => [
  275. {
  276. type: StepType.VERIFY,
  277. description: tct(
  278. "Then you'll be able to add metrics as [codeCounters:counters], [codeSets:sets], [codeDistribution:distributions], and [codeGauge:gauges]. These are available under the [codeNamespace:SentrySDK.metrics()] namespace. Try out this example:",
  279. {
  280. codeCounters: <code />,
  281. codeSets: <code />,
  282. codeDistribution: <code />,
  283. codeGauge: <code />,
  284. codeNamespace: <code />,
  285. }
  286. ),
  287. configurations: [
  288. {
  289. configurations: [
  290. {
  291. code: [
  292. {
  293. label: 'Swift',
  294. value: 'swift',
  295. language: 'swift',
  296. code: getVerifyMetricsSnippetSwift(),
  297. },
  298. {
  299. label: 'Objective-C',
  300. value: 'c',
  301. language: 'c',
  302. code: getVerifyMetricsSnippetObjC(),
  303. },
  304. ],
  305. },
  306. ],
  307. },
  308. {
  309. description: t(
  310. 'With a bit of delay you can see the data appear in the Sentry UI.'
  311. ),
  312. },
  313. {
  314. description: tct(
  315. 'Learn more about metrics and how to configure them, by reading the [docsLink:docs].',
  316. {
  317. docsLink: (
  318. <ExternalLink href="https://docs.sentry.io/platforms/apple/metrics/" />
  319. ),
  320. }
  321. ),
  322. },
  323. ],
  324. },
  325. ],
  326. };
  327. const docs: Docs = {
  328. onboarding,
  329. feedbackOnboardingCrashApi: appleFeedbackOnboarding,
  330. crashReportOnboarding: appleFeedbackOnboarding,
  331. customMetricsOnboarding: metricsOnboarding,
  332. };
  333. export default docs;