azurefunctions.tsx 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  1. import {StepType} from 'sentry/components/onboarding/gettingStartedDoc/step';
  2. import type {
  3. Docs,
  4. DocsParams,
  5. OnboardingConfig,
  6. } from 'sentry/components/onboarding/gettingStartedDoc/types';
  7. import {getUploadSourceMapsStep} from 'sentry/components/onboarding/gettingStartedDoc/utils';
  8. import {
  9. getCrashReportJavaScriptInstallStep,
  10. getCrashReportModalConfigDescription,
  11. getCrashReportModalIntroduction,
  12. } from 'sentry/components/onboarding/gettingStartedDoc/utils/feedbackOnboarding';
  13. import {t, tct} from 'sentry/locale';
  14. import {getInstallConfig, getSdkInitSnippet} from 'sentry/utils/gettingStartedDocs/node';
  15. type Params = DocsParams;
  16. const getSdkSetupSnippet = (params: Params) => `
  17. "use strict";
  18. // IMPORTANT: Make sure to import and initialize Sentry at the top of your file.
  19. ${getSdkInitSnippet(params, 'node')}
  20. // Place any other require/import statements here
  21. module.exports = async function (context, req) {
  22. try {
  23. await notExistFunction();
  24. } catch (e) {
  25. Sentry.captureException(e);
  26. await Sentry.flush(2000);
  27. }
  28. context.res = {
  29. status: 200,
  30. body: "Hello from Azure Cloud Function!",
  31. };
  32. };
  33. `;
  34. const onboarding: OnboardingConfig = {
  35. introduction: () =>
  36. tct('In this quick guide you’ll use [strong:npm] or [strong:yarn] to set up:', {
  37. strong: <strong />,
  38. }),
  39. install: params => [
  40. {
  41. type: StepType.INSTALL,
  42. description: t('Add the Sentry Node SDK as a dependency:'),
  43. configurations: getInstallConfig(params),
  44. },
  45. ],
  46. configure: params => [
  47. {
  48. type: StepType.CONFIGURE,
  49. description: tct(
  50. 'Ensure that Sentry is imported and initialized at the beginning of your file, prior to any other [code:require] or [code:import] statements.',
  51. {code: <code />}
  52. ),
  53. configurations: [
  54. {
  55. language: 'javascript',
  56. description: tct(
  57. 'Note: You need to call both [code:captureException] and [code:flush] for captured events to be successfully delivered to Sentry.',
  58. {code: <code />}
  59. ),
  60. },
  61. {
  62. language: 'javascript',
  63. code: getSdkSetupSnippet(params),
  64. },
  65. ],
  66. },
  67. getUploadSourceMapsStep({
  68. guideLink:
  69. 'https://docs.sentry.io/platforms/javascript/guides/azure-functions/sourcemaps/',
  70. ...params,
  71. }),
  72. ],
  73. verify: () => [],
  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/azure-functions/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;