From ddebde27e1fe12ddad1a638637c828bc028742dc Mon Sep 17 00:00:00 2001 From: k-fish Date: Tue, 9 Feb 2021 15:33:17 -0800 Subject: [PATCH 1/2] 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) { From b766f8b50cb47cc81c4ebe137b2d4152f47c606c Mon Sep 17 00:00:00 2001 From: k-fish Date: Fri, 12 Feb 2021 10:41:26 -0800 Subject: [PATCH 2/2] Update packages/ember/index.js MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Kamil Ogórek --- packages/ember/index.js | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/packages/ember/index.js b/packages/ember/index.js index c2d665aeacb8..c51410e9348c 100644 --- a/packages/ember/index.js +++ b/packages/ember/index.js @@ -18,8 +18,7 @@ module.exports = { config(_, appConfig) { const addonConfig = appConfig['@sentry/ember']; - const options = Object.assign({}, addonConfig); - this.options['@embroider/macros'].setOwnConfig.sentryConfig = options; + this.options['@embroider/macros'].setOwnConfig.sentryConfig = { ...addonConfig }; return this._super(...arguments); },