A series of
- Sentry-go SDK Chinese Practice Guide
- Plan together according to official documents in Sentry For Go
- Snuba: Sentry’s new search infrastructure (based on ClickHouse)
- Sentry 10 K8S cloud native architecture exploration, fast access to Vue App in 1 minute
- Sentry(V20.12.1) K8S cloud native architecture exploration, play forward/back end monitoring and event log big data analysis, high performance + high availability + scalable + scalable cluster deployment
NPM
# to use yarn
yarn add @sentry/browser @sentry/tracing
# use NPM
npm install --save @sentry/browser @sentry/tracing
Copy the code
CDN
Sentry supports loading its JavaScript SDK through THE CDN. In general, we recommend using the NPM package (@Sentry/Browser) as a CDN creation scheme where sentries cannot load due to network problems or common extensions like advertising extensions. If you must use CDN, take a look at how to lazily load Sentry using our JS loader.
<script
src="https://browser.sentry-cdn.com/5.29.2/bundle.min.js"
integrity="sha384-ir4+BihBClNpjZk3UKgHTr0cwRhujAjy/M5VEGvcOzjhM1Db79GAg9xLxYn4uVK4"
crossorigin="anonymous"
></script>
Copy the code
Performance of the Bundle
To use Sentry’s performance tracing, you need an alternative bundle. This allows us to reduce file sizes for users who only need error monitoring.
<script
src="https://browser.sentry-cdn.com/5.29.2/bundle.tracing.min.js"
integrity="sha384-4zxA5Bnxor/VkZae20EqPP3A/6vDlw1ZhqF7EvpmeTfWYFjPIDdaUSOk/q7G/bYw"
crossorigin="anonymous"
></script>
Copy the code
You only need to load bundle.tracing.min.js to provide error and performance monitoring.
The most important thing to note here is that Sentry.Integrations is already available and can be referenced when sentry.init is called:
Sentry.init({
dsn: "___PUBLIC_DSN___".release: "my-project-name@" + process.env.npm_package_version,
integrations: [new Sentry.Integrations.BrowserTracing()],
// We recommend adjusting this value in production or using tracesSampler for finer control
tracesSampleRate: 1.0});Copy the code
The available Bundles
A variety of bundles are provided that are optimized for the various integrations of Sentry.
File | Integrity Checksum |
---|---|
angular.js | sha384-oGlOwTDeutKQy8iIj86N5Iz+cg3oB7k7DwwAFF+JvU5Ryk3QpBd9RWe7b1dvbytH- |
angular.min.js | sha384-glEOteL1rvN2KINqDwBkOPyi+yM/AuHdHZoW89/oufCLWhmOZvRLTQcMarZLrahO |
bundle.es6.js | sha384-C/1UhIXVvIEeHWK+Oon2qJ5dknXU/6yoOszWad+UgIQaMvkuRapwg7GBAm89WKkY |
bundle.es6.min.js | sha384-YtQnmGXv08gDRhGCtnUN32p5tEk2xCJePCG5XGcFefgts4LACdWXenPO5/kVkQKg |
bundle.js | sha384-70m6a/iRDkIhWo9D2seDfr054bdBakn8SM/I1Qx/2E1E2oeFrB/UlfRRQ7lk6w29 |
bundle.min.js | sha384-ir4+BihBClNpjZk3UKgHTr0cwRhujAjy/M5VEGvcOzjhM1Db79GAg9xLxYn4uVK4 |
bundle.tracing.js | sha384-tsSu02fvNXxzKOYMmsMHW6Zjb3xpUtLkKsF3h63S/8uzbyoI4sURznHBWWmmYBnT |
bundle.tracing.min.js | sha384-4zxA5Bnxor/VkZae20EqPP3A/6vDlw1ZhqF7EvpmeTfWYFjPIDdaUSOk/q7G/bYw |
captureconsole.js | sha384-FB7wnw52/iiuFH+aV7+yF3+Hb8y+UeaYjreZafP7GzE9VjoWZ0k196k4XseGRkeK |
captureconsole.min.js | sha384-6YIh+FyIHrE7APnLltmw5AcyyEI7yV3pgn5I/aww3gYxGrAsotTDRIsix05d1bmg |
debug.js | sha384-CzFfkxQdU/85sLu1YXX2lWrZU/pJEkSB7qiwkIwFwHQn/+dWp9Qz8YADcVNlwpUY |
debug.min.js | sha384-gfwqW2T9/pJzXG5kGMjh219m8NxYr4sFdNEmk8Kcmm03LLR3e7u0MUCJtF+BvwlA |
dedupe.js | sha384-w30Nic/lP8/Lwg/nJr5WAydru2HshwlpwrbablyGtwy93SdrKOXBENhAbFar8U61 |
dedupe.min.js | sha384-991Pgp/m4NC5gP7q/xzXphPFKPZI3iGG04gFtnoHlyH13gSiR/cQJVh+/5vjnULG |
ember.js | sha384-uIwfFqGm1HIvIFAzmFi7+254jT3en0RDGQBep5yjZlUM5m5+wkxlV3iwtxbRSiDL |
ember.min.js | sha384-AoDWDCFzGgUlcjpTPIOucLHY0TcDkJISfQTounFvJC9id+SLfT+LMV/omYXeSxtk |
extraerrordata.js | sha384-UJSF3duqUmoZZYNHJIgczPWi0zF4dj9ZjXfU+HWSGsCkmbAwHvXqcdgc5IcmZBUb |
extraerrordata.min.js | sha384-32fXO2AIiHJpC33l8L8jhTkgPMY5QyAMH+E+3qyI4LI+RC4BsMtaqi1Y0wncuONI |
offline.js | sha384-6AWlLn2pEAwsHjZOeLUKhHPtfAzzAC7GXXYpFW1XZQ1OChliYYUvWwSfrmEPe+R8 |
offline.min.js | sha384-nOHWW5k4teYVTgdr9pem7/0/N/mt6DLwL/vipeoYd/0u0lh3Ld9IiRAIWgk+ubid |
reportingobserver.js | sha384-ZtU5drTUdMPOWXuUZvgv4QyqMxkDNdiBiEbj8aD5CmwABHCI/XUFd2eC3iRRlc+p |
reportingobserver.min.js | sha384-c8fGh3K1+dBi9WNNtK2eVmaEgfoM3Rq1gY6KeRoA/WSi7RlhxRkUmVK37DJTwr7F |
rewriteframes.js | sha384-k1F/xgCZmOcziSivt8QoKMaELWZmjNJFm+n2PX/2MEKWrszB2IL6S4q+JDJ7o/8N |
rewriteframes.min.js | sha384-22utNfjd1bJOgWt7yrPsUIWR7gluO23PO7d2m30lqrmnj5DH3OmVa8fwcwZhbfPp |
sessiontiming.js | sha384-9srvADRpjm3FrmiK6dY0NGV4wnTG4dt8onLWUx6LRVN1xhtw+oRJnQ1LtKi4kqGB |
sessiontiming.min.js | sha384-yy0Jah9kyZt8VCnKVBxDj92pIC/E9XFkw5G6NXx2+0ZJbTBn83Y3X32KqAZxhF9b |
transaction.js | sha384-KN4xQF97K+t2Zgsqg8FiZE5++QLb0PCD4+v0k0ZVg6rl47vvmUIiSueozKB29Gu1 |
transaction.min.js | sha384-p+n3NUtytg2Zgunyx5gQNdbZk7AieZyquN8nOaL7+hbqbe0SZomZIQJ5apsiXuLd |
vue.js | sha384-e6Vy50VfbAicS4Fa6R4tigCfJ3q+ifS/AYFyhP7+OtXcLjr0C8zHCoh2DCJ1EMNP |
vue.min.js | sha384-FKagncFah3a9nkKNEIDQqXhYnny5Wzc37/AZV5eKKnRVS8uPpeFPdu9dnrvAnRpF |
Additional configuration
Use the defer
If you include defer in your script, make sure that the application can monitor everything that follows. We strongly recommend that you use defer, with the script tag from the Browser SDK in the first place, and mark it — and all other scripts — defer (rather than Async) to ensure that it is executed before any other scripts.
If you don’t, you’ll find that errors can occur before loading the Sentry, which means you’ll ignore them.
Content security Policy
If you have a content security policy (CSP) set up on your site, you need to add script-src from where to load the SDK and the source of the DSN. Such as:
script-src: https://browser.sentry-cdn.com
connect-src: *.sentry.io
Lazy loading of Sentry
Loader is a small wrapper around our SDK that does a few things:
- Always have the latest recommended stable version of our SDK
- Capture allGlobal errorandUnprocessed promises rejections
- Delayed injection of our SDK into your site
- After loading the SDK, the Loader sends everything to Sentry
The loader’s compression (gzipped) is less than 1kB and includes the sentry.init call in your DSN.
<script
src="https://js.sentry-cdn.com/___PUBLIC_KEY___.min.js"
crossorigin="anonymous"
></script>
Copy the code
Additional configuration
If you want to set other options, you must set them like this:
OnLoad is the only function provided by Loader; Once the SDK is injected into the site, Loader calls it. Loader init() also works differently. For convenience, we have incorporated these options internally, rather than just setting the options, for convenience, so you don’t have to set the DSN again because the Loader already includes it.
As mentioned earlier, Loader will lazily load our SDK and inject it into your site, but you can also tell Loader to get it now instead of just getting it when you need it. Setting data-lazy to no tells the Loader to inject the SDK as soon as possible:
<script>
Sentry.onLoad(function() {
// Use any sentry. * function you want
});
Sentry.forceLoad();
</script>
Copy the code
The SDK version
Go to the Sentry Web UI, go to Settings -> Projects -> Client Keys (DSN), and press the Configure button. Here, you can view the options for configuring DSN and select the SDK version that Loader should load.
Because the changes are cached, it can take several minutes to see the changes in your code.
The current limit
Because we are injecting our SDK asynchronously, we will only monitor global errors and unprocessed promises for you until the SDK is fully loaded. This means we might miss breadcrumbs during the download.
For example, a user clicking a button on your web site is making an XHR request. Until the SDK is fully loaded, we won’t miss anything and just leave breadcrumbs behind. You can reduce this time by manually calling forceLoad or setting data-lazy=”no”.
If you want to understand the inner workings of the Loader itself, you can read the fully documented source code in sentry-javascript Repository.
Chinese documents have been synchronized to:
- getsentry.hacker-linner.com
I am for less. Wechat: uuhells123. Public account: Hacker afternoon tea. Thank you for your support 👍👍👍!Copy the code