This project provides a setup to build Sentry into ES5-compatible JavaScript files for use in older browsers environments. It uses TypeScript Compiler (TSC) and Terser to handle the build process and package the output files.
- Converts Sentry-Javascript source code to ES5 for compatibility with older browsers environments.
- Produces CDN-ready bundles similar to Sentry's official bundles.
Make sure you have the following installed:
- Node.js (>= 14.x)
- npm (comes with Node.js)
Clone the repository and install the dependencies:
git clone https://github.com/duyquangnvx/sentryjs-es5
cd sentryjs-es5
npm install
The project uses tsc and terser to compile and bundle the code.
Run the following command to compile the TypeScript source files and bundle them with Terser:
npm run build
The final output file will be located in the dist/sentry.js.
Once the build is complete, you can include the generated ES5 bundle in your project. This makes the Sentry Javascript ES5 library available globally as Sentry. You can initialize Sentry like this:
Sentry.init({
dsn: 'https://example@sentry.io/123456',
integrations: [new Sentry.BrowserTracing()],
tracesSampleRate: 1.0,
});
-
Download the the Sentry CDN Bundle from the following URL (replace [version] with your desired version):
https://browser.sentry-cdn.com/[version]/bundle.js
For more information, see the official Sentry documentation.
-
Replace your downloaded bundle with the file located at:
src/sentry/bundle.js