From 6c3f0f2de54012e0677d368b879a0dea448a2e0a Mon Sep 17 00:00:00 2001 From: Vladimir-Ayrikh Date: Tue, 21 Jan 2025 18:24:58 +0300 Subject: [PATCH 1/4] TILES-7179 Removed Google Analytics --- config.main.json | 2 -- src/DGCore/src/DGCore.js | 28 ---------------------- src/DGCustomization/src/DGCustomization.js | 25 ------------------- src/DGGeoclicker/src/Controller.js | 8 ------- src/DGGeoclicker/src/DGGeoclicker.js | 7 ------ src/DGPopup/src/DGPopup.js | 7 ------ 6 files changed, 77 deletions(-) diff --git a/config.main.json b/config.main.json index 0db72c91c..44597ef74 100644 --- a/config.main.json +++ b/config.main.json @@ -26,8 +26,6 @@ "projectLeaveMaxZoom": 16, "flampUrl": "http://flamp.ru/r/", "flampGoogleAnalytics": "utm_source=api2gis&utm_medium=api&utm_campaign=geoclicker", - "gaCode": "UA-38243181-2", - "gaName": "mapsapi2gis", "protocol": "http:", diff --git a/src/DGCore/src/DGCore.js b/src/DGCore/src/DGCore.js index 3660ca281..f94858824 100644 --- a/src/DGCore/src/DGCore.js +++ b/src/DGCore/src/DGCore.js @@ -25,34 +25,6 @@ window.__dgApi__ = window.__dgApi__ || {}; DG.version = window.__dgApi__.version; DG.Icon.Default.imagePath = '../img/vendors/leaflet'; -DG.Map.addInitHook((function() { - var inited = false; - - // Analytics inited once - return function() { - if (!inited) { - /*eslint-disable */ - (function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){ - (i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o), - m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m) - })(window,document,'script',DG.config.googleAnalytics,'ga'); - /*eslint-enable */ - - inited = true; - } - - /*eslint-disable */ - ga('create', DG.config.gaCode, { - storage: 'none', // don't store and use cookies thanks GDPR - name: DG.config.gaName, - sampleRate: 50 - }); - ga(DG.config.gaName + '.set', 'anonymizeIp', true); - ga(DG.config.gaName + '.send', 'pageview'); - /*eslint-enable */ - }; -})()); - // Improve IHandler DG.Map.include({ addHandler: function(name, HandlerClass) { diff --git a/src/DGCustomization/src/DGCustomization.js b/src/DGCustomization/src/DGCustomization.js index 99b3d9930..7a6158966 100644 --- a/src/DGCustomization/src/DGCustomization.js +++ b/src/DGCustomization/src/DGCustomization.js @@ -104,34 +104,9 @@ L.Canvas.include({ // TODO: remove after successful research if (DG.Path) { var pathInitialize = DG.Path.prototype.onAdd; - var loggedGeometryTypes = {}; DG.Path.include({ onAdd: function(map) { - var type = 'Unknown'; - - if (DG.Rectangle && this instanceof DG.Rectangle) { - type = 'Rectangle'; - } else if (DG.Circle && this instanceof DG.Circle) { - type = 'Circle'; - } else if (DG.CircleMarker && this instanceof DG.CircleMarker) { - type = 'CircleMarker' - } else if (DG.Polygon && this instanceof DG.Polygon) { - type = 'Polygon'; - } else if (DG.Polyline && this instanceof DG.Polyline) { - type = 'Polyline'; - } - - // Don't send event twice for same type - if (!loggedGeometryTypes[type]) { - loggedGeometryTypes[type] = true; - - if (typeof ga !== undefined) { - // eslint-disable-next-line no-undef - ga(DG.config.gaName + '.send', 'event', 'Geometry', 'Use', type); - } - } - return pathInitialize.call(this, map); }, }); diff --git a/src/DGGeoclicker/src/Controller.js b/src/DGGeoclicker/src/Controller.js index 9eef89c03..4ca406ee3 100644 --- a/src/DGGeoclicker/src/Controller.js +++ b/src/DGGeoclicker/src/Controller.js @@ -48,14 +48,6 @@ DG.Geoclicker.Controller = DG.Class.extend({ var self = this, args = Array.prototype.slice.call(arguments, 0); - - // Monitor geoclicker user usage statistics - // TODO: remove after successful research - if (typeof ga !== undefined) { - // eslint-disable-next-line no-undef - ga(DG.config.gaName + '.send', 'event', 'Geoclicker', 'Use'); - } - function beforeRequest() { var loader = self._view.initLoader(); self._view._popup.clear(); diff --git a/src/DGGeoclicker/src/DGGeoclicker.js b/src/DGGeoclicker/src/DGGeoclicker.js index 73fc49a65..b94398b7a 100644 --- a/src/DGGeoclicker/src/DGGeoclicker.js +++ b/src/DGGeoclicker/src/DGGeoclicker.js @@ -15,13 +15,6 @@ DG.Geoclicker = DG.Handler.extend({ addHooks: function() { this._toggleEvents(true); - // Monitor geoclicker usage statistics - // TODO: remove after successful research - if (typeof ga !== undefined) { - // eslint-disable-next-line no-undef - ga(DG.config.gaName + '.send', 'event', 'Geoclicker', 'Enable'); - } - this._map .on('rulerstart', this._pause, this) .on('rulerend', this._unpause, this); diff --git a/src/DGPopup/src/DGPopup.js b/src/DGPopup/src/DGPopup.js index c9debbdfe..c802fc528 100644 --- a/src/DGPopup/src/DGPopup.js +++ b/src/DGPopup/src/DGPopup.js @@ -75,13 +75,6 @@ require('../../../vendors/baron'); }, this); originalOnAdd.call(this, map); this._animateOpening(); - - // Monitor popups usage - // TODO: remove after successful research - if (typeof ga !== undefined) { - // eslint-disable-next-line no-undef - ga(DG.config.gaName + '.send', 'event', 'Popup', 'Use'); - } }, onRemove: function(map) { // (Map) From 95e5d2c6906f6184824dd012d3fed7fd8890ea3b Mon Sep 17 00:00:00 2001 From: Vladimir-Ayrikh Date: Thu, 23 Jan 2025 17:52:18 +0300 Subject: [PATCH 2/4] Fixed CI, skipped failed test --- .github/workflows/test.yml | 9 +++ .../test/TrafficControlSpec.js | 67 ++++++++++--------- 2 files changed, 43 insertions(+), 33 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index adfcec84e..1af7ebb82 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -9,11 +9,20 @@ jobs: - name: Checkout 🛎️ uses: actions/checkout@v2 + - name: Set env var to fix the PhantomJS error + run: | + echo "OPENSSL_CONF=/tmp/openssl.cnf" >> "$GITHUB_ENV" + - name: Setup node 🔧 uses: actions/setup-node@v2 with: node-version: 12 + - name: Downgrade the Python version to fix the install errors + uses: actions/setup-python@v5 + with: + python-version: '3.10' + - name: Test ✔️ run: | npm ci diff --git a/src/DGTrafficControl/test/TrafficControlSpec.js b/src/DGTrafficControl/test/TrafficControlSpec.js index 4392f0f86..57184b80a 100644 --- a/src/DGTrafficControl/test/TrafficControlSpec.js +++ b/src/DGTrafficControl/test/TrafficControlSpec.js @@ -25,61 +25,61 @@ describe('DG.TrafficControl', function() { center: centerSpb, zoom: 15 }); - + control = mapContainer.getElementsByClassName(controlClass); trafficControl = DG.control.traffic(); - + document.body.appendChild(mapContainer); map.addControl(trafficControl); }); - + after(function () { map.remove(); document.body.removeChild(mapContainer); mapContainer = map = control = trafficControl = controlParent = null; }); - + describe('module init', function () { it('traffic control show', function () { expect(control.length).to.be(1); - + control = control[0]; controlParent = control.parentElement; }); - + it('remove hide class from control parent element', function () { expect(controlParent.className).not.contain(controlParentHiddenClass); }); }); - + describe('turn on control', function () { before(function () { happen.click(controlParent); }); - + it('add active class to control parent element', function () { expect(controlParent.className).to.contain(controlParentActiveClass); }); - + it('add traffic layer to map', function () { expect(map.hasLayer(trafficControl._trafficLayer)).to.be(true); }); }); - + describe('turn off control', function () { before(function () { happen.click(controlParent); }); - + it('remove active class from control parent element', function () { expect(controlParent.className).not.contain(controlParentActiveClass); }); - + it('remove traffic layer from map', function () { expect(map.hasLayer(trafficControl._trafficLayer)).to.be(false); }); }); - + describe('traffic point request', function () { var xhr, center, zoom, requests; @@ -88,13 +88,13 @@ describe('DG.TrafficControl', function() { center = map.getCenter(); xhr = sinon.useFakeXMLHttpRequest(); requests = []; - + xhr.onCreate = function (xhr) { requests.push(xhr); }; - + happen.click(controlParent); - + }); after(function () { @@ -102,13 +102,13 @@ describe('DG.TrafficControl', function() { map.setView(center, zoom); happen.click(controlParent); }); - + it('traffic points request called', function () { var urlRE = new RegExp('http://traffic\\d+.maps.2gis.com/\\w+/meta/score/0/'); expect(urlRE.test(requests[0].url)).to.be(true); }); }); - + describe('traffic point timer request', function () { var xhr, center, zoom, requests, clock; @@ -118,13 +118,13 @@ describe('DG.TrafficControl', function() { xhr = sinon.useFakeXMLHttpRequest(); clock = sinon.useFakeTimers(); requests = []; - + xhr.onCreate = function (xhr) { requests.push(xhr); }; - + happen.click(controlParent); - + }); after(function () { @@ -133,7 +133,7 @@ describe('DG.TrafficControl', function() { map.setView(center, zoom); happen.click(controlParent); }); - + it('traffic points update request called', function () { var urlRE = new RegExp('http://traffic\\d+.maps.2gis.com/\\w+/meta/speed/time/'); clock.tick(DG.config.trafficLayerUpdateInterval + 1); @@ -155,16 +155,16 @@ describe('DG.TrafficControl', function() { center: centerSpb, zoom: 15 }); - + trafficControl = DG.control.traffic(); - + document.body.appendChild(mapContainer); map.addControl(trafficControl); control = mapContainer.getElementsByClassName(controlClass)[0]; controlParent = control.parentElement; }); - + afterEach(function () { map.remove(); document.body.removeChild(mapContainer); @@ -179,7 +179,8 @@ describe('DG.TrafficControl', function() { expect(controlParent.className).not.contain(controlParentHiddenClass); }); - it('add hide class to control parent element', function (done) { + // TODO: unskip after fixing TILES-7238 + it.skip('add hide class to control parent element', function (done) { var onProjectLeave = function (ev) { map.off('projectleave', onProjectLeave); expect(controlParent.className).to.contain(controlParentHiddenClass); @@ -234,7 +235,7 @@ describe('DG.TrafficControl', function() { expect(map.hasLayer(trafficControl._trafficLayer)).to.be(true); done(); }; - + map.setView(centerWithoutProject, 15, {animate: false}); map.on('projectchange', onProjectChange); map.setView(centerSpb, 15, {animate: false}); @@ -246,28 +247,28 @@ describe('DG.TrafficControl', function() { }); }); - describe('traffic test on project change', function () { + describe('traffic test on project change', function () { describe('with traffic off', function () { // traffic layer is off after map initialization - + it('control parent element haven\'t active class', function () { map.setView(centerNsk, 15, {animate: false}); expect(controlParent.className).not.contain(controlParentActiveClass); }); }); - - describe('with traffic on', function () { + + describe('with traffic on', function () { beforeEach(function () { // traffic layer is on, click on traffic control happen.click(controlParent); control.innerHTML = -50; }); - + it('control parent element have active class', function () { map.setView(centerNsk, 15, {animate: false}); expect(controlParent.className).to.contain(controlParentActiveClass); }); - + it('update traffic balls in control', function () { expect(control.innerHTML).not.be(-50); }); From 38d6a21f6a3db29940bb06821ec36264e92aa74a Mon Sep 17 00:00:00 2001 From: Vladimir-Ayrikh Date: Fri, 24 Jan 2025 12:50:47 +0300 Subject: [PATCH 3/4] Unskip fixed test --- src/DGTrafficControl/test/TrafficControlSpec.js | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/DGTrafficControl/test/TrafficControlSpec.js b/src/DGTrafficControl/test/TrafficControlSpec.js index 57184b80a..87f5c91d3 100644 --- a/src/DGTrafficControl/test/TrafficControlSpec.js +++ b/src/DGTrafficControl/test/TrafficControlSpec.js @@ -5,7 +5,7 @@ describe('DG.TrafficControl', function() { centerNsk = [55.017493, 82.819576], centerSpb = [59.937706, 30.13249], - centerWithoutProject = [55.363990665081126, 77.81307220458986]; + centerWithoutProject = [77.81307220458986, 55.363990665081126]; // севернее Новой земли after(function () { controlClass = controlParentActiveClass = controlParentHiddenClass = centerNsk = null; @@ -179,8 +179,7 @@ describe('DG.TrafficControl', function() { expect(controlParent.className).not.contain(controlParentHiddenClass); }); - // TODO: unskip after fixing TILES-7238 - it.skip('add hide class to control parent element', function (done) { + it('add hide class to control parent element', function (done) { var onProjectLeave = function (ev) { map.off('projectleave', onProjectLeave); expect(controlParent.className).to.contain(controlParentHiddenClass); From 068e7b1cc46b7a887a2c2ef03c134603eacf6b9b Mon Sep 17 00:00:00 2001 From: Vladimir-Ayrikh Date: Mon, 27 Jan 2025 09:25:20 +0300 Subject: [PATCH 4/4] Removed the unused config property --- config.main.json | 2 -- 1 file changed, 2 deletions(-) diff --git a/config.main.json b/config.main.json index 44597ef74..7ad29c947 100644 --- a/config.main.json +++ b/config.main.json @@ -56,7 +56,5 @@ "webApiServer": "//catalog.api.2gis.ru", - "googleAnalytics": "https://www.google-analytics.com/analytics.js", - "loadProjectListTimeout": 5000 }