From c5e8b37a945ba75591cdc5855e74470069e27ec1 Mon Sep 17 00:00:00 2001 From: Diego Antonelli Date: Fri, 18 Jun 2021 09:56:31 +0200 Subject: [PATCH 1/2] Fix script execution when GA script is not loaded. --- CHANGELOG.md | 12 + package-lock.json | 230 +++++++++++++----- package.json | 2 +- .../widget/AdvancedPageTracker.js | 20 +- src/GoogleAnalytics/widget/EventTracker.js | 14 +- .../widget/EventTrackerButton.js | 2 +- .../widget/MasterPageTracker.js | 44 ++-- src/GoogleAnalytics/widget/PageTracker.js | 12 +- src/GoogleAnalytics/widget/TrackerCore.js | 14 +- src/package.xml | 4 +- test/widgets/GoogleAnalytics.mpk | Bin 52540 -> 52877 bytes 11 files changed, 249 insertions(+), 105 deletions(-) create mode 100644 CHANGELOG.md diff --git a/CHANGELOG.md b/CHANGELOG.md new file mode 100644 index 0000000..c0e6dc6 --- /dev/null +++ b/CHANGELOG.md @@ -0,0 +1,12 @@ +# Changelog +All notable changes to this widget will be documented in this file. + +The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). + +## 3.3.6 - 2021-06-18 + +### Changed +- Fixed an issue while having ads blocker or tracking option disable in the browser. + +## Older releases +See [marketplace](https://marketplace.mendix.com/link/component/105) for previous releases. diff --git a/package-lock.json b/package-lock.json index 7f03f39..6be473b 100644 --- a/package-lock.json +++ b/package-lock.json @@ -4,6 +4,15 @@ "lockfileVersion": 1, "requires": true, "dependencies": { + "ansi-colors": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/ansi-colors/-/ansi-colors-1.1.0.tgz", + "integrity": "sha512-SFKX67auSNoVR38N3L+nvsPjOE0bybKTYbkf5tRvushrAPQ9V75huw0ZxBkKVeRU9kqH3d6HA4xTckbwZ4ixmA==", + "dev": true, + "requires": { + "ansi-wrap": "^0.1.0" + } + }, "ansi-cyan": { "version": "0.1.1", "resolved": "https://registry.npmjs.org/ansi-cyan/-/ansi-cyan-0.1.1.tgz", @@ -131,9 +140,9 @@ "dev": true }, "atob": { - "version": "2.0.3", - "resolved": "https://registry.npmjs.org/atob/-/atob-2.0.3.tgz", - "integrity": "sha1-GcenYEc3dEaPILLS0DNyrX1Mv10=", + "version": "2.1.2", + "resolved": "https://registry.npmjs.org/atob/-/atob-2.1.2.tgz", + "integrity": "sha512-Wm6ukoaOGJi/73p/cl2GvLjTI5JM1k/O14isD73YML8StrH/7/lRFgmg8nICZgD3bZZvjwCGxtMOD3wWNAu8cg==", "dev": true }, "balanced-match": { @@ -336,12 +345,61 @@ "integrity": "sha1-KY1+IjFmD0DAA8LtMUDezz9TCF8=", "dev": true }, + "clone-buffer": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/clone-buffer/-/clone-buffer-1.0.0.tgz", + "integrity": "sha1-4+JbIHrE5wGvch4staFnksrD3Fg=", + "dev": true + }, "clone-stats": { "version": "0.0.1", "resolved": "https://registry.npmjs.org/clone-stats/-/clone-stats-0.0.1.tgz", "integrity": "sha1-uI+UqCzzi4eR1YBG6kAprYjKmdE=", "dev": true }, + "cloneable-readable": { + "version": "1.1.3", + "resolved": "https://registry.npmjs.org/cloneable-readable/-/cloneable-readable-1.1.3.tgz", + "integrity": "sha512-2EF8zTQOxYq70Y4XKtorQupqF0m49MBz2/yf5Bj+MHjvpG3Hy7sImifnqD6UA+TKYxeSV+u6qqQPawN5UvnpKQ==", + "dev": true, + "requires": { + "inherits": "^2.0.1", + "process-nextick-args": "^2.0.0", + "readable-stream": "^2.3.5" + }, + "dependencies": { + "isarray": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/isarray/-/isarray-1.0.0.tgz", + "integrity": "sha1-u5NdSFgsuhaMBoNJV6VKPgcSTxE=", + "dev": true + }, + "readable-stream": { + "version": "2.3.7", + "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-2.3.7.tgz", + "integrity": "sha512-Ebho8K4jIbHAxnuxi7o42OrZgF/ZTNcsZj6nRKyUmkhLFq8CHItp/fy6hQZuZmP/n3yZ9VBUbp4zz/mX8hmYPw==", + "dev": true, + "requires": { + "core-util-is": "~1.0.0", + "inherits": "~2.0.3", + "isarray": "~1.0.0", + "process-nextick-args": "~2.0.0", + "safe-buffer": "~5.1.1", + "string_decoder": "~1.1.1", + "util-deprecate": "~1.0.1" + } + }, + "string_decoder": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-1.1.1.tgz", + "integrity": "sha512-n/ShnvDi6FHbbVfviro+WojiFzv+s8MPMHBczVePfUpDJLwoLT0ht1l4YwBCbi8pJAveEEdnkHyPyTP/mzRfwg==", + "dev": true, + "requires": { + "safe-buffer": "~5.1.0" + } + } + } + }, "code-point-at": { "version": "1.1.0", "resolved": "https://registry.npmjs.org/code-point-at/-/code-point-at-1.1.0.tgz", @@ -1118,14 +1176,82 @@ } }, "gulp-json-transform": { - "version": "0.4.5", - "resolved": "https://registry.npmjs.org/gulp-json-transform/-/gulp-json-transform-0.4.5.tgz", - "integrity": "sha512-kaGUaAhgjxeLgIMNF3IPFFmYCF6AgvzBQwqmVowiIStNADZSoILtPNDisYA4mKfpwMTqSiWLogQt1q5U75+uwA==", + "version": "0.4.7", + "resolved": "https://registry.npmjs.org/gulp-json-transform/-/gulp-json-transform-0.4.7.tgz", + "integrity": "sha512-Wi0p5GpoLXbTDwaZnw6rgj3FMLW3PscaHaX1okxrTgPWeqnIiMo4aJz7VlG68JYkxPeAXJrPce8AGEfcT2IifA==", "dev": true, "requires": { - "gulp-util": "^3.0.8", + "ansi-colors": "^1.0.1", + "fancy-log": "^1.3.2", + "plugin-error": "^1.0.1", "promise": "^8.0.1", - "through2": "^2.0.3" + "through2": "^2.0.3", + "vinyl": "^2.1.0" + }, + "dependencies": { + "clone": { + "version": "2.1.2", + "resolved": "https://registry.npmjs.org/clone/-/clone-2.1.2.tgz", + "integrity": "sha1-G39Ln1kfHo+DZwQBYANFoCiHQ18=", + "dev": true + }, + "clone-stats": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/clone-stats/-/clone-stats-1.0.0.tgz", + "integrity": "sha1-s3gt/4u1R04Yuba/D9/ngvh3doA=", + "dev": true + }, + "extend-shallow": { + "version": "3.0.2", + "resolved": "https://registry.npmjs.org/extend-shallow/-/extend-shallow-3.0.2.tgz", + "integrity": "sha1-Jqcarwc7OfshJxcnRhMcJwQCjbg=", + "dev": true, + "requires": { + "assign-symbols": "^1.0.0", + "is-extendable": "^1.0.1" + } + }, + "is-extendable": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/is-extendable/-/is-extendable-1.0.1.tgz", + "integrity": "sha512-arnXMxT1hhoKo9k1LZdmlNyJdDDfy2v0fXjFlmok4+i8ul/6WlbVge9bhM74OpNPQPMGUToDtz+KXa1PneJxOA==", + "dev": true, + "requires": { + "is-plain-object": "^2.0.4" + } + }, + "plugin-error": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/plugin-error/-/plugin-error-1.0.1.tgz", + "integrity": "sha512-L1zP0dk7vGweZME2i+EeakvUNqSrdiI3F91TwEoYiGrAfUXmVv6fJIq4g82PAXxNsWOp0J7ZqQy/3Szz0ajTxA==", + "dev": true, + "requires": { + "ansi-colors": "^1.0.1", + "arr-diff": "^4.0.0", + "arr-union": "^3.1.0", + "extend-shallow": "^3.0.2" + } + }, + "replace-ext": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/replace-ext/-/replace-ext-1.0.1.tgz", + "integrity": "sha512-yD5BHCe7quCgBph4rMQ+0KkIRKwWCrHDOX1p1Gp6HwjPM5kVoCdKGNhN7ydqqsX6lJEnQDKZ/tFMiEdQ1dvPEw==", + "dev": true + }, + "vinyl": { + "version": "2.2.1", + "resolved": "https://registry.npmjs.org/vinyl/-/vinyl-2.2.1.tgz", + "integrity": "sha512-LII3bXRFBZLlezoG5FfZVcXflZgWP/4dCwKtxd5ky9+LOtM4CS3bIRQsmR1KMnMW07jpE8fqR2lcxPZ+8sJIcw==", + "dev": true, + "requires": { + "clone": "^2.1.1", + "clone-buffer": "^1.0.0", + "clone-stats": "^1.0.0", + "cloneable-readable": "^1.0.0", + "remove-trailing-separator": "^1.0.1", + "replace-ext": "^1.0.0" + } + } } }, "gulp-match": { @@ -1264,9 +1390,9 @@ } }, "hosted-git-info": { - "version": "2.5.0", - "resolved": "https://registry.npmjs.org/hosted-git-info/-/hosted-git-info-2.5.0.tgz", - "integrity": "sha512-pNgbURSuab90KbTqvRPsseaTxOJCZBD0a7t+haSN33piP9cCM4l0CqdzAif2hUqm716UovKB2ROmiabGAKVXyg==", + "version": "2.8.9", + "resolved": "https://registry.npmjs.org/hosted-git-info/-/hosted-git-info-2.8.9.tgz", + "integrity": "sha512-mxIDAb9Lsm6DoOJ7xH+5+X4y1LU/4Hi50L9C5sIswK3JzULS4bwk1FvjdBgvYR4bzT4tuUQiC15FE2f5HbLvYw==", "dev": true }, "inflight": { @@ -1286,9 +1412,9 @@ "dev": true }, "ini": { - "version": "1.3.5", - "resolved": "https://registry.npmjs.org/ini/-/ini-1.3.5.tgz", - "integrity": "sha512-RZY5huIKCMRWDUqZlEi72f/lmXKMvuszcMBduliQ3nnWbx9X/ZBQO7DijMEYS9EhHBb2qacRUMtC7svLwe0lcw==", + "version": "1.3.8", + "resolved": "https://registry.npmjs.org/ini/-/ini-1.3.8.tgz", + "integrity": "sha512-JV/yugV2uzW5iMRSiZAyDtQd+nxtUnjeLt0acNdw98kKLrvuRVyB80tsREOE7yvGVgalhZ6RNXCmEHkUKBKxew==", "dev": true }, "interpret": { @@ -1510,9 +1636,9 @@ "dev": true }, "kind-of": { - "version": "6.0.2", - "resolved": "https://registry.npmjs.org/kind-of/-/kind-of-6.0.2.tgz", - "integrity": "sha512-s5kLOcnH0XqDO+FvuaLX8DDjZ18CGFk7VygH40QoKPUQhW4e2rvM0rwUq0t8IQDOwYSeLK01U90OjzBTme2QqA==", + "version": "6.0.3", + "resolved": "https://registry.npmjs.org/kind-of/-/kind-of-6.0.3.tgz", + "integrity": "sha512-dcS1ul+9tmeD95T+x28/ehLgd9mENa3LsvDTtzm3vyBEO7RPptvAD+t44WVXaUjTBRcrpFeFlC8WCruUR456hw==", "dev": true }, "lazy-cache": { @@ -1823,9 +1949,9 @@ } }, "minimist": { - "version": "1.2.0", - "resolved": "https://registry.npmjs.org/minimist/-/minimist-1.2.0.tgz", - "integrity": "sha1-o1AIsg9BOD7sH7kU9M1d95omQoQ=", + "version": "1.2.5", + "resolved": "https://registry.npmjs.org/minimist/-/minimist-1.2.5.tgz", + "integrity": "sha512-FM9nNUYrRBAELZQT3xeZQ7fmMOBg6nWNmJKTcgsJeaLstP/UODVpGsr5OhXhhXg6f+qtJ8uiZ+PUxkDWcgIXLw==", "dev": true }, "mixin-deep": { @@ -1850,20 +1976,12 @@ } }, "mkdirp": { - "version": "0.5.1", - "resolved": "https://registry.npmjs.org/mkdirp/-/mkdirp-0.5.1.tgz", - "integrity": "sha1-MAV0OOrGz3+MR2fzhkjWaX11yQM=", + "version": "0.5.5", + "resolved": "https://registry.npmjs.org/mkdirp/-/mkdirp-0.5.5.tgz", + "integrity": "sha512-NKmAlESf6jMGym1++R0Ra7wvhV+wFW63FaSOFPwRahvea0gMUcGUhVeAg/0BC0wiv9ih5NYPB1Wn1UEI1/L+xQ==", "dev": true, "requires": { - "minimist": "0.0.8" - }, - "dependencies": { - "minimist": { - "version": "0.0.8", - "resolved": "https://registry.npmjs.org/minimist/-/minimist-0.0.8.tgz", - "integrity": "sha1-hX/Kv8M5fSYluCKCYuhqp6ARsF0=", - "dev": true - } + "minimist": "^1.2.5" } }, "ms": { @@ -2297,12 +2415,12 @@ "dev": true }, "promise": { - "version": "8.0.1", - "resolved": "https://registry.npmjs.org/promise/-/promise-8.0.1.tgz", - "integrity": "sha1-5F1osAoXZHttpxG/he1u1HII9FA=", + "version": "8.1.0", + "resolved": "https://registry.npmjs.org/promise/-/promise-8.1.0.tgz", + "integrity": "sha512-W04AqnILOL/sPRXziNicCjSNRruLAuIHEOVBazepu0545DDNGYHz7ar9ZgZ1fMU8/MA4mVxp5rkBWRi6OXIy3Q==", "dev": true, "requires": { - "asap": "~2.0.3" + "asap": "~2.0.6" } }, "read-pkg": { @@ -2356,6 +2474,12 @@ "extend-shallow": "^2.0.1" } }, + "remove-trailing-separator": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/remove-trailing-separator/-/remove-trailing-separator-1.1.0.tgz", + "integrity": "sha1-wkvOKig62tW8P1jg1IJJuSN52O8=", + "dev": true + }, "repeat-element": { "version": "1.1.2", "resolved": "https://registry.npmjs.org/repeat-element/-/repeat-element-1.1.2.tgz", @@ -2460,9 +2584,9 @@ } }, "set-value": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/set-value/-/set-value-2.0.0.tgz", - "integrity": "sha512-hw0yxk9GT/Hr5yJEYnHNKYXkIA8mVJgd9ditYZCe16ZczcaELYYcfvaXesNACk2O8O0nTiPQcQhGUQj8JLzeeg==", + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/set-value/-/set-value-2.0.1.tgz", + "integrity": "sha512-JxHc1weCN68wRY0fhCoXpyK55m/XPHafOmK4UWD7m2CI14GMcFypt4w/0+NV5f/ZMby2F6S2wwA7fgynh9gWSw==", "dev": true, "requires": { "extend-shallow": "^2.0.1", @@ -3032,29 +3156,15 @@ "dev": true }, "union-value": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/union-value/-/union-value-1.0.0.tgz", - "integrity": "sha1-XHHDTLW61dzr4+oM0IIHulqhrqQ=", + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/union-value/-/union-value-1.0.1.tgz", + "integrity": "sha512-tJfXmxMeWYnczCVs7XAEvIV7ieppALdyepWMkHkwciRpZraG/xwT+s2JN8+pr1+8jCRf80FFzvr+MpQeeoF4Xg==", "dev": true, "requires": { "arr-union": "^3.1.0", "get-value": "^2.0.6", "is-extendable": "^0.1.1", - "set-value": "^0.4.3" - }, - "dependencies": { - "set-value": { - "version": "0.4.3", - "resolved": "https://registry.npmjs.org/set-value/-/set-value-0.4.3.tgz", - "integrity": "sha1-fbCPnT0i3H945Trzw79GZuzfzPE=", - "dev": true, - "requires": { - "extend-shallow": "^2.0.1", - "is-extendable": "^0.1.1", - "is-plain-object": "^2.0.1", - "to-object-path": "^0.3.0" - } - } + "set-value": "^2.0.1" } }, "unique-stream": { @@ -3367,9 +3477,9 @@ "dev": true }, "y18n": { - "version": "3.2.1", - "resolved": "https://registry.npmjs.org/y18n/-/y18n-3.2.1.tgz", - "integrity": "sha1-bRX7qITAhnnA136I53WegR4H+kE=", + "version": "3.2.2", + "resolved": "https://registry.npmjs.org/y18n/-/y18n-3.2.2.tgz", + "integrity": "sha512-uGZHXkHnhF0XeeAPgnKfPv1bgKAYyVvmNL1xlKsPYZPaIHxGti2hHqvOCQv71XMsLxu1QjergkqogUnms5D3YQ==", "dev": true }, "yargs": { diff --git a/package.json b/package.json index c3ae483..e945ec8 100644 --- a/package.json +++ b/package.json @@ -11,7 +11,7 @@ "gulp": "^3.9.1", "gulp-if": "^2.0.1", "gulp-intercept": "^0.1.0", - "gulp-json-transform": "^0.4.2", + "gulp-json-transform": "^0.4.7", "gulp-newer": "^1.3.0", "gulp-util": "^3.0.7", "gulp-zip": "^3.2.0", diff --git a/src/GoogleAnalytics/widget/AdvancedPageTracker.js b/src/GoogleAnalytics/widget/AdvancedPageTracker.js index cc533e4..e17e999 100644 --- a/src/GoogleAnalytics/widget/AdvancedPageTracker.js +++ b/src/GoogleAnalytics/widget/AdvancedPageTracker.js @@ -45,7 +45,9 @@ define("GoogleAnalytics/widget/AdvancedPageTracker", [ for (var i = 0; i < this.metricDimensionList.length; i++) { var dimension = this.metricDimensionList[i]; if (dimension.name.indexOf("dimension") === 0) { - ga("set", dimension.name, this._contextObj.get(dimension.attr)); + if (this._gaScriptAvailable()) { + ga("set", dimension.name, this._contextObj.get(dimension.attr)); + } } } callback(); @@ -55,13 +57,15 @@ define("GoogleAnalytics/widget/AdvancedPageTracker", [ logger.debug(this.id + "._addPage"); this._replaceTags(this.trackUrl, lang.hitch(this, function (newTrackUrl) { this._replaceTags(this.pageTitle, lang.hitch(this, function (newPageTitle) { - this._setDimensions(function () { - ga("send", { - hitType: "pageview", - page: newTrackUrl, - title: newPageTitle - }); - }); + this._setDimensions(lang.hitch(this, function () { + if (this._gaScriptAvailable()) { + ga("send", { + hitType: "pageview", + page: newTrackUrl, + title: newPageTitle + }); + } + })); })); }) ); diff --git a/src/GoogleAnalytics/widget/EventTracker.js b/src/GoogleAnalytics/widget/EventTracker.js index 09a30b3..7d5bd7a 100644 --- a/src/GoogleAnalytics/widget/EventTracker.js +++ b/src/GoogleAnalytics/widget/EventTracker.js @@ -18,12 +18,14 @@ define("GoogleAnalytics/widget/EventTracker", [ _addEvent: function () { logger.debug(this.id + "._addEvent"); - ga("send", - "event", - this.category, - this.action, - (this._contextObj !== null) ? this._contextObj.get(this.label) : "", - (this._contextObj !== null) ? this._contextObj.get(this.value) : ""); + if (this._gaScriptAvailable()) { + ga("send", + "event", + this.category, + this.action, + (this._contextObj !== null) ? this._contextObj.get(this.label) : "", + (this._contextObj !== null) ? this._contextObj.get(this.value) : ""); + } } }); diff --git a/src/GoogleAnalytics/widget/EventTrackerButton.js b/src/GoogleAnalytics/widget/EventTrackerButton.js index 4fcf240..156adbe 100644 --- a/src/GoogleAnalytics/widget/EventTrackerButton.js +++ b/src/GoogleAnalytics/widget/EventTrackerButton.js @@ -28,7 +28,7 @@ define("GoogleAnalytics/widget/EventTrackerButton", [ _addEvent: function () { logger.debug(this.id + "._addEvent"); - if (this.addEvent) { + if (this.addEvent && this._gaScriptAvailable()) { ga("send", "event", this.category, diff --git a/src/GoogleAnalytics/widget/MasterPageTracker.js b/src/GoogleAnalytics/widget/MasterPageTracker.js index dda001c..8512bb2 100644 --- a/src/GoogleAnalytics/widget/MasterPageTracker.js +++ b/src/GoogleAnalytics/widget/MasterPageTracker.js @@ -65,24 +65,28 @@ define("GoogleAnalytics/widget/MasterPageTracker", [ logger.debug(this.id + "._insertGoogleAnalytics"); this._addGoogle(window, document, "script", "https://www.google-analytics.com/analytics.js", "ga"); - if (typeof window.mxGoogleAnalytics === "undefined") { - this._replaceTags(this.uaTrackCode, lang.hitch(this, function (text) { - var opts = { "cookieDomain": "auto" }; + if (this._gaScriptAvailable()) { + if (typeof window.mxGoogleAnalytics === "undefined") { + this._replaceTags(this.uaTrackCode, lang.hitch(this, function(text) { + var opts = { "cookieDomain": "auto" }; - if (this.useridAttr !== "") { - var uid = this._contextObj.get(this.useridAttr); - opts.userId = uid; - ga("create", text, opts); - ga("set", "&uid", uid); + if (this.useridAttr !== "") { + var uid = this._contextObj.get(this.useridAttr); + opts.userId = uid; + ga("create", text, opts); + ga("set", "&uid", uid); - if (this.userIdDimension > 0) - ga("set", "dimension"+this.userIdDimension, uid); + if (this.userIdDimension > 0) + ga("set", "dimension" + this.userIdDimension, uid); - } else { - ga("create", text, opts); - } + } else { + ga("create", text, opts); + } - })); + })); + } + } else { + logger.warn("Google Analytics script could not be loaded, please check if you dont have an ads blocker extension or tracking feature disabled."); } }, _buildFullPath: function(prefix, includePageName, oriMendixPath) { @@ -98,11 +102,13 @@ define("GoogleAnalytics/widget/MasterPageTracker", [ logger.debug(this.id + "._addPage"); this._replaceTags(this.prefix, lang.hitch(this, function(text) { var path = this._buildFullPath(text, this.includePageName, this.mxform.path); - ga("send", { - "hitType": "pageview", - "page": path, - "title": this.mxform.title - }); + if (this._gaScriptAvailable()) { + ga("send", { + "hitType": "pageview", + "page": path, + "title": this.mxform.title + }); + } })); } }); diff --git a/src/GoogleAnalytics/widget/PageTracker.js b/src/GoogleAnalytics/widget/PageTracker.js index 94ef6ff..0080bd7 100644 --- a/src/GoogleAnalytics/widget/PageTracker.js +++ b/src/GoogleAnalytics/widget/PageTracker.js @@ -20,11 +20,13 @@ define("GoogleAnalytics/widget/PageTracker", [ _addPage: function () { logger.debug(this.id + "._addPage"); - ga("send", { - "hitType": "pageview", - "page": this.trackUrl, - "title": this.pageTitle - }); + if (this._gaScriptAvailable()) { + ga("send", { + "hitType": "pageview", + "page": this.trackUrl, + "title": this.pageTitle + }); + } } }); diff --git a/src/GoogleAnalytics/widget/TrackerCore.js b/src/GoogleAnalytics/widget/TrackerCore.js index 3db4ca6..ecdd0bc 100644 --- a/src/GoogleAnalytics/widget/TrackerCore.js +++ b/src/GoogleAnalytics/widget/TrackerCore.js @@ -42,11 +42,19 @@ define([ logger.debug(this.id + ".TrackerCore._insertGoogleAnalytics"); this._addGoogle(window, document, "script", "https://www.google-analytics.com/analytics.js", "ga"); - if (typeof window.mxGoogleAnalytics === "undefined") { - ga("create", this.uaTrackCode, "auto"); + if (this._gaScriptAvailable()) { + if (typeof window.mxGoogleAnalytics === "undefined") { + ga("create", this.uaTrackCode, "auto"); + } + + ga("set", "checkProtocolTask", null); + } else { + logger.warn("Google Analytics script could not be loaded, please check if you dont have an ads blocker extension or tracking feature disabled."); } + }, - ga("set", "checkProtocolTask", null); + _gaScriptAvailable: function () { + return typeof ga !== "undefined"; }, }); diff --git a/src/package.xml b/src/package.xml index 135bb6a..4bda98b 100644 --- a/src/package.xml +++ b/src/package.xml @@ -1,6 +1,6 @@ - + @@ -13,4 +13,4 @@ - \ No newline at end of file + diff --git a/test/widgets/GoogleAnalytics.mpk b/test/widgets/GoogleAnalytics.mpk index 744e856443d7804e28e5950e2592d89f756fdb66..783a8c8a344a2ed2b9a07a8fe9a1e9e036cc3dc2 100644 GIT binary patch delta 5329 zcmZ9QbzD?k^T3y0SQ?g+mXK~~knR#mQMz*hX}EOvf`T+GsDy%aDlFa7pnwPx($Z2t z#OM7zukZcm#C$*J+&gp5+?i>4iI$LqhOe!LhE56sfk7Z~wXugO`0N0c=Genj+4^6H zAP@)x4FrPRv~K2>j^?)3+&<1u#i=rCoxFq*yO&S~ZxU-6`7v&e*RL=LAi0+O+n8__ z`;zTnyLe^q=bu4qL^UIKTQhwf8X>uOqs-)0D+b?E1s;%8AWK#xC&`5ajG(2Ht9rs8 z-Gxh1U1R1Rv-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I9oNA2e%fo`e{;^?Kvd@ykQ4OJCH(RQN_c=4TNra~q`r#`1swq4v48xf_CJfb B3v2)Y From 522033ec218beb0e434b6856f54cc90b67c96b2a Mon Sep 17 00:00:00 2001 From: Diego Antonelli <45102481+diego-antonelli@users.noreply.github.com> Date: Fri, 18 Jun 2021 10:08:03 +0200 Subject: [PATCH 2/2] Update CHANGELOG.md Co-authored-by: Chak Shun Yu --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index c0e6dc6..895c127 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,7 +6,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), ## 3.3.6 - 2021-06-18 ### Changed -- Fixed an issue while having ads blocker or tracking option disable in the browser. +- Fixed the widget throwing errors and crashing the page while having ads blocker or tracking option disabled in the browser. ## Older releases See [marketplace](https://marketplace.mendix.com/link/component/105) for previous releases.