cordova.tsx 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. import {Fragment} from 'react';
  2. import ExternalLink from 'sentry/components/links/externalLink';
  3. import {Layout, LayoutProps} from 'sentry/components/onboarding/gettingStartedDoc/layout';
  4. import {ModuleProps} from 'sentry/components/onboarding/gettingStartedDoc/sdkDocumentation';
  5. import {StepType} from 'sentry/components/onboarding/gettingStartedDoc/step';
  6. import {t, tct} from 'sentry/locale';
  7. // Configuration Start
  8. export const steps = ({
  9. dsn,
  10. }: {
  11. dsn?: string;
  12. } = {}): LayoutProps['steps'] => [
  13. {
  14. type: StepType.INSTALL,
  15. description: t('Install our SDK using the cordova command:'),
  16. configurations: [
  17. {
  18. language: 'bash',
  19. code: 'cordova plugin add sentry-cordova',
  20. },
  21. ],
  22. },
  23. {
  24. type: StepType.CONFIGURE,
  25. description: (
  26. <p>
  27. {tct(
  28. '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]',
  29. {
  30. initCode: <code />,
  31. deviceReadyCode: <code />,
  32. link: (
  33. <ExternalLink href="https://docs.sentry.io/platforms/javascript/guides/cordova/" />
  34. ),
  35. }
  36. )}
  37. </p>
  38. ),
  39. configurations: [
  40. {
  41. language: 'javascript',
  42. code: `
  43. onDeviceReady: function() {
  44. var Sentry = cordova.require('sentry-cordova.Sentry');
  45. Sentry.init({ dsn: '${dsn}' });
  46. }
  47. `,
  48. },
  49. ],
  50. },
  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. // Configuration End
  70. export function GettingStartedWithCordova({dsn, ...props}: ModuleProps) {
  71. return <Layout steps={steps({dsn})} {...props} />;
  72. }
  73. export default GettingStartedWithCordova;