@eventlook/sdk 1.4.6 → 1.4.20
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.
- package/dev-frontend.sh +32 -0
- package/dist/cjs/context/GlobalContext.js +2 -1
- package/dist/cjs/context/GlobalContext.js.map +1 -1
- package/dist/cjs/form/PaymentSuccess.js +39 -2
- package/dist/cjs/form/PaymentSuccess.js.map +1 -1
- package/dist/cjs/form/TicketForm.js +6 -3
- package/dist/cjs/form/TicketForm.js.map +1 -1
- package/dist/cjs/form/TicketSelection.js.map +1 -1
- package/dist/cjs/form/TicketSelectionMap.js +43 -0
- package/dist/cjs/form/TicketSelectionMap.js.map +1 -0
- package/dist/cjs/form/index.js +2 -2
- package/dist/cjs/form/index.js.map +1 -1
- package/dist/cjs/locales/cs.js +1 -0
- package/dist/cjs/locales/cs.js.map +1 -1
- package/dist/cjs/locales/en.js +1 -0
- package/dist/cjs/locales/en.js.map +1 -1
- package/dist/cjs/locales/es.js +1 -0
- package/dist/cjs/locales/es.js.map +1 -1
- package/dist/cjs/locales/pl.js +1 -0
- package/dist/cjs/locales/pl.js.map +1 -1
- package/dist/cjs/locales/sk.js +1 -0
- package/dist/cjs/locales/sk.js.map +1 -1
- package/dist/cjs/locales/uk.js +1 -0
- package/dist/cjs/locales/uk.js.map +1 -1
- package/dist/cjs/utils/gtm.js +20 -0
- package/dist/cjs/utils/gtm.js.map +1 -1
- package/dist/esm/context/GlobalContext.js +2 -1
- package/dist/esm/context/GlobalContext.js.map +1 -1
- package/dist/esm/form/PaymentSuccess.js +39 -2
- package/dist/esm/form/PaymentSuccess.js.map +1 -1
- package/dist/esm/form/TicketForm.js +6 -3
- package/dist/esm/form/TicketForm.js.map +1 -1
- package/dist/esm/form/TicketSelection.js.map +1 -1
- package/dist/esm/form/TicketSelectionMap.js +39 -0
- package/dist/esm/form/TicketSelectionMap.js.map +1 -0
- package/dist/esm/form/index.js +2 -2
- package/dist/esm/form/index.js.map +1 -1
- package/dist/esm/locales/cs.js +1 -0
- package/dist/esm/locales/cs.js.map +1 -1
- package/dist/esm/locales/en.js +1 -0
- package/dist/esm/locales/en.js.map +1 -1
- package/dist/esm/locales/es.js +1 -0
- package/dist/esm/locales/es.js.map +1 -1
- package/dist/esm/locales/pl.js +1 -0
- package/dist/esm/locales/pl.js.map +1 -1
- package/dist/esm/locales/sk.js +1 -0
- package/dist/esm/locales/sk.js.map +1 -1
- package/dist/esm/locales/uk.js +1 -0
- package/dist/esm/locales/uk.js.map +1 -1
- package/dist/esm/utils/gtm.js +19 -1
- package/dist/esm/utils/gtm.js.map +1 -1
- package/dist/types/context/GlobalContext.d.ts +2 -1
- package/dist/types/form/PaymentSuccess.d.ts +2 -0
- package/dist/types/form/TicketSelectionMap.d.ts +7 -0
- package/dist/types/form/index.d.ts +1 -0
- package/dist/types/locales/cs.d.ts +1 -0
- package/dist/types/locales/en.d.ts +1 -0
- package/dist/types/locales/es.d.ts +1 -0
- package/dist/types/locales/pl.d.ts +1 -0
- package/dist/types/locales/sk.d.ts +1 -0
- package/dist/types/locales/uk.d.ts +1 -0
- package/dist/types/utils/gtm.d.ts +3 -1
- package/dist/types/utils/types/event.type.d.ts +1 -0
- package/dist/types/utils/types/global.type.d.ts +1 -0
- package/dist/types/utils/types/gtm.type.d.ts +5 -0
- package/dist/types/utils/types/order.type.d.ts +1 -0
- package/dist/types/utils/types/ticket.type.d.ts +16 -3
- package/package.json +8 -3
- package/rollup.config.mjs +15 -1
- package/src/context/GlobalContext.tsx +3 -0
- package/src/form/PaymentSuccess.tsx +46 -3
- package/src/form/TicketForm.tsx +10 -3
- package/src/form/TicketSelection.tsx +1 -0
- package/src/form/TicketSelectionMap.tsx +56 -0
- package/src/form/index.tsx +3 -0
- package/src/locales/cs.tsx +1 -0
- package/src/locales/en.tsx +1 -0
- package/src/locales/es.tsx +1 -0
- package/src/locales/pl.tsx +1 -0
- package/src/locales/sk.tsx +1 -0
- package/src/locales/uk.tsx +1 -0
- package/src/utils/gtm.ts +29 -0
- package/src/utils/types/event.type.ts +1 -0
- package/src/utils/types/global.type.ts +1 -0
- package/src/utils/types/gtm.type.ts +6 -0
- package/src/utils/types/order.type.ts +1 -0
- package/src/utils/types/ticket.type.ts +16 -1
- package/dist/cjs/_virtual/_commonjsHelpers.js +0 -6
- package/dist/cjs/_virtual/_commonjsHelpers.js.map +0 -1
- package/dist/cjs/_virtual/colorManipulator.js +0 -6
- package/dist/cjs/_virtual/colorManipulator.js.map +0 -1
- package/dist/cjs/_virtual/createStyled.js +0 -6
- package/dist/cjs/_virtual/createStyled.js.map +0 -1
- package/dist/cjs/_virtual/customParseFormat.js +0 -6
- package/dist/cjs/_virtual/customParseFormat.js.map +0 -1
- package/dist/cjs/_virtual/dayjs.min.js +0 -6
- package/dist/cjs/_virtual/dayjs.min.js.map +0 -1
- package/dist/cjs/_virtual/extends.js +0 -6
- package/dist/cjs/_virtual/extends.js.map +0 -1
- package/dist/cjs/_virtual/index.js +0 -6
- package/dist/cjs/_virtual/index.js.map +0 -1
- package/dist/cjs/_virtual/index.umd.js +0 -6
- package/dist/cjs/_virtual/index.umd.js.map +0 -1
- package/dist/cjs/_virtual/index10.js +0 -11
- package/dist/cjs/_virtual/index10.js.map +0 -1
- package/dist/cjs/_virtual/index11.js +0 -11
- package/dist/cjs/_virtual/index11.js.map +0 -1
- package/dist/cjs/_virtual/index12.js +0 -6
- package/dist/cjs/_virtual/index12.js.map +0 -1
- package/dist/cjs/_virtual/index13.js +0 -6
- package/dist/cjs/_virtual/index13.js.map +0 -1
- package/dist/cjs/_virtual/index14.js +0 -6
- package/dist/cjs/_virtual/index14.js.map +0 -1
- package/dist/cjs/_virtual/index15.js +0 -6
- package/dist/cjs/_virtual/index15.js.map +0 -1
- package/dist/cjs/_virtual/index2.js +0 -6
- package/dist/cjs/_virtual/index2.js.map +0 -1
- package/dist/cjs/_virtual/index3.js +0 -6
- package/dist/cjs/_virtual/index3.js.map +0 -1
- package/dist/cjs/_virtual/index4.js +0 -11
- package/dist/cjs/_virtual/index4.js.map +0 -1
- package/dist/cjs/_virtual/index5.js +0 -11
- package/dist/cjs/_virtual/index5.js.map +0 -1
- package/dist/cjs/_virtual/index6.js +0 -11
- package/dist/cjs/_virtual/index6.js.map +0 -1
- package/dist/cjs/_virtual/index7.js +0 -11
- package/dist/cjs/_virtual/index7.js.map +0 -1
- package/dist/cjs/_virtual/index8.js +0 -11
- package/dist/cjs/_virtual/index8.js.map +0 -1
- package/dist/cjs/_virtual/index9.js +0 -11
- package/dist/cjs/_virtual/index9.js.map +0 -1
- package/dist/cjs/_virtual/interopRequireDefault.js +0 -6
- package/dist/cjs/_virtual/interopRequireDefault.js.map +0 -1
- package/dist/cjs/_virtual/isBetween.js +0 -6
- package/dist/cjs/_virtual/isBetween.js.map +0 -1
- package/dist/cjs/_virtual/jsx-runtime.js +0 -6
- package/dist/cjs/_virtual/jsx-runtime.js.map +0 -1
- package/dist/cjs/_virtual/localizedFormat.js +0 -6
- package/dist/cjs/_virtual/localizedFormat.js.map +0 -1
- package/dist/cjs/_virtual/lodash.js +0 -6
- package/dist/cjs/_virtual/lodash.js.map +0 -1
- package/dist/cjs/_virtual/lottie.js +0 -6
- package/dist/cjs/_virtual/lottie.js.map +0 -1
- package/dist/cjs/_virtual/numeral.js +0 -6
- package/dist/cjs/_virtual/numeral.js.map +0 -1
- package/dist/cjs/_virtual/objectWithoutPropertiesLoose.js +0 -6
- package/dist/cjs/_virtual/objectWithoutPropertiesLoose.js.map +0 -1
- package/dist/cjs/_virtual/react-is.development.js +0 -6
- package/dist/cjs/_virtual/react-is.development.js.map +0 -1
- package/dist/cjs/_virtual/react-is.development2.js +0 -6
- package/dist/cjs/_virtual/react-is.development2.js.map +0 -1
- package/dist/cjs/_virtual/react-is.development3.js +0 -6
- package/dist/cjs/_virtual/react-is.development3.js.map +0 -1
- package/dist/cjs/_virtual/react-is.production.js +0 -6
- package/dist/cjs/_virtual/react-is.production.js.map +0 -1
- package/dist/cjs/_virtual/react-is.production.min.js +0 -6
- package/dist/cjs/_virtual/react-is.production.min.js.map +0 -1
- package/dist/cjs/_virtual/react-is.production.min2.js +0 -6
- package/dist/cjs/_virtual/react-is.production.min2.js.map +0 -1
- package/dist/cjs/_virtual/react-jsx-runtime.development.js +0 -6
- package/dist/cjs/_virtual/react-jsx-runtime.development.js.map +0 -1
- package/dist/cjs/_virtual/react-jsx-runtime.production.min.js +0 -6
- package/dist/cjs/_virtual/react-jsx-runtime.production.min.js.map +0 -1
- package/dist/cjs/_virtual/timezone.js +0 -6
- package/dist/cjs/_virtual/timezone.js.map +0 -1
- package/dist/cjs/_virtual/use-sync-external-store-shim.development.js +0 -6
- package/dist/cjs/_virtual/use-sync-external-store-shim.development.js.map +0 -1
- package/dist/cjs/_virtual/use-sync-external-store-shim.production.js +0 -6
- package/dist/cjs/_virtual/use-sync-external-store-shim.production.js.map +0 -1
- package/dist/cjs/_virtual/useThemeWithoutDefault.js +0 -6
- package/dist/cjs/_virtual/useThemeWithoutDefault.js.map +0 -1
- package/dist/cjs/_virtual/utc.js +0 -6
- package/dist/cjs/_virtual/utc.js.map +0 -1
- package/dist/cjs/_virtual/weekOfYear.js +0 -6
- package/dist/cjs/_virtual/weekOfYear.js.map +0 -1
- package/dist/cjs/utils/data/order.js +0 -8
- package/dist/cjs/utils/data/order.js.map +0 -1
- package/dist/esm/_virtual/_commonjsHelpers.js +0 -4
- package/dist/esm/_virtual/_commonjsHelpers.js.map +0 -1
- package/dist/esm/_virtual/colorManipulator.js +0 -4
- package/dist/esm/_virtual/colorManipulator.js.map +0 -1
- package/dist/esm/_virtual/createStyled.js +0 -4
- package/dist/esm/_virtual/createStyled.js.map +0 -1
- package/dist/esm/_virtual/customParseFormat.js +0 -4
- package/dist/esm/_virtual/customParseFormat.js.map +0 -1
- package/dist/esm/_virtual/dayjs.min.js +0 -4
- package/dist/esm/_virtual/dayjs.min.js.map +0 -1
- package/dist/esm/_virtual/extends.js +0 -4
- package/dist/esm/_virtual/extends.js.map +0 -1
- package/dist/esm/_virtual/index.js +0 -4
- package/dist/esm/_virtual/index.js.map +0 -1
- package/dist/esm/_virtual/index.umd.js +0 -4
- package/dist/esm/_virtual/index.umd.js.map +0 -1
- package/dist/esm/_virtual/index10.js +0 -7
- package/dist/esm/_virtual/index10.js.map +0 -1
- package/dist/esm/_virtual/index11.js +0 -7
- package/dist/esm/_virtual/index11.js.map +0 -1
- package/dist/esm/_virtual/index12.js +0 -4
- package/dist/esm/_virtual/index12.js.map +0 -1
- package/dist/esm/_virtual/index13.js +0 -4
- package/dist/esm/_virtual/index13.js.map +0 -1
- package/dist/esm/_virtual/index14.js +0 -4
- package/dist/esm/_virtual/index14.js.map +0 -1
- package/dist/esm/_virtual/index15.js +0 -4
- package/dist/esm/_virtual/index15.js.map +0 -1
- package/dist/esm/_virtual/index2.js +0 -4
- package/dist/esm/_virtual/index2.js.map +0 -1
- package/dist/esm/_virtual/index3.js +0 -4
- package/dist/esm/_virtual/index3.js.map +0 -1
- package/dist/esm/_virtual/index4.js +0 -7
- package/dist/esm/_virtual/index4.js.map +0 -1
- package/dist/esm/_virtual/index5.js +0 -7
- package/dist/esm/_virtual/index5.js.map +0 -1
- package/dist/esm/_virtual/index6.js +0 -7
- package/dist/esm/_virtual/index6.js.map +0 -1
- package/dist/esm/_virtual/index7.js +0 -7
- package/dist/esm/_virtual/index7.js.map +0 -1
- package/dist/esm/_virtual/index8.js +0 -7
- package/dist/esm/_virtual/index8.js.map +0 -1
- package/dist/esm/_virtual/index9.js +0 -7
- package/dist/esm/_virtual/index9.js.map +0 -1
- package/dist/esm/_virtual/interopRequireDefault.js +0 -4
- package/dist/esm/_virtual/interopRequireDefault.js.map +0 -1
- package/dist/esm/_virtual/isBetween.js +0 -4
- package/dist/esm/_virtual/isBetween.js.map +0 -1
- package/dist/esm/_virtual/jsx-runtime.js +0 -4
- package/dist/esm/_virtual/jsx-runtime.js.map +0 -1
- package/dist/esm/_virtual/localizedFormat.js +0 -4
- package/dist/esm/_virtual/localizedFormat.js.map +0 -1
- package/dist/esm/_virtual/lodash.js +0 -4
- package/dist/esm/_virtual/lodash.js.map +0 -1
- package/dist/esm/_virtual/lottie.js +0 -4
- package/dist/esm/_virtual/lottie.js.map +0 -1
- package/dist/esm/_virtual/numeral.js +0 -4
- package/dist/esm/_virtual/numeral.js.map +0 -1
- package/dist/esm/_virtual/objectWithoutPropertiesLoose.js +0 -4
- package/dist/esm/_virtual/objectWithoutPropertiesLoose.js.map +0 -1
- package/dist/esm/_virtual/react-is.development.js +0 -4
- package/dist/esm/_virtual/react-is.development.js.map +0 -1
- package/dist/esm/_virtual/react-is.development2.js +0 -4
- package/dist/esm/_virtual/react-is.development2.js.map +0 -1
- package/dist/esm/_virtual/react-is.development3.js +0 -4
- package/dist/esm/_virtual/react-is.development3.js.map +0 -1
- package/dist/esm/_virtual/react-is.production.js +0 -4
- package/dist/esm/_virtual/react-is.production.js.map +0 -1
- package/dist/esm/_virtual/react-is.production.min.js +0 -4
- package/dist/esm/_virtual/react-is.production.min.js.map +0 -1
- package/dist/esm/_virtual/react-is.production.min2.js +0 -4
- package/dist/esm/_virtual/react-is.production.min2.js.map +0 -1
- package/dist/esm/_virtual/react-jsx-runtime.development.js +0 -4
- package/dist/esm/_virtual/react-jsx-runtime.development.js.map +0 -1
- package/dist/esm/_virtual/react-jsx-runtime.production.min.js +0 -4
- package/dist/esm/_virtual/react-jsx-runtime.production.min.js.map +0 -1
- package/dist/esm/_virtual/timezone.js +0 -4
- package/dist/esm/_virtual/timezone.js.map +0 -1
- package/dist/esm/_virtual/use-sync-external-store-shim.development.js +0 -4
- package/dist/esm/_virtual/use-sync-external-store-shim.development.js.map +0 -1
- package/dist/esm/_virtual/use-sync-external-store-shim.production.js +0 -4
- package/dist/esm/_virtual/use-sync-external-store-shim.production.js.map +0 -1
- package/dist/esm/_virtual/useThemeWithoutDefault.js +0 -4
- package/dist/esm/_virtual/useThemeWithoutDefault.js.map +0 -1
- package/dist/esm/_virtual/utc.js +0 -4
- package/dist/esm/_virtual/utc.js.map +0 -1
- package/dist/esm/_virtual/weekOfYear.js +0 -4
- package/dist/esm/_virtual/weekOfYear.js.map +0 -1
- package/dist/esm/utils/data/order.js +0 -8
- package/dist/esm/utils/data/order.js.map +0 -1
- package/dist/index.cjs.js +0 -90295
- package/dist/index.cjs.js.map +0 -1
- package/dist/index.esm.js +0 -90275
- package/dist/index.esm.js.map +0 -1
- package/dist/types/hooks/data/useShoppingCart.d.ts +0 -8
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"gtm.js","sources":["../../../src/utils/gtm.ts"],"sourcesContent":["import { isBrowser } from '@utils/isBrowser';\nimport Cookies from 'js-cookie';\nimport {\n IPageView,\n IPageType,\n ISearchShow,\n IViewItem,\n IEcommerce,\n ICheckout,\n IEcommerceCartItems,\n IAddPaymentInfo,\n IPurchase,\n IEcommercePurchase,\n IUserData,\n IPixels,\n IViewItemList,\n ISelectItem,\n IAddToCart,\n IRemoveFromCart,\n} from '@utils/types/gtm.type';\nimport { UserIpCookie } from '@utils/data/cookie';\nimport { IUser } from '@utils/types/user.type';\n\nexport const getGtmPageView = (url: string, userData?: IUserData) => {\n const userIp = Cookies.get(UserIpCookie);\n const pageEvent: IPageView = {\n event: 'page_view',\n page: url,\n ip: userIp || '',\n user_data: userData || null,\n };\n\n return pageEvent;\n};\n\nexport const gtmPageView = (url: string, userData?: IUserData) => {\n const pageEvent = getGtmPageView(url, userData);\n if (isBrowser() && window.dataLayer) window.dataLayer.push(pageEvent);\n return pageEvent;\n};\n\nexport const gtmPageType = (type: string) => {\n const cookie = Cookies.get('_ga');\n const userIp = Cookies.get(UserIpCookie);\n const pageEvent: IPageType = {\n visitorType: cookie ? 'returning' : 'new',\n clientID: cookie,\n pageType: type,\n ip: userIp || '',\n };\n if (isBrowser() && window.dataLayer) window.dataLayer.push(pageEvent);\n return pageEvent;\n};\n\nexport const gtmSearchShow = () => {\n const userIp = Cookies.get(UserIpCookie);\n const pageEvent: ISearchShow = {\n event: 'search',\n eventAction: 'showSearchWindow',\n ip: userIp || '',\n };\n if (isBrowser() && window.dataLayer) window.dataLayer.push(pageEvent);\n return pageEvent;\n};\n\nexport const gtmSearchInSearchWindow = () => {\n const userIp = Cookies.get(UserIpCookie);\n const pageEvent: ISearchShow = {\n event: 'search',\n eventAction: 'userSearchInSearchWindow',\n ip: userIp || '',\n };\n if (isBrowser() && window.dataLayer) window.dataLayer.push(pageEvent);\n return pageEvent;\n};\n\nexport const gtmViewItem = (item: IEcommerce, pixels?: IPixels, userData?: IUserData) => {\n const userIp = Cookies.get(UserIpCookie);\n const pageEvent: IViewItem & IPixels = {\n event: 'view_item',\n fb_pixel_id: pixels?.fb_pixel_id || '',\n tiktok_pixel_id: pixels?.tiktok_pixel_id || '',\n ecommerce: item,\n ip: userIp || '',\n user_data: userData || null,\n };\n if (isBrowser() && window.dataLayer) setTimeout(() => window.dataLayer.push(pageEvent), 500);\n return pageEvent;\n};\n\nexport const gtmViewItemList = () => {\n const userIp = Cookies.get(UserIpCookie);\n const pageEvent: IViewItemList = {\n event: 'view_item_list',\n ip: userIp || '',\n };\n if (isBrowser() && window.dataLayer) setTimeout(() => window.dataLayer.push(pageEvent), 500);\n return pageEvent;\n};\n\nexport const gtmSelectItem = () => {\n const userIp = Cookies.get(UserIpCookie);\n const pageEvent: ISelectItem = {\n event: 'select_item',\n ip: userIp || '',\n };\n if (isBrowser() && window.dataLayer) window.dataLayer.push(pageEvent);\n return pageEvent;\n};\n\nexport const getGtmBeginCheckout = (item: IEcommerce, pixels?: IPixels, userData?: IUserData) => {\n const userIp = Cookies.get(UserIpCookie);\n const pageEvent: ICheckout & IPixels = {\n event: 'begin_checkout',\n fb_pixel_id: pixels?.fb_pixel_id || '',\n tiktok_pixel_id: pixels?.tiktok_pixel_id || '',\n ecommerce: item,\n ip: userIp || '',\n user_data: userData || null,\n };\n\n return pageEvent;\n};\n\nexport const gtmBeginCheckout = (item: IEcommerce, pixels?: IPixels, userData?: IUserData) => {\n const pageEvent = getGtmBeginCheckout(item, pixels, userData);\n if (isBrowser() && window.dataLayer) window.dataLayer.push(pageEvent);\n return pageEvent;\n};\n\nexport const getGtmViewCart = (item: IEcommerce, pixels?: IPixels) => {\n const userIp = Cookies.get(UserIpCookie);\n const pageEvent: ICheckout & IPixels = {\n event: 'view_cart',\n fb_pixel_id: pixels?.fb_pixel_id || '',\n tiktok_pixel_id: pixels?.tiktok_pixel_id || '',\n ecommerce: item,\n ip: userIp || '',\n };\n\n return pageEvent;\n};\n\nexport const gtmViewCart = (item: IEcommerce, pixels?: IPixels) => {\n const pageEvent = getGtmViewCart(item, pixels);\n if (isBrowser() && window.dataLayer) setTimeout(() => window.dataLayer.push(pageEvent), 500);\n return pageEvent;\n};\n\nexport const gtmAddToCart = (pixels?: IPixels, userData?: IUserData) => {\n const userIp = Cookies.get(UserIpCookie);\n const pageEvent: IAddToCart & IPixels = {\n event: 'add_to_cart',\n fb_pixel_id: pixels?.fb_pixel_id || '',\n tiktok_pixel_id: pixels?.tiktok_pixel_id || '',\n ip: userIp || '',\n user_data: userData || null,\n };\n if (isBrowser() && window.dataLayer) window.dataLayer.push(pageEvent);\n return pageEvent;\n};\n\nexport const gtmRemoveFromCart = (item: IEcommerceCartItems, pixels?: IPixels) => {\n const userIp = Cookies.get(UserIpCookie);\n const pageEvent: IRemoveFromCart & IPixels = {\n event: 'remove_from_cart',\n fb_pixel_id: pixels?.fb_pixel_id || '',\n tiktok_pixel_id: pixels?.tiktok_pixel_id || '',\n ecommerce: item,\n ip: userIp || '',\n };\n if (isBrowser() && window.dataLayer) window.dataLayer.push(pageEvent);\n return pageEvent;\n};\n\nexport const getGtmAddPaymentInfo = (\n item: IEcommerceCartItems,\n pixels?: IPixels,\n userData?: IUserData\n) => {\n const userIp = Cookies.get(UserIpCookie);\n const pageEvent: IAddPaymentInfo & IPixels = {\n event: 'add_payment_info',\n fb_pixel_id: pixels?.fb_pixel_id || '',\n tiktok_pixel_id: pixels?.tiktok_pixel_id || '',\n ecommerce: item,\n ip: userIp || '',\n user_data: userData || null,\n };\n\n return pageEvent;\n};\n\nexport const gtmAddPaymentInfo = (item: IEcommerceCartItems, pixels?: IPixels) => {\n const pageEvent = getGtmAddPaymentInfo(item, pixels);\n if (isBrowser() && window.dataLayer) setTimeout(() => window.dataLayer.push(pageEvent), 500);\n return pageEvent;\n};\n\nexport const getGtmPurchase = (\n item: IEcommercePurchase | null,\n pixels?: IPixels,\n userData?: IUserData\n) => {\n const userIp = Cookies.get(UserIpCookie);\n const pageEvent: IPurchase & IPixels = {\n event: 'purchase',\n fb_pixel_id: pixels?.fb_pixel_id || '',\n tiktok_pixel_id: pixels?.tiktok_pixel_id || '',\n ecommerce: item,\n user_data: userData || null,\n ip: userIp || '',\n };\n\n return pageEvent;\n};\n\nexport const gtmPurchase = (\n item: IEcommercePurchase | null,\n pixels?: IPixels,\n userData?: IUserData\n) => {\n const pageEvent = getGtmPurchase(item, pixels, userData);\n if (isBrowser() && window.dataLayer) setTimeout(() => window.dataLayer.push(pageEvent), 500);\n return pageEvent;\n};\n\nexport const mapUserToUserData = (user: IUser) => ({\n em: user.email,\n ph: user.phone,\n ln: user.lastName,\n fn: user.firstName,\n});\n"],"names":[],"mappings":";;;;MAuBa,cAAc,GAAG,CAAC,GAAW,EAAE,QAAoB,KAAI;IAClE,MAAM,MAAM,GAAG,OAAO,CAAC,GAAG,CAAC,YAAY,CAAC;AACxC,IAAA,MAAM,SAAS,GAAc;AAC3B,QAAA,KAAK,EAAE,WAAW;AAClB,QAAA,IAAI,EAAE,GAAG;QACT,EAAE,EAAE,MAAM,IAAI,EAAE;QAChB,SAAS,EAAE,QAAQ,IAAI,IAAI;KAC5B;AAED,IAAA,OAAO,SAAS;AAClB;AA6EO,MAAM,mBAAmB,GAAG,CAAC,IAAgB,EAAE,MAAgB,EAAE,QAAoB,KAAI;IAC9F,MAAM,MAAM,GAAG,OAAO,CAAC,GAAG,CAAC,YAAY,CAAC;AACxC,IAAA,MAAM,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,GAAG,CACzB,IAA+B,EAC/B,MAAgB,EAChB,QAAoB,KAClB;IACF,MAAM,SAAS,GAAG,cAAc,CAAC,IAAI,EAAE,MAAM,EAAE,QAAQ,CAAC;AACxD,IAAA,IAAI,SAAS,EAAE,IAAI,MAAM,CAAC,SAAS;AAAE,QAAA,UAAU,CAAC,MAAM,MAAM,CAAC,SAAS,CAAC,IAAI,CAAC,SAAS,CAAC,EAAE,GAAG,CAAC;AAC5F,IAAA,OAAO,SAAS;AAClB;MAEa,iBAAiB,GAAG,CAAC,IAAW,MAAM;IACjD,EAAE,EAAE,IAAI,CAAC,KAAK;IACd,EAAE,EAAE,IAAI,CAAC,KAAK;IACd,EAAE,EAAE,IAAI,CAAC,QAAQ;IACjB,EAAE,EAAE,IAAI,CAAC,SAAS;AACnB,CAAA;;;;"}
|
|
1
|
+
{"version":3,"file":"gtm.js","sources":["../../../src/utils/gtm.ts"],"sourcesContent":["import { isBrowser } from '@utils/isBrowser';\nimport Cookies from 'js-cookie';\nimport {\n IPageView,\n IPageType,\n ISearchShow,\n IViewItem,\n IEcommerce,\n ICheckout,\n IEcommerceCartItems,\n IAddPaymentInfo,\n IPurchase,\n IEcommercePurchase,\n IUserData,\n IPixels,\n IViewItemList,\n ISelectItem,\n IAddToCart,\n IRemoveFromCart,\n IPurchasePaid,\n} from '@utils/types/gtm.type';\nimport { UserIpCookie } from '@utils/data/cookie';\nimport { IUser } from '@utils/types/user.type';\n\nexport const getGtmPageView = (url: string, userData?: IUserData) => {\n const userIp = Cookies.get(UserIpCookie);\n const pageEvent: IPageView = {\n event: 'page_view',\n page: url,\n ip: userIp || '',\n user_data: userData || null,\n };\n\n return pageEvent;\n};\n\nexport const gtmPageView = (url: string, userData?: IUserData) => {\n const pageEvent = getGtmPageView(url, userData);\n if (isBrowser() && window.dataLayer) window.dataLayer.push(pageEvent);\n return pageEvent;\n};\n\nexport const gtmPageType = (type: string) => {\n const cookie = Cookies.get('_ga');\n const userIp = Cookies.get(UserIpCookie);\n const pageEvent: IPageType = {\n visitorType: cookie ? 'returning' : 'new',\n clientID: cookie,\n pageType: type,\n ip: userIp || '',\n };\n if (isBrowser() && window.dataLayer) window.dataLayer.push(pageEvent);\n return pageEvent;\n};\n\nexport const gtmSearchShow = () => {\n const userIp = Cookies.get(UserIpCookie);\n const pageEvent: ISearchShow = {\n event: 'search',\n eventAction: 'showSearchWindow',\n ip: userIp || '',\n };\n if (isBrowser() && window.dataLayer) window.dataLayer.push(pageEvent);\n return pageEvent;\n};\n\nexport const gtmSearchInSearchWindow = () => {\n const userIp = Cookies.get(UserIpCookie);\n const pageEvent: ISearchShow = {\n event: 'search',\n eventAction: 'userSearchInSearchWindow',\n ip: userIp || '',\n };\n if (isBrowser() && window.dataLayer) window.dataLayer.push(pageEvent);\n return pageEvent;\n};\n\nexport const gtmViewItem = (item: IEcommerce, pixels?: IPixels, userData?: IUserData) => {\n const userIp = Cookies.get(UserIpCookie);\n const pageEvent: IViewItem & IPixels = {\n event: 'view_item',\n fb_pixel_id: pixels?.fb_pixel_id || '',\n tiktok_pixel_id: pixels?.tiktok_pixel_id || '',\n ecommerce: item,\n ip: userIp || '',\n user_data: userData || null,\n };\n if (isBrowser() && window.dataLayer) setTimeout(() => window.dataLayer.push(pageEvent), 500);\n return pageEvent;\n};\n\nexport const gtmViewItemList = () => {\n const userIp = Cookies.get(UserIpCookie);\n const pageEvent: IViewItemList = {\n event: 'view_item_list',\n ip: userIp || '',\n };\n if (isBrowser() && window.dataLayer) setTimeout(() => window.dataLayer.push(pageEvent), 500);\n return pageEvent;\n};\n\nexport const gtmSelectItem = () => {\n const userIp = Cookies.get(UserIpCookie);\n const pageEvent: ISelectItem = {\n event: 'select_item',\n ip: userIp || '',\n };\n if (isBrowser() && window.dataLayer) window.dataLayer.push(pageEvent);\n return pageEvent;\n};\n\nexport const getGtmBeginCheckout = (item: IEcommerce, pixels?: IPixels, userData?: IUserData) => {\n const userIp = Cookies.get(UserIpCookie);\n const pageEvent: ICheckout & IPixels = {\n event: 'begin_checkout',\n fb_pixel_id: pixels?.fb_pixel_id || '',\n tiktok_pixel_id: pixels?.tiktok_pixel_id || '',\n ecommerce: item,\n ip: userIp || '',\n user_data: userData || null,\n };\n\n return pageEvent;\n};\n\nexport const gtmBeginCheckout = (item: IEcommerce, pixels?: IPixels, userData?: IUserData) => {\n const pageEvent = getGtmBeginCheckout(item, pixels, userData);\n if (isBrowser() && window.dataLayer) window.dataLayer.push(pageEvent);\n return pageEvent;\n};\n\nexport const getGtmViewCart = (item: IEcommerce, pixels?: IPixels) => {\n const userIp = Cookies.get(UserIpCookie);\n const pageEvent: ICheckout & IPixels = {\n event: 'view_cart',\n fb_pixel_id: pixels?.fb_pixel_id || '',\n tiktok_pixel_id: pixels?.tiktok_pixel_id || '',\n ecommerce: item,\n ip: userIp || '',\n };\n\n return pageEvent;\n};\n\nexport const gtmViewCart = (item: IEcommerce, pixels?: IPixels) => {\n const pageEvent = getGtmViewCart(item, pixels);\n if (isBrowser() && window.dataLayer) setTimeout(() => window.dataLayer.push(pageEvent), 500);\n return pageEvent;\n};\n\nexport const gtmAddToCart = (pixels?: IPixels, userData?: IUserData) => {\n const userIp = Cookies.get(UserIpCookie);\n const pageEvent: IAddToCart & IPixels = {\n event: 'add_to_cart',\n fb_pixel_id: pixels?.fb_pixel_id || '',\n tiktok_pixel_id: pixels?.tiktok_pixel_id || '',\n ip: userIp || '',\n user_data: userData || null,\n };\n if (isBrowser() && window.dataLayer) window.dataLayer.push(pageEvent);\n return pageEvent;\n};\n\nexport const gtmRemoveFromCart = (item: IEcommerceCartItems, pixels?: IPixels) => {\n const userIp = Cookies.get(UserIpCookie);\n const pageEvent: IRemoveFromCart & IPixels = {\n event: 'remove_from_cart',\n fb_pixel_id: pixels?.fb_pixel_id || '',\n tiktok_pixel_id: pixels?.tiktok_pixel_id || '',\n ecommerce: item,\n ip: userIp || '',\n };\n if (isBrowser() && window.dataLayer) window.dataLayer.push(pageEvent);\n return pageEvent;\n};\n\nexport const getGtmAddPaymentInfo = (\n item: IEcommerceCartItems,\n pixels?: IPixels,\n userData?: IUserData\n) => {\n const userIp = Cookies.get(UserIpCookie);\n const pageEvent: IAddPaymentInfo & IPixels = {\n event: 'add_payment_info',\n fb_pixel_id: pixels?.fb_pixel_id || '',\n tiktok_pixel_id: pixels?.tiktok_pixel_id || '',\n ecommerce: item,\n ip: userIp || '',\n user_data: userData || null,\n };\n\n return pageEvent;\n};\n\nexport const gtmAddPaymentInfo = (item: IEcommerceCartItems, pixels?: IPixels) => {\n const pageEvent = getGtmAddPaymentInfo(item, pixels);\n if (isBrowser() && window.dataLayer) setTimeout(() => window.dataLayer.push(pageEvent), 500);\n return pageEvent;\n};\n\nexport const getGtmPurchase = (\n item: IEcommercePurchase | null,\n pixels?: IPixels,\n userData?: IUserData\n) => {\n const userIp = Cookies.get(UserIpCookie);\n const pageEvent: IPurchase & IPixels = {\n event: 'purchase',\n fb_pixel_id: pixels?.fb_pixel_id || '',\n tiktok_pixel_id: pixels?.tiktok_pixel_id || '',\n ecommerce: item,\n user_data: userData || null,\n ip: userIp || '',\n };\n\n return pageEvent;\n};\n\nexport const gtmPurchase = (\n item: IEcommercePurchase | null,\n pixels?: IPixels,\n userData?: IUserData\n) => {\n const pageEvent = getGtmPurchase(item, pixels, userData);\n if (isBrowser() && window.dataLayer) setTimeout(() => window.dataLayer.push(pageEvent), 500);\n return pageEvent;\n};\n\nexport const getGtmPurchasePaid = (\n item: IEcommercePurchase | null,\n pixels?: IPixels,\n userData?: IUserData\n) => {\n const userIp = Cookies.get(UserIpCookie);\n const pageEvent: IPurchasePaid & IPixels = {\n event: 'purchase_paid',\n fb_pixel_id: pixels?.fb_pixel_id || '',\n tiktok_pixel_id: pixels?.tiktok_pixel_id || '',\n ecommerce: item,\n user_data: userData || null,\n ip: userIp || '',\n };\n\n return pageEvent;\n};\n\nexport const gtmPurchasePaid = (\n item: IEcommercePurchase | null,\n pixels?: IPixels,\n userData?: IUserData\n) => {\n const pageEvent = getGtmPurchasePaid(item, pixels, userData);\n if (isBrowser() && window.dataLayer) setTimeout(() => window.dataLayer.push(pageEvent), 500);\n return pageEvent;\n};\n\nexport const mapUserToUserData = (user: IUser) => ({\n em: user.email,\n ph: user.phone,\n ln: user.lastName,\n fn: user.firstName,\n});\n"],"names":[],"mappings":";;;;MAwBa,cAAc,GAAG,CAAC,GAAW,EAAE,QAAoB,KAAI;IAClE,MAAM,MAAM,GAAG,OAAO,CAAC,GAAG,CAAC,YAAY,CAAC;AACxC,IAAA,MAAM,SAAS,GAAc;AAC3B,QAAA,KAAK,EAAE,WAAW;AAClB,QAAA,IAAI,EAAE,GAAG;QACT,EAAE,EAAE,MAAM,IAAI,EAAE;QAChB,SAAS,EAAE,QAAQ,IAAI,IAAI;KAC5B;AAED,IAAA,OAAO,SAAS;AAClB;AA6EO,MAAM,mBAAmB,GAAG,CAAC,IAAgB,EAAE,MAAgB,EAAE,QAAoB,KAAI;IAC9F,MAAM,MAAM,GAAG,OAAO,CAAC,GAAG,CAAC,YAAY,CAAC;AACxC,IAAA,MAAM,SAAS,GAAwB;AACrC,QAAA,KAAK,EAAE,gBAAgB;AACvB,QAAA,WAAW,EAAE,MAAM,EAAE,WAAW,IAAI,EAAE;AACtC,QAAA,eAAe,EAAE,MAAM,EAAE,eAAe,IAAI,EAAE;AAC9C,QAAA,SAAS,EAAE,IAAI;QACf,EAAE,EAAE,MAAM,IAAI,EAAE;QAChB,SAAS,EAAE,QAAQ,IAAI,IAAI;KAC5B;AAED,IAAA,OAAO,SAAS;AAClB;AAEO,MAAM,gBAAgB,GAAG,CAAC,IAAgB,EAAE,MAAgB,EAAE,QAAoB,KAAI;IAC3F,MAAM,SAAS,GAAG,mBAAmB,CAAC,IAAI,EAAE,MAAM,EAAE,QAAQ,CAAC;AAC7D,IAAA,IAAI,SAAS,EAAE,IAAI,MAAM,CAAC,SAAS;AAAE,QAAA,MAAM,CAAC,SAAS,CAAC,IAAI,CAAC,SAAS,CAAC;AACrE,IAAA,OA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,EAAE,MAAM,EAAE,eAAe,IAAI,EAAE;AAC9C,QAAA,SAAS,EAAE,IAAI;QACf,SAAS,EAAE,QAAQ,IAAI,IAAI;QAC3B,EAAE,EAAE,MAAM,IAAI,EAAE;KACjB;AAED,IAAA,OAAO,SAAS;AAClB;AAEO,MAAM,eAAe,GAAG,CAC7B,IAA+B,EAC/B,MAAgB,EAChB,QAAoB,KAClB;IACF,MAAM,SAAS,GAAG,kBAAkB,CAAC,IAAI,EAAE,MAAM,EAAE,QAAQ,CAAC;AAC5D,IAAA,IAAI,SAAS,EAAE,IAAI,MAAM,CAAC,SAAS;AAAE,QAAA,UAAU,CAAC,MAAM,MAAM,CAAC,SAAS,CAAC,IAAI,CAAC,SAAS,CAAC,EAAE,GAAG,CAAC;AAC5F,IAAA,OAAO,SAAS;AAClB;MAEa,iBAAiB,GAAG,CAAC,IAAW,MAAM;IACjD,EAAE,EAAE,IAAI,CAAC,KAAK;IACd,EAAE,EAAE,IAAI,CAAC,KAAK;IACd,EAAE,EAAE,IAAI,CAAC,QAAQ;IACjB,EAAE,EAAE,IAAI,CAAC,SAAS;AACnB,CAAA;;;;"}
|
|
@@ -10,6 +10,7 @@ type Props = {
|
|
|
10
10
|
showSnackbar?: IGlobalContext['showSnackbar'];
|
|
11
11
|
options?: IGlobalContext['options'];
|
|
12
12
|
content?: IGlobalContext['content'];
|
|
13
|
+
seatingIframeUrl?: IGlobalContext['seatingIframeUrl'];
|
|
13
14
|
};
|
|
14
|
-
declare function GlobalProvider({ children, lang, showSnackbar, callbacks, links, options, content, }: Props): React.JSX.Element;
|
|
15
|
+
declare function GlobalProvider({ children, lang, showSnackbar, callbacks, links, options, content, seatingIframeUrl, }: Props): React.JSX.Element;
|
|
15
16
|
export { GlobalProvider, GlobalContext };
|
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
import React, { Dispatch, SetStateAction } from 'react';
|
|
2
|
+
import { IPixels } from '@utils/types/gtm.type.ts';
|
|
2
3
|
interface Props {
|
|
3
4
|
setIsPaying: Dispatch<SetStateAction<boolean>>;
|
|
4
5
|
isIframe?: boolean;
|
|
6
|
+
pixels?: IPixels;
|
|
5
7
|
}
|
|
6
8
|
declare const PaymentSuccess: React.FC<Props>;
|
|
7
9
|
export default PaymentSuccess;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { IPageView, IPageType, ISearchShow, IViewItem, IEcommerce, ICheckout, IEcommerceCartItems, IAddPaymentInfo, IPurchase, IEcommercePurchase, IUserData, IPixels, IViewItemList, ISelectItem, IAddToCart, IRemoveFromCart } from '@utils/types/gtm.type';
|
|
1
|
+
import { IPageView, IPageType, ISearchShow, IViewItem, IEcommerce, ICheckout, IEcommerceCartItems, IAddPaymentInfo, IPurchase, IEcommercePurchase, IUserData, IPixels, IViewItemList, ISelectItem, IAddToCart, IRemoveFromCart, IPurchasePaid } from '@utils/types/gtm.type';
|
|
2
2
|
import { IUser } from '@utils/types/user.type';
|
|
3
3
|
export declare const getGtmPageView: (url: string, userData?: IUserData) => IPageView;
|
|
4
4
|
export declare const gtmPageView: (url: string, userData?: IUserData) => IPageView;
|
|
@@ -18,6 +18,8 @@ export declare const getGtmAddPaymentInfo: (item: IEcommerceCartItems, pixels?:
|
|
|
18
18
|
export declare const gtmAddPaymentInfo: (item: IEcommerceCartItems, pixels?: IPixels) => IAddPaymentInfo & IPixels;
|
|
19
19
|
export declare const getGtmPurchase: (item: IEcommercePurchase | null, pixels?: IPixels, userData?: IUserData) => IPurchase & IPixels;
|
|
20
20
|
export declare const gtmPurchase: (item: IEcommercePurchase | null, pixels?: IPixels, userData?: IUserData) => IPurchase & IPixels;
|
|
21
|
+
export declare const getGtmPurchasePaid: (item: IEcommercePurchase | null, pixels?: IPixels, userData?: IUserData) => IPurchasePaid & IPixels;
|
|
22
|
+
export declare const gtmPurchasePaid: (item: IEcommercePurchase | null, pixels?: IPixels, userData?: IUserData) => IPurchasePaid & IPixels;
|
|
21
23
|
export declare const mapUserToUserData: (user: IUser) => {
|
|
22
24
|
em: string;
|
|
23
25
|
ph: string;
|
|
@@ -78,6 +78,11 @@ export interface IPurchase extends IBase {
|
|
|
78
78
|
ecommerce: IEcommercePurchase | null;
|
|
79
79
|
user_data: IUserData | null;
|
|
80
80
|
}
|
|
81
|
+
export interface IPurchasePaid extends IBase {
|
|
82
|
+
event: 'purchase_paid';
|
|
83
|
+
ecommerce: IEcommercePurchase | null;
|
|
84
|
+
user_data: IUserData | null;
|
|
85
|
+
}
|
|
81
86
|
export interface IPixels {
|
|
82
87
|
fb_pixel_id?: number | string;
|
|
83
88
|
tiktok_pixel_id?: number | string;
|
|
@@ -31,13 +31,25 @@ export interface ITicketFormTicket {
|
|
|
31
31
|
products: IEventProductForm[];
|
|
32
32
|
extraFields: IExtraFieldForm[][];
|
|
33
33
|
eventTimeslotId?: number | null;
|
|
34
|
+
location?: ITicketLocation | null;
|
|
34
35
|
}
|
|
36
|
+
export interface ITicketLocation {
|
|
37
|
+
id: string;
|
|
38
|
+
type: string;
|
|
39
|
+
locationDescription?: {
|
|
40
|
+
type: BaseLocationDescriptionType | 'custom';
|
|
41
|
+
label: string;
|
|
42
|
+
value: string;
|
|
43
|
+
}[] | null;
|
|
44
|
+
}
|
|
45
|
+
type BaseLocationDescriptionType = 'seatNumber' | 'rowNumber' | 'sectionName';
|
|
46
|
+
export type EventTicketsType = {
|
|
47
|
+
[eventId: string]: ITicketFormTicket[];
|
|
48
|
+
};
|
|
35
49
|
export interface ITicketForm {
|
|
36
50
|
uuid?: string | null;
|
|
37
51
|
eventId: number;
|
|
38
|
-
tickets:
|
|
39
|
-
[eventId: string]: ITicketFormTicket[];
|
|
40
|
-
};
|
|
52
|
+
tickets: EventTicketsType;
|
|
41
53
|
total: number;
|
|
42
54
|
originalPrice: number;
|
|
43
55
|
firstName: string;
|
|
@@ -92,3 +104,4 @@ export interface ICreateTicket {
|
|
|
92
104
|
price: number;
|
|
93
105
|
number: string;
|
|
94
106
|
}
|
|
107
|
+
export {};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@eventlook/sdk",
|
|
3
|
-
"version": "1.4.
|
|
3
|
+
"version": "1.4.20",
|
|
4
4
|
"main": "dist/cjs/index.js",
|
|
5
5
|
"module": "dist/esm/index.js",
|
|
6
6
|
"types": "dist/types/index.d.ts",
|
|
@@ -15,9 +15,13 @@
|
|
|
15
15
|
"scripts": {
|
|
16
16
|
"build": "rollup -c && tsc -p tsconfig.build.json",
|
|
17
17
|
"prepare": "yarn run build",
|
|
18
|
+
"push": "yalc push --force",
|
|
19
|
+
"push:initial": "yarn build && yalc push --force",
|
|
18
20
|
"watch:rollup": "rollup -c -w",
|
|
19
|
-
"watch:
|
|
20
|
-
"
|
|
21
|
+
"watch:types": "tsc -p tsconfig.build.json --watch",
|
|
22
|
+
"watch:push": "chokidar 'dist/**/*' -c 'yalc push --changed --force'",
|
|
23
|
+
"dev": "concurrently --kill-others-on-fail --kill-others \"yarn watch:rollup\" \"yarn watch:types\" \"yarn watch:push\"",
|
|
24
|
+
"dev:simple": "concurrently --kill-others-on-fail \"yarn watch:rollup\" \"yarn watch:types\"",
|
|
21
25
|
"publish": "npm publish",
|
|
22
26
|
"lint:fix": "eslint --fix --ext .ts,.tsx .",
|
|
23
27
|
"prettier": "prettier --write 'src/**/*.{js,jsx,ts,tsx}'",
|
|
@@ -61,6 +65,7 @@
|
|
|
61
65
|
"@rollup/plugin-node-resolve": "^15.0.0",
|
|
62
66
|
"@rollup/plugin-replace": "^6.0.2",
|
|
63
67
|
"@rollup/plugin-typescript": "^11.0.0",
|
|
68
|
+
"@seat-picker/seat-picker-sdk": "^1.0.5",
|
|
64
69
|
"@types/js-cookie": "^3.0.6",
|
|
65
70
|
"@types/lodash": "^4.17.20",
|
|
66
71
|
"@types/numeral": "^2.0.5",
|
package/rollup.config.mjs
CHANGED
|
@@ -52,5 +52,19 @@ export default {
|
|
|
52
52
|
},
|
|
53
53
|
}),
|
|
54
54
|
],
|
|
55
|
-
external: [
|
|
55
|
+
external: [
|
|
56
|
+
'react',
|
|
57
|
+
'react-dom',
|
|
58
|
+
'fs',
|
|
59
|
+
'path',
|
|
60
|
+
'http',
|
|
61
|
+
'https',
|
|
62
|
+
'stream',
|
|
63
|
+
'swr',
|
|
64
|
+
'mui-tel-input',
|
|
65
|
+
'@seat-picker/seat-picker-sdk',
|
|
66
|
+
'@mui/material',
|
|
67
|
+
'@emotion/react',
|
|
68
|
+
'@emotion/styled',
|
|
69
|
+
],
|
|
56
70
|
};
|
|
@@ -30,6 +30,7 @@ type Props = {
|
|
|
30
30
|
showSnackbar?: IGlobalContext['showSnackbar'];
|
|
31
31
|
options?: IGlobalContext['options'];
|
|
32
32
|
content?: IGlobalContext['content'];
|
|
33
|
+
seatingIframeUrl?: IGlobalContext['seatingIframeUrl'];
|
|
33
34
|
};
|
|
34
35
|
|
|
35
36
|
function GlobalProvider({
|
|
@@ -40,6 +41,7 @@ function GlobalProvider({
|
|
|
40
41
|
links,
|
|
41
42
|
options,
|
|
42
43
|
content,
|
|
44
|
+
seatingIframeUrl,
|
|
43
45
|
}: Props) {
|
|
44
46
|
const [global, setGlobal] = useState<IGlobalContext>({
|
|
45
47
|
...initialState,
|
|
@@ -49,6 +51,7 @@ function GlobalProvider({
|
|
|
49
51
|
links,
|
|
50
52
|
options,
|
|
51
53
|
content,
|
|
54
|
+
seatingIframeUrl,
|
|
52
55
|
});
|
|
53
56
|
|
|
54
57
|
const handleSetGlobal = (value: Partial<IGlobalContext>) => {
|
|
@@ -9,20 +9,23 @@ import { PropsWithChildren } from '@utils/types/global.type';
|
|
|
9
9
|
import { IPaidTicket } from '@utils/types/ticket.type';
|
|
10
10
|
import useResponsive from '@hooks/useResponsive';
|
|
11
11
|
import { getPlaceAsString } from '@utils/place';
|
|
12
|
-
import { fCurrency
|
|
12
|
+
import { fCurrency } from '@utils/formatNumber';
|
|
13
13
|
import { useTheme } from '@mui/material/styles';
|
|
14
14
|
import { IPaidProduct } from '@utils/types/product.type';
|
|
15
15
|
import dayjs from 'dayjs';
|
|
16
16
|
import useGlobal from '@hooks/useGlobal';
|
|
17
17
|
import { Trans } from '@components/Trans';
|
|
18
|
+
import { getGtmPurchasePaid, gtmPurchasePaid, mapUserToUserData } from '@utils/gtm.ts';
|
|
19
|
+
import { IPixels } from '@utils/types/gtm.type.ts';
|
|
18
20
|
|
|
19
21
|
interface Props {
|
|
20
22
|
setIsPaying: Dispatch<SetStateAction<boolean>>;
|
|
21
23
|
isIframe?: boolean;
|
|
24
|
+
pixels?: IPixels;
|
|
22
25
|
}
|
|
23
26
|
|
|
24
|
-
const PaymentSuccess: React.FC<Props> = ({ setIsPaying, isIframe }) => {
|
|
25
|
-
const { showSnackbar, t, lang, callbacks, content } = useGlobal();
|
|
27
|
+
const PaymentSuccess: React.FC<Props> = ({ setIsPaying, isIframe, pixels }) => {
|
|
28
|
+
const { showSnackbar, t, lang, callbacks, content, user } = useGlobal();
|
|
26
29
|
const theme = useTheme();
|
|
27
30
|
const defaultState = 'PROCESSING';
|
|
28
31
|
const errorState = 'ERROR';
|
|
@@ -53,9 +56,49 @@ const PaymentSuccess: React.FC<Props> = ({ setIsPaying, isIframe }) => {
|
|
|
53
56
|
setProducts(products);
|
|
54
57
|
setState(data.state);
|
|
55
58
|
setGwUrl(data.gwUrl);
|
|
59
|
+
|
|
60
|
+
const items = [
|
|
61
|
+
...data.tickets.map((ticket) => ({
|
|
62
|
+
item_id: ticket.number,
|
|
63
|
+
item_name: `${ticket.eventName} - ${ticket.releaseCategoryName} - ${ticket.releaseName}`,
|
|
64
|
+
price: ticket.price,
|
|
65
|
+
quantity: 1,
|
|
66
|
+
})),
|
|
67
|
+
];
|
|
68
|
+
if (data.extraFee) {
|
|
69
|
+
items.push({
|
|
70
|
+
item_id: 'service_fee',
|
|
71
|
+
item_name: `Service fee`,
|
|
72
|
+
price: data.extraFee,
|
|
73
|
+
quantity: 1,
|
|
74
|
+
});
|
|
75
|
+
}
|
|
76
|
+
const item = {
|
|
77
|
+
currency: data.currency,
|
|
78
|
+
value: data.totalPrice,
|
|
79
|
+
tax: 0,
|
|
80
|
+
payment_type: data.paymentType,
|
|
81
|
+
transaction_id: String(data.orderNumber),
|
|
82
|
+
coupon: data?.promoCodes?.map((p) => p.code) || [],
|
|
83
|
+
items,
|
|
84
|
+
};
|
|
85
|
+
|
|
56
86
|
switch (data.state) {
|
|
57
87
|
case GopayState.PAID:
|
|
58
88
|
setTitle('event.tickets.payment_success.paid.title');
|
|
89
|
+
if (isIframe) {
|
|
90
|
+
setTimeout(() => {
|
|
91
|
+
parent.postMessage(
|
|
92
|
+
{
|
|
93
|
+
type: 'eventlookFrameGtm',
|
|
94
|
+
item: getGtmPurchasePaid(item, pixels),
|
|
95
|
+
},
|
|
96
|
+
'*'
|
|
97
|
+
);
|
|
98
|
+
}, 1000);
|
|
99
|
+
} else {
|
|
100
|
+
gtmPurchasePaid(item, pixels, user ? mapUserToUserData(user) : undefined);
|
|
101
|
+
}
|
|
59
102
|
break;
|
|
60
103
|
default:
|
|
61
104
|
setTitle('event.tickets.payment_success.unpaid');
|
package/src/form/TicketForm.tsx
CHANGED
|
@@ -3,6 +3,7 @@ import PaymentSuccess from '@form/PaymentSuccess';
|
|
|
3
3
|
import FormProvider, { RHFCheckbox } from '@components/hook-form';
|
|
4
4
|
import {
|
|
5
5
|
Box,
|
|
6
|
+
Button,
|
|
6
7
|
Grid,
|
|
7
8
|
Link,
|
|
8
9
|
LinkProps,
|
|
@@ -55,6 +56,7 @@ import useGlobal from '@hooks/useGlobal';
|
|
|
55
56
|
import { Trans } from '@components/Trans';
|
|
56
57
|
import { EVENTLOOK_ORDER_FORM_ID } from '@utils/data/global.ts';
|
|
57
58
|
import ChildEventSection from './ChildEvents';
|
|
59
|
+
import TicketSelectionMap from '@form/TicketSelectionMap.tsx';
|
|
58
60
|
|
|
59
61
|
interface Props {
|
|
60
62
|
event: IEvent;
|
|
@@ -71,7 +73,8 @@ const TicketForm: React.FC<Props> = ({
|
|
|
71
73
|
isIframe,
|
|
72
74
|
isInline,
|
|
73
75
|
}) => {
|
|
74
|
-
const { t, setGlobal, callbacks, links, user, options, showSnackbar, content } =
|
|
76
|
+
const { t, setGlobal, callbacks, links, user, options, showSnackbar, content, seatingIframeUrl } =
|
|
77
|
+
useGlobal();
|
|
75
78
|
const { transformErrors } = useErrors(t('event.tickets.error.order'));
|
|
76
79
|
const { data: eventProducts, isLoading } = useActiveEventProducts(event.id);
|
|
77
80
|
const [paymentRedirect, setPaymentRedirect] = useState<string | null>(null);
|
|
@@ -333,6 +336,8 @@ const TicketForm: React.FC<Props> = ({
|
|
|
333
336
|
itemName: item.itemName,
|
|
334
337
|
products: item.products,
|
|
335
338
|
extraFields: item.extraFields,
|
|
339
|
+
eventTimeslotId: item.eventTimeslotId,
|
|
340
|
+
location: item.location,
|
|
336
341
|
}));
|
|
337
342
|
return acc;
|
|
338
343
|
},
|
|
@@ -473,7 +478,7 @@ const TicketForm: React.FC<Props> = ({
|
|
|
473
478
|
return (
|
|
474
479
|
<Box id={EVENTLOOK_ORDER_FORM_ID}>
|
|
475
480
|
{hasGopayId ? (
|
|
476
|
-
<PaymentSuccess setIsPaying={setIsPaying} isIframe={isIframe} />
|
|
481
|
+
<PaymentSuccess setIsPaying={setIsPaying} isIframe={isIframe} pixels={pixels} />
|
|
477
482
|
) : isPaying ? (
|
|
478
483
|
<PaymentPending />
|
|
479
484
|
) : paymentRedirect ? (
|
|
@@ -510,7 +515,9 @@ const TicketForm: React.FC<Props> = ({
|
|
|
510
515
|
<Step active>
|
|
511
516
|
<StepLabel>{t('event.tickets.stepper.1.title')}</StepLabel>
|
|
512
517
|
<StepContent>
|
|
513
|
-
{event.
|
|
518
|
+
{event.mapId && seatingIframeUrl ? (
|
|
519
|
+
<TicketSelectionMap event={event} />
|
|
520
|
+
) : event.hasMerchandise ? (
|
|
514
521
|
<TicketWithMerchandiseSelection event={event} />
|
|
515
522
|
) : (
|
|
516
523
|
<TicketSelection event={event} />
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import useGlobal from '@hooks/useGlobal.ts';
|
|
3
|
+
import { IEvent } from '@utils/types/event.type.ts';
|
|
4
|
+
import { Button } from '@mui/material';
|
|
5
|
+
import { iframe, TicketSelection } from '@seat-picker/seat-picker-sdk';
|
|
6
|
+
import { useFormContext } from 'react-hook-form';
|
|
7
|
+
import { ITicketForm, ITicketFormTicket } from '@utils/types/ticket.type.ts';
|
|
8
|
+
|
|
9
|
+
interface Props {
|
|
10
|
+
event: IEvent;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
const TicketSelectionMap: React.FC<Props> = ({ event }) => {
|
|
14
|
+
const { t, seatingIframeUrl } = useGlobal();
|
|
15
|
+
const { setValue } = useFormContext<ITicketForm>();
|
|
16
|
+
|
|
17
|
+
const onSelect = (seats: TicketSelection) => {
|
|
18
|
+
const tickets: ITicketFormTicket[] = [];
|
|
19
|
+
for(const seat of seats) {
|
|
20
|
+
tickets.push({
|
|
21
|
+
releaseId: seat.ticket.id,
|
|
22
|
+
price: seat.ticket.price,
|
|
23
|
+
quantity: 1,
|
|
24
|
+
itemName: `${seat.ticket.releaseCategoryName} - ${seat.ticket.name}`,
|
|
25
|
+
products: [],
|
|
26
|
+
extraFields: [],
|
|
27
|
+
location: {
|
|
28
|
+
id: seat.locationId || '',
|
|
29
|
+
type: 'zone',
|
|
30
|
+
locationDescription: seat.locationTypeDescription,
|
|
31
|
+
}
|
|
32
|
+
})
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
setValue(`tickets.${event.id}`, tickets);
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
if (!seatingIframeUrl) return null;
|
|
39
|
+
|
|
40
|
+
return (
|
|
41
|
+
<Button
|
|
42
|
+
variant="contained"
|
|
43
|
+
onClick={() =>
|
|
44
|
+
iframe.openPicker({
|
|
45
|
+
eventId: String(event.id),
|
|
46
|
+
onSelect,
|
|
47
|
+
baseUrl: seatingIframeUrl,
|
|
48
|
+
})
|
|
49
|
+
}
|
|
50
|
+
>
|
|
51
|
+
{t('form.labels.open_map')}
|
|
52
|
+
</Button>
|
|
53
|
+
);
|
|
54
|
+
};
|
|
55
|
+
|
|
56
|
+
export default TicketSelectionMap;
|
package/src/form/index.tsx
CHANGED
|
@@ -27,6 +27,7 @@ import { csCZ, enUS, ukUA, esES, deDE, skSK } from '@mui/x-date-pickers/locales'
|
|
|
27
27
|
export interface OrderFormProps {
|
|
28
28
|
eventSlug: string;
|
|
29
29
|
apiUrl: string;
|
|
30
|
+
seatingIframeUrl?: string;
|
|
30
31
|
callbacks: IGlobalContext['callbacks'];
|
|
31
32
|
links: IGlobalContext['links'];
|
|
32
33
|
lang?: Languages;
|
|
@@ -42,6 +43,7 @@ export interface OrderFormProps {
|
|
|
42
43
|
const ClientRender: React.FC<OrderFormProps> = ({
|
|
43
44
|
eventSlug,
|
|
44
45
|
apiUrl,
|
|
46
|
+
seatingIframeUrl,
|
|
45
47
|
lang,
|
|
46
48
|
slots,
|
|
47
49
|
options,
|
|
@@ -100,6 +102,7 @@ const ClientRender: React.FC<OrderFormProps> = ({
|
|
|
100
102
|
links={links}
|
|
101
103
|
options={options}
|
|
102
104
|
content={content}
|
|
105
|
+
seatingIframeUrl={seatingIframeUrl}
|
|
103
106
|
>
|
|
104
107
|
{!data || !!error ? (
|
|
105
108
|
<TicketFormSkeleton />
|
package/src/locales/cs.tsx
CHANGED
package/src/locales/en.tsx
CHANGED
package/src/locales/es.tsx
CHANGED
package/src/locales/pl.tsx
CHANGED
package/src/locales/sk.tsx
CHANGED
package/src/locales/uk.tsx
CHANGED
package/src/utils/gtm.ts
CHANGED
|
@@ -17,6 +17,7 @@ import {
|
|
|
17
17
|
ISelectItem,
|
|
18
18
|
IAddToCart,
|
|
19
19
|
IRemoveFromCart,
|
|
20
|
+
IPurchasePaid,
|
|
20
21
|
} from '@utils/types/gtm.type';
|
|
21
22
|
import { UserIpCookie } from '@utils/data/cookie';
|
|
22
23
|
import { IUser } from '@utils/types/user.type';
|
|
@@ -225,6 +226,34 @@ export const gtmPurchase = (
|
|
|
225
226
|
return pageEvent;
|
|
226
227
|
};
|
|
227
228
|
|
|
229
|
+
export const getGtmPurchasePaid = (
|
|
230
|
+
item: IEcommercePurchase | null,
|
|
231
|
+
pixels?: IPixels,
|
|
232
|
+
userData?: IUserData
|
|
233
|
+
) => {
|
|
234
|
+
const userIp = Cookies.get(UserIpCookie);
|
|
235
|
+
const pageEvent: IPurchasePaid & IPixels = {
|
|
236
|
+
event: 'purchase_paid',
|
|
237
|
+
fb_pixel_id: pixels?.fb_pixel_id || '',
|
|
238
|
+
tiktok_pixel_id: pixels?.tiktok_pixel_id || '',
|
|
239
|
+
ecommerce: item,
|
|
240
|
+
user_data: userData || null,
|
|
241
|
+
ip: userIp || '',
|
|
242
|
+
};
|
|
243
|
+
|
|
244
|
+
return pageEvent;
|
|
245
|
+
};
|
|
246
|
+
|
|
247
|
+
export const gtmPurchasePaid = (
|
|
248
|
+
item: IEcommercePurchase | null,
|
|
249
|
+
pixels?: IPixels,
|
|
250
|
+
userData?: IUserData
|
|
251
|
+
) => {
|
|
252
|
+
const pageEvent = getGtmPurchasePaid(item, pixels, userData);
|
|
253
|
+
if (isBrowser() && window.dataLayer) setTimeout(() => window.dataLayer.push(pageEvent), 500);
|
|
254
|
+
return pageEvent;
|
|
255
|
+
};
|
|
256
|
+
|
|
228
257
|
export const mapUserToUserData = (user: IUser) => ({
|
|
229
258
|
em: user.email,
|
|
230
259
|
ph: user.phone,
|