solid.tsx 9.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314
  1. import crashReportCallout from 'sentry/components/onboarding/gettingStartedDoc/feedback/crashReportCallout';
  2. import widgetCallout from 'sentry/components/onboarding/gettingStartedDoc/feedback/widgetCallout';
  3. import TracePropagationMessage from 'sentry/components/onboarding/gettingStartedDoc/replay/tracePropagationMessage';
  4. import {StepType} from 'sentry/components/onboarding/gettingStartedDoc/step';
  5. import type {
  6. Docs,
  7. DocsParams,
  8. OnboardingConfig,
  9. } from 'sentry/components/onboarding/gettingStartedDoc/types';
  10. import {getUploadSourceMapsStep} from 'sentry/components/onboarding/gettingStartedDoc/utils';
  11. import {
  12. getCrashReportJavaScriptInstallStep,
  13. getCrashReportModalConfigDescription,
  14. getCrashReportModalIntroduction,
  15. getFeedbackConfigOptions,
  16. getFeedbackConfigureDescription,
  17. } from 'sentry/components/onboarding/gettingStartedDoc/utils/feedbackOnboarding';
  18. import {getJSMetricsOnboarding} from 'sentry/components/onboarding/gettingStartedDoc/utils/metricsOnboarding';
  19. import {getProfilingDocumentHeaderConfigurationStep} from 'sentry/components/onboarding/gettingStartedDoc/utils/profilingOnboarding';
  20. import {
  21. getReplayConfigOptions,
  22. getReplayConfigureDescription,
  23. } from 'sentry/components/onboarding/gettingStartedDoc/utils/replayOnboarding';
  24. import {t, tct} from 'sentry/locale';
  25. type Params = DocsParams;
  26. const getSdkSetupSnippet = (params: Params) => `
  27. import * as Sentry from "@sentry/solid";
  28. import { render } from "solid-js/web";
  29. import App from "./app";
  30. Sentry.init({
  31. dsn: "${params.dsn}",
  32. integrations: [${
  33. params.isPerformanceSelected
  34. ? `
  35. Sentry.browserTracingIntegration(),`
  36. : ''
  37. }${
  38. params.isProfilingSelected
  39. ? `
  40. Sentry.browserProfilingIntegration(),`
  41. : ''
  42. }${
  43. params.isFeedbackSelected
  44. ? `
  45. Sentry.feedbackIntegration({
  46. // Additional SDK configuration goes in here, for example:
  47. colorScheme: "system",
  48. ${getFeedbackConfigOptions(params.feedbackOptions)}}),`
  49. : ''
  50. }${
  51. params.isReplaySelected
  52. ? `
  53. Sentry.replayIntegration(${getReplayConfigOptions(params.replayOptions)}),`
  54. : ''
  55. }
  56. ],${
  57. params.isPerformanceSelected
  58. ? `
  59. // Performance Monitoring
  60. tracesSampleRate: 1.0, // Capture 100% of the transactions
  61. // Set 'tracePropagationTargets' to control for which URLs distributed tracing should be enabled
  62. tracePropagationTargets: ["localhost", /^https:\\/\\/yourserver\\.io\\/api/],`
  63. : ''
  64. }${
  65. params.isReplaySelected
  66. ? `
  67. // Session Replay
  68. replaysSessionSampleRate: 0.1, // This sets the sample rate at 10%. You may want to change it to 100% while in development and then sample at a lower rate in production.
  69. replaysOnErrorSampleRate: 1.0, // If you're not already sampling the entire session, change the sample rate to 100% when sampling sessions where errors occur.`
  70. : ''
  71. }${
  72. params.isProfilingSelected
  73. ? `
  74. // Profiling
  75. profilesSampleRate: 1.0, // Profile 100% of the transactions. This value is relative to tracesSampleRate`
  76. : ''
  77. }
  78. });
  79. const app = document.getElementById("app");
  80. if (!app) throw new Error("No #app element found in the DOM.");
  81. render(() => <App />, app);
  82. `;
  83. const getVerifySolidSnippet = () => `
  84. <button
  85. type="button"
  86. onClick={() => {
  87. throw new Error("Sentry Frontend Error");
  88. }}
  89. >
  90. Throw error
  91. </button>`;
  92. const getInstallConfig = () => [
  93. {
  94. language: 'bash',
  95. code: [
  96. {
  97. label: 'npm',
  98. value: 'npm',
  99. language: 'bash',
  100. code: 'npm install --save @sentry/solid',
  101. },
  102. {
  103. label: 'yarn',
  104. value: 'yarn',
  105. language: 'bash',
  106. code: 'yarn add @sentry/solid',
  107. },
  108. ],
  109. },
  110. ];
  111. const onboarding: OnboardingConfig = {
  112. install: () => [
  113. {
  114. type: StepType.INSTALL,
  115. description: tct(
  116. 'Add the Sentry SDK as a dependency using [codeNpm:npm] or [codeYarn:yarn]:',
  117. {
  118. codeYarn: <code />,
  119. codeNpm: <code />,
  120. }
  121. ),
  122. configurations: getInstallConfig(),
  123. },
  124. ],
  125. configure: (params: Params) => [
  126. {
  127. type: StepType.CONFIGURE,
  128. description: tct(
  129. "Initialize Sentry as early as possible in your application's lifecycle, usually your solid app's entry point ([code:main.ts/js]):",
  130. {code: <code />}
  131. ),
  132. configurations: [
  133. {
  134. code: [
  135. {
  136. label: 'JavaScript',
  137. value: 'javascript',
  138. language: 'javascript',
  139. code: getSdkSetupSnippet(params),
  140. },
  141. ],
  142. },
  143. ],
  144. },
  145. ...(params.isProfilingSelected
  146. ? [getProfilingDocumentHeaderConfigurationStep()]
  147. : []),
  148. getUploadSourceMapsStep({
  149. guideLink: 'https://docs.sentry.io/platforms/javascript/guides/solid/sourcemaps/',
  150. }),
  151. ],
  152. verify: () => [
  153. {
  154. type: StepType.VERIFY,
  155. description: t(
  156. "This snippet contains an intentional error and can be used as a test to make sure that everything's working as expected."
  157. ),
  158. configurations: [
  159. {
  160. code: [
  161. {
  162. label: 'JavaScript',
  163. value: 'javascript',
  164. language: 'javascript',
  165. code: getVerifySolidSnippet(),
  166. },
  167. ],
  168. },
  169. ],
  170. },
  171. ],
  172. nextSteps: () => [
  173. {
  174. id: 'solid-features',
  175. name: t('Solid Features'),
  176. description: t('Learn about our first class integration with the Solid framework.'),
  177. link: 'https://docs.sentry.io/platforms/javascript/guides/solid/features/',
  178. },
  179. {
  180. id: 'performance-monitoring',
  181. name: t('Performance Monitoring'),
  182. description: t(
  183. 'Track down transactions to connect the dots between 10-second page loads and poor-performing API calls or slow database queries.'
  184. ),
  185. link: 'https://docs.sentry.io/platforms/javascript/guides/solid/tracing/',
  186. },
  187. {
  188. id: 'session-replay',
  189. name: t('Session Replay'),
  190. description: t(
  191. 'Get to the root cause of an error or latency issue faster by seeing all the technical details related to that issue in one visual replay on your web application.'
  192. ),
  193. link: 'https://docs.sentry.io/platforms/javascript/guides/solid/session-replay/',
  194. },
  195. ],
  196. };
  197. const replayOnboarding: OnboardingConfig = {
  198. install: () => [
  199. {
  200. type: StepType.INSTALL,
  201. description: tct(
  202. 'You need a minimum version 8.9.1 of [code:@sentry/solid] in order to use Session Replay. You do not need to install any additional packages.',
  203. {
  204. code: <code />,
  205. }
  206. ),
  207. configurations: getInstallConfig(),
  208. },
  209. ],
  210. configure: (params: Params) => [
  211. {
  212. type: StepType.CONFIGURE,
  213. description: getReplayConfigureDescription({
  214. link: 'https://docs.sentry.io/platforms/javascript/guides/solid/session-replay/',
  215. }),
  216. configurations: [
  217. {
  218. code: [
  219. {
  220. label: 'JavaScript',
  221. value: 'javascript',
  222. language: 'javascript',
  223. code: getSdkSetupSnippet(params),
  224. },
  225. ],
  226. additionalInfo: <TracePropagationMessage />,
  227. },
  228. ],
  229. },
  230. ],
  231. verify: () => [],
  232. nextSteps: () => [],
  233. };
  234. const feedbackOnboarding: OnboardingConfig = {
  235. install: () => [
  236. {
  237. type: StepType.INSTALL,
  238. description: tct(
  239. 'For the User Feedback integration to work, you must have the Sentry browser SDK package, or an equivalent framework SDK (e.g. [code:@sentry/solid]) installed, minimum version 7.85.0.',
  240. {
  241. code: <code />,
  242. }
  243. ),
  244. configurations: getInstallConfig(),
  245. },
  246. ],
  247. configure: (params: Params) => [
  248. {
  249. type: StepType.CONFIGURE,
  250. description: getFeedbackConfigureDescription({
  251. linkConfig:
  252. 'https://docs.sentry.io/platforms/javascript/guides/solid/user-feedback/configuration/',
  253. linkButton:
  254. 'https://docs.sentry.io/platforms/javascript/guides/solid/user-feedback/configuration/#bring-your-own-button',
  255. }),
  256. configurations: [
  257. {
  258. code: [
  259. {
  260. label: 'JavaScript',
  261. value: 'javascript',
  262. language: 'javascript',
  263. code: getSdkSetupSnippet(params),
  264. },
  265. ],
  266. },
  267. ],
  268. additionalInfo: crashReportCallout({
  269. link: 'https://docs.sentry.io/platforms/javascript/guides/solid/user-feedback/#crash-report-modal',
  270. }),
  271. },
  272. ],
  273. verify: () => [],
  274. nextSteps: () => [],
  275. };
  276. const crashReportOnboarding: OnboardingConfig = {
  277. introduction: () => getCrashReportModalIntroduction(),
  278. install: (params: Params) => getCrashReportJavaScriptInstallStep(params),
  279. configure: () => [
  280. {
  281. type: StepType.CONFIGURE,
  282. description: getCrashReportModalConfigDescription({
  283. link: 'https://docs.sentry.io/platforms/javascript/guides/solid/user-feedback/configuration/#crash-report-modal',
  284. }),
  285. additionalInfo: widgetCallout({
  286. link: 'https://docs.sentry.io/platforms/javascript/guides/solid/user-feedback/#user-feedback-widget',
  287. }),
  288. },
  289. ],
  290. verify: () => [],
  291. nextSteps: () => [],
  292. };
  293. const docs: Docs = {
  294. onboarding,
  295. feedbackOnboardingNpm: feedbackOnboarding,
  296. replayOnboardingNpm: replayOnboarding,
  297. customMetricsOnboarding: getJSMetricsOnboarding({getInstallConfig}),
  298. crashReportOnboarding,
  299. };
  300. export default docs;