cordova.tsx 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  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}' });
  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 [initCode:init] the SDK in the [deviceReadyCode:deviceReady] function, to make sure the native integrations runs. For more details about Cordova [link:click here]',
  39. {
  40. initCode: <code />,
  41. deviceReadyCode: <code />,
  42. link: (
  43. <ExternalLink href="https://docs.sentry.io/platforms/javascript/guides/cordova/" />
  44. ),
  45. }
  46. ),
  47. configurations: [
  48. {
  49. language: 'javascript',
  50. code: getConfigureSnippet(params),
  51. },
  52. ],
  53. },
  54. ],
  55. verify: () => [
  56. {
  57. type: StepType.VERIFY,
  58. description: (
  59. <Fragment>
  60. {t(
  61. 'One way to verify your setup is by intentionally causing an error that breaks your application.'
  62. )}
  63. <p>{t('Calling an undefined function will throw an exception:')}</p>
  64. </Fragment>
  65. ),
  66. configurations: [
  67. {
  68. language: 'javascript',
  69. code: 'myUndefinedFunction();',
  70. },
  71. ],
  72. },
  73. ],
  74. };
  75. const crashReportOnboarding: OnboardingConfig = {
  76. introduction: () => getCrashReportModalIntroduction(),
  77. install: (params: Params) => getCrashReportJavaScriptInstallStep(params),
  78. configure: () => [
  79. {
  80. type: StepType.CONFIGURE,
  81. description: getCrashReportModalConfigDescription({
  82. link: 'https://docs.sentry.io/platforms/javascript/guides/cordova/user-feedback/configuration/#crash-report-modal',
  83. }),
  84. },
  85. ],
  86. verify: () => [],
  87. nextSteps: () => [],
  88. };
  89. const docs: Docs = {
  90. onboarding,
  91. crashReportOnboarding,
  92. };
  93. export default docs;