gcpfunctions.tsx 5.7 KB

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