go.tsx 2.4 KB

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