Skip to content

Commit f5ff350

Browse files
k-fishahmedetefy
authored andcommitted
fix(ember): Fixing fetching config during build step (#3246)
* 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 b95123b commit f5ff350

File tree

1 file changed

+4
-22
lines changed

1 file changed

+4
-22
lines changed

packages/ember/index.js

Lines changed: 4 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -16,32 +16,14 @@ 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+
this.options['@embroider/macros'].setOwnConfig.sentryConfig = { ...addonConfig };
22+
return this._super(...arguments);
3723
},
3824

3925
contentFor(type, config) {
4026
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;
4527

4628
const { disablePerformance, disableInitialLoadInstrumentation } = addonConfig;
4729
if (disablePerformance || disableInitialLoadInstrumentation) {

0 commit comments

Comments
 (0)