Skip to content

Commit

Permalink
fix(ember): Fixing fetching config during build step (#3246)
Browse files Browse the repository at this point in the history
* fix(ember): Fixing fetching config during build step

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 authored and ahmedetefy committed Mar 10, 2021
1 parent b95123b commit f5ff350
Showing 1 changed file with 4 additions and 22 deletions.
26 changes: 4 additions & 22 deletions packages/ember/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,32 +16,14 @@ 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'];
this.options['@embroider/macros'].setOwnConfig.sentryConfig = { ...addonConfig };
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 f5ff350

Please sign in to comment.