Skip to content

Commit 3840dd6

Browse files
committed
feat(App): Remove Google Analytics
1 parent d0968d1 commit 3840dd6

File tree

3 files changed

+29
-42
lines changed

3 files changed

+29
-42
lines changed

src/lib/analytics.js

Lines changed: 26 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -1,53 +1,44 @@
11
import { app } from '@electron/remote';
2-
import querystring from 'querystring';
2+
// import querystring from 'querystring';
33

4-
import { STATS_API } from '../config';
5-
import { isDevMode, GA_ID } from '../environment';
4+
// import { STATS_API } from '../config';
5+
// import { isDevMode, GA_ID } from '../environment';
66

77
const debug = require('debug')('Franz:Analytics');
88

99
/* eslint-disable */
10-
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
11-
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
12-
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
13-
})(window,document,'script','https://www.google-analytics.com/analytics.js','ga');
10+
const _paq = window._paq = window._paq || [];
11+
12+
_paq.push(['setCustomDimension', 1, app.getVersion()]);
13+
_paq.push(['trackPageView']);
14+
_paq.push(['enableLinkTracking']);
15+
16+
(function() {
17+
const u="https:////analytics.franzinfra.com/";
18+
_paq.push(['setTrackerUrl', u+'matomo.php']);
19+
_paq.push(['setSiteId', '1']);
20+
const d=document, g=d.createElement('script'), s=d.getElementsByTagName('script')[0];
21+
g.type='text/javascript'; g.async=true; g.src=u+'matomo.js'; s.parentNode.insertBefore(g,s);
22+
})();
1423
/* eslint-enable */
1524

16-
const GA_LOCAL_STORAGE_KEY = 'gaUid';
25+
// const GA_LOCAL_STORAGE_KEY = 'gaUid';
1726

18-
ga('create', GA_ID, {
19-
storage: 'none',
20-
clientId: localStorage.getItem(GA_LOCAL_STORAGE_KEY),
21-
});
27+
// ga((tracker) => {
28+
// localStorage.setItem(GA_LOCAL_STORAGE_KEY, tracker.get('clientId'));
29+
// });
30+
// ga('set', 'checkProtocolTask', null);
31+
// ga('set', 'version', app.getVersion());
2232

23-
ga((tracker) => {
24-
localStorage.setItem(GA_LOCAL_STORAGE_KEY, tracker.get('clientId'));
25-
});
26-
ga('set', 'checkProtocolTask', null);
27-
ga('set', 'version', app.getVersion());
28-
ga('send', 'App');
33+
// ga('send', 'App');
2934

3035
export function gaPage(page) {
31-
ga('send', 'pageview', page);
36+
_paq.push(['trackPageView']);
3237
debug('GA track page', page);
3338
}
3439

3540
export function gaEvent(category, action, label) {
36-
ga('send', 'event', category, action, label);
41+
// ga('send', 'event', category, action, label);
42+
_paq.push(['trackEvent', category, action, label]);
3743
debug('GA track event', category, action, label);
3844
}
39-
40-
export function statsEvent(key, value) {
41-
const params = {
42-
key,
43-
value: value || key,
44-
platform: process.platform,
45-
version: app.getVersion(),
46-
};
47-
48-
debug('Send Franz stats event', params);
49-
50-
if (!isDevMode) {
51-
window.fetch(`${STATS_API}/event/?${querystring.stringify(params)}`);
52-
}
53-
}

src/stores/AppStore.js

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ import Request from './lib/Request';
1919
import { CHECK_INTERVAL, DEFAULT_APP_SETTINGS } from '../config';
2020
import { isMac } from '../environment';
2121
import locales from '../i18n/translations';
22-
import { gaEvent, gaPage, statsEvent } from '../lib/analytics';
22+
import { gaEvent, gaPage } from '../lib/analytics';
2323
import { getLocale } from '../helpers/i18n-helpers';
2424

2525
import { getServiceIdsFromPartitions, removeServicePartitionDirectory } from '../helpers/service-helpers.js';
@@ -227,8 +227,6 @@ export default class AppStore extends Store {
227227
window.location.reload();
228228
}
229229
}, ms('2s'));
230-
231-
statsEvent('resumed-app');
232230
}
233231
});
234232

@@ -246,8 +244,6 @@ export default class AppStore extends Store {
246244
localStorage.setItem(CATALINA_NOTIFICATION_HACK_KEY, true);
247245
}
248246
}
249-
250-
statsEvent('app-start');
251247
}
252248

253249
@computed get cacheSize() {

src/stores/ServicesStore.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ import Store from './lib/Store';
1414
import Request from './lib/Request';
1515
import CachedRequest from './lib/CachedRequest';
1616
import { matchRoute } from '../helpers/routing-helpers';
17-
import { gaEvent, statsEvent } from '../lib/analytics';
17+
import { gaEvent } from '../lib/analytics';
1818
import { workspaceStore } from '../features/workspaces';
1919
import { serviceLimitStore } from '../features/serviceLimit';
2020
import { RESTRICTION_TYPES } from '../models/Service';
@@ -407,7 +407,7 @@ export default class ServicesStore extends Store {
407407
this.actions.todos.toggleTodosFeatureVisibility();
408408
}
409409

410-
statsEvent('activate-service', service.recipe.id);
410+
gaEvent('Service', 'activate-service', service.recipe.id);
411411

412412
this._focusActiveService();
413413
}

0 commit comments

Comments
 (0)