gcpfunctions.tsx 6.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230
  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.public}",
  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 tracing.
  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 [code:Function] class through [code:FunctionsStartup]:',
  120. {
  121. code: <code />,
  122. }
  123. ),
  124. configurations: [
  125. {
  126. language: 'csharp',
  127. code: getConfigureCSharpSnippet(),
  128. },
  129. {
  130. language: 'json',
  131. description: (
  132. <p>
  133. {tct(
  134. "Additionally, you'll need to set up your [code:Sentry] settings on [code:appsettings.json]:",
  135. {code: <code />}
  136. )}
  137. </p>
  138. ),
  139. code: getConfigureJsonSnippet(params),
  140. },
  141. ],
  142. },
  143. ],
  144. verify: () => [
  145. {
  146. type: StepType.VERIFY,
  147. description: t('To verify your setup, you can capture a message with the SDK:'),
  148. configurations: [
  149. {
  150. language: 'csharp',
  151. code: getVerifySnippet(),
  152. },
  153. ],
  154. },
  155. {
  156. title: t('Samples'),
  157. description: (
  158. <Fragment>
  159. {t(
  160. 'See the following examples that demonstrate how to integrate Sentry with various frameworks.'
  161. )}
  162. <List symbol="bullet">
  163. <ListItem>
  164. {tct('[link:Google Cloud Functions sample]', {
  165. link: (
  166. <ExternalLink href="https://github.com/getsentry/sentry-dotnet/tree/main/samples/Sentry.Samples.Google.Cloud.Functions" />
  167. ),
  168. })}
  169. </ListItem>
  170. <ListItem>
  171. {tct(
  172. '[link:Multiple samples in the [code:dotnet] SDK repository] [strong:(C#)]',
  173. {
  174. link: (
  175. <ExternalLink href="https://github.com/getsentry/sentry-dotnet/tree/main/samples" />
  176. ),
  177. strong: <strong />,
  178. code: <code />,
  179. }
  180. )}
  181. </ListItem>
  182. <ListItem>
  183. {tct('[link:Basic F# sample] [strong:(F#)]', {
  184. link: <ExternalLink href="https://github.com/sentry-demos/fsharp" />,
  185. strong: <strong />,
  186. })}
  187. </ListItem>
  188. </List>
  189. </Fragment>
  190. ),
  191. },
  192. ],
  193. };
  194. const crashReportOnboarding: OnboardingConfig = {
  195. introduction: () => getCrashReportModalIntroduction(),
  196. install: (params: Params) => getCrashReportGenericInstallStep(params),
  197. configure: () => [
  198. {
  199. type: StepType.CONFIGURE,
  200. description: getCrashReportModalConfigDescription({
  201. link: 'https://docs.sentry.io/platforms/dotnet/guides/google-cloud-functions/user-feedback/configuration/#crash-report-modal',
  202. }),
  203. },
  204. ],
  205. verify: () => [],
  206. nextSteps: () => [],
  207. };
  208. const docs: Docs = {
  209. onboarding,
  210. feedbackOnboardingCrashApi: csharpFeedbackOnboarding,
  211. customMetricsOnboarding: getDotnetMetricsOnboarding({
  212. packageName: 'Sentry.Google.Cloud.Functions',
  213. }),
  214. crashReportOnboarding,
  215. };
  216. export default docs;