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