@tap-payments/auth-jsconnect 2.4.42-test → 2.4.44-test

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.
@@ -577,4 +577,12 @@ export declare type IndividualDataVerification = {
577
577
  relation: string;
578
578
  status: string;
579
579
  };
580
+ export declare type DataLayer = {
581
+ event: string;
582
+ event_category: string;
583
+ event_action: string;
584
+ event_label?: string;
585
+ event_value?: number | string;
586
+ event_noninteraction?: number;
587
+ };
580
588
  export {};
@@ -508,6 +508,7 @@ export var updateLeadBusinessType = createAsyncThunk('updateLeadBusinessType', f
508
508
  return [4, API.accountService.createAccount(accountBody)];
509
509
  case 3:
510
510
  accountData = _f.sent();
511
+ thunkApi.dispatch(updateStepName(BUSINESS_STEP_NAMES.BUSINESS_INFO_CONFIRM));
511
512
  return [4, API.brandService.retrieveBrand(brand === null || brand === void 0 ? void 0 : brand.id)];
512
513
  case 4:
513
514
  brandRes = (_f.sent()).brand;
@@ -71,7 +71,7 @@ import { handleNextScreenStep } from '../../../app/settings';
71
71
  import { CONNECT_STEP_NAMES, defaultCountry, IDENTIFICATION_TYPE, OTHER_BRAND } from '../../../constants';
72
72
  import { createAsyncThunk, createSlice } from '@reduxjs/toolkit';
73
73
  import { AuthForType, FlowsTypes } from '../../../@types';
74
- import { capitalizeTheFirstLetterOfEachWord, concatenateObjectValues, findCountryByIddPrefix, fixBrandList, isTwitter, getIndividualName, isWebsite, sleep } from '../../../utils';
74
+ import { capitalizeTheFirstLetterOfEachWord, concatenateObjectValues, findCountryByIddPrefix, fixBrandList, isTwitter, getIndividualName, isWebsite, sleep, sendCustomEventToGTM } from '../../../utils';
75
75
  export var createMobileAuth = createAsyncThunk('createMobileAuth', function (params, thunkApi) { return __awaiter(void 0, void 0, void 0, function () {
76
76
  var settings, requestBody, data;
77
77
  var _a, _b;
@@ -252,6 +252,11 @@ export var verifyAuth = createAsyncThunk('connect/verifyAuth', function (params,
252
252
  return [4, API.authService.verifyAuth(payload)];
253
253
  case 1:
254
254
  data = (_g.sent()).data;
255
+ sendCustomEventToGTM({
256
+ event: 'Send Event',
257
+ event_category: 'User Registration Flow',
258
+ event_action: 'First OTP Success'
259
+ });
255
260
  if ((_c = data.errors) === null || _c === void 0 ? void 0 : _c.length)
256
261
  throw new Error(data.errors[0].description);
257
262
  lead_id = data.lead_id;
@@ -20,7 +20,7 @@ import { store } from '../../app/store';
20
20
  import { connectSelector, setDefaultCountryCode } from '../app/connect/connectStore';
21
21
  import { ReduxProvider, ThemeProvider } from '../../components/Providers';
22
22
  import Collapse from '../../components/Collapse';
23
- import { isKW, findOrCreateElementAndInject } from '../../utils';
23
+ import { isKW, findOrCreateElementAndInject, initializeGTM, sendCustomEventToGTM } from '../../utils';
24
24
  import { CONNECT_SCREENS_NAVIGATION } from '../../constants';
25
25
  import { connectFeatureScreens } from '../featuresScreens';
26
26
  import Background from '../shared/Background';
@@ -30,9 +30,16 @@ var Connect = memo(function (props) {
30
30
  var _a = useAppSelector(settingsSelector), data = _a.data, error = _a.error, settingLoading = _a.loading;
31
31
  var _b = useAppSelector(connectSelector), connectError = _b.error, loading = _b.loading;
32
32
  useAppConfig(__assign({ navigation: CONNECT_SCREENS_NAVIGATION, maturity: 'full' }, props));
33
- useErrorListener(connectError || error);
33
+ useErrorListener(connectError || error, {
34
+ event: 'Send Event',
35
+ event_category: 'User Registration Flow',
36
+ event_action: 'Registration Error'
37
+ });
34
38
  useStepStartedListener();
35
39
  var activeScreen = data.activeScreen, isTapOrigin = data.isTapOrigin, open = data.open, merchant = data.merchant;
40
+ React.useEffect(function () {
41
+ initializeGTM();
42
+ }, []);
36
43
  React.useEffect(function () {
37
44
  var _a;
38
45
  if (!settingLoading) {
@@ -41,9 +48,16 @@ var Connect = memo(function (props) {
41
48
  }
42
49
  }, [settingLoading]);
43
50
  React.useEffect(function () {
44
- var _a;
45
- if (!!((_a = data.businessCountry) === null || _a === void 0 ? void 0 : _a.iso2))
51
+ var _a, _b;
52
+ if (!!((_a = data.businessCountry) === null || _a === void 0 ? void 0 : _a.iso2)) {
46
53
  dispatch(setDefaultCountryCode(data.businessCountry));
54
+ sendCustomEventToGTM({
55
+ event: 'Send Event',
56
+ event_category: 'User Registration Flow',
57
+ event_action: 'Registration Landing Page Viewed',
58
+ event_label: (_b = data.businessCountry) === null || _b === void 0 ? void 0 : _b.iso2
59
+ });
60
+ }
47
61
  }, [data.businessCountry]);
48
62
  var handleDialogClose = function () {
49
63
  dispatch(handleOpen(false));
@@ -40,7 +40,7 @@ import MobileNumber from './MobileNumber';
40
40
  import { countriesCode } from '../../../../constants';
41
41
  import { AuthForType } from '../../../../@types';
42
42
  import Collapse from '../../../../components/Collapse';
43
- import { isKW } from '../../../../utils';
43
+ import { isKW, sendCustomEventToGTM } from '../../../../utils';
44
44
  var FormStyled = styled(Form)(function () { return ({
45
45
  display: 'flex',
46
46
  flexDirection: 'column',
@@ -67,6 +67,13 @@ var Individual = function (_a) {
67
67
  mode: 'onChange'
68
68
  });
69
69
  useSetFromDefaultValues(methods, individualData, true);
70
+ React.useEffect(function () {
71
+ sendCustomEventToGTM({
72
+ event: 'Send Event',
73
+ event_category: 'User Registration Flow',
74
+ event_action: 'Name and Email Page Viewed'
75
+ });
76
+ }, []);
70
77
  React.useEffect(function () {
71
78
  if (defaultValues.countryCode.iso2 !== methods.getValues('countryCode.iso2'))
72
79
  methods.setValue('countryCode', defaultValues.countryCode);
@@ -18,6 +18,7 @@ import Collapse from '@mui/material/Collapse';
18
18
  import { yupResolver } from '@hookform/resolvers/yup';
19
19
  import { useAppDispatch, useAppSelector } from '../../../../hooks';
20
20
  import { handlePrevScreenStep } from '../../../../app/settings';
21
+ import { sendCustomEventToGTM } from '../../../../utils';
21
22
  import Form from '../../../../components/Form';
22
23
  import { ScreenContainer } from '../../../shared/Containers';
23
24
  import Button from '../../../shared/Button';
@@ -44,6 +45,13 @@ var Merchant = function (_a) {
44
45
  var _g = data.brandData, brandName = _g.brandName, selectedBrandItem = _g.selectedBrandItem, termAndConditionChecked = _g.termAndConditionChecked, responseBody = _g.responseBody, salesChannels = _g.salesChannels, segment = _g.segment, teamSize = _g.teamSize;
45
46
  var brandList = (responseBody || {}).brand_list;
46
47
  var _h = React.useState(), listActive = _h[0], setListActive = _h[1];
48
+ React.useEffect(function () {
49
+ sendCustomEventToGTM({
50
+ event: 'Send Event',
51
+ event_category: 'User Registration Flow',
52
+ event_action: 'Brand Details Step'
53
+ });
54
+ }, []);
47
55
  var methods = useForm({
48
56
  resolver: yupResolver(MerchantValidationSchema(isRequiredNewBrand)),
49
57
  defaultValues: {
@@ -9,17 +9,6 @@ var __assign = (this && this.__assign) || function () {
9
9
  };
10
10
  return __assign.apply(this, arguments);
11
11
  };
12
- var __rest = (this && this.__rest) || function (s, e) {
13
- var t = {};
14
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
15
- t[p] = s[p];
16
- if (s != null && typeof Object.getOwnPropertySymbols === "function")
17
- for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
18
- if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
19
- t[p[i]] = s[p[i]];
20
- }
21
- return t;
22
- };
23
12
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
24
13
  import * as React from 'react';
25
14
  import Box from '@mui/material/Box';
@@ -36,7 +25,7 @@ import ScreenContainer from '../../../shared/Containers/ScreenContainer';
36
25
  import { clearError, connectSelector, createMobileAuth, resetNIDScreen, resetCivilScreen, resetOTPScreen, resetStore } from '../../../app/connect/connectStore';
37
26
  import { useLanguage } from '../../../../hooks';
38
27
  import Divider from '@mui/material/Divider';
39
- import { isKW } from '../../../../utils';
28
+ import { isKW, sendCustomEventToGTM } from '../../../../utils';
40
29
  import Text from '../../../../components/Text';
41
30
  import MIDTitle from './Title';
42
31
  import MobileNumber from './MobileNumber';
@@ -89,15 +78,18 @@ var Mobile = function (_a) {
89
78
  var settingsStore = useAppSelector(settingsSelector);
90
79
  var _c = useAppSelector(connectSelector), data = _c.data, loading = _c.loading, error = _c.error;
91
80
  var _d = React.useState(), listType = _d[0], setListType = _d[1];
92
- var _e = data.mobileData, countryCode = _e.countryCode, mobile = _e.mobile;
93
81
  var dispatch = useAppDispatch();
94
- var _f = data.mobileData, responseBody = _f.responseBody, defaultValues = __rest(_f, ["responseBody"]);
82
+ var _e = data.mobileData, mobile = _e.mobile, countryCode = _e.countryCode, termAndConditionChecked = _e.termAndConditionChecked;
95
83
  var methods = useForm({
96
84
  resolver: yupResolver(PhoneValidationSchema),
97
- defaultValues: defaultValues,
85
+ defaultValues: {
86
+ mobile: mobile,
87
+ countryCode: countryCode,
88
+ termAndConditionChecked: termAndConditionChecked
89
+ },
98
90
  mode: 'onChange'
99
91
  });
100
- useSetFromDefaultValues(methods, defaultValues);
92
+ useSetFromDefaultValues(methods, data.mobileData);
101
93
  var t = useTranslation().t;
102
94
  var isAr = useLanguage().isAr;
103
95
  var handleMenuListClick = function (flag) {
@@ -117,6 +109,11 @@ var Mobile = function (_a) {
117
109
  };
118
110
  var isKWCountry = React.useMemo(function () { var _a; return isKW((_a = settingsStore.data.businessCountry) === null || _a === void 0 ? void 0 : _a.iso2); }, [(_b = settingsStore.data.businessCountry) === null || _b === void 0 ? void 0 : _b.iso2]);
119
111
  var onBack = function () {
112
+ sendCustomEventToGTM({
113
+ event: 'Send Event',
114
+ event_category: 'User Registration Flow',
115
+ event_action: 'Switch to ID Login Clicked'
116
+ });
120
117
  dispatch(handlePrevScreenStep(isKWCountry ? 'CONNECT_CIVIL_ID_STEP' : 'CONNECT_NID_STEP'));
121
118
  };
122
119
  React.useEffect(function () {
@@ -35,7 +35,7 @@ import { connectSelector } from '../../../app/connect/connectStore';
35
35
  import ExpandIcon from '../../../../components/ExpandIcon';
36
36
  import Input from '../../../shared/Input';
37
37
  import SimpleList from '../../../../components/SimpleList';
38
- import { removeAllCharsFromNumber } from '../../../../utils';
38
+ import { removeAllCharsFromNumber, sendCustomEventToGTM } from '../../../../utils';
39
39
  import { useLanguage, useAppSelector } from '../../../../hooks';
40
40
  import Search from '../../../shared/Search';
41
41
  var LabelContainerStyled = styled(Box)(function (_a) {
@@ -133,6 +133,13 @@ var MobileNumber = React.forwardRef(function (_a, ref) {
133
133
  var onSelectItem = function (country) {
134
134
  onCloseCountryList();
135
135
  setValue('mobile', '');
136
+ var prevCountry = countryCodeValue === null || countryCodeValue === void 0 ? void 0 : countryCodeValue.iso2;
137
+ sendCustomEventToGTM({
138
+ event: 'Send Event',
139
+ event_category: 'User Registration Flow',
140
+ event_action: 'switch mobile country clicked',
141
+ event_label: "From ".concat(prevCountry, " to ").concat(country.iso2)
142
+ });
136
143
  countryCodeControl.field.onChange(country);
137
144
  };
138
145
  var handleSearch = function (value) {
@@ -22,6 +22,7 @@ import { clearError, connectSelector, createNIDAuth, resetMobileScreen, resetSto
22
22
  import Form from '../../../../components/Form';
23
23
  import Button, { MobileButton } from '../../../shared/Button';
24
24
  import { ScreenContainer } from '../../../shared/Containers';
25
+ import { sendCustomEventToGTM } from '../../../../utils';
25
26
  import Collapse from '../../../../components/Collapse';
26
27
  import Box from '@mui/material/Box';
27
28
  import Divider from '@mui/material/Divider';
@@ -83,6 +84,11 @@ var NID = function (_a) {
83
84
  dispatch(clearError());
84
85
  };
85
86
  var onBack = function () {
87
+ sendCustomEventToGTM({
88
+ event: 'Send Event',
89
+ event_category: 'User Registration Flow',
90
+ event_action: 'Switch to mobile number Login Clicked'
91
+ });
86
92
  dispatch(handlePrevScreenStep('CONNECT_MOBILE_STEP'));
87
93
  };
88
94
  React.useEffect(function () {
@@ -9,17 +9,6 @@ var __assign = (this && this.__assign) || function () {
9
9
  };
10
10
  return __assign.apply(this, arguments);
11
11
  };
12
- var __rest = (this && this.__rest) || function (s, e) {
13
- var t = {};
14
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
15
- t[p] = s[p];
16
- if (s != null && typeof Object.getOwnPropertySymbols === "function")
17
- for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
18
- if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
19
- t[p[i]] = s[p[i]];
20
- }
21
- return t;
22
- };
23
12
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
24
13
  import Box from '@mui/material/Box/Box';
25
14
  import { styled } from '@mui/material/styles';
@@ -36,7 +25,7 @@ import { AuthForType } from '../../../../@types';
36
25
  import { useForm, FormProvider } from 'react-hook-form';
37
26
  import { yupResolver } from '@hookform/resolvers/yup';
38
27
  import Form from '../../../../components/Form';
39
- import { maskPhone, maskID } from '../../../../utils';
28
+ import { maskPhone, maskID, sendCustomEventToGTM } from '../../../../utils';
40
29
  import { OTPValidation } from './validation';
41
30
  import OTPInput from './OTPInput';
42
31
  var OTPTitleContainerStyled = styled(Box)(function (_a) {
@@ -62,16 +51,25 @@ var OTP = function () {
62
51
  var _a;
63
52
  var dispatch = useAppDispatch();
64
53
  var _b = useAppSelector(connectSelector), data = _b.data, loading = _b.loading, error = _b.error;
65
- var _c = data.otpData, responseBody = _c.responseBody, defaultValues = __rest(_c, ["responseBody"]);
54
+ var otp = data.otpData.otp;
66
55
  var methods = useForm({
67
56
  resolver: yupResolver(OTPValidation),
68
- defaultValues: defaultValues,
57
+ defaultValues: {
58
+ otp: otp
59
+ },
69
60
  mode: 'onChange'
70
61
  });
71
- useSetFromDefaultValues(methods, defaultValues);
62
+ useSetFromDefaultValues(methods, data.otpData);
72
63
  var t = useTranslation().t;
73
64
  var isAr = useLanguage().isAr;
74
65
  var startWithNID = data.otpData.authFor === AuthForType.NATIONAL_ID;
66
+ React.useEffect(function () {
67
+ sendCustomEventToGTM({
68
+ event: 'Send Event',
69
+ event_category: 'User Registration Flow',
70
+ event_action: 'First OTP Page Viewed'
71
+ });
72
+ }, []);
75
73
  React.useEffect(function () {
76
74
  if (error)
77
75
  dispatch(clearError());
@@ -20,6 +20,7 @@ import { DEFAULT_TIMER_VALUE } from '../../../../constants';
20
20
  import { AuthForType } from '../../../../@types';
21
21
  import { connectSelector, resendOTPMobile, resendOTPNID } from '../../../app/connect/connectStore';
22
22
  import { useAppDispatch, useAppSelector } from '../../../../hooks';
23
+ import { sendCustomEventToGTM } from '../../../../utils';
23
24
  var BoxStyled = styled(Box)(function (_a) {
24
25
  var theme = _a.theme;
25
26
  return ({
@@ -38,14 +39,23 @@ var OTPInput = function (_a) {
38
39
  var handleOnOTPChange = function (otp) {
39
40
  otpControl.field.onChange(otp);
40
41
  };
42
+ var sendEventAskAnotherOTP = function () {
43
+ sendCustomEventToGTM({
44
+ event: 'Send Event',
45
+ event_category: 'User Registration Flow',
46
+ event_action: 'Another OTP asked'
47
+ });
48
+ };
41
49
  var handleOnResendOTP = function () {
42
50
  if (otpControl.field.value)
43
51
  setValue('otp', '', { shouldValidate: true });
52
+ sendEventAskAnotherOTP();
44
53
  dispatch(resendOTPMobile());
45
54
  };
46
55
  var handleOnResendAbsherOTP = function () {
47
56
  if (otpControl.field.value)
48
57
  setValue('otp', '', { shouldValidate: true });
58
+ sendEventAskAnotherOTP();
49
59
  dispatch(resendOTPNID());
50
60
  };
51
61
  var otpValue = otpControl.field.value;
@@ -2,15 +2,26 @@ import { jsx as _jsx } from "react/jsx-runtime";
2
2
  import * as React from 'react';
3
3
  import { useTranslation, Trans } from 'react-i18next';
4
4
  import SuccessScreen from '../../../shared/SuccessScreen';
5
- import { connectSelector } from '../../../../features/app/connect/connectStore';
5
+ import { connectSelector } from '../../../app/connect/connectStore';
6
6
  import { useAppSelector } from '../../../../hooks';
7
- import { maskEmail } from '../../../../utils';
7
+ import { maskEmail, sendCustomEventToGTM } from '../../../../utils';
8
8
  var ThankYou = function (_a) {
9
9
  var _b, _c, _d;
10
10
  var t = useTranslation().t;
11
11
  var data = useAppSelector(connectSelector).data;
12
12
  var userEmail = ((_c = (_b = data.individualData.responseBody) === null || _b === void 0 ? void 0 : _b.contact) === null || _c === void 0 ? void 0 : _c.email) || ((_d = data.individualData) === null || _d === void 0 ? void 0 : _d.email);
13
13
  var email = maskEmail(userEmail);
14
+ React.useEffect(function () {
15
+ var _a;
16
+ var id = (_a = data.individualData.responseBody) === null || _a === void 0 ? void 0 : _a.id;
17
+ sendCustomEventToGTM({
18
+ event: 'Send Event',
19
+ event_category: 'User Registration Flow',
20
+ event_action: 'Registration Completed',
21
+ event_label: 'Product Type',
22
+ event_value: id
23
+ });
24
+ }, []);
14
25
  return (_jsx(SuccessScreen, { title: t("connect_completed_title"), description: _jsx(Trans, { i18nKey: 'connect_completed_description_dev', values: { email: email } }), showEmailProviders: true }));
15
26
  };
16
27
  export default React.memo(ThankYou);
@@ -16,7 +16,7 @@ import { styled } from '@mui/material/styles';
16
16
  import Box from '@mui/material/Box';
17
17
  import Link from '@mui/material/Link';
18
18
  import { ICONS_NAMES } from '../../../constants';
19
- import { getBrowserInfo } from '../../../utils';
19
+ import { getBrowserInfo, sendCustomEventToGTM } from '../../../utils';
20
20
  var Image = styled('img')(function (_a) {
21
21
  var theme = _a.theme;
22
22
  return ({
@@ -63,5 +63,12 @@ export default function EmailProvidersButtons(_a) {
63
63
  var gmail = _a.gmail, outlook = _a.outlook, apple = _a.apple, mail = _a.mail;
64
64
  var os = getBrowserInfo().os;
65
65
  var _c = React.useState(false), hoverApple = _c[0], setHoverApple = _c[1];
66
- return (_jsxs(ButtonBoxStyled, { children: [_jsx(Link, __assign({ href: gmail.href, underline: 'none', target: '_blank' }, { children: _jsx(GMailButtonStyled, __assign({ variant: 'outlined', startIcon: _jsx(Image, { src: ICONS_NAMES.GMAIL_Filled_ICON, alt: gmail.title }), type: 'button' }, { children: gmail.title })) })), ((_b = os === null || os === void 0 ? void 0 : os.name) === null || _b === void 0 ? void 0 : _b.toLowerCase()) === 'windows' ? (_jsx(Link, __assign({ href: mail.href, underline: 'none', target: '_blank' }, { children: _jsx(OutlookButtonStyled, __assign({ variant: 'outlined', onMouseDown: function () { return setHoverApple(true); }, onMouseUp: function () { return setHoverApple(false); }, startIcon: _jsx(Image, { src: ICONS_NAMES.Mail_Filled_icon, alt: outlook.title }), type: 'button' }, { children: mail.title })) }))) : (_jsx(Link, __assign({ href: apple.href, underline: 'none', target: '_blank' }, { children: _jsx(AppleButtonStyled, __assign({ variant: 'outlined', onMouseEnter: function () { return setHoverApple(true); }, onMouseLeave: function () { return setHoverApple(false); }, startIcon: _jsx(Image, { src: hoverApple ? ICONS_NAMES.apple_white_icon : ICONS_NAMES.Apple_Filled_ICON, alt: apple.title }), type: 'button' }, { children: apple.title })) }))), _jsx(Link, __assign({ href: outlook.href, underline: 'none', target: '_blank' }, { children: _jsx(OutlookButtonStyled, __assign({ variant: 'outlined', startIcon: _jsx(Image, { src: ICONS_NAMES.outlook_Filled_ICON, alt: outlook.title }), type: 'button' }, { children: outlook.title })) }))] }));
66
+ var emailEvent = function (provider) {
67
+ sendCustomEventToGTM({
68
+ event: 'Send Event',
69
+ event_category: 'User Registration Flow',
70
+ event_action: "open ".concat(provider, " clicked")
71
+ });
72
+ };
73
+ return (_jsxs(ButtonBoxStyled, { children: [_jsx(Link, __assign({ href: gmail.href, underline: 'none', target: '_blank' }, { children: _jsx(GMailButtonStyled, __assign({ variant: 'outlined', onClick: function () { return emailEvent('gmail'); }, startIcon: _jsx(Image, { src: ICONS_NAMES.GMAIL_Filled_ICON, alt: gmail.title }), type: 'button' }, { children: gmail.title })) })), ((_b = os === null || os === void 0 ? void 0 : os.name) === null || _b === void 0 ? void 0 : _b.toLowerCase()) === 'windows' ? (_jsx(Link, __assign({ href: mail.href, underline: 'none', target: '_blank' }, { children: _jsx(OutlookButtonStyled, __assign({ variant: 'outlined', onClick: function () { return emailEvent('mail'); }, onMouseDown: function () { return setHoverApple(true); }, onMouseUp: function () { return setHoverApple(false); }, startIcon: _jsx(Image, { src: ICONS_NAMES.Mail_Filled_icon, alt: outlook.title }), type: 'button' }, { children: mail.title })) }))) : (_jsx(Link, __assign({ href: apple.href, underline: 'none', target: '_blank' }, { children: _jsx(AppleButtonStyled, __assign({ variant: 'outlined', onClick: function () { return emailEvent('apple'); }, onMouseEnter: function () { return setHoverApple(true); }, onMouseLeave: function () { return setHoverApple(false); }, startIcon: _jsx(Image, { src: hoverApple ? ICONS_NAMES.apple_white_icon : ICONS_NAMES.Apple_Filled_ICON, alt: apple.title }), type: 'button' }, { children: apple.title })) }))), _jsx(Link, __assign({ href: outlook.href, underline: 'none', target: '_blank' }, { children: _jsx(OutlookButtonStyled, __assign({ onClick: function () { return emailEvent('outlook'); }, variant: 'outlined', startIcon: _jsx(Image, { src: ICONS_NAMES.outlook_Filled_ICON, alt: outlook.title }), type: 'button' }, { children: outlook.title })) }))] }));
67
74
  }
@@ -4,13 +4,21 @@ import { useAppDispatch, useLanguage, useAppSelector } from '../../../hooks';
4
4
  import { handleLanguage, settingsSelector } from '../../../app/settings';
5
5
  import Footer from '../../../components/Footer';
6
6
  import { useTranslation } from 'react-i18next';
7
+ import { sendCustomEventToGTM } from '../../../utils';
7
8
  export default function CustomFooter() {
8
9
  var isEn = useLanguage().isEn;
9
10
  var t = useTranslation().t;
10
11
  var dispatch = useAppDispatch();
11
12
  var data = useAppSelector(settingsSelector).data;
12
13
  var handleChangeLanguage = function () {
14
+ var prevLanguage = isEn ? LanguageMode.EN : LanguageMode.AR;
13
15
  var language = isEn ? LanguageMode.AR : LanguageMode.EN;
16
+ sendCustomEventToGTM({
17
+ event: 'Send Event',
18
+ event_category: 'User Registration Flow',
19
+ event_action: 'switch language clicked',
20
+ event_label: "From ".concat(prevLanguage, " to ").concat(language)
21
+ });
14
22
  dispatch(handleLanguage(language));
15
23
  };
16
24
  var country = data.businessCountry;
@@ -1 +1,2 @@
1
- export declare const useErrorListener: (error?: string | null) => void;
1
+ import { DataLayer } from '../@types';
2
+ export declare const useErrorListener: (error?: string | null, event?: DataLayer) => void;
@@ -1,11 +1,26 @@
1
+ var __assign = (this && this.__assign) || function () {
2
+ __assign = Object.assign || function(t) {
3
+ for (var s, i = 1, n = arguments.length; i < n; i++) {
4
+ s = arguments[i];
5
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
6
+ t[p] = s[p];
7
+ }
8
+ return t;
9
+ };
10
+ return __assign.apply(this, arguments);
11
+ };
1
12
  import { useEffect } from 'react';
2
13
  import { settingsSelector } from '../app/settings';
14
+ import { sendCustomEventToGTM } from '../utils';
3
15
  import { useAppSelector } from './useAppSelector';
4
- export var useErrorListener = function (error) {
16
+ export var useErrorListener = function (error, event) {
5
17
  var settings = useAppSelector(settingsSelector);
6
18
  useEffect(function () {
7
19
  var _a, _b;
8
20
  if (error) {
21
+ if (event) {
22
+ sendCustomEventToGTM(__assign(__assign({}, event), { event_label: error }));
23
+ }
9
24
  (_b = (_a = settings.data.appConfig) === null || _a === void 0 ? void 0 : _a.onError) === null || _b === void 0 ? void 0 : _b.call(_a, error);
10
25
  }
11
26
  }, [error]);
@@ -0,0 +1,4 @@
1
+ import { DataLayer } from '../@types';
2
+ export declare const pushToDataLayer: (data: DataLayer) => void;
3
+ export declare const initializeGTM: () => void;
4
+ export declare const sendCustomEventToGTM: (data: DataLayer) => void;
@@ -0,0 +1,23 @@
1
+ var __assign = (this && this.__assign) || function () {
2
+ __assign = Object.assign || function(t) {
3
+ for (var s, i = 1, n = arguments.length; i < n; i++) {
4
+ s = arguments[i];
5
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
6
+ t[p] = s[p];
7
+ }
8
+ return t;
9
+ };
10
+ return __assign.apply(this, arguments);
11
+ };
12
+ import TagManager from 'react-gtm-module';
13
+ export var pushToDataLayer = function (data) {
14
+ if (window.dataLayer) {
15
+ window.dataLayer.push(data);
16
+ }
17
+ };
18
+ export var initializeGTM = function () {
19
+ TagManager.initialize({ gtmId: 'GTM-5RR5CKD' });
20
+ };
21
+ export var sendCustomEventToGTM = function (data) {
22
+ pushToDataLayer(__assign({ event_value: 0, event_noninteraction: 0, event_label: '' }, data));
23
+ };
@@ -10,3 +10,4 @@ export * from './rsa';
10
10
  export * from './common';
11
11
  export * from './date';
12
12
  export * from './error';
13
+ export * from './gtm';
@@ -10,3 +10,4 @@ export * from './rsa';
10
10
  export * from './common';
11
11
  export * from './date';
12
12
  export * from './error';
13
+ export * from './gtm';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tap-payments/auth-jsconnect",
3
- "version": "2.4.42-test",
3
+ "version": "2.4.44-test",
4
4
  "description": "connect library, auth",
5
5
  "private": false,
6
6
  "main": "build/index.js",
@@ -38,6 +38,7 @@
38
38
  "@types/react": "^18.0.15",
39
39
  "@types/react-calendar": "~3.5.1",
40
40
  "@types/react-dom": "^18.0.6",
41
+ "@types/react-gtm-module": "~2.0.1",
41
42
  "@typescript-eslint/eslint-plugin": "^5.30.5",
42
43
  "@typescript-eslint/parser": "^5.30.5",
43
44
  "babel-loader": "^8.2.5",
@@ -95,6 +96,7 @@
95
96
  "react-device-detect": "^2.2.2",
96
97
  "react-dom": "^18.2.0",
97
98
  "react-dropzone": "^14.2.2",
99
+ "react-gtm-module": "^2.0.11",
98
100
  "react-hook-form": "^7.33.1",
99
101
  "react-i18next": "^11.18.1",
100
102
  "react-multi-date-picker": "^3.3.4",