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

GH-2229: Ensure that BROWSER_INFO_READY before using BROWSER_INFO #642

Merged
merged 1 commit into from Dec 9, 2020
Merged
Changes from all commits
Commits
File filter
Filter file types
Jump to
Jump to file
Failed to load files.

Always

Just for now

Make sure globals._checkBrowserInfo has resolved before we use BROWSE…

…R_INFO values in Metrics
  • Loading branch information
Ilya Zarembsky
Ilya Zarembsky committed Dec 8, 2020
commit 91dc343e0b0019fd9a681bec51fec3ea2edee558
@@ -25,7 +25,12 @@ const FREQUENCIES = { // in milliseconds
};
const CRITICAL_METRICS = ['install', 'install_complete', 'upgrade', 'active', 'engaged', 'uninstall'];
const CAMPAIGN_METRICS = ['install', 'active', 'uninstall'];
const { METRICS_BASE_URL, EXTENSION_VERSION, BROWSER_INFO } = globals;
const {
BROWSER_INFO,
BROWSER_INFO_READY,
EXTENSION_VERSION,
METRICS_BASE_URL,
} = globals;
const MAX_DELAYED_PINGS = 100;
// Set of conf keys used in constructing telemetry url
const METRICS_URL_SET = new Set([
@@ -221,6 +226,11 @@ class Metrics {
* @return {string} complete telemetry url
*/
async _buildMetricsUrl(type, frequency) {
// Make sure that Globals._checkBrowserInfo() has resolved before we proceed,
// so that we use the correct BROWSER_INFO values if we are in
// the Ghostery Desktop or Ghostery Android browsers
await BROWSER_INFO_READY;

const frequencyString = (type !== 'uninstall') ? `/${frequency}` : '';

let metrics_url = `${METRICS_BASE_URL}/${type}${frequencyString}?gr=-1`;
@@ -248,7 +258,7 @@ class Metrics {
// Subscription Interval
this._buildQueryPair('si', Metrics._getSubscriptionInterval().toString()) +
// Product ID Parameter
this._buildQueryPair('pi', Metrics._getProductID());
this._buildQueryPair('pi', await Metrics._getProductID());

if (type !== 'uninstall') {
metrics_url +=
@@ -376,7 +386,9 @@ class Metrics {
*
* @return {string} The Product ID
*/
static _getProductID() {
static async _getProductID() {
// Make sure that Globals._checkBrowserInfo() has resolved before we proceed
await BROWSER_INFO_READY;
if (BROWSER_INFO.token === 'gd') return 'gd';
return 'gbe';
}
ProTip! Use n and p to navigate between commits in a pull request.