native.tsx 3.1 KB

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