Skip to content

Commit ddebde2

Browse files
committed
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.
1 parent d8ecb2b commit ddebde2

File tree

1 file changed

+5
-22
lines changed

1 file changed

+5
-22
lines changed

packages/ember/index.js

Lines changed: 5 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -16,32 +16,15 @@ module.exports = {
1616
},
1717
},
1818

19-
getAddonConfig(app) {
20-
let config = {};
21-
try {
22-
config = require(app.options.configPath)(app.env);
23-
} catch(_) {
24-
// Config not found
25-
}
26-
return config['@sentry/ember'] || {};
27-
},
28-
29-
included() {
30-
this._super.included.apply(this, arguments);
31-
const app = this._findHost(this);
32-
if (!('@embroider/core' in app.dependencies())) {
33-
const addonConfig = this.getAddonConfig(app);
34-
const options = Object.assign({}, addonConfig);
35-
this.options['@embroider/macros'].setOwnConfig.sentryConfig = options;
36-
}
19+
config(_, appConfig) {
20+
const addonConfig = appConfig['@sentry/ember'];
21+
const options = Object.assign({}, addonConfig);
22+
this.options['@embroider/macros'].setOwnConfig.sentryConfig = options;
23+
return this._super(...arguments);
3724
},
3825

3926
contentFor(type, config) {
4027
const addonConfig = config['@sentry/ember'] || {};
41-
const app = this._findHost(this);
42-
this.app = app;
43-
const options = Object.assign({}, addonConfig);
44-
this.options['@embroider/macros'].setOwnConfig.sentryConfig = options;
4528

4629
const { disablePerformance, disableInitialLoadInstrumentation } = addonConfig;
4730
if (disablePerformance || disableInitialLoadInstrumentation) {

0 commit comments

Comments
 (0)