Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TILES-7179 Removed Google Analytics, fixed CI, fixed no project test case #576

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
2 changes: 0 additions & 2 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
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
Loading