|
1 | 1 | import { app } from '@electron/remote'; |
2 | | -import querystring from 'querystring'; |
| 2 | +// import querystring from 'querystring'; |
3 | 3 |
|
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'; |
6 | 6 |
|
7 | 7 | const debug = require('debug')('Franz:Analytics'); |
8 | 8 |
|
9 | 9 | /* 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 | +})(); |
14 | 23 | /* eslint-enable */ |
15 | 24 |
|
16 | | -const GA_LOCAL_STORAGE_KEY = 'gaUid'; |
| 25 | +// const GA_LOCAL_STORAGE_KEY = 'gaUid'; |
17 | 26 |
|
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()); |
22 | 32 |
|
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'); |
29 | 34 |
|
30 | 35 | export function gaPage(page) { |
31 | | - ga('send', 'pageview', page); |
| 36 | + _paq.push(['trackPageView']); |
32 | 37 | debug('GA track page', page); |
33 | 38 | } |
34 | 39 |
|
35 | 40 | 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]); |
37 | 43 | debug('GA track event', category, action, label); |
38 | 44 | } |
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 | | -} |
0 commit comments