Sentry🔗
Setup a Sentry integration for Javascript.
Installation🔗
See the official installation guide
Configuration🔗
Get your Sentry DSN from Settings > Projects > Your project > Client Keys (DSN). You will also need to define the environment, the project name and optionally a release version.
Use .env
files to set these variables for your different environments:
1 2 3 4 5 |
|
Alternatively, you can configure the Sentry project related info in a sentry.properties
file:
1 2 3 |
|
Info
The APP_RUNTIME_ENV
comes from the Symfony convention for identifying the target / deploy environment
(we also call this a tier
in Manala).
If you use a VERSION file to store the app version number, you can use the following code to get it:
1 2 |
|
Then use the APP_VERSION
variable instead of process.env.APP_VERSION
in the next code samples.
Note
If you don't bump the release version number in your project, you may want to set at least a different
release name for production and staging releases.
You can use the target environment name for that (ie: 1.0
and 1.0-staging
or production
and staging
).
While not mandatory, it'll allow you to have a clear separation between these environments and their generated artefacts.
Create a Sentry configuration module:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
|
Note
The release
value must be unique accross your Sentry organization. The convention is project_name@version
.
See official documentation.
Tip
In order to use the env vars inside this runtime code snippet, you need to forward the env vars at build time,
from your webpack.config.js
file using the DefinePlugin Plugin
and declaring each of the variables to forward explicitly in a AppConfig
object.
Consult the dotenv cookbook to see how to do this.
Then, in your main javascript app file:
1 2 3 4 5 6 7 8 |
|
Vue.js🔗
To use Sentry with your Vue application, add the following integration to your Sentry configuration:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 |
|
Send source maps to Sentry🔗
To allow Sentry to indicate you the line in error in your not compiled/transpiled source code, you can ask Webpack to send your source maps to Sentry.
Use the Sentry for tools & CI special auth token on and put it in production and staging .env file.
Warning
This token is meant to be secret, and should therefore not be committed to your repository
if it's likely to be opened somehow.
The Onisep project is such a case.
Add the following env var:
1 |
|
Install Sentry Webpack plugin:
1 |
|
Configure sur plugin in the Webpack config:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 |
|
Note
The release
must be the same as in Sentry configuration.
Alternatively, you can also consult how this is made in the Onisep project.