gcpfunctions.tsx 6.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231
  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. params.isPerformanceSelected
  62. ? `,
  63. // Set TracesSampleRate to 1.0 to capture 100% of transactions for performance monitoring.
  64. // We recommend adjusting this value in production.
  65. "TracesSampleRate": 1`
  66. : ''
  67. }
  68. }
  69. }`;
  70. const getVerifySnippet = () => `
  71. using System.Threading.Tasks;
  72. using Microsoft.AspNetCore.Http;
  73. using Sentry;
  74. public Task HandleAsync(HttpContext context)
  75. {
  76. SentrySdk.CaptureMessage("Hello Sentry");
  77. }`;
  78. const onboarding: OnboardingConfig = {
  79. install: params => [
  80. {
  81. type: StepType.INSTALL,
  82. configurations: [
  83. {
  84. description: tct(
  85. 'Install the [strong:NuGet] package with Package Manager or .NET Core CLI:',
  86. {
  87. strong: <strong />,
  88. }
  89. ),
  90. partialLoading: params.sourcePackageRegistries.isLoading,
  91. code: [
  92. {
  93. language: 'shell',
  94. label: 'Package Manager',
  95. value: 'packageManager',
  96. code: getInstallSnippetPackageManager(params),
  97. },
  98. {
  99. language: 'shell',
  100. label: '.NET Core CLI',
  101. value: 'coreCli',
  102. code: getInstallSnippetCoreCli(params),
  103. },
  104. ],
  105. },
  106. {
  107. language: 'xml',
  108. partialLoading: params.sourcePackageRegistries?.isLoading,
  109. description: t('Or, manually add the Sentry dependency into your csproj file:'),
  110. code: getInstallSnippetManual(params),
  111. },
  112. ],
  113. },
  114. ],
  115. configure: params => [
  116. {
  117. type: StepType.CONFIGURE,
  118. description: tct(
  119. 'Then, add Sentry to the [functionCode:Function] class through [functionStartupCode:FunctionsStartup]:',
  120. {
  121. functionCode: <code />,
  122. functionStartupCode: <code />,
  123. }
  124. ),
  125. configurations: [
  126. {
  127. language: 'csharp',
  128. code: getConfigureCSharpSnippet(),
  129. },
  130. {
  131. language: 'json',
  132. description: (
  133. <p>
  134. {tct(
  135. "Additionally, you'll need to set up your [sentryCode:Sentry] settings on [appsettingsCode:appsettings.json]:",
  136. {sentryCode: <code />, appsettingsCode: <code />}
  137. )}
  138. </p>
  139. ),
  140. code: getConfigureJsonSnippet(params),
  141. },
  142. ],
  143. },
  144. ],
  145. verify: () => [
  146. {
  147. type: StepType.VERIFY,
  148. description: t('To verify your setup, you can capture a message with the SDK:'),
  149. configurations: [
  150. {
  151. language: 'csharp',
  152. code: getVerifySnippet(),
  153. },
  154. ],
  155. },
  156. {
  157. title: t('Samples'),
  158. description: (
  159. <Fragment>
  160. {t(
  161. 'See the following examples that demonstrate how to integrate Sentry with various frameworks.'
  162. )}
  163. <List symbol="bullet">
  164. <ListItem>
  165. {tct('[link:Google Cloud Functions sample]', {
  166. link: (
  167. <ExternalLink href="https://github.com/getsentry/sentry-dotnet/tree/main/samples/Sentry.Samples.Google.Cloud.Functions" />
  168. ),
  169. })}
  170. </ListItem>
  171. <ListItem>
  172. {tct(
  173. '[link:Multiple samples in the [code:dotnet] SDK repository] [strong:(C#)]',
  174. {
  175. link: (
  176. <ExternalLink href="https://github.com/getsentry/sentry-dotnet/tree/main/samples" />
  177. ),
  178. strong: <strong />,
  179. code: <code />,
  180. }
  181. )}
  182. </ListItem>
  183. <ListItem>
  184. {tct('[link:Basic F# sample] [strong:(F#)]', {
  185. link: <ExternalLink href="https://github.com/sentry-demos/fsharp" />,
  186. strong: <strong />,
  187. })}
  188. </ListItem>
  189. </List>
  190. </Fragment>
  191. ),
  192. },
  193. ],
  194. };
  195. const crashReportOnboarding: OnboardingConfig = {
  196. introduction: () => getCrashReportModalIntroduction(),
  197. install: (params: Params) => getCrashReportGenericInstallStep(params),
  198. configure: () => [
  199. {
  200. type: StepType.CONFIGURE,
  201. description: getCrashReportModalConfigDescription({
  202. link: 'https://docs.sentry.io/platforms/dotnet/guides/google-cloud-functions/user-feedback/configuration/#crash-report-modal',
  203. }),
  204. },
  205. ],
  206. verify: () => [],
  207. nextSteps: () => [],
  208. };
  209. const docs: Docs = {
  210. onboarding,
  211. feedbackOnboardingCrashApi: csharpFeedbackOnboarding,
  212. customMetricsOnboarding: getDotnetMetricsOnboarding({
  213. packageName: 'Sentry.Google.Cloud.Functions',
  214. }),
  215. crashReportOnboarding,
  216. };
  217. export default docs;