PageSourceSearch

https://allembroidered.com/wp-content/plugins/wp127/assets/ae-attribution-bridge.js?ver=1.2.27

js allembroidered.com collected 2026-10-02 18:16:45 UTC 4,845 bytes, 90 lines download raw bytes

1/* All Embroidered Attribution Bridge v1.1.0 */
2(()=>{
3  'use strict';
4  const VERSION='1.1.0';
5  const FIRST_KEY='ae_attribution_first_v1';
6  const CURRENT_KEY='ae_attribution_current_v1';
7  const SESSION_KEY='ae_attribution_session_v1';
8  const PORTAL_ORIGIN='https://app.allembroidered.com';
9  const DEBUG=new URLSearchParams(location.search).get('ae_attr_debug')==='1';
10  const log=(...a)=>{if(DEBUG&&window.console)console.log('[AE Attribution]',...a)};
11  const limit=(v,n)=>String(v||'').slice(0,n);
12  const params=new URLSearchParams(location.search);
13  const pick=name=>limit(params.get(name)||'',2048);
14  const cookieRead=key=>{
15    try{
16      const hit=document.cookie.split('; ').find(row=>row.startsWith(key+'='));
17      return hit?JSON.parse(decodeURIComponent(hit.split('=').slice(1).join('='))):null;
18    }catch(e){return null}
19  };
20  const read=key=>{
21    try{const v=JSON.parse(localStorage.getItem(key)||'null');if(v)return v}catch(e){}
22    return cookieRead(key);
23  };
24  const write=(key,value)=>{
25    try{localStorage.setItem(key,JSON.stringify(value))}catch(e){}
26    try{document.cookie=key+'='+encodeURIComponent(JSON.stringify(value))+'; Max-Age=7776000; Path=/; SameSite=Lax; Secure'}catch(e){}
27  };
28  const externalReferrer=()=>{
29    try{
30      if(!document.referrer)return '';
31      const u=new URL(document.referrer);
32      if(/(^|\.)allembroidered\.com$/i.test(u.hostname))return '';
33      return limit(document.referrer,2048);
34    }catch(e){return ''}
35  };
36  const makeTouch=()=>({
37    utm_source:pick('utm_source'),utm_medium:pick('utm_medium'),utm_campaign:pick('utm_campaign'),
38    utm_content:pick('utm_content'),utm_term:pick('utm_term'),gclid:pick('gclid'),gbraid:pick('gbraid'),
39    wbraid:pick('wbraid'),fbclid:pick('fbclid'),referrer:externalReferrer(),
40    landing_url:limit(location.href,2048),landing_path:limit(location.pathname+location.search,1024),
41    visit_at:new Date().toISOString()
42  });
43  const hasAcquisition=t=>['utm_source','utm_medium','utm_campaign','utm_content','utm_term','gclid','gbraid','wbraid','fbclid'].some(k=>!!t[k])||!!t.referrer;
44  const now=makeTouch();
45  let first=read(FIRST_KEY);
46  if(!first){first=now;write(FIRST_KEY,first);log('First touch saved',first)}
47  let current=read(CURRENT_KEY);
48  let newSession=false;
49  try{newSession=!sessionStorage.getItem(SESSION_KEY);sessionStorage.setItem(SESSION_KEY,'1')}catch(e){}
50  if(hasAcquisition(now)||!current||newSession){current=now;write(CURRENT_KEY,current);log('Current touch saved',current)}
51  const payload=()=>({
52    version:VERSION,
53    first_touch:first,
54    current_touch:current||now,
55    parent_page:{url:limit(location.href,2048),path:limit(location.pathname+location.search,1024),title:limit(document.title||'',255)},
56    click_ids:{
57      gclid:limit((current&&current.gclid)||(first&&first.gclid)||'',2048),
58      gbraid:limit((current&&current.gbraid)||(first&&first.gbraid)||'',2048),
59      wbraid:limit((current&&current.wbraid)||(first&&first.wbraid)||'',2048),
60      fbclid:limit((current&&current.fbclid)||(first&&first.fbclid)||'',2048)
61    }
62  });
63  const isPortalFrame=frame=>{
64    try{return new URL(frame.src,location.href).origin===PORTAL_ORIGIN}catch(e){return false}
65  };
66  const send=frame=>{
67    if(!frame||!isPortalFrame(frame))return;
68    try{frame.contentWindow&&frame.contentWindow.postMessage({type:'ae-marketing-attribution',attribution:payload()},PORTAL_ORIGIN);log('Sent to iframe',frame.src,payload())}catch(e){log('Send failed',e)}
69  };
70  const sendAll=()=>document.querySelectorAll('iframe').forEach(send);
71  const watch=()=>{
72    if(!document.documentElement||typeof MutationObserver==='undefined')return;
73    new MutationObserver(records=>{
74      for(const r of records){for(const node of r.addedNodes||[]){
75        if(!node||node.nodeType!==1)continue;
76        if(node.tagName==='IFRAME')send(node);
77        if(node.querySelectorAll)node.querySelectorAll('iframe').forEach(send);
78      }}
79    }).observe(document.documentElement,{childList:true,subtree:true});
80  };
81  window.addEventListener('message',event=>{
82    if(event.origin!==PORTAL_ORIGIN||!event.data||event.data.type!=='ae-attribution-ready')return;
83    document.querySelectorAll('iframe').forEach(frame=>{if(frame.contentWindow===event.source)send(frame)});
84  });
85  document.addEventListener('DOMContentLoaded',()=>{sendAll();watch()});
86  window.addEventListener('load',sendAll);
87  setTimeout(sendAll,500);setTimeout(sendAll,1500);setTimeout(sendAll,3500);
88  window.AEAttribution={version:VERSION,get:payload,send:sendAll,reset:()=>{try{localStorage.removeItem(FIRST_KEY);localStorage.removeItem(CURRENT_KEY);sessionStorage.removeItem(SESSION_KEY)}catch(e){};document.cookie=FIRST_KEY+'=; Max-Age=0; Path=/';document.cookie=CURRENT_KEY+'=; Max-Age=0; Path=/';location.reload()}};
89  log('Bridge loaded',payload());
90})();

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.