native-qt.tsx 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111
  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 <QtWidgets>
  13. #include <sentry.h>
  14. int main(int argc, char *argv[])
  15. {
  16. sentry_options_t *options = sentry_options_new();
  17. sentry_options_set_dsn(options, "${params.dsn}");
  18. // This is also the default-path. For further information and recommendations:
  19. // https://docs.sentry.io/platforms/native/configuration/options/#database-path
  20. sentry_options_set_database_path(options, ".sentry-native");
  21. sentry_options_set_release(options, "my-project-name@2.3.12");
  22. sentry_options_set_debug(options, 1);
  23. sentry_init(options);
  24. // Make sure everything flushes
  25. auto sentryClose = qScopeGuard([] { sentry_close(); });
  26. QApplication app(argc, argv);
  27. /* ... */
  28. return app.exec();
  29. }`;
  30. const getVerifySnippet = () => `
  31. sentry_capture_event(sentry_value_new_message_event(
  32. /* level */ SENTRY_LEVEL_INFO,
  33. /* logger */ "custom",
  34. /* message */ "It works!"
  35. ));`;
  36. const onboarding: OnboardingConfig = {
  37. install: () => [
  38. {
  39. type: StepType.INSTALL,
  40. description: tct(
  41. 'Install the SDK by downloading the [releasesLink:latest release]. Next, follow the instructions in the [nativeQTSDKDocumentationLink:Native SDK Documentation] to build the SDK library.',
  42. {
  43. releasesLink: (
  44. <ExternalLink href="https://github.com/getsentry/sentry-native/releases" />
  45. ),
  46. nativeQTSDKDocumentationLink: (
  47. <ExternalLink href="https://docs.sentry.io/platforms/native/guides/qt/" />
  48. ),
  49. }
  50. ),
  51. },
  52. ],
  53. configure: params => [
  54. {
  55. type: StepType.CONFIGURE,
  56. description: t(
  57. 'Import and initialize the Sentry SDK early in your application setup:'
  58. ),
  59. configurations: [
  60. {
  61. language: 'c',
  62. code: getConfigureSnippet(params),
  63. },
  64. ],
  65. additionalInfo: tct(
  66. 'Alternatively, the DSN can be passed as [code:SENTRY_DSN] environment variable during runtime. This can be especially useful for server applications.',
  67. {
  68. code: <code />,
  69. }
  70. ),
  71. },
  72. ],
  73. verify: () => [
  74. {
  75. type: StepType.VERIFY,
  76. description: t(
  77. 'The quickest way to verify Sentry in your Qt application is by capturing a message:'
  78. ),
  79. configurations: [
  80. {
  81. language: 'c',
  82. code: getVerifySnippet(),
  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. };
  98. const docs: Docs = {
  99. onboarding,
  100. };
  101. export default docs;