Incompatible data table: Error: Unknown address type
-
Hello Beehive Analytics Support Team,
I’ve encountered an issue with the “Top Countries” GeoChart in Beehive Analytics (version 3.4.16) that prevents it from rendering correctly out of the box. The console shows a “Type mismatch” error related to data processing, which I managed to fix with a workaround. Below is a detailed explanation of the issue, diagnostic steps, the fix, and additional warnings that persist. Issue 1: “Type mismatch” Error in GeoChart
- Error Message:
chunk-vendors.min.js?ver=3.4.16:81 Error: Type mismatch. Value 0 does not match type number in column index 1 at gvjs_yk (jsapi_compiled_default_module.js:277:264) at gvjs_M.<anonymous> (jsapi_compiled_default_module.js:294:194) at gvjs_M.<anonymous> (jsapi_compiled_default_module.js:295:73) at o.setupList (chunk-common.min.js?ver=3.4.16:1:43105) at o.onChartReady (chunk-common.min.js?ver=3.4.16:1:43611) at zn (chunk-vendors.min.js?ver=3.4.16:81:24932) at o.n (chunk-vendors.min.js?ver=3.4.16:81:14729) at zn (chunk-vendors.min.js?ver=3.4.16:81:24932) at o.$emit (chunk-vendors.min.js?ver=3.4.16:81:30959) at chunk-vendors.min.js?ver=3.4.16:191:5754- Description: The GeoChart in the “Top Countries” section fails to render, showing the above error in the browser console. This indicates that the Google Visualization API (GeoChart) received a non-numeric value in the sessions column (index 1), which should always be a number.
- Cause: After debugging, I found that the
stats.countriesarray from Google Analytics contains an entry["(not set)", "(not set)", "0"], where the session value"0"is a string instead of a number. The GeoChart expects numeric values in column 1, and this mismatch causes the error.
Initial Debugging:
- Added
console.log('Raw stats for countries:', t.stats.countries)tosetupListinchunk-common.min.js. - Output:
stats.countriescontains 27 entries, including["(not set)", "(not set)", "0"]with a string"0". - Confirmed that other entries (e.g.,
["Italy", "IT", 48]) have numeric session values.
Data Processing Check:
- Inspected the
setupListmethod, which builds aDataTablefor GeoChart:javascript s.addColumn("string", this.$i18n.label.country); s.addColumn("number", this.$i18n.label.sessions); s.addColumn({ type: "string", role: "tooltip", p: { html: !0 } }); Object.keys(t.stats.countries).forEach(function (s) { e.push([t.stats.countries[s][0], t.stats.countries[s][2], t.geoToolTip(...)]); }); s.addRows(e); - Found that
t.stats.countries[s][2](session value) is passed directly toewithout type conversion, so"0"remains a string.
- Reproduction:
- Connected Beehive Analytics to a Google Analytics property.
- Navigated to the Analytics dashboard in WordPress admin.
- Opened the “Top Countries” section and checked the console, confirming the error.
Fix Applied
To resolve the “Type mismatch” error, I modified the
setupListmethod inchunk-common.min.jsto:- Convert session values to numbers explicitly.
- Filter out the invalid “(not set)” entry.
Original Code (simplified):
setupList: function () { if (!this.isEmpty && this.chartApi) { var t = this, e = [], s = new this.chartApi.visualization.DataTable(); s.addColumn("string", this.$i18n.label.country); s.addColumn("number", this.$i18n.label.sessions); s.addColumn({ type: "string", role: "tooltip", p: { html: !0 } }); Object.keys(t.stats.countries).forEach(function (s) { e.push([t.stats.countries[s][0], t.stats.countries[s][2], t.geoToolTip(...)]); }); s.addRows(e); this.chartData = s; } }Modified Code:
setupList: function () { if (!this.isEmpty && this.chartApi) { var t = this, e = [], s = new this.chartApi.visualization.DataTable(); s.addColumn("string", "Country"); s.addColumn("number", "Sessions"); s.addColumn({ type: "string", role: "tooltip", p: { html: true } }); console.log('Raw stats for countries:', t.stats.countries); Object.keys(t.stats.countries).forEach(function (s) { var countryName = t.stats.countries[s][0]; var sessionValue = t.stats.countries[s][2]; var tooltip = t.geoToolTip(t.stats.countries[s][0], t.stats.countries[s][1], sessionValue); var numericValue = Number(sessionValue); if (isNaN(numericValue)) numericValue = 0; if (countryName === "(not set)") { console.log('Skipping (not set):', countryName, numericValue); return; } console.log('Country:', countryName, 'Sessions (raw):', sessionValue, 'Sessions (numeric):', numericValue); e.push([countryName, numericValue, tooltip]); }); console.log('GeoChart data before DataTable:', e); if (e.length === 0) { console.log('No valid countries to display'); this.chartData = {}; return; } s.addRows(e); this.chartData = s; console.log('Final chartData (DataTable):', this.chartData); } else { this.chartData = {}; } }Result:
- After applying this fix, the GeoChart renders correctly with 26 valid countries (excluding “(not set)”).
- Console log example:
Raw stats for countries: [["Italy", "IT", 48], ..., ["(not set)", "(not set)", "0"]]
Country: Italy Sessions (raw): 48 Sessions (numeric): 48
...
Skipping (not set): (not set) 0
GeoChart data before DataTable: [["Italy", 48, "<tooltip...>"], ...]
Final chartData (DataTable): <gvjs_M object with 26 rows>- The “Type mismatch” error no longer appears.
Issue 2: Google Maps API Warnings
Even after fixing the chart, the following warnings persist in the console:
Google Maps JavaScript API has been loaded directly without loading=async. Geocoding Service: You must use an API key to authenticate each request. Google Maps JavaScript API warning: NoApiKeys. Google Maps JavaScript API warning: InvalidKey.- Cause:
- The plugin loads the Google Maps API synchronously without
loading=async. - It attempts to use the Geocoding Service (e.g., for “Czechia” and “Türkiye”) but does not provide a valid API key.
- Impact: These warnings do not break the chart but indicate suboptimal performance and missing configuration.
Environment
- WordPress Version: [6.7.2]
- Beehive Analytics Version: 3.4.16
- PHP Version: [8.4.5]
- Browser: [Opera 117.0.5408.53]
Suggestions for Fix – Type Mismatch:
- The plugin should validate and convert all session values (
stats.countries[s][2]) to numbers before passing them to GeoChart. - Filter out invalid entries like “(not set)” by default to avoid breaking the chart.
Google Maps API:
- Update the Google Maps API loading to use
loading=asyncfor better performance. - Include a default API key for the Google Maps/Geocoding API or add a clear setup guide in the plugin documentation for users to provide their own key.
Conclusion
The “Type mismatch” error is a bug in Beehive Analytics due to improper handling of data types from Google Analytics. The additional API warnings suggest incomplete integration with Google Maps API. As a user, I shouldn’t need to manually edit plugin files to make the GeoChart work. Please address these issues in a future update.
Let me know if you need more details or logs to reproduce this!
Thank you,
Mark
The topic ‘Incompatible data table: Error: Unknown address type’ is closed to new replies.