karthikaruna
karthikaruna

Reputation: 3236

How to set the release version as a part of Ember build?

I want to set the version on the frontend (a meta tag in index.html or a property on window once the code is loaded in the browser, or in some other way) as a part of the build/deployment process in Ember. What would be the ideal way to accomplish this? I need this for mapping sourcemaps to versions in Sentry.

Upvotes: 0

Views: 326

Answers (3)

jrjohnson
jrjohnson

Reputation: 2459

We use a combination of ember-cli-app-version and a Github Action to set this at deployment time and send it with each error report to Sentry.

In our sentry.js file we set the error version with:

import * as Sentry from '@sentry/browser';
import { Ember } from '@sentry/integrations/esm/ember';
import { versionRegExp } from 'ember-cli-app-version/utils/regexp';

function startSentry(config) {
  Sentry.init({
    ...config.sentry,
    integrations: [new Ember()],
    release: config.APP.version.match(versionRegExp)[0],
  });
}

export {
  startSentry,
};

The github action uses the git tag and looks like:

- name: Create a Sentry.io release
      run: |
        # Create new Sentry release
        export SENTRY_RELEASE=$(sentry-cli releases propose-version)
        sentry-cli releases new $SENTRY_RELEASE
        sentry-cli releases set-commits --auto $SENTRY_RELEASE
        sentry-cli releases files $SENTRY_RELEASE upload-sourcemaps tmp/deploy-dist/
        sentry-cli releases finalize $SENTRY_RELEASE
      env:
        SENTRY_AUTH_TOKEN: ${{ secrets.SENTRY_AUTH_TOKEN }}

Upvotes: 2

Lux
Lux

Reputation: 18240

You can use ember-cli-app-version to display the app version.

Upvotes: 1

Codebreaker007
Codebreaker007

Reputation: 2989

Have you looked into this plugin:
ember-cli-deploy-sentry
Look also at the issues and PRs, at least the source code could get you started.

Upvotes: 0

Related Questions