tf-checkout-react 1.3.39-beta.2 → 1.3.40

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1 +1 @@
1
- export declare const usePixel: (key: string, eventId: string | number) => Promise<void>;
1
+ export declare const usePixel: (key: string | string[], eventId: string | number, alreadyLoadedEventData?: any) => Promise<void>;
@@ -1212,7 +1212,7 @@ var createElementFromHTML = function createElementFromHTML(htmlString) {
1212
1212
  var div = document.createElement('div');
1213
1213
  div.innerHTML = htmlString.trim(); // Change this to div.childNodes to support multiple top-level nodes.
1214
1214
 
1215
- return div.firstChild || '';
1215
+ return div.childNodes || [];
1216
1216
  };
1217
1217
 
1218
1218
  var isWindowDefined = typeof window !== 'undefined';
@@ -1617,34 +1617,75 @@ var getCheckoutPageConfigs = /*#__PURE__*/function () {
1617
1617
  }();
1618
1618
 
1619
1619
  var usePixel = /*#__PURE__*/function () {
1620
- var _ref = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee2(key, eventId) {
1621
- var getEventData;
1620
+ var _ref = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee2(key, eventId, alreadyLoadedEventData) {
1621
+ var addPixel, getEventData;
1622
1622
  return runtime_1.wrap(function _callee2$(_context2) {
1623
1623
  while (1) {
1624
1624
  switch (_context2.prev = _context2.next) {
1625
1625
  case 0:
1626
+ addPixel = function addPixel(pixel) {
1627
+ var _document;
1628
+
1629
+ if ((_document = document) != null && _document.head && pixel) {
1630
+ var nodes = createElementFromHTML(pixel);
1631
+
1632
+ for (var _i = 0, _Array$from = Array.from(nodes); _i < _Array$from.length; _i++) {
1633
+ var element = _Array$from[_i];
1634
+ document.head.append(element);
1635
+ }
1636
+ }
1637
+ };
1638
+
1626
1639
  getEventData = /*#__PURE__*/function () {
1627
1640
  var _ref2 = _asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee() {
1628
- var _document;
1629
-
1630
- var eventResponse, event, pixel;
1641
+ var isEventDataUndefined, eventResponse, event, pixel;
1631
1642
  return runtime_1.wrap(function _callee$(_context) {
1632
1643
  while (1) {
1633
1644
  switch (_context.prev = _context.next) {
1634
1645
  case 0:
1635
- _context.next = 2;
1636
- return getEvent(eventId);
1646
+ if (eventId) {
1647
+ _context.next = 2;
1648
+ break;
1649
+ }
1650
+
1651
+ return _context.abrupt("return");
1637
1652
 
1638
1653
  case 2:
1639
- eventResponse = _context.sent;
1640
- event = _get(eventResponse, 'data.data.attributes');
1641
- pixel = event[key];
1654
+ // Check if event data object passed or not. If not then the value will be undefined.
1655
+ // If event data passed, then it's initial value will be null.
1656
+ isEventDataUndefined = alreadyLoadedEventData === undefined;
1642
1657
 
1643
- if ((_document = document) != null && _document.head && pixel) {
1644
- document.head.append(createElementFromHTML(pixel));
1658
+ if (!isEventDataUndefined) {
1659
+ _context.next = 9;
1660
+ break;
1645
1661
  }
1646
1662
 
1663
+ _context.next = 6;
1664
+ return getEvent(eventId);
1665
+
1647
1666
  case 6:
1667
+ _context.t0 = _context.sent;
1668
+ _context.next = 10;
1669
+ break;
1670
+
1671
+ case 9:
1672
+ _context.t0 = null;
1673
+
1674
+ case 10:
1675
+ eventResponse = _context.t0;
1676
+ event = isEventDataUndefined ? _get(eventResponse, 'data.data.attributes', {}) : alreadyLoadedEventData || {};
1677
+
1678
+ if (typeof key === 'string') {
1679
+ pixel = event[key];
1680
+ addPixel(pixel);
1681
+ } else {
1682
+ _forEach(key, function (item) {
1683
+ var pixel = event[item];
1684
+ addPixel(pixel);
1685
+ });
1686
+ }
1687
+
1688
+ case 13:
1648
1689
  case "end":
1649
1690
  return _context.stop();
1650
1691
  }
@@ -1658,10 +1699,10 @@ var usePixel = /*#__PURE__*/function () {
1658
1699
  }();
1659
1700
 
1660
1701
  React.useEffect(function () {
1661
- getEventData();
1662
- }, []);
1702
+ getEventData(); // eslint-disable-next-line react-hooks/exhaustive-deps
1703
+ }, [eventId, alreadyLoadedEventData]);
1663
1704
 
1664
- case 2:
1705
+ case 3:
1665
1706
  case "end":
1666
1707
  return _context2.stop();
1667
1708
  }
@@ -1669,7 +1710,7 @@ var usePixel = /*#__PURE__*/function () {
1669
1710
  }, _callee2);
1670
1711
  }));
1671
1712
 
1672
- return function usePixel(_x, _x2) {
1713
+ return function usePixel(_x, _x2, _x3) {
1673
1714
  return _ref.apply(this, arguments);
1674
1715
  };
1675
1716
  }();
@@ -3639,7 +3680,7 @@ var BillingInfoContainer = /*#__PURE__*/React__default.memo(function (_ref4) {
3639
3680
  return item.code.toLowerCase() === defaultCountry;
3640
3681
  }) || {};
3641
3682
  var initialCountry = selectedCountry.id || _get(userData, 'country', '') || '1';
3642
- usePixel('checkoutPixels', eventId);
3683
+ usePixel(['checkoutPixels', 'brandCheckoutPixels'], eventId);
3643
3684
  return React__default.createElement(styles.ThemeProvider, {
3644
3685
  theme: themeMui
3645
3686
  }, (loading || isCountriesLoading) && React__default.createElement(Backdrop, {
@@ -5057,7 +5098,7 @@ var ConfirmationContainer = function ConfirmationContainer(_ref) {
5057
5098
  confirmationMain = _confirmationLabels$c2 === void 0 ? 'Your tickets are available in My Tickets section' : _confirmationLabels$c2,
5058
5099
  _confirmationLabels$c3 = confirmationLabels.confirmationHelper,
5059
5100
  confirmationHelper = _confirmationLabels$c3 === void 0 ? 'Please bring them with you to the event' : _confirmationLabels$c3;
5060
- usePixel('conversionPixels', data == null ? void 0 : data.product_id);
5101
+ usePixel(['conversionPixels', 'brandConversionPixels'], data == null ? void 0 : data.product_id);
5061
5102
  return React__default.createElement("div", {
5062
5103
  className: "confirmation-page"
5063
5104
  }, data && React__default.createElement(React__default.Fragment, null, React__default.createElement("div", {
@@ -5921,7 +5962,7 @@ var TicketsContainer = function TicketsContainer(_ref) {
5921
5962
  useCookieListener(X_TF_ECOMMERCE, function (value) {
5922
5963
  return setIsLogged(Boolean(value));
5923
5964
  });
5924
- usePixel('pagePixels', eventId);
5965
+ usePixel(['pagePixels', 'brandPagePixels'], eventId, event);
5925
5966
  React.useEffect(function () {
5926
5967
  if (typeof window !== 'undefined') {
5927
5968
  var access_token = window.localStorage.getItem('access_token');