mirror of
https://github.com/lrsjng/h5ai.git
synced 2025-05-31 23:38:20 -04:00
Update piwik-analytics code.
This commit is contained in:
parent
b7f25c45f2
commit
f0bee58869
2 changed files with 15 additions and 5 deletions
|
@ -17,17 +17,27 @@ const init = () => {
|
||||||
// reference: http://piwik.org/docs/javascript-tracking/
|
// reference: http://piwik.org/docs/javascript-tracking/
|
||||||
|
|
||||||
const pkBaseURL = (win.location.protocol === 'https:' ? 'https://' : 'http://') + settings.baseURL + '/';
|
const pkBaseURL = (win.location.protocol === 'https:' ? 'https://' : 'http://') + settings.baseURL + '/';
|
||||||
|
const queue = [];
|
||||||
let piwikTracker = null;
|
let piwikTracker = null;
|
||||||
|
|
||||||
dom('<script></script>').attr('src', pkBaseURL + 'piwik.js').appTo('body');
|
dom('<script></script>').attr('src', pkBaseURL + 'piwik.js').appTo('body');
|
||||||
onLoad(() => {
|
onLoad(() => {
|
||||||
piwikTracker = win.Piwik.getTracker(pkBaseURL + 'piwik.php', settings.idSite);
|
piwikTracker = win.Piwik && win.Piwik.getTracker(pkBaseURL + 'piwik.php', settings.idSite);
|
||||||
piwikTracker.enableLinkTracking();
|
if (piwikTracker) {
|
||||||
|
piwikTracker.enableLinkTracking();
|
||||||
|
while (queue.length) {
|
||||||
|
piwikTracker.trackPageView(queue.shift());
|
||||||
|
}
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
event.sub('location.changed', item => {
|
event.sub('location.changed', item => {
|
||||||
const title = item.getCrumb().map(i => i.label).join(' > ');
|
const title = item.getCrumb().map(i => i.label).join(' > ');
|
||||||
piwikTracker.trackPageView(title);
|
if (piwikTracker) {
|
||||||
|
piwikTracker.trackPageView(title);
|
||||||
|
} else {
|
||||||
|
queue.push(title);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -40,8 +40,8 @@ const addTest = (label, info, passed, result) => {
|
||||||
const $test = dom(testTpl).appTo('#tests');
|
const $test = dom(testTpl).appTo('#tests');
|
||||||
$test.find('.label').text(label);
|
$test.find('.label').text(label);
|
||||||
$test.find('.result')
|
$test.find('.result')
|
||||||
.addCls(passed ? 'passed' : 'failed')
|
.addCls(passed ? 'passed' : 'failed')
|
||||||
.text(result ? result : passed ? 'yes' : 'no');
|
.text(result ? result : passed ? 'yes' : 'no');
|
||||||
$test.find('.info').html(info);
|
$test.find('.info').html(info);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue