@roomstay/frontend 2.6.40 → 2.6.42
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/dist/586.bundle.js +1 -1
- package/dist/839.bundle.js +1 -1
- package/dist/927.bundle.js +1 -1
- package/dist/main.bundle.js +1 -1
- package/dist/src/components/generic/modal/SigninModal/AuthenticatedUserModal.d.ts +0 -1
- package/dist/src/components/generic/modal/SigninModal/AuthenticatedUserModal.js +2 -2
- package/dist/src/components/generic/modal/SigninModal/AuthenticatedUserModal.js.map +1 -1
- package/dist/src/components/steps/date/PeoplePickerRow.js +47 -60
- package/dist/src/components/steps/date/PeoplePickerRow.js.map +1 -1
- package/dist/src/components/steps/room/AvailableUpgradesModal.js +9 -4
- package/dist/src/components/steps/room/AvailableUpgradesModal.js.map +1 -1
- package/dist/src/components/steps/room/roomDetails/RoomDetails.js +9 -2
- package/dist/src/components/steps/room/roomDetails/RoomDetails.js.map +1 -1
- package/dist/src/components/steps/room/roomDetails/roomRates/ReadMoreRoomRateRow.js +5 -1
- package/dist/src/components/steps/room/roomDetails/roomRates/ReadMoreRoomRateRow.js.map +1 -1
- package/dist/src/components/steps/room/roomDetails/roomRates/RoomRateDescriptionTab.js +2 -1
- package/dist/src/components/steps/room/roomDetails/roomRates/RoomRateDescriptionTab.js.map +1 -1
- package/dist/src/components/steps/room/roomDetails/roomRates/RoomRateRow.js +5 -2
- package/dist/src/components/steps/room/roomDetails/roomRates/RoomRateRow.js.map +1 -1
- package/dist/src/contexts/BasketContext/BasketContextType.js.map +1 -1
- package/dist/src/contexts/CompanyContext/CompanyContextWrapper.js +2 -10
- package/dist/src/contexts/CompanyContext/CompanyContextWrapper.js.map +1 -1
- package/dist/src/contexts/FullPageEngineContext/EnginePageLayout.js +32 -1
- package/dist/src/contexts/FullPageEngineContext/EnginePageLayout.js.map +1 -1
- package/dist/src/contexts/FullPageEngineContext/FullPageEngineContextWrapper.js.map +1 -1
- package/dist/src/engines/MemberPortalWidget/MemberPortalWidget.d.ts +3 -4
- package/dist/src/engines/MemberPortalWidget/MemberPortalWidget.js +1 -0
- package/dist/src/engines/MemberPortalWidget/MemberPortalWidget.js.map +1 -1
- package/dist/src/engines/MemberPortalWidget/MemberPortalWidgetElement.d.ts +2 -2
- package/dist/src/engines/MemberPortalWidget/MemberPortalWidgetElement.js +20 -9
- package/dist/src/engines/MemberPortalWidget/MemberPortalWidgetElement.js.map +1 -1
- package/dist/src/hooks/useSignedInMember.d.ts +1 -1
- package/dist/src/index.d.ts +1 -0
- package/dist/src/index.js +4 -2
- package/dist/src/index.js.map +1 -1
- package/dist/src/models/Api/HotelDTO.d.ts +1 -0
- package/dist/src/models/Api/HotelDTO.js.map +1 -1
- package/dist/src/models/Room/Room.d.ts +4 -1
- package/dist/src/models/Room/Room.js +6 -1
- package/dist/src/models/Room/Room.js.map +1 -1
- package/dist/src/models/Room/RoomRate.d.ts +6 -1
- package/dist/src/models/Room/RoomRate.js +12 -1
- package/dist/src/models/Room/RoomRate.js.map +1 -1
- package/dist/src/models/Room/RoomRateSortable.d.ts +2 -1
- package/dist/src/models/Room/RoomRateSortable.js.map +1 -1
- package/dist/src/pages/findReservation/ReservationRow.js +1 -1
- package/dist/src/pages/findReservation/ReservationRow.js.map +1 -1
- package/dist/src/pages/hotel/HotelInfo.js +20 -15
- package/dist/src/pages/hotel/HotelInfo.js.map +1 -1
- package/dist/src/providers/RoomSortProvider.js +6 -2
- package/dist/src/providers/RoomSortProvider.js.map +1 -1
- package/dist/src/util/Analytics/Analytics.d.ts +31 -0
- package/dist/src/util/Analytics/Analytics.js +22 -0
- package/dist/src/util/Analytics/Analytics.js.map +1 -0
- package/dist/src/util/Analytics/GoogleAnalytics4.d.ts +127 -0
- package/dist/src/util/Analytics/GoogleAnalytics4.js +217 -0
- package/dist/src/util/Analytics/GoogleAnalytics4.js.map +1 -0
- package/dist/src/util/Analytics/UniversalAnalytics.d.ts +110 -0
- package/dist/src/util/Analytics/UniversalAnalytics.js +210 -0
- package/dist/src/util/Analytics/UniversalAnalytics.js.map +1 -0
- package/dist/src/util/DataLayer.d.ts +33 -29
- package/dist/src/util/DataLayer.js +78 -233
- package/dist/src/util/DataLayer.js.map +1 -1
- package/dist/test.bundle.js +1 -1
- package/dist/tests/jest/models/RoomRate.test.js +1 -1
- package/dist/tests/jest/models/RoomRate.test.js.map +1 -1
- package/dist/tests/offline/entry/OfflineEngineDefaults.js +4 -0
- package/dist/tests/offline/entry/OfflineEngineDefaults.js.map +1 -1
- package/dist/vendors.bundle.js +1 -1
- package/package.json +2 -2
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
import ReservationsDTO, { ReservationDTO } from '../../models/Api/ReservationsDTO';
|
|
2
|
+
import BasketAddonRow from '../../models/BasketAddonRow';
|
|
3
|
+
import BasketRow from '../../models/BasketRow';
|
|
4
|
+
import { DateRange, GenericAnalyticsAccommodation as GenericAnalyticsAccommodation } from '../DataLayer';
|
|
5
|
+
import { Analytics } from './Analytics';
|
|
6
|
+
interface GA4Item {
|
|
7
|
+
item_name: string;
|
|
8
|
+
item_id: string;
|
|
9
|
+
item_brand: string;
|
|
10
|
+
item_category: string;
|
|
11
|
+
item_category2?: string;
|
|
12
|
+
item_category3?: string;
|
|
13
|
+
item_category5?: string;
|
|
14
|
+
item_list_name: string;
|
|
15
|
+
coupon?: string;
|
|
16
|
+
discount?: number;
|
|
17
|
+
index: number;
|
|
18
|
+
price: number;
|
|
19
|
+
quantity: number;
|
|
20
|
+
selected_dates?: string;
|
|
21
|
+
upgrade?: string;
|
|
22
|
+
upgrade_price_dif?: number;
|
|
23
|
+
}
|
|
24
|
+
declare class GoogleAnalytics4 extends Analytics {
|
|
25
|
+
private formatDateRange;
|
|
26
|
+
private generateRoomRateProductInfo;
|
|
27
|
+
private generateAddonProductInfo;
|
|
28
|
+
generateRoomImpressionMessageObject(impressions: GenericAnalyticsAccommodation[]): {
|
|
29
|
+
event: string;
|
|
30
|
+
currency: string;
|
|
31
|
+
ecommerce: {
|
|
32
|
+
items: GA4Item[];
|
|
33
|
+
};
|
|
34
|
+
};
|
|
35
|
+
generateProductClickMessageObject(product: GenericAnalyticsAccommodation): {
|
|
36
|
+
event: string;
|
|
37
|
+
ecommerce: {
|
|
38
|
+
currency: string;
|
|
39
|
+
item_list_name: string;
|
|
40
|
+
items: GA4Item[];
|
|
41
|
+
};
|
|
42
|
+
};
|
|
43
|
+
generateDateSelectionMessageObject(dateRange: DateRange, adults: number, children: number, infants?: number | undefined): {
|
|
44
|
+
event: string;
|
|
45
|
+
ecommerce: {
|
|
46
|
+
currency: string;
|
|
47
|
+
arrival_date: string;
|
|
48
|
+
departure_date: string;
|
|
49
|
+
adult_count: number;
|
|
50
|
+
child_count: number;
|
|
51
|
+
infant_count: number;
|
|
52
|
+
};
|
|
53
|
+
};
|
|
54
|
+
generateAddToCartMessageObject(product: GenericAnalyticsAccommodation): {
|
|
55
|
+
event: string;
|
|
56
|
+
ecommerce: {
|
|
57
|
+
currency: string;
|
|
58
|
+
items: GA4Item[];
|
|
59
|
+
};
|
|
60
|
+
};
|
|
61
|
+
generateUpsellConfirmedMessageObject(oldProduct: GenericAnalyticsAccommodation, newProduct: GenericAnalyticsAccommodation): {
|
|
62
|
+
event: string;
|
|
63
|
+
ecommerce: {
|
|
64
|
+
currency: string;
|
|
65
|
+
items: {
|
|
66
|
+
old: GA4Item;
|
|
67
|
+
new: GA4Item;
|
|
68
|
+
};
|
|
69
|
+
};
|
|
70
|
+
};
|
|
71
|
+
generateUpsellCancelledMessageObject(product: GenericAnalyticsAccommodation): {
|
|
72
|
+
event: string;
|
|
73
|
+
ecommerce: {
|
|
74
|
+
currency: string;
|
|
75
|
+
items: GA4Item[];
|
|
76
|
+
};
|
|
77
|
+
};
|
|
78
|
+
generateCheckoutViewMessageObject(basketRows: BasketRow[], addonRows: BasketAddonRow[]): {
|
|
79
|
+
event: string;
|
|
80
|
+
ecommerce: {
|
|
81
|
+
currency: string;
|
|
82
|
+
items: GA4Item[];
|
|
83
|
+
page_type: string;
|
|
84
|
+
};
|
|
85
|
+
};
|
|
86
|
+
generateRoomPurchaseMessageObject(basketRows: BasketRow[], addonRows: BasketAddonRow[], reservations: ReservationsDTO): {
|
|
87
|
+
event: string;
|
|
88
|
+
ecommerce: {
|
|
89
|
+
currency: string;
|
|
90
|
+
transaction_id: string;
|
|
91
|
+
value: string | undefined;
|
|
92
|
+
tax: number;
|
|
93
|
+
coupon: undefined;
|
|
94
|
+
payment_type: import("../../../../core/dist").EBookingPaymentMethod | undefined;
|
|
95
|
+
page_type: string;
|
|
96
|
+
items: GA4Item[];
|
|
97
|
+
};
|
|
98
|
+
}[];
|
|
99
|
+
generateRefundMessageObject(reservation: ReservationDTO): {
|
|
100
|
+
event: string;
|
|
101
|
+
ecommerce: {
|
|
102
|
+
currency: string;
|
|
103
|
+
transaction_id: string;
|
|
104
|
+
value: number;
|
|
105
|
+
items: {
|
|
106
|
+
item_name: string;
|
|
107
|
+
item_id: string;
|
|
108
|
+
item_brand: string;
|
|
109
|
+
item_category: string;
|
|
110
|
+
item_category2: string;
|
|
111
|
+
item_category3: string;
|
|
112
|
+
item_category5: string;
|
|
113
|
+
item_list_name: string;
|
|
114
|
+
coupon: undefined;
|
|
115
|
+
discount: string;
|
|
116
|
+
index: number;
|
|
117
|
+
price: number;
|
|
118
|
+
quantity: number;
|
|
119
|
+
selected_dates: string;
|
|
120
|
+
upgrade: undefined;
|
|
121
|
+
upgrade_price_dif: undefined;
|
|
122
|
+
}[];
|
|
123
|
+
};
|
|
124
|
+
};
|
|
125
|
+
}
|
|
126
|
+
declare const ga4: GoogleAnalytics4;
|
|
127
|
+
export { ga4 as GoogleAnalytics4 };
|
|
@@ -0,0 +1,217 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.GoogleAnalytics4 = void 0;
|
|
7
|
+
const dayjs_1 = __importDefault(require("dayjs"));
|
|
8
|
+
const Analytics_1 = require("./Analytics");
|
|
9
|
+
const DATALAYER_DATE_FORMAT = 'YYYY-M-D';
|
|
10
|
+
class GoogleAnalytics4 extends Analytics_1.Analytics {
|
|
11
|
+
formatDateRange(dateRange) {
|
|
12
|
+
if (!dateRange)
|
|
13
|
+
return '';
|
|
14
|
+
return `ci:${dateRange.from.format('YYYY-MM-DD')} co:${dateRange.to.format('YYYY-MM-DD')}`;
|
|
15
|
+
}
|
|
16
|
+
generateRoomRateProductInfo(room, dateRange, rate, listPosition, quantity, coupon) {
|
|
17
|
+
var _a, _b, _c, _d, _e;
|
|
18
|
+
const providerId = (_a = this.hotel) === null || _a === void 0 ? void 0 : _a.providerHotelID;
|
|
19
|
+
const price = rate ? rate.getAveragePrice() : room.getLowestPrice();
|
|
20
|
+
const discount = rate ? rate.getTotalDiscount() : 0;
|
|
21
|
+
const idParts = [providerId, room.code];
|
|
22
|
+
if (rate) {
|
|
23
|
+
idParts.push(rate.code);
|
|
24
|
+
}
|
|
25
|
+
return {
|
|
26
|
+
item_name: ((_b = this.company) === null || _b === void 0 ? void 0 : _b.brandSuffix) + ' Accommodation',
|
|
27
|
+
item_id: idParts.join(' - '),
|
|
28
|
+
item_brand: [(_c = this.hotel) === null || _c === void 0 ? void 0 : _c.name, providerId].filter(Boolean).join(' - '),
|
|
29
|
+
item_category: 'Room',
|
|
30
|
+
item_category2: (rate === null || rate === void 0 ? void 0 : rate.name) || undefined,
|
|
31
|
+
item_category3: room.name,
|
|
32
|
+
item_category5: ((_d = this.hotel) === null || _d === void 0 ? void 0 : _d.name) + ' Room',
|
|
33
|
+
item_list_name: 'BE List',
|
|
34
|
+
coupon,
|
|
35
|
+
discount,
|
|
36
|
+
index: listPosition || 0,
|
|
37
|
+
price,
|
|
38
|
+
quantity: quantity || 1,
|
|
39
|
+
selected_dates: (_e = this.formatDateRange({ from: dateRange.from, to: dateRange.to })) !== null && _e !== void 0 ? _e : undefined,
|
|
40
|
+
upgrade: undefined,
|
|
41
|
+
upgrade_price_dif: undefined,
|
|
42
|
+
};
|
|
43
|
+
}
|
|
44
|
+
generateAddonProductInfo(room, listPosition) {
|
|
45
|
+
var _a, _b, _c, _d;
|
|
46
|
+
const providerId = (_a = this.hotel) === null || _a === void 0 ? void 0 : _a.providerHotelID;
|
|
47
|
+
const price = room.getTotalPrice();
|
|
48
|
+
const idParts = [providerId, room.getAddon().code];
|
|
49
|
+
return {
|
|
50
|
+
// This is still accommodation as it's part of a greater category.
|
|
51
|
+
item_name: ((_b = this.company) === null || _b === void 0 ? void 0 : _b.brandSuffix) + ' Accommodation',
|
|
52
|
+
item_id: idParts.join(' - '),
|
|
53
|
+
item_brand: [(_c = this.hotel) === null || _c === void 0 ? void 0 : _c.name, providerId].filter(Boolean).join(' - '),
|
|
54
|
+
item_category: 'addon',
|
|
55
|
+
item_category2: undefined,
|
|
56
|
+
item_category3: room.getAddon().name,
|
|
57
|
+
item_category5: ((_d = this.hotel) === null || _d === void 0 ? void 0 : _d.name) + ' Addon',
|
|
58
|
+
item_list_name: 'BE List',
|
|
59
|
+
coupon: undefined,
|
|
60
|
+
discount: 0,
|
|
61
|
+
index: listPosition || 0,
|
|
62
|
+
price,
|
|
63
|
+
quantity: room.getQuantity() || 1,
|
|
64
|
+
selected_dates: undefined,
|
|
65
|
+
upgrade: undefined,
|
|
66
|
+
upgrade_price_dif: undefined,
|
|
67
|
+
};
|
|
68
|
+
}
|
|
69
|
+
generateRoomImpressionMessageObject(impressions) {
|
|
70
|
+
return {
|
|
71
|
+
event: 'view_item_list',
|
|
72
|
+
currency: this.currency.original,
|
|
73
|
+
ecommerce: {
|
|
74
|
+
items: impressions.map((item, index) => {
|
|
75
|
+
const { room, rate, quantity, promoCode, dateRange } = item;
|
|
76
|
+
return this.generateRoomRateProductInfo(room, dateRange, rate, index, quantity, promoCode);
|
|
77
|
+
}),
|
|
78
|
+
},
|
|
79
|
+
};
|
|
80
|
+
}
|
|
81
|
+
generateProductClickMessageObject(product) {
|
|
82
|
+
return {
|
|
83
|
+
event: 'select_item',
|
|
84
|
+
ecommerce: {
|
|
85
|
+
currency: this.currency.original,
|
|
86
|
+
item_list_name: 'BE List',
|
|
87
|
+
items: [this.generateRoomRateProductInfo(product.room, product.dateRange, undefined, undefined, product.quantity, product.promoCode)],
|
|
88
|
+
},
|
|
89
|
+
};
|
|
90
|
+
}
|
|
91
|
+
generateDateSelectionMessageObject(dateRange, adults, children, infants) {
|
|
92
|
+
return {
|
|
93
|
+
event: 'select_dates',
|
|
94
|
+
ecommerce: {
|
|
95
|
+
currency: this.currency.original,
|
|
96
|
+
arrival_date: dateRange.from.format(DATALAYER_DATE_FORMAT),
|
|
97
|
+
departure_date: dateRange.to.format(DATALAYER_DATE_FORMAT),
|
|
98
|
+
adult_count: adults,
|
|
99
|
+
child_count: children,
|
|
100
|
+
infant_count: infants || 0,
|
|
101
|
+
},
|
|
102
|
+
};
|
|
103
|
+
}
|
|
104
|
+
generateAddToCartMessageObject(product) {
|
|
105
|
+
return {
|
|
106
|
+
event: 'add_to_cart',
|
|
107
|
+
ecommerce: {
|
|
108
|
+
currency: this.currency.original,
|
|
109
|
+
items: [this.generateRoomRateProductInfo(product.room, product.dateRange, product.rate, undefined, product.quantity, product.promoCode)],
|
|
110
|
+
},
|
|
111
|
+
};
|
|
112
|
+
}
|
|
113
|
+
generateUpsellConfirmedMessageObject(oldProduct, newProduct) {
|
|
114
|
+
return {
|
|
115
|
+
event: 'upsell_confirmed',
|
|
116
|
+
ecommerce: {
|
|
117
|
+
currency: this.currency.original,
|
|
118
|
+
items: {
|
|
119
|
+
old: this.generateRoomRateProductInfo(oldProduct.room, oldProduct.dateRange, oldProduct.rate, undefined, oldProduct.quantity, oldProduct.promoCode),
|
|
120
|
+
new: this.generateRoomRateProductInfo(newProduct.room, newProduct.dateRange, newProduct.rate, undefined, newProduct.quantity, newProduct.promoCode),
|
|
121
|
+
},
|
|
122
|
+
},
|
|
123
|
+
};
|
|
124
|
+
}
|
|
125
|
+
generateUpsellCancelledMessageObject(product) {
|
|
126
|
+
return {
|
|
127
|
+
event: 'upsell_cancelled',
|
|
128
|
+
ecommerce: {
|
|
129
|
+
currency: this.currency.original,
|
|
130
|
+
items: [this.generateRoomRateProductInfo(product.room, product.dateRange, product.rate, undefined, product.quantity, product.promoCode)],
|
|
131
|
+
},
|
|
132
|
+
};
|
|
133
|
+
}
|
|
134
|
+
generateCheckoutViewMessageObject(basketRows, addonRows) {
|
|
135
|
+
const productItems = basketRows.map((row, index) => {
|
|
136
|
+
var _a;
|
|
137
|
+
return this.generateRoomRateProductInfo(row.getRoom(), { to: row.getStartDate(), from: row.getEndDate() }, (_a = row.getRate()) !== null && _a !== void 0 ? _a : undefined, index, 1, row.getPromoCode());
|
|
138
|
+
});
|
|
139
|
+
addonRows === null || addonRows === void 0 ? void 0 : addonRows.forEach((row, index) => {
|
|
140
|
+
productItems.push(this.generateAddonProductInfo(row, index));
|
|
141
|
+
});
|
|
142
|
+
return {
|
|
143
|
+
event: 'begin_checkout',
|
|
144
|
+
ecommerce: {
|
|
145
|
+
currency: this.currency.original,
|
|
146
|
+
items: productItems,
|
|
147
|
+
page_type: 'conversionintent',
|
|
148
|
+
},
|
|
149
|
+
};
|
|
150
|
+
}
|
|
151
|
+
generateRoomPurchaseMessageObject(basketRows, addonRows, reservations) {
|
|
152
|
+
const productItems = basketRows.map((row, index) => {
|
|
153
|
+
var _a;
|
|
154
|
+
return this.generateRoomRateProductInfo(row.getRoom(), { to: row.getStartDate(), from: row.getEndDate() }, (_a = row.getRate()) !== null && _a !== void 0 ? _a : undefined, index, 1, row.getPromoCode());
|
|
155
|
+
});
|
|
156
|
+
addonRows === null || addonRows === void 0 ? void 0 : addonRows.forEach((row, index) => {
|
|
157
|
+
productItems.push(this.generateAddonProductInfo(row, index));
|
|
158
|
+
});
|
|
159
|
+
return [
|
|
160
|
+
{
|
|
161
|
+
event: 'purchase',
|
|
162
|
+
ecommerce: {
|
|
163
|
+
currency: this.currency.original,
|
|
164
|
+
transaction_id: reservations.itineraryNumber,
|
|
165
|
+
value: reservations.total,
|
|
166
|
+
tax: 0,
|
|
167
|
+
coupon: undefined,
|
|
168
|
+
payment_type: reservations.reservations[0].paymentMethod,
|
|
169
|
+
page_type: 'conversion',
|
|
170
|
+
items: productItems,
|
|
171
|
+
},
|
|
172
|
+
},
|
|
173
|
+
];
|
|
174
|
+
}
|
|
175
|
+
generateRefundMessageObject(reservation) {
|
|
176
|
+
var _a, _b, _c, _d, _e;
|
|
177
|
+
const providerId = (_a = this.hotel) === null || _a === void 0 ? void 0 : _a.providerHotelID;
|
|
178
|
+
const nightKeys = Object.keys(reservation.nights);
|
|
179
|
+
const startDate = (0, dayjs_1.default)(nightKeys[0]);
|
|
180
|
+
const endDate = (0, dayjs_1.default)(nightKeys[nightKeys.length - 1]);
|
|
181
|
+
const discount = nightKeys.reduce((acc, key) => {
|
|
182
|
+
return acc + Number(reservation.nights[key].discount);
|
|
183
|
+
});
|
|
184
|
+
const idParts = [providerId, reservation.roomCode, reservation.rate];
|
|
185
|
+
return {
|
|
186
|
+
event: 'refund',
|
|
187
|
+
ecommerce: {
|
|
188
|
+
currency: this.currency.original,
|
|
189
|
+
transaction_id: reservation.reservationNumber,
|
|
190
|
+
value: reservation.total.afterTax,
|
|
191
|
+
items: [
|
|
192
|
+
{
|
|
193
|
+
item_name: ((_b = this.company) === null || _b === void 0 ? void 0 : _b.brandSuffix) + ' Accommodation',
|
|
194
|
+
item_id: idParts.join('-'),
|
|
195
|
+
item_brand: [(_c = this.hotel) === null || _c === void 0 ? void 0 : _c.name, providerId].filter(Boolean).join(' - '),
|
|
196
|
+
item_category: 'Room',
|
|
197
|
+
item_category2: reservation.rate,
|
|
198
|
+
item_category3: reservation.roomType,
|
|
199
|
+
item_category5: ((_d = this.hotel) === null || _d === void 0 ? void 0 : _d.name) + ' Room',
|
|
200
|
+
item_list_name: 'BE List',
|
|
201
|
+
coupon: undefined,
|
|
202
|
+
discount,
|
|
203
|
+
index: 0,
|
|
204
|
+
price: reservation.total.afterTax,
|
|
205
|
+
quantity: 1,
|
|
206
|
+
selected_dates: (_e = this.formatDateRange({ from: startDate, to: endDate })) !== null && _e !== void 0 ? _e : undefined,
|
|
207
|
+
upgrade: undefined,
|
|
208
|
+
upgrade_price_dif: undefined,
|
|
209
|
+
},
|
|
210
|
+
],
|
|
211
|
+
},
|
|
212
|
+
};
|
|
213
|
+
}
|
|
214
|
+
}
|
|
215
|
+
const ga4 = new GoogleAnalytics4();
|
|
216
|
+
exports.GoogleAnalytics4 = ga4;
|
|
217
|
+
//# sourceMappingURL=GoogleAnalytics4.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"GoogleAnalytics4.js","sourceRoot":"/","sources":["src/util/Analytics/GoogleAnalytics4.ts"],"names":[],"mappings":";;;;;;AAAA,kDAA0B;AAS1B,2CAAwC;AAqBxC,MAAM,qBAAqB,GAAG,UAAU,CAAC;AAEzC,MAAM,gBAAiB,SAAQ,qBAAS;IAC5B,eAAe,CAAC,SAAqB;QACzC,IAAI,CAAC,SAAS;YAAE,OAAO,EAAE,CAAC;QAC1B,OAAO,MAAM,SAAS,CAAC,IAAI,CAAC,MAAM,CAAC,YAAY,CAAC,OAAO,SAAS,CAAC,EAAE,CAAC,MAAM,CAAC,YAAY,CAAC,EAAE,CAAC;IAC/F,CAAC;IAEO,2BAA2B,CAAC,IAAU,EAAE,SAAoB,EAAE,IAAe,EAAE,YAAqB,EAAE,QAAiB,EAAE,MAAe;;QAC5I,MAAM,UAAU,GAAG,MAAA,IAAI,CAAC,KAAK,0CAAE,eAAe,CAAC;QAE/C,MAAM,KAAK,GAAG,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,eAAe,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,cAAc,EAAE,CAAC;QACpE,MAAM,QAAQ,GAAG,IAAI,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AAE;oBACH;wBACI,SAAS,EAAE,CAAA,MAAA,IAAI,CAAC,OAAO,0CAAE,WAAW,IAAG,gBAAgB;wBACvD,OAAO,EAAE,OAAO,CAAC,IAAI,CAAC,GAAG,CAAC;wBAC1B,UAAU,EAAE,CAAC,MAAA,IAAI,CAAC,KAAK,0CAAE,IAAI,EAAE,UAAU,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC;wBACtE,aAAa,EAAE,MAAM;wBACrB,cAAc,EAAE,WAAW,CAAC,IAAI;wBAChC,cAAc,EAAE,WAAW,CAAC,QAAQ;wBACpC,cAAc,EAAE,CAAA,MAAA,IAAI,CAAC,KAAK,0CAAE,IAAI,IAAG,OAAO;wBAC1C,cAAc,EAAE,SAAS;wBACzB,MAAM,EAAE,SAAS;wBACjB,QAAQ;wBACR,KAAK,EAAE,CAAC;wBACR,KAAK,EAAE,WAAW,CAAC,KAAK,CAAC,QAAQ;wBACjC,QAAQ,EAAE,CAAC;wBACX,cAAc,EAAE,MAAA,IAAI,CAAC,eAAe,CAAC,EAAE,IAAI,EAAE,SAAS,EAAE,EAAE,EAAE,OAAO,EAAE,CAAC,mCAAI,SAAS;wBACnF,OAAO,EAAE,SAAS;wBAClB,iBAAiB,EAAE,SAAS;qBAC/B;iBACJ;aACJ;SACJ,CAAC;IACN,CAAC;CACJ;AAED,MAAM,GAAG,GAAG,IAAI,gBAAgB,EAAE,CAAC;AAEnB,+BAAgB","sourcesContent":["import dayjs from 'dayjs';\n\nimport ReservationsDTO, { ReservationDTO } from '@/models/Api/ReservationsDTO';\nimport BasketAddonRow from '@/models/BasketAddonRow';\nimport BasketRow from '@/models/BasketRow';\nimport { Room } from '@/models/Room/Room';\nimport { RoomRate } from '@/models/Room/RoomRate';\n\nimport { DateRange, GenericAnalyticsAccommodation as GenericAnalyticsAccommodation } from '../DataLayer';\nimport { Analytics } from './Analytics';\n\ninterface GA4Item {\n item_name: string;\n item_id: string;\n item_brand: string;\n item_category: string;\n item_category2?: string;\n item_category3?: string;\n item_category5?: string;\n item_list_name: string;\n coupon?: string;\n discount?: number;\n index: number;\n price: number;\n quantity: number;\n selected_dates?: string;\n upgrade?: string;\n upgrade_price_dif?: number;\n}\n\nconst DATALAYER_DATE_FORMAT = 'YYYY-M-D';\n\nclass GoogleAnalytics4 extends Analytics {\n private formatDateRange(dateRange?: DateRange): string {\n if (!dateRange) return '';\n return `ci:${dateRange.from.format('YYYY-MM-DD')} co:${dateRange.to.format('YYYY-MM-DD')}`;\n }\n\n private generateRoomRateProductInfo(room: Room, dateRange: DateRange, rate?: RoomRate, listPosition?: number, quantity?: number, coupon?: string): GA4Item {\n const providerId = this.hotel?.providerHotelID;\n\n const price = rate ? rate.getAveragePrice() : room.getLowestPrice();\n const discount = rate ? rate.getTotalDiscount() : 0;\n\n const idParts = [providerId, room.code];\n if (rate) {\n idParts.push(rate.code);\n }\n\n return {\n item_name: this.company?.brandSuffix + ' Accommodation',\n item_id: idParts.join(' - '),\n item_brand: [this.hotel?.name, providerId].filter(Boolean).join(' - '),\n item_category: 'Room',\n item_category2: rate?.name || undefined,\n item_category3: room.name,\n item_category5: this.hotel?.name + ' Room',\n item_list_name: 'BE List',\n coupon,\n discount,\n index: listPosition || 0,\n price,\n quantity: quantity || 1,\n selected_dates: this.formatDateRange({ from: dateRange.from, to: dateRange.to }) ?? undefined,\n upgrade: undefined,\n upgrade_price_dif: undefined,\n };\n }\n\n private generateAddonProductInfo(room: BasketAddonRow, listPosition?: number): GA4Item {\n const providerId = this.hotel?.providerHotelID;\n\n const price = room.getTotalPrice();\n\n const idParts = [providerId, room.getAddon().code];\n\n return {\n // This is still accommodation as it's part of a greater category.\n item_name: this.company?.brandSuffix + ' Accommodation',\n item_id: idParts.join(' - '),\n item_brand: [this.hotel?.name, providerId].filter(Boolean).join(' - '),\n item_category: 'addon',\n item_category2: undefined,\n item_category3: room.getAddon().name,\n item_category5: this.hotel?.name + ' Addon',\n item_list_name: 'BE List',\n coupon: undefined,\n discount: 0,\n index: listPosition || 0,\n price,\n quantity: room.getQuantity() || 1,\n selected_dates: undefined,\n upgrade: undefined,\n upgrade_price_dif: undefined,\n };\n }\n\n public generateRoomImpressionMessageObject(impressions: GenericAnalyticsAccommodation[]) {\n return {\n event: 'view_item_list',\n currency: this.currency.original,\n ecommerce: {\n items: impressions.map((item, index) => {\n const { room, rate, quantity, promoCode, dateRange } = item;\n return this.generateRoomRateProductInfo(room, dateRange, rate, index, quantity, promoCode);\n }),\n },\n };\n }\n\n public generateProductClickMessageObject(product: GenericAnalyticsAccommodation) {\n return {\n event: 'select_item',\n ecommerce: {\n currency: this.currency.original,\n item_list_name: 'BE List',\n items: [this.generateRoomRateProductInfo(product.room, product.dateRange, undefined, undefined, product.quantity, product.promoCode)],\n },\n };\n }\n\n public generateDateSelectionMessageObject(dateRange: DateRange, adults: number, children: number, infants?: number | undefined) {\n return {\n event: 'select_dates',\n ecommerce: {\n currency: this.currency.original,\n arrival_date: dateRange.from.format(DATALAYER_DATE_FORMAT),\n departure_date: dateRange.to.format(DATALAYER_DATE_FORMAT),\n adult_count: adults,\n child_count: children,\n infant_count: infants || 0,\n },\n };\n }\n\n public generateAddToCartMessageObject(product: GenericAnalyticsAccommodation) {\n return {\n event: 'add_to_cart',\n ecommerce: {\n currency: this.currency.original,\n items: [this.generateRoomRateProductInfo(product.room, product.dateRange, product.rate, undefined, product.quantity, product.promoCode)],\n },\n };\n }\n\n public generateUpsellConfirmedMessageObject(oldProduct: GenericAnalyticsAccommodation, newProduct: GenericAnalyticsAccommodation) {\n return {\n event: 'upsell_confirmed',\n ecommerce: {\n currency: this.currency.original,\n items: {\n old: this.generateRoomRateProductInfo(oldProduct.room, oldProduct.dateRange, oldProduct.rate, undefined, oldProduct.quantity, oldProduct.promoCode),\n new: this.generateRoomRateProductInfo(newProduct.room, newProduct.dateRange, newProduct.rate, undefined, newProduct.quantity, newProduct.promoCode),\n },\n },\n };\n }\n\n public generateUpsellCancelledMessageObject(product: GenericAnalyticsAccommodation) {\n return {\n event: 'upsell_cancelled',\n ecommerce: {\n currency: this.currency.original,\n items: [this.generateRoomRateProductInfo(product.room, product.dateRange, product.rate, undefined, product.quantity, product.promoCode)],\n },\n };\n }\n\n public generateCheckoutViewMessageObject(basketRows: BasketRow[], addonRows: BasketAddonRow[]) {\n const productItems = basketRows.map((row, index) => {\n return this.generateRoomRateProductInfo(row.getRoom(), { to: row.getStartDate(), from: row.getEndDate() }, row.getRate() ?? undefined, index, 1, row.getPromoCode());\n });\n\n addonRows?.forEach((row, index) => {\n productItems.push(this.generateAddonProductInfo(row, index));\n });\n\n return {\n event: 'begin_checkout',\n ecommerce: {\n currency: this.currency.original,\n items: productItems,\n page_type: 'conversionintent',\n },\n };\n }\n\n public generateRoomPurchaseMessageObject(basketRows: BasketRow[], addonRows: BasketAddonRow[], reservations: ReservationsDTO) {\n const productItems = basketRows.map((row, index) => {\n return this.generateRoomRateProductInfo(row.getRoom(), { to: row.getStartDate(), from: row.getEndDate() }, row.getRate() ?? undefined, index, 1, row.getPromoCode());\n });\n\n addonRows?.forEach((row, index) => {\n productItems.push(this.generateAddonProductInfo(row, index));\n });\n\n return [\n {\n event: 'purchase',\n ecommerce: {\n currency: this.currency.original,\n transaction_id: reservations.itineraryNumber,\n value: reservations.total,\n tax: 0,\n coupon: undefined,\n payment_type: reservations.reservations[0].paymentMethod,\n page_type: 'conversion',\n\n items: productItems,\n },\n },\n ];\n }\n\n public generateRefundMessageObject(reservation: ReservationDTO) {\n const providerId = this.hotel?.providerHotelID;\n\n const nightKeys = Object.keys(reservation.nights);\n\n const startDate = dayjs(nightKeys[0]);\n const endDate = dayjs(nightKeys[nightKeys.length - 1]);\n\n const discount = nightKeys.reduce((acc, key) => {\n return acc + Number(reservation.nights[key].discount);\n });\n\n const idParts = [providerId, reservation.roomCode, reservation.rate];\n\n return {\n event: 'refund',\n ecommerce: {\n currency: this.currency.original,\n transaction_id: reservation.reservationNumber,\n value: reservation.total.afterTax,\n items: [\n {\n item_name: this.company?.brandSuffix + ' Accommodation',\n item_id: idParts.join('-'),\n item_brand: [this.hotel?.name, providerId].filter(Boolean).join(' - '),\n item_category: 'Room',\n item_category2: reservation.rate,\n item_category3: reservation.roomType,\n item_category5: this.hotel?.name + ' Room',\n item_list_name: 'BE List',\n coupon: undefined,\n discount,\n index: 0,\n price: reservation.total.afterTax,\n quantity: 1,\n selected_dates: this.formatDateRange({ from: startDate, to: endDate }) ?? undefined,\n upgrade: undefined,\n upgrade_price_dif: undefined,\n },\n ],\n },\n };\n }\n}\n\nconst ga4 = new GoogleAnalytics4();\n\nexport { ga4 as GoogleAnalytics4 };\n"]}
|
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
import ReservationsDTO, { ReservationDTO } from '../../models/Api/ReservationsDTO';
|
|
2
|
+
import BasketAddonRow from '../../models/BasketAddonRow';
|
|
3
|
+
import BasketRow from '../../models/BasketRow';
|
|
4
|
+
import { DateRange, GenericAnalyticsAccommodation } from '../DataLayer';
|
|
5
|
+
import { Analytics } from './Analytics';
|
|
6
|
+
declare class UniversalAnalytics extends Analytics {
|
|
7
|
+
private getProductInfo;
|
|
8
|
+
private generateAddonProductInfo;
|
|
9
|
+
generateRoomImpressionMessageObject(impressions: GenericAnalyticsAccommodation[]): {
|
|
10
|
+
event: string;
|
|
11
|
+
ecommerce: {
|
|
12
|
+
currencyCode: string;
|
|
13
|
+
impressions: Product[];
|
|
14
|
+
};
|
|
15
|
+
};
|
|
16
|
+
generateProductClickMessageObject(product: GenericAnalyticsAccommodation): {
|
|
17
|
+
event: string;
|
|
18
|
+
ecommerce: {
|
|
19
|
+
currencyCode: string;
|
|
20
|
+
click: {
|
|
21
|
+
products: Product[];
|
|
22
|
+
};
|
|
23
|
+
StartDate: string;
|
|
24
|
+
EndDate: string;
|
|
25
|
+
};
|
|
26
|
+
};
|
|
27
|
+
generateDateSelectionMessageObject(dateRange: DateRange, adults: number, children: number, infants?: number | undefined): {
|
|
28
|
+
event: string;
|
|
29
|
+
arrivalDate: string;
|
|
30
|
+
departureDate: string;
|
|
31
|
+
adultQty: string | null;
|
|
32
|
+
childQty: string | null;
|
|
33
|
+
infantQty: string | null;
|
|
34
|
+
};
|
|
35
|
+
generateAddToCartMessageObject(product: GenericAnalyticsAccommodation): {
|
|
36
|
+
event: string;
|
|
37
|
+
ecommerce: {
|
|
38
|
+
currencyCode: string;
|
|
39
|
+
add: {
|
|
40
|
+
products: Product[];
|
|
41
|
+
};
|
|
42
|
+
StartDate: string;
|
|
43
|
+
EndDate: string;
|
|
44
|
+
};
|
|
45
|
+
};
|
|
46
|
+
generateUpsellConfirmedMessageObject(oldProduct: GenericAnalyticsAccommodation, newProduct: GenericAnalyticsAccommodation): {
|
|
47
|
+
event: string;
|
|
48
|
+
priceDifference: number;
|
|
49
|
+
old: {
|
|
50
|
+
products: Product[];
|
|
51
|
+
};
|
|
52
|
+
new: {
|
|
53
|
+
products: Product[];
|
|
54
|
+
};
|
|
55
|
+
} | null;
|
|
56
|
+
generateUpsellCancelledMessageObject(product: GenericAnalyticsAccommodation): {
|
|
57
|
+
event: string;
|
|
58
|
+
item: Product[];
|
|
59
|
+
};
|
|
60
|
+
generateCheckoutViewMessageObject(basketRows: BasketRow[], addonRows: BasketAddonRow[]): {
|
|
61
|
+
event: string;
|
|
62
|
+
ecommerce: {
|
|
63
|
+
currencyCode: string;
|
|
64
|
+
checkout: {
|
|
65
|
+
actionField: {
|
|
66
|
+
step: number;
|
|
67
|
+
};
|
|
68
|
+
products: Product[];
|
|
69
|
+
};
|
|
70
|
+
StartDate: string | undefined;
|
|
71
|
+
EndDate: string | undefined;
|
|
72
|
+
PageType: string;
|
|
73
|
+
};
|
|
74
|
+
};
|
|
75
|
+
generateRoomPurchaseMessageObject(basketRows: BasketRow[], addonRows: BasketAddonRow[], reservations: ReservationsDTO): ({
|
|
76
|
+
event: string;
|
|
77
|
+
ecommerce: {
|
|
78
|
+
checkoutUpsell?: any;
|
|
79
|
+
currencyCode: string;
|
|
80
|
+
purchase: {
|
|
81
|
+
actionField: {
|
|
82
|
+
id: string;
|
|
83
|
+
revenue: number;
|
|
84
|
+
tax: number;
|
|
85
|
+
coupon: string;
|
|
86
|
+
};
|
|
87
|
+
products: Product[];
|
|
88
|
+
};
|
|
89
|
+
StartDate: string;
|
|
90
|
+
EndDate: string;
|
|
91
|
+
BookingDate: string;
|
|
92
|
+
PageType: string;
|
|
93
|
+
paymentType: import("../../../../core/dist").EBookingPaymentMethod | undefined;
|
|
94
|
+
};
|
|
95
|
+
} | undefined)[];
|
|
96
|
+
generateRefundMessageObject(reservation: ReservationDTO): any;
|
|
97
|
+
}
|
|
98
|
+
declare const ua: UniversalAnalytics;
|
|
99
|
+
export { ua as UniversalAnalytics };
|
|
100
|
+
type Product = {
|
|
101
|
+
name: string;
|
|
102
|
+
id: string;
|
|
103
|
+
price: number;
|
|
104
|
+
brand: string;
|
|
105
|
+
category: string;
|
|
106
|
+
variant?: string;
|
|
107
|
+
list?: string;
|
|
108
|
+
position?: number;
|
|
109
|
+
quantity?: number;
|
|
110
|
+
};
|