Skip to content

Commit

Permalink
Remove caching from OAuth submissions on experiment branch
Browse files Browse the repository at this point in the history
  • Loading branch information
maxxcrawford committed Apr 1, 2020
1 parent 63d7557 commit c9d6af5
Showing 1 changed file with 16 additions and 5 deletions.
21 changes: 16 additions & 5 deletions public/js/monitor.js
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,14 @@ function doOauth(el, {emailWatch = false} = {}) {
// Growth Experiment: This logic is complex to handle the different scenarios of users logging into FxA.
let email = false;

let growthTaggedURL = new URL("/oauth/init", document.body.dataset.serverUrl);
growthTaggedURL = appendFxaParams(growthTaggedURL, document.body.dataset);

["flowId", "flowBeginTime", "entrypoint", "form_type"].forEach(key => {
growthTaggedURL.searchParams.append(key, encodeURIComponent(el.dataset[key]));
});


if (document.querySelector("#scan-user-email input[type=email]")) {
email = document.querySelector("#scan-user-email input[type=email]").value;

Expand All @@ -84,7 +92,7 @@ function doOauth(el, {emailWatch = false} = {}) {
// Growth Experiment: Set UTMs from in-line body tag data elements.
["utm_source", "utm_medium", "utm_campaign", "utm_term", "utm_content" ].forEach(key => {
if (document.body.dataset[key]) {
url.searchParams.append(key, document.body.dataset[key]);
growthTaggedURL.searchParams.append(key, document.body.dataset[key]);
}
});

Expand Down Expand Up @@ -119,9 +127,9 @@ function doOauth(el, {emailWatch = false} = {}) {

// Append whichever email was set, and start OAuth flow!
if (email) {
url.searchParams.append("email", email);
growthTaggedURL.searchParams.append("email", email);
}
window.location.assign(url);
window.location.assign(growthTaggedURL);
}


Expand Down Expand Up @@ -459,11 +467,14 @@ function addBentoObserver(){

submitBtn.addEventListener("click", (e)=> {
document.body.dataset.utm_content = "opt-out";

// Email Validation
const scanForm = document.getElementById("scan-user-email");

if (createFxaCheckbox.checked) {
e.preventDefault();

// Email Validation
const scanForm = document.getElementById("scan-user-email");

const scanFormEmailValue = document.querySelector("#scan-user-email input[type='email']").value;

if (scanFormEmailValue.length < 1 || !isValidEmail(scanFormEmailValue)) {
Expand Down

0 comments on commit c9d6af5

Please sign in to comment.