native-qt.tsx 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112
  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 [nativeQTSDKDocumentationLink:Native SDK Documentation] to build the SDK library.',
  19. {
  20. releasesLink: (
  21. <ExternalLink href="https://github.com/getsentry/sentry-native/releases" />
  22. ),
  23. nativeQTSDKDocumentationLink: (
  24. <ExternalLink href="https://docs.sentry.io/platforms/native/guides/qt/" />
  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 <QtWidgets>
  41. #include <sentry.h>
  42. int main(int argc, char *argv[])
  43. {
  44. sentry_options_t *options = sentry_options_new();
  45. sentry_options_set_dsn(options, "${dsn}");
  46. // This is also the default-path. For further information and recommendations:
  47. // https://docs.sentry.io/platforms/native/configuration/options/#database-path
  48. sentry_options_set_database_path(options, ".sentry-native");
  49. sentry_options_set_release(options, "my-project-name@2.3.12");
  50. sentry_options_set_debug(options, 1);
  51. sentry_init(options);
  52. // Make sure everything flushes
  53. auto sentryClose = qScopeGuard([] { sentry_close(); });
  54. QApplication app(argc, argv);
  55. /* ... */
  56. return app.exec();
  57. }
  58. `,
  59. },
  60. ],
  61. additionalInfo: (
  62. <p>
  63. {tct(
  64. 'Alternatively, the DSN can be passed as [code:SENTRY_DSN] environment variable during runtime. This can be especially useful for server applications.',
  65. {
  66. code: <code />,
  67. }
  68. )}
  69. </p>
  70. ),
  71. },
  72. {
  73. type: StepType.VERIFY,
  74. description: t(
  75. 'The quickest way to verify Sentry in your Qt application is by capturing a message:'
  76. ),
  77. configurations: [
  78. {
  79. language: 'c',
  80. code: `
  81. sentry_capture_event(sentry_value_new_message_event(
  82. /* level */ SENTRY_LEVEL_INFO,
  83. /* logger */ "custom",
  84. /* message */ "It works!"
  85. ));
  86. `,
  87. },
  88. ],
  89. additionalInfo: (
  90. <Fragment>
  91. {t(
  92. "If you're new to Sentry, use the email alert to access your account and complete a product tour."
  93. )}
  94. {t(
  95. "If you're an existing user and have disabled alerts, you won't receive this email."
  96. )}
  97. </Fragment>
  98. ),
  99. },
  100. ];
  101. // Configuration End
  102. export function GettingStartedWithNativeQT({dsn, ...props}: ModuleProps) {
  103. return <Layout steps={steps({dsn})} {...props} />;
  104. }
  105. export default GettingStartedWithNativeQT;