go.tsx 3.2 KB

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