ctt-babylon 0.25.1 → 0.25.3
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/esm2022/lib/components/core/babylon-booking-widget/babylon-booking-widget.component.mjs +142 -6
- package/esm2022/lib/services/mapper/mapper.service.mjs +2 -2
- package/fesm2022/ctt-babylon.mjs +142 -6
- package/fesm2022/ctt-babylon.mjs.map +1 -1
- package/lib/components/core/babylon-booking-widget/babylon-booking-widget.component.d.ts +1 -0
- package/package.json +1 -1
package/fesm2022/ctt-babylon.mjs
CHANGED
|
@@ -7580,7 +7580,7 @@ class MapperService {
|
|
|
7580
7580
|
title: texts?.title?.color?.trim(),
|
|
7581
7581
|
subtitle: texts?.subtitle?.color?.trim(),
|
|
7582
7582
|
},
|
|
7583
|
-
|
|
7583
|
+
backgroundImage: this.getImageResponsive(props?.multimedia?.backgroundimage?.[0], false),
|
|
7584
7584
|
years,
|
|
7585
7585
|
};
|
|
7586
7586
|
}
|
|
@@ -8648,16 +8648,152 @@ class BabylonBookingWidgetComponent {
|
|
|
8648
8648
|
return;
|
|
8649
8649
|
this.mounted = true;
|
|
8650
8650
|
const el = this.widgetContainer.nativeElement;
|
|
8651
|
-
// Opción A (si existe): init global manual
|
|
8651
|
+
// Opción A (si existe): init global manual
|
|
8652
8652
|
if (window.initializeWidgetSearch) {
|
|
8653
8653
|
window.initializeWidgetSearch();
|
|
8654
|
-
return;
|
|
8655
8654
|
}
|
|
8656
|
-
// Opción B: constructor
|
|
8657
|
-
if (window.WidgetSearch) {
|
|
8658
|
-
// Si tu WidgetSearch acepta (el, config), aquí puedes pasar config.
|
|
8655
|
+
// Opción B: constructor (Solo entra si no existe la A)
|
|
8656
|
+
else if (window.WidgetSearch) {
|
|
8659
8657
|
new window.WidgetSearch(el, {});
|
|
8660
8658
|
}
|
|
8659
|
+
this.injectMarketingParams(el);
|
|
8660
|
+
}
|
|
8661
|
+
injectMarketingParams(element) {
|
|
8662
|
+
// PROTECCIÓN SSR: Si estamos en el servidor de Node, abortamos para evitar cuelgues
|
|
8663
|
+
if (typeof window === 'undefined' ||
|
|
8664
|
+
typeof sessionStorage === 'undefined') {
|
|
8665
|
+
return;
|
|
8666
|
+
}
|
|
8667
|
+
// 1. DICCIONARIOS DE NOMENCLATURAS ESTÁNDAR
|
|
8668
|
+
// Clic IDs automáticos de las principales plataformas publicitarias[cite: 16]
|
|
8669
|
+
const CLICK_IDS = [
|
|
8670
|
+
'gclid',
|
|
8671
|
+
'gbraid',
|
|
8672
|
+
'wbraid',
|
|
8673
|
+
'dclid',
|
|
8674
|
+
'msclkid',
|
|
8675
|
+
'vmcid',
|
|
8676
|
+
'yclid',
|
|
8677
|
+
'ymclid',
|
|
8678
|
+
'fbclid',
|
|
8679
|
+
'ttclid',
|
|
8680
|
+
'li_fat_id',
|
|
8681
|
+
'twclid',
|
|
8682
|
+
'epik',
|
|
8683
|
+
'rdt_cid',
|
|
8684
|
+
'ScCid',
|
|
8685
|
+
'qclid',
|
|
8686
|
+
'si',
|
|
8687
|
+
'awclid',
|
|
8688
|
+
'tblci',
|
|
8689
|
+
'dicbo',
|
|
8690
|
+
'ad_id',
|
|
8691
|
+
'irclickid',
|
|
8692
|
+
'cjevent', // Afiliados (Impact, CJ)[cite: 16]
|
|
8693
|
+
];
|
|
8694
|
+
// Estándar manual UTM
|
|
8695
|
+
const UTMS = [
|
|
8696
|
+
'utm_source',
|
|
8697
|
+
'utm_medium',
|
|
8698
|
+
'utm_campaign',
|
|
8699
|
+
'utm_term',
|
|
8700
|
+
'utm_content',
|
|
8701
|
+
];
|
|
8702
|
+
const marketingData = {};
|
|
8703
|
+
const params = new URLSearchParams(window.location.search);
|
|
8704
|
+
// --- CAPA 1: ESCANEO DE LA URL ---
|
|
8705
|
+
[...CLICK_IDS, ...UTMS, 'origin'].forEach((key) => {
|
|
8706
|
+
const value = params.get(key);
|
|
8707
|
+
if (value)
|
|
8708
|
+
marketingData[key] = value;
|
|
8709
|
+
});
|
|
8710
|
+
// --- CAPA 2: ESCANEO DE COOKIES (Si la URL está limpia pero hay rastro publicitario) ---
|
|
8711
|
+
const getCookie = (name) => {
|
|
8712
|
+
const match = document.cookie.match(new RegExp('(^| )' + name + '=([^;]+)'));
|
|
8713
|
+
return match ? match[2] : null;
|
|
8714
|
+
};
|
|
8715
|
+
if (Object.keys(marketingData).length === 0) {
|
|
8716
|
+
// Google Ads guarda su GCLID en la cookie _gcl_aw (formato: GCL.timestamp.id)
|
|
8717
|
+
const gclAw = getCookie('_gcl_aw');
|
|
8718
|
+
if (gclAw && gclAw.split('.').length >= 3) {
|
|
8719
|
+
marketingData['gclid'] = gclAw.split('.')[2];
|
|
8720
|
+
}
|
|
8721
|
+
// Facebook guarda su FBCLID en la cookie _fbp
|
|
8722
|
+
const fbp = getCookie('_fbp');
|
|
8723
|
+
if (fbp) {
|
|
8724
|
+
marketingData['fbclid'] = fbp;
|
|
8725
|
+
}
|
|
8726
|
+
}
|
|
8727
|
+
// --- CAPA 3: ESCANEO DEL DATALAYER (Inyecciones silenciosas de Tag Manager) ---
|
|
8728
|
+
if (Object.keys(marketingData).length === 0 &&
|
|
8729
|
+
window.dataLayer) {
|
|
8730
|
+
const dl = window.dataLayer;
|
|
8731
|
+
// Recorremos de más reciente a más antiguo
|
|
8732
|
+
for (let i = dl.length - 1; i >= 0; i--) {
|
|
8733
|
+
const item = dl[i];
|
|
8734
|
+
[...CLICK_IDS, ...UTMS, 'traffic_source', 'origin'].forEach((key) => {
|
|
8735
|
+
if (item[key] && !marketingData[key]) {
|
|
8736
|
+
// Mapear un nombre interno (ej. traffic_source) al estándar
|
|
8737
|
+
const finalKey = key === 'traffic_source' ? 'origin' : key;
|
|
8738
|
+
marketingData[finalKey] = item[key];
|
|
8739
|
+
}
|
|
8740
|
+
});
|
|
8741
|
+
if (Object.keys(marketingData).length > 0)
|
|
8742
|
+
break;
|
|
8743
|
+
}
|
|
8744
|
+
}
|
|
8745
|
+
// --- CAPA 4: RECUPERAR / GUARDAR SESIÓN (Protección SPA en Angular) ---
|
|
8746
|
+
if (Object.keys(marketingData).length === 0) {
|
|
8747
|
+
// No hay datos nuevos, recuperamos todo lo que tenga prefijo 'mkt_'
|
|
8748
|
+
const storedKeys = Object.keys(sessionStorage).filter((k) => k.startsWith('mkt_'));
|
|
8749
|
+
storedKeys.forEach((k) => {
|
|
8750
|
+
const originalKey = k.replace('mkt_', '');
|
|
8751
|
+
const val = sessionStorage.getItem(k);
|
|
8752
|
+
if (val)
|
|
8753
|
+
marketingData[originalKey] = val;
|
|
8754
|
+
});
|
|
8755
|
+
}
|
|
8756
|
+
else {
|
|
8757
|
+
// Hay datos nuevos, los guardamos para la próxima vez que navegue por la web
|
|
8758
|
+
try {
|
|
8759
|
+
Object.entries(marketingData).forEach(([key, value]) => {
|
|
8760
|
+
sessionStorage.setItem(`mkt_${key}`, value);
|
|
8761
|
+
});
|
|
8762
|
+
}
|
|
8763
|
+
catch (error) {
|
|
8764
|
+
console.warn('Acceso a sessionStorage bloqueado por el navegador.');
|
|
8765
|
+
}
|
|
8766
|
+
}
|
|
8767
|
+
// --- ENVÍO AL WIDGET ---
|
|
8768
|
+
if (Object.keys(marketingData).length > 0) {
|
|
8769
|
+
// Witbooking y motores similares suelen necesitar un "origin" genérico además de los parámetros opacos
|
|
8770
|
+
if (!marketingData['origin']) {
|
|
8771
|
+
if (marketingData['utm_source']) {
|
|
8772
|
+
marketingData['origin'] =
|
|
8773
|
+
marketingData['utm_source'] +
|
|
8774
|
+
(marketingData['utm_medium']
|
|
8775
|
+
? `_${marketingData['utm_medium']}`
|
|
8776
|
+
: '');
|
|
8777
|
+
}
|
|
8778
|
+
else if (marketingData['gclid'] ||
|
|
8779
|
+
marketingData['wbraid'] ||
|
|
8780
|
+
marketingData['gbraid']) {
|
|
8781
|
+
marketingData['origin'] = 'google_cpc';
|
|
8782
|
+
}
|
|
8783
|
+
else if (marketingData['fbclid']) {
|
|
8784
|
+
marketingData['origin'] = 'meta_ads';
|
|
8785
|
+
}
|
|
8786
|
+
else if (marketingData['ttclid']) {
|
|
8787
|
+
marketingData['origin'] = 'tiktok_ads';
|
|
8788
|
+
}
|
|
8789
|
+
}
|
|
8790
|
+
setTimeout(() => {
|
|
8791
|
+
const event = new CustomEvent('widgetUpdateParams', {
|
|
8792
|
+
detail: marketingData,
|
|
8793
|
+
});
|
|
8794
|
+
element.dispatchEvent(event);
|
|
8795
|
+
}, 500);
|
|
8796
|
+
}
|
|
8661
8797
|
}
|
|
8662
8798
|
ngOnChanges(changes) {
|
|
8663
8799
|
if (changes['ticker']) {
|