gcpfunctions.tsx 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206
  1. import {Fragment} from 'react';
  2. import ExternalLink from 'sentry/components/links/externalLink';
  3. import List from 'sentry/components/list';
  4. import ListItem from 'sentry/components/list/listItem';
  5. import {StepType} from 'sentry/components/onboarding/gettingStartedDoc/step';
  6. import type {
  7. Docs,
  8. DocsParams,
  9. OnboardingConfig,
  10. } from 'sentry/components/onboarding/gettingStartedDoc/types';
  11. import {getDotnetMetricsOnboarding} from 'sentry/components/onboarding/gettingStartedDoc/utils/metricsOnboarding';
  12. import {csharpFeedbackOnboarding} from 'sentry/gettingStartedDocs/dotnet/dotnet';
  13. import {t, tct} from 'sentry/locale';
  14. import {getPackageVersion} from 'sentry/utils/gettingStartedDocs/getPackageVersion';
  15. type Params = DocsParams;
  16. const getInstallSnippetPackageManager = (params: Params) => `
  17. Install-Package Sentry.Google.Cloud.Functions -Version ${getPackageVersion(
  18. params,
  19. 'sentry.dotnet.google-cloud-function',
  20. '3.34.0'
  21. )}`;
  22. const getInstallSnippetCoreCli = (params: Params) => `
  23. dotnet add package Sentry.Google.Cloud.Functions -v ${getPackageVersion(
  24. params,
  25. 'sentry.dotnet.google-cloud-function',
  26. '3.34.0'
  27. )}`;
  28. const getInstallSnippetManual = (params: Params) => `
  29. <ItemGroup>
  30. <PackageReference Include="Sentry.Google.Cloud.Functions" Version="${getPackageVersion(
  31. params,
  32. 'sentry.dotnet.google-cloud-function',
  33. '3.34.0'
  34. )}"/>
  35. </ItemGroup>`;
  36. const getConfigureCSharpSnippet = () => `
  37. // Add the following line:
  38. [assembly: FunctionsStartup(typeof(SentryStartup))]
  39. public class Function : IHttpFunction
  40. {
  41. public Task HandleAsync(HttpContext context)
  42. {
  43. // Your function code here.
  44. }
  45. }`;
  46. const getConfigureJsonSnippet = (params: Params) => `
  47. {
  48. "Sentry": {
  49. "Dsn": "${params.dsn}",
  50. // Sends Cookies, User Id when one is logged on and user IP address to sentry. It's turned off by default.
  51. "SendDefaultPii": true,
  52. // When configuring for the first time, to see what the SDK is doing:
  53. "Debug": true,
  54. // Opt-in for payload submission.
  55. "MaxRequestBodySize": "Always",
  56. // Set TracesSampleRate to 1.0 to capture 100% of transactions for performance monitoring.
  57. // We recommend adjusting this value in production.
  58. "TracesSampleRate": 1
  59. }
  60. }`;
  61. const getVerifySnippet = () => `
  62. using System.Threading.Tasks;
  63. using Microsoft.AspNetCore.Http;
  64. using Sentry;
  65. public Task HandleAsync(HttpContext context)
  66. {
  67. SentrySdk.CaptureMessage("Hello Sentry");
  68. }`;
  69. const onboarding: OnboardingConfig = {
  70. install: params => [
  71. {
  72. type: StepType.INSTALL,
  73. configurations: [
  74. {
  75. description: tct(
  76. 'Install the [strong:NuGet] package with Package Manager or .NET Core CLI:',
  77. {
  78. strong: <strong />,
  79. }
  80. ),
  81. partialLoading: params.sourcePackageRegistries.isLoading,
  82. code: [
  83. {
  84. language: 'shell',
  85. label: 'Package Manager',
  86. value: 'packageManager',
  87. code: getInstallSnippetPackageManager(params),
  88. },
  89. {
  90. language: 'shell',
  91. label: '.NET Core CLI',
  92. value: 'coreCli',
  93. code: getInstallSnippetCoreCli(params),
  94. },
  95. ],
  96. },
  97. {
  98. language: 'xml',
  99. partialLoading: params.sourcePackageRegistries?.isLoading,
  100. description: t('Or, manually add the Sentry dependency into your csproj file:'),
  101. code: getInstallSnippetManual(params),
  102. },
  103. ],
  104. },
  105. ],
  106. configure: params => [
  107. {
  108. type: StepType.CONFIGURE,
  109. description: tct(
  110. 'Then, add Sentry to the [functionCode:Function] class through [functionStartupCode:FunctionsStartup]:',
  111. {
  112. functionCode: <code />,
  113. functionStartupCode: <code />,
  114. }
  115. ),
  116. configurations: [
  117. {
  118. language: 'csharp',
  119. code: getConfigureCSharpSnippet(),
  120. },
  121. {
  122. language: 'json',
  123. description: (
  124. <p>
  125. {tct(
  126. "Additionally, you'll need to set up your [sentryCode:Sentry] settings on [appsettingsCode:appsettings.json]:",
  127. {sentryCode: <code />, appsettingsCode: <code />}
  128. )}
  129. </p>
  130. ),
  131. code: getConfigureJsonSnippet(params),
  132. },
  133. ],
  134. },
  135. ],
  136. verify: () => [
  137. {
  138. type: StepType.VERIFY,
  139. description: t('To verify your setup, you can capture a message with the SDK:'),
  140. configurations: [
  141. {
  142. language: 'csharp',
  143. code: getVerifySnippet(),
  144. },
  145. ],
  146. },
  147. {
  148. title: t('Samples'),
  149. description: (
  150. <Fragment>
  151. {t(
  152. 'See the following examples that demonstrate how to integrate Sentry with various frameworks.'
  153. )}
  154. <List symbol="bullet">
  155. <ListItem>
  156. {tct('[link:Google Cloud Functions sample]', {
  157. link: (
  158. <ExternalLink href="https://github.com/getsentry/sentry-dotnet/tree/main/samples/Sentry.Samples.Google.Cloud.Functions" />
  159. ),
  160. })}
  161. </ListItem>
  162. <ListItem>
  163. {tct(
  164. '[link:Multiple samples in the [code:dotnet] SDK repository] [strong:(C#)]',
  165. {
  166. link: (
  167. <ExternalLink href="https://github.com/getsentry/sentry-dotnet/tree/main/samples" />
  168. ),
  169. strong: <strong />,
  170. code: <code />,
  171. }
  172. )}
  173. </ListItem>
  174. <ListItem>
  175. {tct('[link:Basic F# sample] [strong:(F#)]', {
  176. link: <ExternalLink href="https://github.com/sentry-demos/fsharp" />,
  177. strong: <strong />,
  178. })}
  179. </ListItem>
  180. </List>
  181. </Fragment>
  182. ),
  183. },
  184. ],
  185. };
  186. const docs: Docs = {
  187. onboarding,
  188. feedbackOnboardingCrashApi: csharpFeedbackOnboarding,
  189. customMetricsOnboarding: getDotnetMetricsOnboarding({
  190. packageName: 'Sentry.Google.Cloud.Functions',
  191. }),
  192. };
  193. export default docs;