native-qt.tsx 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110
  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 [nativeQTSDKDocumentationLink:Native SDK Documentation] to build the SDK library.',
  17. {
  18. releasesLink: (
  19. <ExternalLink href="https://github.com/getsentry/sentry-native/releases" />
  20. ),
  21. nativeQTSDKDocumentationLink: (
  22. <ExternalLink href="https://docs.sentry.io/platforms/native/guides/qt/" />
  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 <QtWidgets>
  39. #include <sentry.h>
  40. int main(int argc, char *argv[])
  41. {
  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. // Make sure everything flushes
  51. auto sentryClose = qScopeGuard([] { sentry_close(); });
  52. QApplication app(argc, argv);
  53. /* ... */
  54. return app.exec();
  55. }
  56. `,
  57. },
  58. ],
  59. additionalInfo: (
  60. <p>
  61. {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. </p>
  68. ),
  69. },
  70. {
  71. type: StepType.VERIFY,
  72. description: t(
  73. 'The quickest way to verify Sentry in your Qt application is by capturing a message:'
  74. ),
  75. configurations: [
  76. {
  77. language: 'c',
  78. code: `
  79. sentry_capture_event(sentry_value_new_message_event(
  80. /* level */ SENTRY_LEVEL_INFO,
  81. /* logger */ "custom",
  82. /* message */ "It works!"
  83. ));
  84. `,
  85. },
  86. ],
  87. additionalInfo: (
  88. <Fragment>
  89. {t(
  90. "If you're new to Sentry, use the email alert to access your account and complete a product tour."
  91. )}
  92. {t(
  93. "If you're an existing user and have disabled alerts, you won't receive this email."
  94. )}
  95. </Fragment>
  96. ),
  97. },
  98. ];
  99. // Configuration End
  100. export function GettingStartedWithNativeQT({dsn, ...props}: ModuleProps) {
  101. return <Layout steps={steps({dsn})} {...props} />;
  102. }
  103. export default GettingStartedWithNativeQT;