go.tsx 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132
  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 {
  8. getCrashReportGenericInstallStep,
  9. getCrashReportModalConfigDescription,
  10. getCrashReportModalIntroduction,
  11. } from 'sentry/components/onboarding/gettingStartedDoc/utils/feedbackOnboarding';
  12. import replayOnboardingJsLoader from 'sentry/gettingStartedDocs/javascript/jsLoader/jsLoader';
  13. import {t, tct} from 'sentry/locale';
  14. type Params = DocsParams;
  15. const getConfigureSnippet = (params: Params) => `
  16. package main
  17. import (
  18. "log"
  19. "github.com/getsentry/sentry-go"
  20. )
  21. func main() {
  22. err := sentry.Init(sentry.ClientOptions{
  23. Dsn: "${params.dsn}",
  24. // Set TracesSampleRate to 1.0 to capture 100%
  25. // of transactions for performance monitoring.
  26. // We recommend adjusting this value in production,
  27. TracesSampleRate: 1.0,
  28. })
  29. if err != nil {
  30. log.Fatalf("sentry.Init: %s", err)
  31. }
  32. }`;
  33. const getVerifySnippet = () => `
  34. package main
  35. import (
  36. "log"
  37. "time"
  38. "github.com/getsentry/sentry-go"
  39. )
  40. func main() {
  41. err := sentry.Init(sentry.ClientOptions{
  42. Dsn: "___PUBLIC_DSN___",
  43. // Set TracesSampleRate to 1.0 to capture 100%
  44. // of transactions for performance monitoring.
  45. // We recommend adjusting this value in production,
  46. TracesSampleRate: 1.0,
  47. })
  48. if err != nil {
  49. log.Fatalf("sentry.Init: %s", err)
  50. }
  51. // Flush buffered events before the program terminates.
  52. defer sentry.Flush(2 * time.Second)
  53. sentry.CaptureMessage("It works!")
  54. }`;
  55. const onboarding: OnboardingConfig = {
  56. install: () => [
  57. {
  58. type: StepType.INSTALL,
  59. description: tct('Install our Go SDK using [code:go get]:', {
  60. code: <code />,
  61. }),
  62. configurations: [
  63. {
  64. language: 'bash',
  65. code: 'go get github.com/getsentry/sentry-go',
  66. },
  67. ],
  68. },
  69. ],
  70. configure: params => [
  71. {
  72. type: StepType.CONFIGURE,
  73. description: t(
  74. "Import and initialize the Sentry SDK early in your application's setup:"
  75. ),
  76. configurations: [
  77. {
  78. language: 'go',
  79. code: getConfigureSnippet(params),
  80. },
  81. ],
  82. },
  83. ],
  84. verify: () => [
  85. {
  86. type: StepType.VERIFY,
  87. description: t(
  88. 'The quickest way to verify Sentry in your Go program is to capture a message:'
  89. ),
  90. configurations: [
  91. {
  92. language: 'go',
  93. code: getVerifySnippet(),
  94. },
  95. ],
  96. },
  97. ],
  98. };
  99. const crashReportOnboarding: OnboardingConfig = {
  100. introduction: () => getCrashReportModalIntroduction(),
  101. install: (params: Params) => getCrashReportGenericInstallStep(params),
  102. configure: () => [
  103. {
  104. type: StepType.CONFIGURE,
  105. description: getCrashReportModalConfigDescription({
  106. link: 'https://docs.sentry.io/platforms/go/user-feedback/configuration/#crash-report-modal',
  107. }),
  108. },
  109. ],
  110. verify: () => [],
  111. nextSteps: () => [],
  112. };
  113. const docs: Docs = {
  114. onboarding,
  115. replayOnboardingJsLoader,
  116. crashReportOnboarding,
  117. };
  118. export default docs;