Skip to content

Commit

Permalink
Merge pull request #239 from adobecom/add-param-anaylitics-sandbox
Browse files Browse the repository at this point in the history
MWPW-154363: Add param anaylitics sandbox
  • Loading branch information
JasonHowellSlavin committed Sep 10, 2024
2 parents 0bde7a2 + 014b4dd commit 229705f
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 7 deletions.
21 changes: 14 additions & 7 deletions scripts/aa-university.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,23 @@ export default function registerAAUniversity() {
const lastName = document.querySelector('input[name="LastName"]');
const email = document.querySelector('input[name="Email"]');
const country = document.querySelector('select[name="Country"]');
const group = document.querySelector('meta[name="sandboxgroup"]');

const postBody = {
first_name: firstName?.value,
last_name: lastName?.value,
email: email?.value,
university: 'none',
country: country?.value,
};

if (group) postBody.group = group.content;

fetch('https://us-central1-adobe---aa-university.cloudfunctions.net/register', {
method: 'POST',
body: JSON.stringify({
first_name: firstName?.value,
last_name: lastName?.value,
email: email?.value,
university: 'none',
country: country?.value,
}),
body: JSON.stringify(postBody),
})
.catch((error) => window.lana.log(`Marketo AA University Error: ${error}`));

return postBody;
}
16 changes: 16 additions & 0 deletions test/scripts/aa-university.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,4 +29,20 @@ describe('AA University', async () => {
window.fetch = ogFetch;
window.lana = ogLana;
});

it('Sends the group parameter with POST if found', () => {
const meta = document.createElement('meta');
meta.setAttribute('name', 'sandboxgroup');
meta.setAttribute('content', 'group');
document.body.prepend(meta);
const body = registerAAUniversity();
expect(body.group).to.equal('group');

document.querySelector('meta').remove();
});

it('Does not send the group parameter with POST if not found', () => {
const body = registerAAUniversity();
expect(body.group).to.be.undefined;
});
});

0 comments on commit 229705f

Please sign in to comment.