native.tsx 3.0 KB

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