cordova.tsx 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  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 {
  10. getCrashReportJavaScriptInstallStep,
  11. getCrashReportModalConfigDescription,
  12. getCrashReportModalIntroduction,
  13. } from 'sentry/components/onboarding/gettingStartedDoc/utils/feedbackOnboarding';
  14. import {t, tct} from 'sentry/locale';
  15. type Params = DocsParams;
  16. const getConfigureSnippet = (params: Params) => `
  17. onDeviceReady: function() {
  18. var Sentry = cordova.require('sentry-cordova.Sentry');
  19. Sentry.init({ dsn: '${params.dsn.public}' });
  20. }`;
  21. const onboarding: OnboardingConfig = {
  22. install: () => [
  23. {
  24. type: StepType.INSTALL,
  25. description: t('Install our SDK using the cordova command:'),
  26. configurations: [
  27. {
  28. language: 'bash',
  29. code: 'cordova plugin add sentry-cordova',
  30. },
  31. ],
  32. },
  33. ],
  34. configure: params => [
  35. {
  36. type: StepType.CONFIGURE,
  37. description: tct(
  38. 'You should [code:init] the SDK in the [code:deviceReady] function, to make sure the native integrations runs. For more details about Cordova [link:click here]',
  39. {
  40. code: <code />,
  41. link: (
  42. <ExternalLink href="https://docs.sentry.io/platforms/javascript/guides/cordova/" />
  43. ),
  44. }
  45. ),
  46. configurations: [
  47. {
  48. language: 'javascript',
  49. code: getConfigureSnippet(params),
  50. },
  51. ],
  52. },
  53. ],
  54. verify: () => [
  55. {
  56. type: StepType.VERIFY,
  57. description: (
  58. <Fragment>
  59. {t(
  60. 'One way to verify your setup is by intentionally causing an error that breaks your application.'
  61. )}
  62. <p>{t('Calling an undefined function will throw an exception:')}</p>
  63. </Fragment>
  64. ),
  65. configurations: [
  66. {
  67. language: 'javascript',
  68. code: 'myUndefinedFunction();',
  69. },
  70. ],
  71. },
  72. ],
  73. };
  74. const crashReportOnboarding: OnboardingConfig = {
  75. introduction: () => getCrashReportModalIntroduction(),
  76. install: (params: Params) => getCrashReportJavaScriptInstallStep(params),
  77. configure: () => [
  78. {
  79. type: StepType.CONFIGURE,
  80. description: getCrashReportModalConfigDescription({
  81. link: 'https://docs.sentry.io/platforms/javascript/guides/cordova/user-feedback/configuration/#crash-report-modal',
  82. }),
  83. },
  84. ],
  85. verify: () => [],
  86. nextSteps: () => [],
  87. };
  88. const docs: Docs = {
  89. onboarding,
  90. crashReportOnboarding,
  91. };
  92. export default docs;