PageSourceSearch

https://www.brylanehome.com/on/demandware.static/Sites-oss-Site/-/…/v1791024463591/js/bloomReachWindowSDK.js

js brylanehome.com collected 2026-10-03 23:48:46 UTC 14,017 bytes, 72 lines download raw bytes

1!function(e){var t={};function n(r){if(t[r])return t[r].exports;var i=t[r]={i:r,l:!1,exports:{}};return e[r].call(i.exports,i,i.exports,n),i.l=!0,i.exports}n.m=e,n.c=t,n.d=function(e,t,r){n.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:r})},n.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},n.t=function(e,t){if(1&t&&(e=n(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var r=Object.create(null);if(n.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var i in e)n.d(r,i,function(t){return e[t]}.bind(null,i));return r},n.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return n.d(t,"a",t),t},n.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},n.p="",n(n.s=105)}({105:function(e,t){
2/*!
3 * Bloomreach window SDK (browser, no framework)
4 *
5 * What it does
6 * ------------
7 * 1. Owns window.brData = { context, page, queue } — merge updates via setContext / setPage.
8 * 2. When items are pushed to brData.queue, maps each { event, payload } to Bloomreach-shaped
9 *    payloads and calls window.brweb.track(eventName, mappedPayload) if brweb is present.
10 * 3. Optionally POSTs a slim copy to middlewareBloomreachApiUrl for view_item and cart_update only
11 *    (Exponea cookie, optional client IP you inject, device/page context).
12 * 4. Does not send purchase / purchase_item to brweb (intentionally skipped).
13 *
14 * Load order
15 * -----------
16 * - Include this script, then call BRSDK.init(...).
17 * - brweb is injected by Adobe Tag Manager (may load after this script). Events pushed
18 *   before brweb exists stay in the queue and are retried until brweb.track is available.
19 *
20 * Typical usage
21 * -------------
22 *   window.BRSDK.init({
23 *     debug: true,
24 *     middlewareBloomreachApiUrl: "https://your-backend.example.com/br-middleware",
25 *     exponeaCookieName: "__exponea_etc__"
26 *   });
27 *   window.BRSDK.setContext({ site: { brand: "x", locale: "en-US", currency: "USD" } });
28 *   window.BRSDK.setPage({ type: "product", product: { product_id: "sku", name: "...", price: 9.99 } });
29 *   window.BRSDK.push({ event: "view_item", payload: { product_id: "sku" } });
30 *
31 * Client IP (middleware POST only)
32 * ---------------------------------
33 * Browsers cannot read the visitor IP reliably. Resolve it on the server and pass it in:
34 *   window.setClientIp("203.0.113.1");
35 * or init({ clientIp: "..." }). Same function as BRSDK.setClientIp. Clear with null/"".
36 * Re-init without a clientIp key keeps an IP set earlier; init({ clientIp: null }) clears it.
37 *
38 * Identify / update (optional)
39 * ----------------------------
40 * BRSDK.identify(ids) and BRSDK.update(attrs) forward to brweb when loaded. identify runs once
41 * per tab session (sessionStorage) unless you change identifySessionKey.
42 *
43 * Optional init keys (see DEFAULT_CONFIG)
44 * ---------------------------------------
45 * startSdk + sdkStartConfig: if true, calls brweb.start(sdkStartConfig) after init when brweb exists.
46 * middlewareBloomreachAttributeKeys: per-event whitelist for attributes in the middleware JSON body.
47 *
48 * Middleware Bloomreach API (contract for backend)
49 * ------------------------------------------------
50 * Method: POST
51 * URL:    value of middlewareBloomreachApiUrl (same origin or CORS as needed)
52 * Headers: Content-Type: application/json
53 * Body (JSON object; empty keys omitted by the client after cleaning):
54 *
55 *   {
56 *     "event": "view_item" | "cart_update",
57 *     "attributes": { ... },
58 *     "brCookie": "<Exponea/Bloomreach cookie value or omitted>",
59 *     "clientIP": "<app-injected IP or omitted>",
60 *     "clientContext": {
61 *       "userAgent", "language", "platform", "vendor",
62 *       "screenWidth", "screenHeight", "viewportWidth", "viewportHeight",
63 *       "devicePixelRatio", "timezone", "pageUrl", "referrer"
64 *     } | omitted if includeClientContextInMiddlewareBloomreach is false
65 *   }
66 *
67 * Default attributes.view_item: product_id, title, price, brand, category_1, page_type, location,
68 *   domain, local_currency, language.
69 * Default attributes.cart_update: action, product_id, page_type, title, price, category_1,
70 *   total_quantity, total_price, product_list, location, domain, local_currency, language.
71 */
72!function(e){if(e){var t={debug:!1,dedupeWindowMs:3e3,observeIntervalMs:250,identifySessionKey:"__brsdk_identified__",startSdk:!1,sdkStartConfig:null,middlewareBloomreachApiUrl:null,exponeaCookieName:"__exponea_etc__",clientIp:null,includeClientContextInMiddlewareBloomreach:!0,middlewareBloomreachCredentials:"same-origin",middlewareBloomreachAttributeKeys:null},n={config:t,dedupeMap:{},processedQueueIndex:0,clientIp:null,pendingIdentify:null,pendingUpdate:null,consentConfig:null,lastIdentifiedEmail:null},r={init:function(r){return n.config=c(t,r||{}),r&&r.consentConfig&&(n.consentConfig=r.consentConfig),r&&Object.prototype.hasOwnProperty.call(r,"clientIp")?p(r.clientIp):n.clientIp&&(n.config.clientIp=n.clientIp),m(),function(){var e=m();if(!e.queue.__brsdkPatched){var t=e.queue.push;e.queue.push=function(){var r=t.apply(e.queue,arguments);return S(n.processedQueueIndex),r},e.queue.__brsdkPatched=!0}}(),e.setInterval((function(){m().queue.length>n.processedQueueIndex&&S(n.processedQueueIndex),k()}),n.config.observeIntervalMs),S(0),C(),i("initialized"),e.brData},setContext:function(e){var t=m();return t.context=c(t.context||{},e||{}),t.context},setPage:function(e){var t=m();return t.page=c(t.page||{},e||{}),t.page},push:function(e){m().queue.push(c({ts:o()},e||{}))},identify:q,update:x,flush:function(){S(n.processedQueueIndex),k()},getState:m,setClientIp:p,getClientIp:s,isCmapiAccepted:function(){var e=d("cmapi_cookie_privacy")||"";return!!e&&-1!==e.indexOf("permit 1,2,3")},isBloomreachEventConsented:l};e.BRSDK=r,e.setClientIp=p}function i(){if(n.config.debug){var e=Array.prototype.slice.call(arguments);e.unshift("[BRSDK]");try{console.log.apply(console,e)}catch(e){}}}function o(){return Date.now?Date.now():(new Date).getTime()}function a(e){return!!e&&"[object Object]"===Object.prototype.toString.call(e)}function c(e,t){var n=a(e)?function(e){try{return JSON.parse(JSON.stringify(e))}catch(t){return e}}(e):{};return a(t)?(Object.keys(t).forEach((function(e){var r=t[e],i=n[e];void 0!==r&&(a(i)&&a(r)?n[e]=c(i,r):n[e]=r)})),n):n}function u(e){if(Array.isArray(e)){var t=e.map(u).filter((function(e){return void 0!==e}));return t.length?t:void 0}if(a(e)){var n={};return Object.keys(e).forEach((function(t){var r=u(e[t]);void 0!==r&&(n[t]=r)})),Object.keys(n).length?n:void 0}if(null!=e&&""!==e)return e}function d(t){if(!t||!e.document||!e.document.cookie)return null;var n=("; "+e.document.cookie).split("; "+t+"=");if(2!==n.length)return null;try{return decodeURIComponent(n.pop().split(";").shift())}catch(e){return n.pop().split(";").shift()}}function l(e){return!0}function p(e){if(null==e||""===String(e).trim())return n.clientIp=null,n.config&&(n.config.clientIp=null),i("clientIp cleared"),null;var t=String(e).trim();return n.clientIp=t,n.config&&(n.config.clientIp=t),i("clientIp set"),t}function s(){return n.clientIp||void 0}function f(t){if(t.includeClientContextInMiddlewareBloomreach)try{return u({userAgent:navigator.userAgent,language:navigator.language,platform:navigator.platform,vendor:navigator.vendor,screenWidth:"undefined"!=typeof screen?screen.width:void 0,screenHeight:"undefined"!=typeof screen?screen.height:void 0,viewportWidth:e.innerWidth,viewportHe
72ight:e.innerHeight,devicePixelRatio:e.devicePixelRatio,timezone:"undefined"!=typeof Intl&&Intl.DateTimeFormat?Intl.DateTimeFormat().resolvedOptions().timeZone:void 0,pageUrl:e.location&&e.location.href,referrer:e.document&&e.document.referrer?e.document.referrer:void 0})}catch(e){return}}function y(e,t){var n={};return e&&t?(t.forEach((function(t){void 0!==e[t]&&null!==e[t]&&(n[t]=e[t])})),n):n}function _(e,t,n){var r=n.middlewareBloomreachAttributeKeys;return r&&r[e]&&Array.isArray(r[e])?y(t,r[e]):"view_item"===e?y(t,["product_id","variant_id","title","original_price","price","brand","category_1","page_type","location","domain","local_currency","language"]):"cart_update"===e?y(t,["action","product_id","page_type","title","price","category_1","total_quantity","total_price","product_list","location","domain","local_currency","language"]):{}}function g(){return e.brweb||null}function v(){var e=g();return!(!e||"function"!=typeof e.track)}function m(){return e.brData&&a(e.brData)||(e.brData={context:{site:{brand:"dummy-brand",locale:"en-US",currency:"USD"},user:{ids:{registered:null,email_id:null},attributes:{logged_in:!1}}},page:{type:null,url:e.location&&e.location.href?e.location.href:"",title:e.document&&e.document.title?e.document.title:"",product:null,cart:null,checkout:null},queue:[]}),Array.isArray(e.brData.queue)||(e.brData.queue=[]),e.brData}function b(e,t){return e+":"+JSON.stringify(u(t)||{})}function h(t,n){return{page_type:n.type||void 0,location:n.url||e.location&&e.location.href,domain:e.location&&e.location.hostname?e.location.hostname:void 0,language:t.site&&t.site.locale?String(t.site.locale).toLowerCase():void 0,local_currency:t.site&&t.site.currency?t.site.currency:void 0}}function w(e,t,n,r){return"view_item"===e?function(e,t,n){var r=t.product||{};return u(c(h(n,t),{product_id:e.product_id||r.product_id,variant_id:e.variant_id||r.variant_id,title:e.title||e.product_name||r.name,original_price:void 0!==e.original_price?e.original_price:r.original_price,price:void 0!==e.price?e.price:r.price,brand:e.brand||n.site.brand,category_1:e.category_1||r.category}))}(t,n,r):"cart_update"===e?function(e,t,n){var r=t.cart||{},i=(Array.isArray(r.items)?r.items:[]).map((function(e){return u({product_id:e.product_id,quantity:e.quantity})})).filter(Boolean);return u(c(h(n,t),{action:e.action,page_type:e.page_type||t.type,product_id:e.product_id,title:e.title,price:e.price,category_1:e.category_1,product_list:i.length?i:void 0,total_quantity:void 0!==e.total_quantity?e.total_quantity:r.total_quantity,total_price:void 0!==e.total_price?e.total_price:r.total_value}))}(t,n,r):"checkout"===e?function(e,t,n){var r=t.checkout||{},i=t.cart||{},o=(Array.isArray(i.items)?i.items:[]).map((function(e){return u({product_id:e.product_id,quantity:e.quantity})})).filter(Boolean);return u(c(h(n,t),{step_number:void 0!==e.step_number?e.step_number:r.step_number,step_title:e.step_title||r.step_title,total_quantity:void 0!==e.total_quantity?e.total_quantity:i.total_quantity,total_price:void 0!==e.total_price?e.total_price:i.total_value,product_list:o.length?o:void 0}))}(t,n,r):"view_category"===e?function(e,t,n){return u(c(h(n,t),{browsed_category_id:e.browsed_category_id,browsed_category_name:e.browsed_category_name,browsed_category_type:e.browsed_category_type,browsed_category_path:e.browsed_category_path,browsed_new_arrivals_category:e.browsed_new_arrivals_category,browsed_best_sellers_category:e.browsed_best_sellers_category,listed_product_ids:e.listed_product_ids,listed_product_ids_channel:e.listed_product_ids_channel,filter_by:e.filter_by,sort_by:e.sort_by,local_currency:e.local_currency,language:e.language,location:e.location,domain:e.domain}))}(t,n,r):u(c(h(r,n),t||{}))}function I(t){var r=m(),a=t||{},c=a.event;if(!c)return!0;if("purchase"===c||"purchase_item"===c)return!0;var l=a.ts||o(),p=w(c,a.payload||{},r.page||{},r.context||{});return function(e,t,r){var i=b(e,t),o=n.dedupeMap[i];return!!o&&r-o<=n.config.dedupeWindowMs}(c,p||{},l)?(i("deduped",c,p),!0):(function(t,r){var o=n.config,a=o.middlewareBloomreachApiUrl;if(a&&("view_item"===t||"cart_update"===t)){var c=u({event:t,attributes:_(t,r||{},o),brCookie:d(o.exponeaCookieName)||void 0,clientIP:s(),clientContext:f(o)});try{e.fetch(a,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(c||{}),credentials:o.middlewareBloomreachCredentials||"same-origin",keepalive:!0}).then((function(){i("middlewareBloomreach OK",t)})).catch((function(e){i("middlewareBloomreach failed",t,e)}))}catch(e){i("middlewareBloomreach error",e)}}}(c,p||{}),v()?!!function(e,t){if(!v())return i("brweb not ready, deferred track",e,t),!1;var n=g();return n&&"function"==typeof n.track?(n.track(e,t),i("tracked",e,t),!0):(i("brweb.track unavailable"),!1)}(c,p||{})&&(function(e,t,r){n.dedupeMap[b(e,t)]=r}(c,p||{},l),!0):(i("brweb not ready, queued for retry",c,p),!1))}
72function S(e){for(var t=m(),r=Math.max(e||0,0);r<t.queue.length;r+=1){if(!I(t.queue[r]))return void(n.processedQueueIndex=r);n.processedQueueIndex=r+1}}function k(){if(n.pendingIdentify){var e=n.pendingIdentify;n.pendingIdentify=null,q(e)}if(n.pendingUpdate){var t=n.pendingUpdate;n.pendingUpdate=null,x(t)}}function q(t){if(!v())return n.pendingIdentify=t,void i("brweb not ready, identify queued",t);var r=g();if(r&&"function"==typeof r.identify){n.pendingIdentify=null;var o=t&&t.email_id?String(t.email_id).trim():"",a=!(!o||!n.lastIdentifiedEmail||o===n.lastIdentifiedEmail);if(a){try{"function"==typeof r.anonymize&&(r.anonymize(),i("anonymized before re-identify",n.lastIdentifiedEmail,"->",o))}catch(e){}try{e.sessionStorage&&e.sessionStorage.removeItem(n.config.identifySessionKey)}catch(e){}}try{if(!a&&e.sessionStorage&&"1"===e.sessionStorage.getItem(n.config.identifySessionKey))return void i("identify skipped (session)")}catch(e){}var c=u(t||{})||{};r.identify(c),o&&(n.lastIdentifiedEmail=o);try{e.sessionStorage&&Object.keys(c).length&&e.sessionStorage.setItem(n.config.identifySessionKey,"1")}catch(e){}i("identified")}else i("brweb.identify unavailable")}function x(e){if(!v())return n.pendingUpdate=e,void i("brweb not ready, update queued",e);var t=g();t&&"function"==typeof t.update?(t.update(u(e||{})||{}),i("updated")):i("brweb.update unavailable")}function C(){if(n.config.startSdk&&v()){var e=g();e&&"function"==typeof e.start&&(e.start(n.config.sdkStartConfig||{}),i("brweb.start"))}}}(window)}});

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.