From 62912e078a8b2becdf4e2dcdb280b7da50675db7 Mon Sep 17 00:00:00 2001 From: Claude Date: Thu, 4 Jun 2026 13:15:19 +0300 Subject: [PATCH] fix(vue): expose countlyGlobal on Vue prototype for template expressions MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit countlyGlobal is a window-level global, but Vue 2's render proxy (present in the dev/warning build, frontend.production=false) does not fall through to window for identifiers used in template expressions. So a bare countlyGlobal.* in a .html template binding resolves to undefined and throws "Cannot read properties of undefined (reading 'path')" during render (it only "worked" in the minified build where with(this) falls through to window). The defensive (countlyGlobal.path || '') form doesn't help, since countlyGlobal.path is evaluated first. Expose it once, centrally, on Vue.prototype via a getter (so it always reflects the current window.countlyGlobal). This covers every dashboard template referencing countlyGlobal across core and all plugins (including enterprise plugins, which render in this same Vue instance) — no per- component shims needed. JS-file uses of countlyGlobal are unaffected. Co-Authored-By: Claude Opus 4.8 (1M context) --- .../express/public/javascripts/countly/vue/core.js | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/frontend/express/public/javascripts/countly/vue/core.js b/frontend/express/public/javascripts/countly/vue/core.js index 1a9e40f53f6..82b73452bc8 100644 --- a/frontend/express/public/javascripts/countly/vue/core.js +++ b/frontend/express/public/javascripts/countly/vue/core.js @@ -619,6 +619,18 @@ Vue.prototype.$route = new BackboneRouteAdapter(); + // countlyGlobal is a window-level global, but Vue 2's render proxy does not fall + // through to window for identifiers in template expressions, so a bare + // countlyGlobal.* in a template resolves to undefined and throws during render. + // Expose it on the prototype (via a getter so it always reflects the current + // window.countlyGlobal) so templates can use countlyGlobal.* safely. + Object.defineProperty(Vue.prototype, "countlyGlobal", { + configurable: true, + get: function() { + return window.countlyGlobal; + } + }); + var DummyCompAPI = VueCompositionAPI.defineComponent({ name: "DummyCompAPI", template: '
',