This an enhancement of the approach in https://github.com/lucasklaassen/angular-rollbar-source-maps
During the build the file src/environments/version.ts
is automatically generated containing the definition of the current Git revision:
// this file is automatically generated by git-version.js script
export const version = {revision: '12f54f9'};
Import that version.ts
file into the file where you create your Rollbar.Configuration
and use it to set your code_version
Rollbar parameter.
The same version is used when uploading the source maps and informing Rollbar of the deploy.
The entire process is initiated by a single command:
npm run prod
- Edit
package.json
and add this line to thescripts
section:
"prod": "node git-version.js && ng build --prod --source-map && node rollbar-deploy.js"
- Create a
.env
file with values populated for (you probably want to add.env
to your.gitignore
file also):
ROLLBAR_WRITE_ACCESS_TOKEN=
MAIN_APP_URL='https://...'
ROLLBAR_USERNAME=
npm install dotenv
- Copy
git-version.js
androllbar-deploy.js
(below) into the same directory as yourpackage.json
- Edit
rollbar.ts
to import theenvironment/version.ts
file and set theversion
in the Rollbar configuration.