From ddebde27e1fe12ddad1a638637c828bc028742dc Mon Sep 17 00:00:00 2001 From: k-fish Date: Tue, 9 Feb 2021 15:33:17 -0800 Subject: [PATCH] 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. --- packages/ember/index.js | 27 +++++---------------------- 1 file changed, 5 insertions(+), 22 deletions(-) diff --git a/packages/ember/index.js b/packages/ember/index.js index 619063e73bc0..c2d665aeacb8 100644 --- a/packages/ember/index.js +++ b/packages/ember/index.js @@ -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) {