solid.tsx 9.7 KB

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