solid.tsx 8.8 KB

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