native.tsx 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109
  1. import {Fragment} from 'react';
  2. import ExternalLink from 'sentry/components/links/externalLink';
  3. import {StepType} from 'sentry/components/onboarding/gettingStartedDoc/step';
  4. import type {
  5. Docs,
  6. DocsParams,
  7. OnboardingConfig,
  8. } from 'sentry/components/onboarding/gettingStartedDoc/types';
  9. import {CrashReportWebApiOnboarding} from 'sentry/components/onboarding/gettingStartedDoc/utils/feedbackOnboarding';
  10. import {t, tct} from 'sentry/locale';
  11. type Params = DocsParams;
  12. const getConfigureSnippet = (params: Params) => `
  13. #include <sentry.h>
  14. int main(void) {
  15. sentry_options_t *options = sentry_options_new();
  16. sentry_options_set_dsn(options, "${params.dsn}");
  17. // This is also the default-path. For further information and recommendations:
  18. // https://docs.sentry.io/platforms/native/configuration/options/#database-path
  19. sentry_options_set_database_path(options, ".sentry-native");
  20. sentry_options_set_release(options, "my-project-name@2.3.12");
  21. sentry_options_set_debug(options, 1);
  22. sentry_init(options);
  23. /* ... */
  24. // make sure everything flushes
  25. sentry_close();
  26. }`;
  27. const getVerifySnippet = () => `
  28. sentry_capture_event(sentry_value_new_message_event(
  29. /* level */ SENTRY_LEVEL_INFO,
  30. /* logger */ "custom",
  31. /* message */ "It works!"
  32. ));`;
  33. const onboarding: OnboardingConfig = {
  34. install: () => [
  35. {
  36. type: StepType.INSTALL,
  37. description: tct(
  38. 'Install the SDK by downloading the [releasesLink:latest release]. Next, follow the instructions in the [nativeSDKDocumentationLink:Native SDK Documentation] to build and link the SDK library.',
  39. {
  40. releasesLink: (
  41. <ExternalLink href="https://github.com/getsentry/sentry-native/releases" />
  42. ),
  43. nativeSDKDocumentationLink: (
  44. <ExternalLink href="https://docs.sentry.io/platforms/native/" />
  45. ),
  46. }
  47. ),
  48. },
  49. ],
  50. configure: params => [
  51. {
  52. type: StepType.CONFIGURE,
  53. description: t(
  54. 'Import and initialize the Sentry SDK early in your application setup:'
  55. ),
  56. configurations: [
  57. {
  58. language: 'c',
  59. code: getConfigureSnippet(params),
  60. },
  61. ],
  62. additionalInfo: tct(
  63. 'Alternatively, the DSN can be passed as [code:SENTRY_DSN] environment variable during runtime. This can be especially useful for server applications.',
  64. {
  65. code: <code />,
  66. }
  67. ),
  68. },
  69. ],
  70. verify: () => [
  71. {
  72. type: StepType.VERIFY,
  73. description: t(
  74. 'The quickest way to verify Sentry in your Native application is by capturing a message:'
  75. ),
  76. configurations: [
  77. {
  78. language: 'c',
  79. code: getVerifySnippet(),
  80. },
  81. ],
  82. additionalInfo: (
  83. <Fragment>
  84. {t(
  85. "If you're new to Sentry, use the email alert to access your account and complete a product tour."
  86. )}
  87. {t(
  88. "If you're an existing user and have disabled alerts, you won't receive this email."
  89. )}
  90. </Fragment>
  91. ),
  92. },
  93. ],
  94. };
  95. const docs: Docs = {
  96. onboarding,
  97. crashReportOnboarding: CrashReportWebApiOnboarding,
  98. };
  99. export default docs;