-
Notifications
You must be signed in to change notification settings - Fork 30
/
Copy pathmatomo.js
43 lines (35 loc) · 972 Bytes
/
matomo.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
/* eslint-disable func-names */
import { hit, noopFunc } from '../helpers';
/**
* @redirect matomo
*
* @description
* Mocks the piwik.js file of Matomo (formerly Piwik).
*
* ### Examples
*
* ```adblock
* ||example.org/piwik.js$script,redirect=matomo
* ```
*
* @added v1.5.0.
*/
export function Matomo(source) {
const Tracker = function () {};
Tracker.prototype.setDoNotTrack = noopFunc;
Tracker.prototype.setDomains = noopFunc;
Tracker.prototype.setCustomDimension = noopFunc;
Tracker.prototype.trackPageView = noopFunc;
const AsyncTracker = function () {};
AsyncTracker.prototype.addListener = noopFunc;
const matomoWrapper = {
getTracker: Tracker,
getAsyncTracker: AsyncTracker,
};
window.Piwik = matomoWrapper;
hit(source);
}
export const MatomoNames = ['matomo'];
// eslint-disable-next-line prefer-destructuring
Matomo.primaryName = MatomoNames[0];
Matomo.injections = [hit, noopFunc];