mirror of
https://github.com/bitwarden/browser
synced 2025-12-14 23:33:31 +00:00
private mode page with message
This commit is contained in:
@@ -1,60 +1,67 @@
|
||||
var gaTrackingId = chrome.extension.getBackgroundPage().bg_utilsService.analyticsId();
|
||||
var gaFunc = null;
|
||||
var isFirefox = chrome.extension.getBackgroundPage().bg_utilsService.isFirefox();
|
||||
|
||||
window.GoogleAnalyticsObject = 'ga';
|
||||
window[window.GoogleAnalyticsObject] = function (action, param1, param2, param3, param4) {
|
||||
if (!gaFunc) {
|
||||
(function () {
|
||||
var bgPage = chrome.extension.getBackgroundPage();
|
||||
if (!bgPage) {
|
||||
return;
|
||||
}
|
||||
|
||||
chrome.storage.local.get('disableGa', function (obj) {
|
||||
// Default for Firefox is disabled.
|
||||
if ((isFirefox && obj.disableGa === undefined) || obj.disableGa) {
|
||||
var gaTrackingId = bgPage.bg_utilsService.analyticsId();
|
||||
var gaFunc = null;
|
||||
var isFirefox = bgPage.bg_utilsService.isFirefox();
|
||||
|
||||
window.GoogleAnalyticsObject = 'ga';
|
||||
window[window.GoogleAnalyticsObject] = function (action, param1, param2, param3, param4) {
|
||||
if (!gaFunc) {
|
||||
return;
|
||||
}
|
||||
|
||||
gaFunc(action, param1, param2, param3, param4);
|
||||
});
|
||||
};
|
||||
chrome.storage.local.get('disableGa', function (obj) {
|
||||
// Default for Firefox is disabled.
|
||||
if ((isFirefox && obj.disableGa === undefined) || obj.disableGa) {
|
||||
return;
|
||||
}
|
||||
|
||||
function gaTrackEvent(options) {
|
||||
return '&t=event&ec=' + (options.eventCategory ? encodeURIComponent(options.eventCategory) : 'Event') +
|
||||
'&ea=' + encodeURIComponent(options.eventAction) +
|
||||
(options.eventLabel ? '&el=' + encodeURIComponent(options.eventLabel) : '') +
|
||||
(options.eventValue ? '&ev=' + encodeURIComponent(options.eventValue) : '') +
|
||||
(options.page ? '&dp=' + encodeURIComponent(options.page) : '');
|
||||
}
|
||||
|
||||
function gaTrackPageView(pagePath) {
|
||||
return '&t=pageview&dp=' + encodeURIComponent(pagePath);
|
||||
}
|
||||
|
||||
chrome.extension.getBackgroundPage().bg_appIdService.getAnonymousAppId(function (gaAnonAppId) {
|
||||
gaFunc = function (action, param1, param2, param3, param4) {
|
||||
if (action !== 'send' || !param1) {
|
||||
return;
|
||||
}
|
||||
|
||||
var version = encodeURIComponent(chrome.runtime.getManifest().version);
|
||||
var message = 'v=1&tid=' + gaTrackingId + '&cid=' + gaAnonAppId + '&cd1=' + version;
|
||||
|
||||
if (param1 === 'pageview' && param2) {
|
||||
message += gaTrackPageView(param2);
|
||||
}
|
||||
else if (param1 === 'event' && param2) {
|
||||
message += gaTrackEvent(param2);
|
||||
}
|
||||
else if (typeof param1 === 'object' && param1.hitType === 'event') {
|
||||
message += gaTrackEvent(param1);
|
||||
}
|
||||
|
||||
var request = new XMLHttpRequest();
|
||||
request.open('POST', 'https://www.google-analytics.com/collect', true);
|
||||
request.send(message);
|
||||
gaFunc(action, param1, param2, param3, param4);
|
||||
});
|
||||
};
|
||||
|
||||
if (typeof bg_isBackground !== 'undefined') {
|
||||
ga('send', 'pageview', '/background.html');
|
||||
function gaTrackEvent(options) {
|
||||
return '&t=event&ec=' + (options.eventCategory ? encodeURIComponent(options.eventCategory) : 'Event') +
|
||||
'&ea=' + encodeURIComponent(options.eventAction) +
|
||||
(options.eventLabel ? '&el=' + encodeURIComponent(options.eventLabel) : '') +
|
||||
(options.eventValue ? '&ev=' + encodeURIComponent(options.eventValue) : '') +
|
||||
(options.page ? '&dp=' + encodeURIComponent(options.page) : '');
|
||||
}
|
||||
});
|
||||
|
||||
function gaTrackPageView(pagePath) {
|
||||
return '&t=pageview&dp=' + encodeURIComponent(pagePath);
|
||||
}
|
||||
|
||||
bgPage.bg_appIdService.getAnonymousAppId(function (gaAnonAppId) {
|
||||
gaFunc = function (action, param1, param2, param3, param4) {
|
||||
if (action !== 'send' || !param1) {
|
||||
return;
|
||||
}
|
||||
|
||||
var version = encodeURIComponent(chrome.runtime.getManifest().version);
|
||||
var message = 'v=1&tid=' + gaTrackingId + '&cid=' + gaAnonAppId + '&cd1=' + version;
|
||||
|
||||
if (param1 === 'pageview' && param2) {
|
||||
message += gaTrackPageView(param2);
|
||||
}
|
||||
else if (param1 === 'event' && param2) {
|
||||
message += gaTrackEvent(param2);
|
||||
}
|
||||
else if (typeof param1 === 'object' && param1.hitType === 'event') {
|
||||
message += gaTrackEvent(param1);
|
||||
}
|
||||
|
||||
var request = new XMLHttpRequest();
|
||||
request.open('POST', 'https://www.google-analytics.com/collect', true);
|
||||
request.send(message);
|
||||
};
|
||||
|
||||
if (typeof bg_isBackground !== 'undefined') {
|
||||
ga('send', 'pageview', '/background.html');
|
||||
}
|
||||
});
|
||||
})();
|
||||
|
||||
Reference in New Issue
Block a user