Skip to content

Commit

Permalink
Merge pull request #50 from herodevs/eduardoRoth-patch-2
Browse files Browse the repository at this point in the history
fix(): check if LogRocket is present before calling it
  • Loading branch information
eduardoRoth authored Sep 27, 2024
2 parents 3b0f9db + 26176db commit 451b194
Showing 1 changed file with 1 addition and 6 deletions.
7 changes: 1 addition & 6 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,15 +23,13 @@
}
}

console.log(parsedFormData);

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

if (window.HD.IS_PROD) {
if (window.HD.IS_PROD && !!LogRocket) {
LogRocket.identify(formDataAsObject.email, {
name: formDataAsObject.firstname + ' ' + formDataAsObject.lastname,
email: formDataAsObject.email,
Expand Down Expand Up @@ -136,7 +132,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 451b194

Please sign in to comment.