Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Desktop browser telemetry #633

Merged
merged 5 commits into from Nov 30, 2020
Merged
Changes from 1 commit
Commits
File filter
Filter file types
Jump to
Jump to file
Failed to load files.

Always

Just for now

Fetch search metrics from search extension
  • Loading branch information
sammacbeth committed Nov 19, 2020
commit e8b85b22ba2618948d6aa1e8e71cb5fc5eac6a39
@@ -21,7 +21,6 @@ module.exports = {
extends: 'airbnb',
globals: {
chrome: true,
browser: true,
t: true,
Atomics: 'readonly',
SharedArrayBuffer: 'readonly',
@@ -310,9 +310,11 @@ class Metrics {
}

if (BROWSER_INFO.token === 'gd') {
metrics_url +=
// default search
this._buildQueryPair('ds', await Metrics._getDefaultSearchEngine());
// fetch metrics from the search extension and append them
const searchMetrics = await Metrics._getSearchExtensionMetrics();
Object.keys(searchMetrics).forEach((k) => {
metrics_url += this._buildQueryPair(k, searchMetrics[k]);
});
}

return metrics_url;
@@ -675,22 +677,12 @@ class Metrics {
}, FREQUENCIES.biweekly);
}

static async _getDefaultSearchEngine() {
// search API is only available in Ghostery browser where this permission is added to the manifest.
if (typeof browser !== 'undefined' && browser.search) {
// limit engines we can send to the specific set we're interested in from search choice screen
const searchEngines = {
'Ghostery Search': 'ghost',
Google: 'google',
Bing: 'bing',
StartPage: 'sp',
Yahoo: 'yahoo',
};
const engines = await browser.search.get();
const defaultSearchEngine = engines.find(s => s.isDefault).name;
return searchEngines[defaultSearchEngine] || 'other';
}
return '';
static async _getSearchExtensionMetrics() {
return new Promise((resolve) => {
chrome.runtime.sendMessage('search@ghostery.com', 'getMetrics', (response) => {
resolve(response || {});
});
});
}
}

ProTip! Use n and p to navigate between commits in a pull request.