gcpfunctions.tsx 6.8 KB

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