qt.tsx 3.3 KB

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