go.tsx 3.3 KB

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