gcpfunctions.tsx 5.5 KB

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