native.tsx 3.0 KB

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