Skip to content

Commit

Permalink
fix(ember): Fixing fetching config during build step
Browse files Browse the repository at this point in the history
As mentioned in #3230, this is still causing problems for build systems. Pulled out the logic to put config into an embroider macro to the 'config' hook for the addon, which gets rid of the conditional logic as well as pulling configPath which could be undefined. Tested on both sides of using Embroider and the existing build system and the macros appear to be populated now, so this should work.
  • Loading branch information
k-fish committed Feb 9, 2021
1 parent d8ecb2b commit ddebde2
Showing 1 changed file with 5 additions and 22 deletions.
27 changes: 5 additions & 22 deletions packages/ember/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,32 +16,15 @@ module.exports = {
},
},

getAddonConfig(app) {
let config = {};
try {
config = require(app.options.configPath)(app.env);
} catch(_) {
// Config not found
}
return config['@sentry/ember'] || {};
},

included() {
this._super.included.apply(this, arguments);
const app = this._findHost(this);
if (!('@embroider/core' in app.dependencies())) {
const addonConfig = this.getAddonConfig(app);
const options = Object.assign({}, addonConfig);
this.options['@embroider/macros'].setOwnConfig.sentryConfig = options;
}
config(_, appConfig) {
const addonConfig = appConfig['@sentry/ember'];
const options = Object.assign({}, addonConfig);
this.options['@embroider/macros'].setOwnConfig.sentryConfig = options;
return this._super(...arguments);
},

contentFor(type, config) {
const addonConfig = config['@sentry/ember'] || {};
const app = this._findHost(this);
this.app = app;
const options = Object.assign({}, addonConfig);
this.options['@embroider/macros'].setOwnConfig.sentryConfig = options;

const { disablePerformance, disableInitialLoadInstrumentation } = addonConfig;
if (disablePerformance || disableInitialLoadInstrumentation) {
Expand Down

0 comments on commit ddebde2

Please sign in to comment.