;!function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{},n=(new Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="94403e2a-96e8-4bce-b4f4-123137d41372",e._sentryDebugIdIdentifier="sentry-dbid-94403e2a-96e8-4bce-b4f4-123137d41372")}catch(e){}}();

    var _global =
      typeof window !== 'undefined' ?
        window :
        typeof global !== 'undefined' ?
          global :
          typeof self !== 'undefined' ?
            self :
            {};

    _global.SENTRY_RELEASE={id:"hs-1729890410895"};
"use strict";
(self["webpackChunkboost_checkout"] = self["webpackChunkboost_checkout"] || []).push([[7609],{

/***/ 67609:
/***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) {


// EXPORTS
__webpack_require__.d(__webpack_exports__, {
  G: function() { return /* binding */ initializeFacebookTracking; },
  c: function() { return /* binding */ trackFacebookLeadConversion; }
});

;// CONCATENATED MODULE: ./src/helpers/react-facebook-pixel/reactFacebookPixel.js
/**
 * React Facebook Pixel Module
 *
 * @package react-facebook-pixel
 * @author  Zain Sajjad <zsajjad93@gmail.com>
 *
 * Not using the react npm package because it is not being maintained and it is missing some needed functionality so pulling in this file only.
 */

let initialized = false;
let debug = false;

/**
 * Utilities
 */

/**
 * Warn
 * @param  {...any} args
 */
const warn = (...args) => {
    if (!debug) {
        return;
    }
    // eslint-disable-next-line no-console
    console.info(...['[react-facebook-pixel]'].concat(args));
};

/**
 * Log
 * @param  {...any} args
 */
const log = (...args) => {
    if (!debug) {
        return;
    }
    // eslint-disable-next-line no-console
    console.info(...['[react-facebook-pixel]'].concat(args));
};

const verifyInit = () => {
    if (!initialized) {
        warn(
            'Pixel not initialized before using call ReactPixel.init with required params',
        );
    }
    return initialized;
};

//
const defaultOptions = {
    autoConfig: true,
    debug: false,
};

//
/* harmony default export */ var reactFacebookPixel = ({
    init(pixelId, advancedMatching = {}, options = defaultOptions) {
        initialized = (typeof window !== 'undefined') && !!window.fbq;
        /* eslint-disable */
        !(function(f, b, e, v, n, t, s) {
            if (f.fbq) return;
            n = f.fbq = function() {
                n.callMethod
                    ? n.callMethod.apply(n, arguments)
                    : n.queue.push(arguments);
            };
            if (!f._fbq) f._fbq = n;
            n.push = n;
            n.loaded = !0;
            n.version = '2.0';
            n.queue = [];
            t = b.createElement(e);
            t.async = !0;
            t.src = v;
            s = b.getElementsByTagName(e)[0];
            s.parentNode.insertBefore(t, s);
        })(
            window,
            document,
            'script',
            'https://connect.facebook.net/en_US/fbevents.js',
        );
        /* eslint-enable */

        if (!pixelId) {
            warn('Please insert pixel id for initializing');
        } else {
            if (options.autoConfig === false) {
                fbq('set', 'autoConfig', false, pixelId); // eslint-disable-line no-undef
            }

            fbq('init', pixelId, advancedMatching); // eslint-disable-line no-undef

            initialized = true;
            debug = options.debug;
        }
    },

    pageView() {
        if (!verifyInit()) {
            return;
        }

        fbq('track', 'PageView'); // eslint-disable-line no-undef

        if (debug) {
            log("called fbq('track', 'PageView');");
        }
    },

    track(title, data, eventData) {
        if (!verifyInit()) {
            return;
        }

        fbq('track', title, data, eventData); // eslint-disable-line no-undef

        if (debug) {
            log(`called fbq('track', '${title}');`);

            if (data) {
                log('with data', data);
            }
        }
    },

    trackSingle(pixel, title, data) {
        if (!verifyInit()) {
            return;
        }

        fbq('trackSingle', pixel, title, data); // eslint-disable-line no-undef

        if (debug) {
            log(`called fbq('trackSingle', '${pixel}', '${title}');`);

            if (data) {
                log('with data', data);
            }
        }
    },

    trackCustom(event, data) {
        if (!verifyInit()) {
            return;
        }

        fbq('trackCustom', event, data); // eslint-disable-line no-undef

        if (debug) {
            log(`called fbq('trackCustom', '${event}');`);

            if (data) {
                log('with data', data);
            }
        }
    },

    trackSingleCustom(pixel, event, data) {
        if (!verifyInit()) {
            return;
        }

        fbq('trackSingle', pixel, event, data); // eslint-disable-line no-undef

        if (debug) {
            log(`called fbq('trackSingleCustom', '${pixel}', '${event}');`);

            if (data) {
                log('with data', data);
            }
        }
    },

    grantConsent() {
        if (!verifyInit()) {
            return;
        }

        fbq('consent', 'grant');

        if (debug) {
            log(`called fbq('consent', 'grant');`);
        }
    },

    revokeConsent() {
        if (!verifyInit()) {
            return;
        }

        // eslint-disable-next-line
        fbq('consent', 'revoke');

        if (debug) {
            log(`called fbq('consent', 'revoke');`);
        }
    },

    fbq(...args) {
        if (!verifyInit()) {
            return;
        }

        // eslint-disable-next-line no-undef
        fbq(...args); // eslint-disable-line no-undef

        if (debug) {
            log(`called fbq('${args.slice(0, 2).join("', '")}')`);

            if (args[2]) {
                log('with data', args[2]);
            }
        }
    },
});
// EXTERNAL MODULE: ./src/helpers/helpers.ts
var helpers = __webpack_require__(72423);
// EXTERNAL MODULE: ./node_modules/uuid/dist/esm-browser/v4.js + 3 modules
var v4 = __webpack_require__(33829);
;// CONCATENATED MODULE: ./src/helpers/facebookPixelHelper.ts



var isFacebookPixelTrackingInitialized = false;
var getFacebookPixelTrackingIds = function getFacebookPixelTrackingIds() {
  var el = document.getElementById('facebookPixelTrackingIds');
  if (!el || !el.dataset) {
    console.warn('FacebookPixelTrackingIds missing!');
    return [];
  }
  var idsString = el.dataset.facebookPixelTrackingIds;
  if (!idsString) {
    return [];
  }
  return idsString.split(',');
};
var initializeFacebookTracking = function initializeFacebookTracking() {
  if (!isFacebookPixelTrackingInitialized) {
    var facebookPixelTrackingIds = getFacebookPixelTrackingIds();
    facebookPixelTrackingIds.forEach(function (pixelId) {
      reactFacebookPixel.init(pixelId);
      isFacebookPixelTrackingInitialized = true;
    });
  }
  if (isFacebookPixelTrackingInitialized) {
    reactFacebookPixel.pageView(); // For tracking page view
  }
};
var trackFacebookLeadConversion = function trackFacebookLeadConversion(formik) {
  var _formik$values$name, _formik$values$email, _formik$values$phone, _params$get, _params$get2;
  // For tracking default events. More info about standard events: https://developers.facebook.com/docs/facebook-pixel/implementation/conversion-tracking#standard-events
  var leadEventName = 'Lead';
  var params = new URLSearchParams(window.location ? window.location.search : []);
  var name = (_formik$values$name = formik.values.name) !== null && _formik$values$name !== void 0 ? _formik$values$name : null;
  var email = (_formik$values$email = formik.values.email) !== null && _formik$values$email !== void 0 ? _formik$values$email : null;
  var phone = (_formik$values$phone = formik.values.phone) !== null && _formik$values$phone !== void 0 ? _formik$values$phone : null;
  var campaignId = (_params$get = params.get('cid')) !== null && _params$get !== void 0 ? _params$get : '';
  var uniqueEventId = (0,v4/* default */.A)() + campaignId; // used by FB to dedupe events since we send via pixel AND conversions api

  // track via the pixel
  reactFacebookPixel.track(leadEventName, {
    name: name,
    email: email,
    phone: phone
  }, {
    eventID: uniqueEventId
  });

  // track via conversions api
  var fbclid = (_params$get2 = params.get('fbclid')) !== null && _params$get2 !== void 0 ? _params$get2 : '';
  var facebookPixelTrackingIds = getFacebookPixelTrackingIds();
  facebookPixelTrackingIds.forEach(function (pixelId) {
    (0,helpers/* HSFetch */.OU)("/lead/track_facebook_conversion_event/".concat(leadEventName), JSON.stringify({
      name: name,
      phone: phone,
      email: email,
      fbclid: fbclid,
      pixel: pixelId,
      eventId: uniqueEventId,
      eventSource: window.location.href
    }));
  });
};

/***/ })

}]);
//# sourceMappingURL=7609.4a6292d65747e76d977b.js.map