fix(vue): expose countlyGlobal on Vue prototype (template render crash in dev build)#7658
Merged
Merged
Conversation
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) <noreply@anthropic.com>
Contributor
There was a problem hiding this comment.
Pull request overview
This PR fixes a Vue 2 dev/warning build render crash by making the existing window.countlyGlobal available as an instance property in Vue template expressions. It centralizes the workaround in the core Vue bootstrap so all core and plugin templates can safely reference countlyGlobal.* without per-component shims.
Changes:
- Expose
countlyGlobalonVue.prototypeusing a getter that returnswindow.countlyGlobal. - Add inline documentation explaining why this is required for Vue 2’s dev-mode render proxy behavior.
pnrgenc
approved these changes
Jun 4, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Symptom
With the dev/warning Vue build (
frontend.production=false), any page whose Vue template referencescountlyGlobalthrows during render and breaks the page:(In countly-platform this crashed the Drill page on every query — the loading/thinking avatar template uses
countlyGlobal.path.)Root cause
countlyGlobalis awindow-level global. Vue 2's render proxy (present in the dev/warning build) does not fall through towindowfor identifiers in template expressions, socountlyGlobalresolves toundefinedandundefined.paththrows. It only "works" in the minified build, wherewith(this)falls through towindow.countlyGlobal. So anycountlyGlobal.*in a.htmltemplate binding (:src=,:href=,{{ }}) is a latent crash. The defensive(countlyGlobal.path || '')form doesn't help —countlyGlobal.pathis evaluated before|| ''. (JS-file uses incountly.models.js/countly.views.jsare fine — this only affects template expressions.)Fix (single, central)
In
frontend/express/public/javascripts/countly/vue/core.js, right afterVue.prototype.$route = new BackboneRouteAdapter();, expose it on the prototype via a getter (so it always reflects the currentwindow.countlyGlobal):This covers every dashboard template referencing
countlyGlobalacross core and all plugins. Enterprise plugins need no separate change — they render inside this same dashboard Vue instance. No per-component data/computed shims. ConfirmedVue.prototype.countlyGlobalwasn't already defined.Verify
node --checkoncore.jspasses; eslint clean.frontend.production=false, a page using acountlyGlobal.*template binding (Drill run-query, push compose preview, views config) renders with no[Vue warn]/render error and resolves asset URLs./min/assets are rebuilt by CI (grunt dist-all); only the source change is committed here.🤖 Generated with Claude Code