cordova.tsx 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  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. onDeviceReady: function() {
  13. var Sentry = cordova.require('sentry-cordova.Sentry');
  14. Sentry.init({ dsn: '${params.dsn}' });
  15. }`;
  16. const onboarding: OnboardingConfig = {
  17. install: () => [
  18. {
  19. type: StepType.INSTALL,
  20. description: t('Install our SDK using the cordova command:'),
  21. configurations: [
  22. {
  23. language: 'bash',
  24. code: 'cordova plugin add sentry-cordova',
  25. },
  26. ],
  27. },
  28. ],
  29. configure: params => [
  30. {
  31. type: StepType.CONFIGURE,
  32. description: tct(
  33. '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]',
  34. {
  35. initCode: <code />,
  36. deviceReadyCode: <code />,
  37. link: (
  38. <ExternalLink href="https://docs.sentry.io/platforms/javascript/guides/cordova/" />
  39. ),
  40. }
  41. ),
  42. configurations: [
  43. {
  44. language: 'javascript',
  45. code: getConfigureSnippet(params),
  46. },
  47. ],
  48. },
  49. ],
  50. verify: () => [
  51. {
  52. type: StepType.VERIFY,
  53. description: (
  54. <Fragment>
  55. {t(
  56. 'One way to verify your setup is by intentionally causing an error that breaks your application.'
  57. )}
  58. <p>{t('Calling an undefined function will throw an exception:')}</p>
  59. </Fragment>
  60. ),
  61. configurations: [
  62. {
  63. language: 'javascript',
  64. code: 'myUndefinedFunction();',
  65. },
  66. ],
  67. },
  68. ],
  69. };
  70. const docs: Docs = {
  71. onboarding,
  72. };
  73. export default docs;