cordova.tsx 2.1 KB

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