gcpfunctions.tsx 4.6 KB

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