Skip to content

Commit

Permalink
TILES-7179 Removed Google Analytics, fixed CI, fixed no project test …
Browse files Browse the repository at this point in the history
…case (#576)

* TILES-7179 Removed Google Analytics

* Fixed CI, skipped failed test

* Unskip fixed test

* Removed the unused config property

---------

Co-authored-by: Vladimir-Ayrikh <[email protected]>
  • Loading branch information
Farfurix and Vladimir-Ayrikh authored Jan 27, 2025
1 parent 2c7dbbb commit b82380c
Show file tree
Hide file tree
Showing 8 changed files with 42 additions and 112 deletions.
9 changes: 9 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 0 additions & 4 deletions config.main.json
Original file line number Diff line number Diff line change
Expand Up @@ -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:",

Expand Down Expand Up @@ -58,7 +56,5 @@

"webApiServer": "//catalog.api.2gis.ru",

"googleAnalytics": "https://www.google-analytics.com/analytics.js",

"loadProjectListTimeout": 5000
}
28 changes: 0 additions & 28 deletions src/DGCore/src/DGCore.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
25 changes: 0 additions & 25 deletions src/DGCustomization/src/DGCustomization.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
},
});
Expand Down
8 changes: 0 additions & 8 deletions src/DGGeoclicker/src/Controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
7 changes: 0 additions & 7 deletions src/DGGeoclicker/src/DGGeoclicker.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
7 changes: 0 additions & 7 deletions src/DGPopup/src/DGPopup.js
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
66 changes: 33 additions & 33 deletions src/DGTrafficControl/test/TrafficControlSpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;

Expand All @@ -88,27 +88,27 @@ describe('DG.TrafficControl', function() {
center = map.getCenter();
xhr = sinon.useFakeXMLHttpRequest();
requests = [];

xhr.onCreate = function (xhr) {
requests.push(xhr);
};

happen.click(controlParent);

});

after(function () {
xhr.restore();
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;

Expand All @@ -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 () {
Expand All @@ -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);
Expand All @@ -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);
Expand Down Expand Up @@ -234,7 +234,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});
Expand All @@ -246,28 +246,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);
});
Expand Down

0 comments on commit b82380c

Please sign in to comment.