Skip to content

Commit b82380c

Browse files
FarfurixVladimir-Ayrikh
andauthored
TILES-7179 Removed Google Analytics, fixed CI, fixed no project test 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 <v.ayrikh@2gis.ru>
1 parent 2c7dbbb commit b82380c

File tree

8 files changed

+42
-112
lines changed

8 files changed

+42
-112
lines changed

.github/workflows/test.yml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,20 @@ jobs:
99
- name: Checkout 🛎️
1010
uses: actions/checkout@v2
1111

12+
- name: Set env var to fix the PhantomJS error
13+
run: |
14+
echo "OPENSSL_CONF=/tmp/openssl.cnf" >> "$GITHUB_ENV"
15+
1216
- name: Setup node 🔧
1317
uses: actions/setup-node@v2
1418
with:
1519
node-version: 12
1620

21+
- name: Downgrade the Python version to fix the install errors
22+
uses: actions/setup-python@v5
23+
with:
24+
python-version: '3.10'
25+
1726
- name: Test ✔️
1827
run: |
1928
npm ci

config.main.json

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,6 @@
2626
"projectLeaveMaxZoom": 16,
2727
"flampUrl": "http://flamp.ru/r/",
2828
"flampGoogleAnalytics": "utm_source=api2gis&utm_medium=api&utm_campaign=geoclicker",
29-
"gaCode": "UA-38243181-2",
30-
"gaName": "mapsapi2gis",
3129

3230
"protocol": "http:",
3331

@@ -58,7 +56,5 @@
5856

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

61-
"googleAnalytics": "https://www.google-analytics.com/analytics.js",
62-
6359
"loadProjectListTimeout": 5000
6460
}

src/DGCore/src/DGCore.js

Lines changed: 0 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -25,34 +25,6 @@ window.__dgApi__ = window.__dgApi__ || {};
2525
DG.version = window.__dgApi__.version;
2626
DG.Icon.Default.imagePath = '../img/vendors/leaflet';
2727

28-
DG.Map.addInitHook((function() {
29-
var inited = false;
30-
31-
// Analytics inited once
32-
return function() {
33-
if (!inited) {
34-
/*eslint-disable */
35-
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
36-
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
37-
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
38-
})(window,document,'script',DG.config.googleAnalytics,'ga');
39-
/*eslint-enable */
40-
41-
inited = true;
42-
}
43-
44-
/*eslint-disable */
45-
ga('create', DG.config.gaCode, {
46-
storage: 'none', // don't store and use cookies thanks GDPR
47-
name: DG.config.gaName,
48-
sampleRate: 50
49-
});
50-
ga(DG.config.gaName + '.set', 'anonymizeIp', true);
51-
ga(DG.config.gaName + '.send', 'pageview');
52-
/*eslint-enable */
53-
};
54-
})());
55-
5628
// Improve IHandler
5729
DG.Map.include({
5830
addHandler: function(name, HandlerClass) {

src/DGCustomization/src/DGCustomization.js

Lines changed: 0 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -104,34 +104,9 @@ L.Canvas.include({
104104
// TODO: remove after successful research
105105
if (DG.Path) {
106106
var pathInitialize = DG.Path.prototype.onAdd;
107-
var loggedGeometryTypes = {};
108107

109108
DG.Path.include({
110109
onAdd: function(map) {
111-
var type = 'Unknown';
112-
113-
if (DG.Rectangle && this instanceof DG.Rectangle) {
114-
type = 'Rectangle';
115-
} else if (DG.Circle && this instanceof DG.Circle) {
116-
type = 'Circle';
117-
} else if (DG.CircleMarker && this instanceof DG.CircleMarker) {
118-
type = 'CircleMarker'
119-
} else if (DG.Polygon && this instanceof DG.Polygon) {
120-
type = 'Polygon';
121-
} else if (DG.Polyline && this instanceof DG.Polyline) {
122-
type = 'Polyline';
123-
}
124-
125-
// Don't send event twice for same type
126-
if (!loggedGeometryTypes[type]) {
127-
loggedGeometryTypes[type] = true;
128-
129-
if (typeof ga !== undefined) {
130-
// eslint-disable-next-line no-undef
131-
ga(DG.config.gaName + '.send', 'event', 'Geometry', 'Use', type);
132-
}
133-
}
134-
135110
return pathInitialize.call(this, map);
136111
},
137112
});

src/DGGeoclicker/src/Controller.js

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -48,14 +48,6 @@ DG.Geoclicker.Controller = DG.Class.extend({
4848
var self = this,
4949
args = Array.prototype.slice.call(arguments, 0);
5050

51-
52-
// Monitor geoclicker user usage statistics
53-
// TODO: remove after successful research
54-
if (typeof ga !== undefined) {
55-
// eslint-disable-next-line no-undef
56-
ga(DG.config.gaName + '.send', 'event', 'Geoclicker', 'Use');
57-
}
58-
5951
function beforeRequest() {
6052
var loader = self._view.initLoader();
6153
self._view._popup.clear();

src/DGGeoclicker/src/DGGeoclicker.js

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,6 @@ DG.Geoclicker = DG.Handler.extend({
1515
addHooks: function() {
1616
this._toggleEvents(true);
1717

18-
// Monitor geoclicker usage statistics
19-
// TODO: remove after successful research
20-
if (typeof ga !== undefined) {
21-
// eslint-disable-next-line no-undef
22-
ga(DG.config.gaName + '.send', 'event', 'Geoclicker', 'Enable');
23-
}
24-
2518
this._map
2619
.on('rulerstart', this._pause, this)
2720
.on('rulerend', this._unpause, this);

src/DGPopup/src/DGPopup.js

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -75,13 +75,6 @@ require('../../../vendors/baron');
7575
}, this);
7676
originalOnAdd.call(this, map);
7777
this._animateOpening();
78-
79-
// Monitor popups usage
80-
// TODO: remove after successful research
81-
if (typeof ga !== undefined) {
82-
// eslint-disable-next-line no-undef
83-
ga(DG.config.gaName + '.send', 'event', 'Popup', 'Use');
84-
}
8578
},
8679

8780
onRemove: function(map) { // (Map)

src/DGTrafficControl/test/TrafficControlSpec.js

Lines changed: 33 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ describe('DG.TrafficControl', function() {
55

66
centerNsk = [55.017493, 82.819576],
77
centerSpb = [59.937706, 30.13249],
8-
centerWithoutProject = [55.363990665081126, 77.81307220458986];
8+
centerWithoutProject = [77.81307220458986, 55.363990665081126]; // севернее Новой земли
99

1010
after(function () {
1111
controlClass = controlParentActiveClass = controlParentHiddenClass = centerNsk = null;
@@ -25,61 +25,61 @@ describe('DG.TrafficControl', function() {
2525
center: centerSpb,
2626
zoom: 15
2727
});
28-
28+
2929
control = mapContainer.getElementsByClassName(controlClass);
3030
trafficControl = DG.control.traffic();
31-
31+
3232
document.body.appendChild(mapContainer);
3333
map.addControl(trafficControl);
3434
});
35-
35+
3636
after(function () {
3737
map.remove();
3838
document.body.removeChild(mapContainer);
3939
mapContainer = map = control = trafficControl = controlParent = null;
4040
});
41-
41+
4242
describe('module init', function () {
4343
it('traffic control show', function () {
4444
expect(control.length).to.be(1);
45-
45+
4646
control = control[0];
4747
controlParent = control.parentElement;
4848
});
49-
49+
5050
it('remove hide class from control parent element', function () {
5151
expect(controlParent.className).not.contain(controlParentHiddenClass);
5252
});
5353
});
54-
54+
5555
describe('turn on control', function () {
5656
before(function () {
5757
happen.click(controlParent);
5858
});
59-
59+
6060
it('add active class to control parent element', function () {
6161
expect(controlParent.className).to.contain(controlParentActiveClass);
6262
});
63-
63+
6464
it('add traffic layer to map', function () {
6565
expect(map.hasLayer(trafficControl._trafficLayer)).to.be(true);
6666
});
6767
});
68-
68+
6969
describe('turn off control', function () {
7070
before(function () {
7171
happen.click(controlParent);
7272
});
73-
73+
7474
it('remove active class from control parent element', function () {
7575
expect(controlParent.className).not.contain(controlParentActiveClass);
7676
});
77-
77+
7878
it('remove traffic layer from map', function () {
7979
expect(map.hasLayer(trafficControl._trafficLayer)).to.be(false);
8080
});
8181
});
82-
82+
8383
describe('traffic point request', function () {
8484
var xhr, center, zoom, requests;
8585

@@ -88,27 +88,27 @@ describe('DG.TrafficControl', function() {
8888
center = map.getCenter();
8989
xhr = sinon.useFakeXMLHttpRequest();
9090
requests = [];
91-
91+
9292
xhr.onCreate = function (xhr) {
9393
requests.push(xhr);
9494
};
95-
95+
9696
happen.click(controlParent);
97-
97+
9898
});
9999

100100
after(function () {
101101
xhr.restore();
102102
map.setView(center, zoom);
103103
happen.click(controlParent);
104104
});
105-
105+
106106
it('traffic points request called', function () {
107107
var urlRE = new RegExp('http://traffic\\d+.maps.2gis.com/\\w+/meta/score/0/');
108108
expect(urlRE.test(requests[0].url)).to.be(true);
109109
});
110110
});
111-
111+
112112
describe('traffic point timer request', function () {
113113
var xhr, center, zoom, requests, clock;
114114

@@ -118,13 +118,13 @@ describe('DG.TrafficControl', function() {
118118
xhr = sinon.useFakeXMLHttpRequest();
119119
clock = sinon.useFakeTimers();
120120
requests = [];
121-
121+
122122
xhr.onCreate = function (xhr) {
123123
requests.push(xhr);
124124
};
125-
125+
126126
happen.click(controlParent);
127-
127+
128128
});
129129

130130
after(function () {
@@ -133,7 +133,7 @@ describe('DG.TrafficControl', function() {
133133
map.setView(center, zoom);
134134
happen.click(controlParent);
135135
});
136-
136+
137137
it('traffic points update request called', function () {
138138
var urlRE = new RegExp('http://traffic\\d+.maps.2gis.com/\\w+/meta/speed/time/');
139139
clock.tick(DG.config.trafficLayerUpdateInterval + 1);
@@ -155,16 +155,16 @@ describe('DG.TrafficControl', function() {
155155
center: centerSpb,
156156
zoom: 15
157157
});
158-
158+
159159
trafficControl = DG.control.traffic();
160-
160+
161161
document.body.appendChild(mapContainer);
162162
map.addControl(trafficControl);
163163

164164
control = mapContainer.getElementsByClassName(controlClass)[0];
165165
controlParent = control.parentElement;
166166
});
167-
167+
168168
afterEach(function () {
169169
map.remove();
170170
document.body.removeChild(mapContainer);
@@ -234,7 +234,7 @@ describe('DG.TrafficControl', function() {
234234
expect(map.hasLayer(trafficControl._trafficLayer)).to.be(true);
235235
done();
236236
};
237-
237+
238238
map.setView(centerWithoutProject, 15, {animate: false});
239239
map.on('projectchange', onProjectChange);
240240
map.setView(centerSpb, 15, {animate: false});
@@ -246,28 +246,28 @@ describe('DG.TrafficControl', function() {
246246
});
247247
});
248248

249-
describe('traffic test on project change', function () {
249+
describe('traffic test on project change', function () {
250250
describe('with traffic off', function () {
251251
// traffic layer is off after map initialization
252-
252+
253253
it('control parent element haven\'t active class', function () {
254254
map.setView(centerNsk, 15, {animate: false});
255255
expect(controlParent.className).not.contain(controlParentActiveClass);
256256
});
257257
});
258-
259-
describe('with traffic on', function () {
258+
259+
describe('with traffic on', function () {
260260
beforeEach(function () {
261261
// traffic layer is on, click on traffic control
262262
happen.click(controlParent);
263263
control.innerHTML = -50;
264264
});
265-
265+
266266
it('control parent element have active class', function () {
267267
map.setView(centerNsk, 15, {animate: false});
268268
expect(controlParent.className).to.contain(controlParentActiveClass);
269269
});
270-
270+
271271
it('update traffic balls in control', function () {
272272
expect(control.innerHTML).not.be(-50);
273273
});

0 commit comments

Comments
 (0)