go.tsx 2.3 KB

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