Skip to content

Commit

Permalink
Merge pull request #53 from herodevs/main
Browse files Browse the repository at this point in the history
chore(): update staging with latest changes
  • Loading branch information
eduardoRoth authored Sep 27, 2024
2 parents eba2260 + b669b4d commit 86d6253
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 15 deletions.
1 change: 1 addition & 0 deletions scripts/global.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
IS_PROD:
window.location.href.toLowerCase().indexOf('www.herodevs.com') > -1,
};

const HD_CONF = {
LIB_SCRIPTS: ['log-rocket.js', 'hubspot.js'],
SCRIPT: {
Expand Down
27 changes: 12 additions & 15 deletions scripts/helpers/hubspot.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,7 @@
$(this).submit(function (e) {
// when the form submits
e.preventDefault(); //stop the form from submitting to webflow
console.log({ target: e.target });
const formData = new FormData(e.target); // get the form data
console.log({ formData: formData.entries() });
const parsedFormData = [...formData.entries()].map(dataObject => ({
// convert data to array
name: dataObject[0], // make sure the name of the input is the same as the hubspot input name
Expand All @@ -25,24 +23,24 @@
}
}

console.log(parsedFormData);

const formDataAsObject = parsedFormData.reduce((acc, current) => {
let newAcc = { ...acc };
newAcc[current.name] = current.value;
return newAcc;
}, {});

if (window.HD.IS_PROD) {
LogRocket.identify(formDataAsObject.email, {
name: formDataAsObject.firstname + ' ' + formDataAsObject.lastname,
email: formDataAsObject.email,

// Add your own custom user variables here
company: formDataAsObject.company,
phone: formDataAsObject.phone,
plan: formDataAsObject.plan,
});
try {
if (window.HD.IS_PROD) {
LogRocket.identify(formDataAsObject.email, {
name: formDataAsObject.firstname + ' ' + formDataAsObject.lastname,
email: formDataAsObject.email,
company: formDataAsObject.company,
phone: formDataAsObject.phone,
plan: formDataAsObject.plan,
});
}
} catch(err) {
console.log('LogRocket is not available!');
}

const goToWebinarWebinarKey = parsedFormData.find(
Expand Down Expand Up @@ -136,7 +134,6 @@
function isOnURL(url) {
return !!~window.location.href.indexOf(url);
}
console.log('url', theUrl);
if (response) {
// if response inline, display contents
if (response.inlineMessage) {
Expand Down

0 comments on commit 86d6253

Please sign in to comment.