in media/js/base/fxa-product-button.es6.js [37:98]
FxaProductButton.fetchTokens = function (buttons) {
// assume the first button should dictate the metrics flow request
const buttonURL = buttons[0].getAttribute('href');
let metricsURL = buttons[0].getAttribute('data-action') + 'metrics-flow';
// strip url to everything after `?`
const buttonURLParams = buttonURL.match(/\?(.*)/)[1];
// collect values from Fxa product button
const params = window._SearchParams.queryStringToObject(buttonURLParams);
// add required params to the token fetch request
metricsURL += '?form_type=' + params.form_type;
// add service identifier for VPN (issue #10811)
if (params.service) {
metricsURL += '&service=' + params.service;
}
metricsURL += '&entrypoint=' + params.entrypoint;
metricsURL += '&utm_source=' + params.utm_source;
// add optional utm params to the token fetch request
if (params.utm_campaign) {
metricsURL += '&utm_campaign=' + params.utm_campaign;
}
if (params.utm_content) {
metricsURL += '&utm_content=' + params.utm_content;
}
if (params.utm_medium) {
metricsURL += '&utm_medium=' + params.utm_medium;
}
if (params.utm_term) {
metricsURL += '&utm_term=' + params.utm_term;
}
if (params.entrypoint_experiment) {
metricsURL += '&entrypoint_experiment=' + params.entrypoint_experiment;
}
if (params.entrypoint_variation) {
metricsURL += '&entrypoint_variation=' + params.entrypoint_variation;
}
return fetch(metricsURL)
.then((resp) => {
return resp.json();
})
.then((r) => {
// add retrieved deviceID, flowBeginTime and flowId values to cta url
let flowParams = '&device_id=' + r.deviceId;
flowParams += '&flow_begin_time=' + r.flowBeginTime;
flowParams += '&flow_id=' + r.flowId;
return flowParams;
})
.catch(() => {
// silently fail: deviceId, flowBeginTime, flowId are not added to url.
});
};