PageSourceSearch

https://www.recheio.pt/portal/webruntime/framework/9434f2fd57/prod/data-cloud-event-dispatcher

js recheio.pt collected 2026-09-26 19:07:23 UTC 13,130 bytes, 2 lines download raw bytes

1!function(){"use strict";class e{static enableDebug(e){this._debug=e}static log(e){this._debug&&console.log(`ExpTagManager: ${e}`)}static warn(e){this._debug&&console.warn(`ExpTagManager: ${e}`)}static error(e){this._debug&&console.error(`ExpTagManager: ${e}`)}}e._debug=!1;const t="identity",a="userEngagement",r="cart",o="search",n="catalog",i="order",s="error",c="cart",l="wish-list",d=["cart-add","cart-remove","cart-replace","cart-update","cart-view","checkout-begin","checkout-contact-info","checkout-user-register","checkout-shipping-address","checkout-billing-address","checkout-shipping-options","checkout-payment","checkout-apply-coupon","checkout-review","checkout-submit"],u=["wish-list-add","wish-list-remove","wish-list-replace","wish-list-update"],p={"cart-add":r,"cart-remove":r,"cart-replace":r,"cart-update":r,"cart-view":r,"checkout-begin":r,"checkout-contact-info":r,"checkout-user-register":r,"checkout-shipping-address":r,"checkout-billing-address":r,"checkout-shipping-options":r,"checkout-payment":r,"checkout-apply-coupon":r,"checkout-review":r,"checkout-submit":r,"wish-list-add":r,"wish-list-remove":r,"wish-list-replace":r,"wish-list-update":r,"catalog-object-view-start":n,"catalog-object-view-stop":n,"catalog-object-click":n,"catalog-object-impression":n,"form-submit":n,"user-engagement":a,"button-click":a,"anchor-click":a,"input-type-button-click":a,"input-type-submit-click":a,"input-type-reset-click":a,"page-scroll-to-bottom":a,"update-user-profile":a,"page-view":a,"email-update":"contactPointEmail","phone-update":"contactPointPhone","address-update":"contactPointAddress","order-accepted":i,"category-search":o,search:o,order:i,error:s},m="CRM_Id",g="ES_Identifier",v="Engagement",h="Profile",y="sftoken";class f{static getJsonFromDataLayer(t){let a;if(null!=t)try{a=JSON.parse(t.textContent.replace(/\s/g,""))}catch(t){e.log("Failed to parse data layer JSON")}return a}static getQueryStringForDataProviderType(e){return`script[type='application/json'][data-provider-type='${e}']`}static getCatalogObjectDataFromDataLayer(e,t){return Array.from(document.querySelectorAll(this.getQueryStringForDataProviderType("catalog"))).flatMap((e=>this.getJsonFromDataLayer(e))).filter((a=>a.type==t&&a.id==e))}static bytesToBase64(e){const t=String.fromCodePoint(...e);return btoa(t)}static isWellFormed(e){try{return encodeURIComponent(e),!0}catch(e){return!1}}}
2/*! js-cookie v3.0.5 | MIT */function I(e){for(var t=1;t<arguments.length;t++){var a=arguments[t];for(var r in a)e[r]=a[r]}return e}!function e(t,a){function r(e,r,o){if("undefined"!=typeof document){"number"==typeof(o=I({},a,o)).expires&&(o.expires=new Date(Date.now()+864e5*o.expires)),o.expires&&(o.expires=o.expires.toUTCString()),e=encodeURIComponent(e).replace(/%(2[346B]|5E|60|7C)/g,decodeURIComponent).replace(/[()]/g,escape);var n="";for(var i in o)o[i]&&(n+="; "+i,!0!==o[i]&&(n+="="+o[i].split(";")[0]));return document.cookie=e+"="+t.write(r,e)+n}}return Object.create({set:r,get:function(e){if("undefined"!=typeof document&&(!arguments.length||e)){for(var a=document.cookie?document.cookie.split("; "):[],r={},o=0;o<a.length;o++){var n=a[o].split("="),i=n.slice(1).join("=");try{var s=decodeURIComponent(n[0]);if(r[s]=t.read(i,s),e===s)break}catch(e){}}return e?r[e]:r}},remove:function(e,t){r(e,"",I({},t,{expires:-1}))},withAttributes:function(t){return e(this.converter,I({},this.attributes,t))},withConverter:function(t){return e(I({},this.converter,t),this.attributes)}},{attributes:{value:Object.freeze(a)},converter:{value:Object.freeze(t)}})}({read:function(e){return'"'===e[0]&&(e=e.slice(1,-1)),e.replace(/(%[\dA-F]{2})+/gi,decodeURIComponent)},write:function(e){return encodeURIComponent(e).replace(/%(2[346BF]|3[AC-F]|40|5[BDE]|60|7[BCD])/g,decodeURIComponent)}},{path:"/"});class b{static async get(t){if(t)try{const a=await fetch(t,{method:"GET"}),{status:r,statusText:o}=a;if(!(r<400)){throw new Error(`Get call failed on URL with status code ${r} and reason is: ${o}}`)}e.log(`Get call successful on URL ${t} with status code ${r}`)}catch(a){e.error(`Get call successful on URL ${t} with message ${a.message}`)}}}class P{static getCommonEventFields(e,t,a,r){const{site:o={},deviceIdentifier:n,source:i}=t,{siteId:s=window.location.host}=o;return{category:a,eventType:r,eventId:crypto.randomUUID(),dateTime:(new Date).toISOString(),deviceId:null==n?void 0:n.deviceId,sessionId:null==n?void 0:n.deviceId,interactionName:e,siteId:s,dataSpaceId:null==i?void 0:i.dataSpaceId,businessUnitId:null==i?void 0:i.businessUnitId}}static transformSearchResultToDLOFormat(e){var t;if(!e||0===Object.keys(e).length)return{};const a=null==e?void 0:e.id,r=null!==(t=null==e?void 0:e.attributes)&&void 0!==t?t:{},{title:o,absolutePosition:n,positionInPage:i,pageNumber:s,correlationId:c}=r;return{searchResultId:a,searchResultTitle:o,searchResultPosition:n,searchResultPositionInPage:i,searchResultPageNumber:s,correlationId:c}}static isIdentityEvent(e){const{name:a=""}=e||{};return a===t}static isPageViewEvent(e){const{name:t=""}=e||{};return"page-view"===t}static isEventFromCMSLandingPage(e){var t;const a=null===(t=null==e?void 0:e.source)||void 0===t?void 0:t.contentTypeName;return!(!a||"sfdc_cms__landingPage"!==a)}static isContactPointEvent(e){const{name:t=""}=e||{};return"email-update"===t||"phone-update"===t||"address-update"===t}static getWebstoreInfo(e){const{site:t={}}=e,{webstore:a={}}=t,{id:r="",...o}=a;return{webStoreId:r,...o}}static removeUndefinedAndNullAttributes(e){const{events:t}=e,a=[];return t.forEach((e=>{const t={};Object.keys(e).forEach((a=>{null!=e[a]&&(t[a]=e[a])})),a.push(t)})),{events:a}}static callTrackingServiceEndpoint(t){var a,r;const o=this.getQueryParamValue(y);if(o){const{deviceIdentifier:{deviceId:n}}=t,i=null===(r=null===(a=window.expTagMgrConfig)||void 0===a?void 0:a.UMA)||void 0===r?void 0:r.trackingSvcEndpoint;if(i)try{const e=new URL(`https://${i}/link?${y}=${o}&deviceId=${n}`);b.get(e.href.replace(/([^:]\/)\/+/g,"$1"))}catch(t){e.error("UMA tracking service endpoint is not a valid URL")}}}static getQueryParamValue(e){return new URLSearchParams(window.location.search).get(e)}}class C{static createContactPointPayload(e,t){const a=P.getCommonEventFields(null==t?void 0:t.name,e,h,p[null==t?void 0:t.name]),{name:r,...o}=t;return{...a,...o}}}class E{static createErrorPayloadFromErrorInteraction(e,t,a){const r=this.createParti
2alPayload(e,t,a),{id:o}=e;return{errorId:o,...r}}static createErrorPayloadFromErrorField(e,t,a,r){let o=null;if(e&&r){o={errorId:r,...this.createPartialPayload(e,t,a)}}return o}static createPartialPayload(e,t,a){const r=P.getCommonEventFields(a,t,v,s),o=null==e?void 0:e.attributes,{message:n,type:i,code:c,...l}=o;return{...r,errorCode:c,errorMessage:n,errorType:i,...l}}}class w{static createIdentityPayload(e,a=null){const{user:r}=e,o=null!=r?r:{attributes:{}},n=P.getCommonEventFields("identity",e,h,"identity"),{attributes:i,crmId:s}=o;let c={...n,...{isAnonymous:s?"0":"1",...i}};if((null==a?void 0:a.name)===t){const{name:e,...t}=a;c={...c,...t}}return c}}class S{static createCatalogObjectsPayload(e,t){const{name:r,catalogObjects:o}=e,i=[];let s=null;o&&(s=Array.isArray(o)?o[0].type:o.type);let c=a;s&&"Product"===s&&(c=n);const l=P.getCommonEventFields(r,t,v,c);return o?Array.isArray(o)?o.forEach((e=>{i.push(this.createCatalogObjectPayload(e,l))})):i.push(this.createCatalogObjectPayload(o,l)):i.push({...l}),i}static createCatalogObjectPayload(e,t){const{id:r,type:o,attributes:n}=e,{eventType:i}=t,s=f.getCatalogObjectDataFromDataLayer(r,o),c=Object.assign({},...s.map((e=>e.attributes)));let l={};return l=i===a?{catalogObjectId:r,catalogObjectType:o}:{id:r,type:o},{...l,...c,...n,...t}}}class k{static createSourcePayload(e){const t=null!=e?e:{},{urlReferrer:a,url:r,locale:o,type:n,channel:i,pageId:s,title:c,name:l,urlAlias:d,dataSpaceId:u,businessUnitId:p,utmSource:m,utmMedium:g,utmCampaign:v,utmTerm:h,utmContent:y,utmId:f,utmPlatform:I}=t;return{sourceUrlReferrer:a,sourceUrl:r,sourceLocale:o,sourceChannel:i,sourcePageType:n,sourcePageId:s,sourcePageTitle:c,sourcePageName:l,sourceURLAlias:d,dataSpaceId:u,businessUnitId:p,utmSource:m,utmMedium:g,utmCampaign:v,utmTerm:h,utmContent:y,utmId:f,utmPlatform:I}}}class F{static createCartOrWishListPayload(e,t,a,r){var o,n,i,s,d,u;const{name:p}=e;let m,g,v,h;const y=P.getWebstoreInfo(t);r===l?(m=null!==(o=e.wishList)&&void 0!==o?o:{},g=null!==(n=m.lineItems)&&void 0!==n?n:[],v=null!==(i=m.attributes)&&void 0!==i?i:{},h=null==m?void 0:m.id):r===c&&(m=null!==(s=e.cart)&&void 0!==s?s:{},g=null!==(d=m.lineItems)&&void 0!==d?d:[],v=null!==(u=m.attributes)&&void 0!==u?u:{},h=null==m?void 0:m.id);const{eventId:f}=a,I={id:h,...a,...v,...y},b=[];return Array.isArray(g)?g.forEach((e=>{b.push(this.createCartOrWishListItemPayload(e,f,p,t))})):b.push(this.createCartOrWishListItemPayload(g,f,p,t)),[I,...b]}static createCartOrWishListItemPayload(e,t,a,r){var o;const{id:n,attributes:i}=e,s=null!==(o=null==e?void 0:e.catalogObject)&&void 0!==o?o:{},{id:c,type:l,attributes:d}=s;return{...P.getCommonEventFields(a,r,v,"cartItem"),cartEventId:t,lineItemId:n,...i,catalogObjectId:c,catalogObjectType:l,...d}}}class T{static createSearchPayload(e,t){var a;const{searchQuery:r,categoryId:o}=e,n=null!==(a=null==e?void 0:e.attributes)&&void 0!==a?a:{},{searchFacetList:i,searchType:s,...c}=n;return{...t,searchQuery:r,categoryId:o,searchFacetList:null==i?void 0:i.toString(),searchType:null==s?void 0:s.toString(),...c}}}class O{static createOrderPayload(e,t){const{order:a}=e,{id:r,attributes:o}=a;return{...t,id:r,...o}}}class D{static createInteractionPayload(e,t){const{source:m,searchResult:g={},screenInfo:h,personalization:y={},userAgent:f,component:I={},catalogObjects:b={}}=t,{name:C,status:w}=e;let D=[];const R=P.getWebstoreInfo(t);if(p[C]===n){D=S.createCatalogObjectsPayload(e,t).map((e=>({...b,...e,...h,...I,...f,...k.createSourcePayload(m),...P.transformSearchResultToDLOFormat(g),...y,...R,eventStatus:w})))}else if(p[C]===r){const a=P.getCommonEventFields(C,t,v,r);u.includes(C)?D=F.createCartOrWishListPayload(e,t,a,l):d.includes(C)&&(D=F.createCartOrWishListPayload(e,t,a,c)),D[0]={...D[0],...h,...I,...f,...k.createSourcePayload(m),...P.transformSearchResultToDLOFormat(g),...y,eventStatus:w}}else if(p[C]===o){const a=P.getCommonEventFields(C,t,v,o),r={...T.createSearchPayload(e,a),...h,...I,...f,...k.createSourcePayload(m),...R,eventStatus:w};D.push(r)}else if(p[C]===s){const a={...E.createErrorPayloadFromErrorInteraction(e,t,C),...h,...I,...f,...R,...k.createSourcePayload(m)};D.push(a)}else if(p[C]===i){const a=P.getCommonEventFields(C,t,v,i),r={...O.createOrderPayload(e,a),...h,...I,...f,...k.createSourcePayload(m),...R,eventStatus:w};D.push(r)}else{const{name:r,...o}=e,{attributes:n={},...i}=o,s={...P.getCommonEventFields(r,t,v,a),...h,...I,...f,...k.createSourcePayload(m),...n,...i,...P.transformSearchResultToDLOFormat(g),...y,...R,eventStatus:w};D.push(s)}return D}}class R{static createPartyIdentificationPayload(e){var t;const{user:a,deviceIdentifier:r}=e,o=null!=a?a:{attributes:{}},n=P.getCommonEventFields("identity",e,h,"partyIdentification"),{crmId:i}=o,s=null!==(t=o.attributes)&&void 0!==t?t:{},{identityResolution:c}=s;let l=null;if(i&&!c){const e=`${null==r?void 0:r.deviceId}_${g}_${m}`;l={...n,IDName:m,IDType:g,userId:i,partyIdentificationId:e}}else if(c){const{partyIdentification:e={}}=c,{idName:t,id:a,idType:r,idNumber:o}=e;a&&o&&(l={...n,IDName:t,IDType:r,userId:o,partyIdentificationId:a})}return l}}class U{static createDataCloudEventPayload(e,t){const a=[];if(P.isIdentityEvent(e)){const r=w.createIdentityPayload(t,e);a.push(r)}else if(P.isContactPointEvent(e)){const r=C.createContactPointPayload(t,e);a.push(r)}else{if(P.isPageViewEvent(e)&&(P.callTrackingServiceEndpoint(t),!P.isEventFromCMSLandingPage(t))){const e=w.createIdentityPayload(t);a.push(e);const r=R.createPartyIdentificationPayload(t);r&&a.push(r)}const r=D.createInteractionPayload(e,t);a.push(...r);const o=E.createErrorPayloadFromErrorField(null==e?void 0:e.error,t,null==e?void 0:e.name,r[0].eventId);o&&a.push(o)}return a}}var L;null===(L=window.ECEngmtEvtDispatchers)||void 0===L||L.push({dispatcherName:"DataCloud",dispatcher:new class{sendEvent(t){const{tenantSpecificEndpoint:a,appSourceId:r}=window.expTagMgrConfig.dataCloud;if(a&&r)if(f.isWellFormed(t)){const e=f.bytesToBase64((new TextEncoder).encode(t)),o=encodeURIComponent(e);let n="";const i=`/web/events/${r}?event=`;n=a.includes("https://")?`${a}${i}`:`https://${a}${i}`,b.get(`${n}${o}`)}else e.log("Payload is not well formed");else e.log("Invalid DC configuration")}send(t,a){var r;if(!(null===(r=window.expTagMgrConfig)||void 0===r?void 0:r.dataCloud)||!a||"0"===a.dataUsePurpose)return void e.log("Could not send event as all conditions are not evaluating to true");const{interactions:o,...n}=t,i=[];if(o.length>1?o.forEach((e=>{(null==e?void 0:e.name)&&i.push(...U.createDataCloudEventPayload(e,{...n}))})):i.push(...U.createDataCloudEventPayload(o[0],{...n})),i.length){const e={events:i},t=P.removeUndefinedAndNullAttributes(e);this.sendEvent(JSON.stringify(t))}}}})}();

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.