@pendo/agent 2.316.0 → 2.317.1

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.
@@ -1,4 +1,4 @@
1
1
  /*
2
2
  @license https://agent.pendo.io/licenses
3
3
  */
4
- !function(){"use strict";class L{constructor(e,t){this.path=e,this.handler=t}}class G{routes={};addRoute(e,t){this.routes[e]||(this.routes[e]=[]),this.routes[e].unshift(new L(e,t))}removeRoute(e){this.routes[e].shift()}lookupRouteProvider(){return e=>this.routes[e]?this.routes[e][0].handler:undefined}}const c=(...e)=>s=>{return[].concat(e).reduce((e,t,i,n)=>{e=t(e,s);return e||n.splice(i,n.length-i),e},s)};let W=0;const i=(e,t,i)=>{if(!e||"string"!=typeof t)return i;let n=e;for(const s of t.split(".")){if(null==n)return i;n=n[s]}return n===undefined?i:n};const t=(t,i)=>{if(t&&i)if(Array.isArray(t))for(let e=0;e<t.length;e++)i(t[e],e,t);else if("object"==typeof t)for(const e in t)t.hasOwnProperty(e)&&i(t[e],e,t);return t},h=e=>"function"==typeof e,O=e=>!(null==e),d=()=>Date.now();class e{app=null;router=null;destination=window.parent||window.top;origin="*";constructor(e,t={}){this.app=e,this.router=e.router,this.config=t,this.events=e.PluginAPI.getEventable()}getConfig(e,t){return i(this.config,e,t)}getDestinationProvider(){return()=>this.destination}getOriginProvider(){return()=>this.origin}triggerOpened(){this.events.trigger("opened",{containerType:this.type})}triggerClosed(){this.events.trigger("closed",{containerType:this.type})}}var a={padding:"0 !important",margin:"0 !important","box-sizing":"border-box !important",border:"none !important",display:"block !important",visibility:"visible !important"},u=2147483647,g={WINDOW_MARGIN:10,HEADER_HEIGHT:50,TOP:100,LEFT:100,HEIGHT:700,WIDTH:500,MIN_HEIGHT:500,MIN_WIDTH:500};const{MIN_HEIGHT:p,MIN_WIDTH:l,WINDOW_MARGIN:f}=g;function s(t,i,n,s,o){let r=0,a=0,d=0,u=0;function c(e){e.preventDefault(),i.css({visibility:"hidden"}),t.releasePointerCapture(e.pointerId),t.removeEventListener("pointermove",h),o()}function h(e){-1!==e.button||0===e.buttons?c(e):(e.preventDefault(),d=r-e.clientX,u=a-e.clientY,r=e.clientX,a=e.clientY,s(d,u))}t.addEventListener("pointerdown",function(e){0===e.button&&(e.preventDefault(),i.css({visibility:"visible"}),r=e.clientX,a=e.clientY,t.setPointerCapture(e.pointerId),t.addEventListener("pointermove",h),n())}),t.addEventListener("pointerup",c),t.addEventListener("pointerout",c)}function U(e,t){const i=e.handle[0],n=e.container[0];s(i,e.blockout,function(){i.style.cursor="grabbing"},function(e,t){n.style.left=m(n,e)+"px",n.style.top=v(n,t)+"px"},function(){i.style.cursor="grab",t()})}function m(e,t){t=e.offsetLeft-t,e=window.innerWidth-e.offsetWidth-f;return t<f||e<f?f:e<t?e:t}function v(e,t){t=e.offsetTop-t,e=window.innerHeight-e.offsetHeight-f;return t<f||e<f?f:e<t?e:t}function _(e,t){var i=e.resizeHandle[0];const n=e.container[0];s(i,e.blockout,()=>{},function(e,t){n.style.width=b(n,e)+"px",n.style.height=w(n,t)+"px"},t)}function b(e,t){t=e.offsetWidth-t,e=window.innerWidth-e.offsetLeft-f;return e<t?e:t<l?l:t}function w(e,t){t=e.offsetHeight-t,e=window.innerHeight-e.offsetTop-f;return e<t?e:t<p?p:t}class F extends e{type="frame";destination=window.parent||window.top;origin=window.location.origin;constructor(n,e){super(n,e);const{pendo:s,PluginAPI:o}=n;e=this.getConfig("containerId","pendo-client-app");this.container=s.dom(`<div id="${e}" class="pendo-ignore">`).css({...a,height:n.state.height,width:n.state.width,"z-index":u-1,"background-color":"#FFFFFF",position:"fixed","box-shadow":"rgb(136, 136, 136) 0px 0px 20px 0px",overflow:"hidden"}),this.handle=s.dom('<div id="pendo-app-draggable-handle">').css({...a,"z-index":u,height:g.HEADER_HEIGHT,width:"calc(100% - 100px)",position:"absolute",cursor:"grab"}).on("dblclick",()=>{n.state.minimized||(this.container.css({height:g.HEIGHT,width:g.WIDTH,transition:"all 250ms linear"}),setTimeout(()=>{this.container&&(this.container.css({transition:"none"}),this.saveSize())},250))}).appendTo(this.container),this.resizeHandle=s.dom('<div id="pendo-app-resize-handle">').css({...a,"z-index":u,visibility:this.app.state.minimized?"hidden":"visible",height:0,width:0,"border-left":"10px solid transparent","border-bottom":"10px solid rgb(136, 136, 136)",cursor:"nwse-resize",position:"absolute",bottom:0,right:0}).appendTo(this.container),this.frame=s.dom('<iframe id="pendo-agent-application" src="about:blank">').css({...a,height:"100%",width:"100%"}).on("load",()=>{if(o.ConfigReader.get("inlineStyleNonce")){const i=this.frame[0].contentDocument.createElement.bind(this.frame[0].contentDocument);this.frame[0].contentDocument.createElement=(e,...t)=>{t=i(e,...t);return"style"===e&&(e=o.ConfigReader.get("inlineStyleNonce"))&&t.setAttribute("nonce",e),t}}var e,t=document.createElement("script");t.src=((e=s)&&e.trustedTypesPolicy?e.trustedTypesPolicy:{createScriptURL(e){return e}}).createScriptURL(o.getAssetUrl(n.assetName)),this.frame[0].contentDocument.body.appendChild(t),this.frame[0].contentWindow.ignoreIframeMonitor=!0,this.triggerOpened()}).appendTo(this.container),this.blockout=s.dom('<div id="pendo-app-dragging-blockout">').css({"z-index":u-2,position:"absolute",height:"100%",width:"100%",top:0,left:0,visibility:"hidden"}).appendTo(s.dom.getBody()),this.elements=[this.container,this.blockout],this.positionFrame=e=>{var{left:t,top:i,height:n}=e,{minimized:e,width:s}=e,t=t||g.LEFT,i=i||g.TOP,n=e?g.HEADER_HEIGHT:n;t=m({offsetLeft:t,offsetWidth:s},0),i=v({offsetTop:i,offsetHeight:n},0),this.container.css({left:t,top:i,height:n}),this.savePosition()},this.saveSize=()=>{var{offsetHeight:e,offsetWidth:t}=this.container[0];e&&t&&this.app.setProperties({height:e,width:t})},this.savePosition=()=>{var{offsetLeft:e,offsetTop:t}=this.container[0];e&&t&&this.app.setProperties({left:e,top:t})},this.toggleMinimize=()=>{this.app.setProperties({minimized:!this.app.state.minimized}),this.resizeHandle.css({visibility:this.app.state.minimized?"hidden":"visible"}),this.positionFrame(this.app.state)},this.positionFrame(this.app.state),U(this,this.savePosition),_(this,this.saveSize),window.addEventListener("resize",r),this.listeners=[["resize",r]];const t=s._.throttle(()=>{return e=this.container[0],0<(t=e.offsetLeft+e.offsetWidth+f-window.innerWidth)&&(e.style.left=m(e,t)+"px",e.offsetWidth>l)&&(e.style.width=b(e,t)+"px"),void(0<(t=e.offsetTop+e.offsetHeight+f-window.innerHeight)&&(e.style.top=v(e,t)+"px",e.offsetHeight>p)&&(e.style.height=w(e,t)+"px"));var e,t},10),i=s._.debounce(()=>{this.savePosition(),this.saveSize()},1e3);function r(){t(),i()}}open(){return this.router.addRoute("app::toggleMinimize",this.toggleMinimize),this.container.appendTo(this.app.pendo.dom.getBody()),Promise.resolve()}close(){this.router.removeRoute("app::toggleMinimize"),this.listeners.forEach(([e,t])=>window.removeEventListener(e,t)),this.elements.forEach(e=>e.remove()),this.triggerClosed()}}const y="promise";function T(e,t,i){this.name=e,this.type=t,this.data=i}T.prototype.toString=function(){return`Message.${this.type} - `+this.name};const $=(e,t,i)=>{e=new T(e,t,i);return t===y&&(e.requestId=""+(W+=1)),e},C=e=>{try{var{name:t,type:i,isResponse:n,data:s,requestId:o,sender:r}=e.data||{},a=new T(t,i,O(s)?JSON.parse(s):undefined);return a.requestId=o,a.sender=r,a.destination=e.source,a.isResponse=n,a}catch(d){return!1}},q=e=>{var t=((e,t)=>{if(!e||"object"!=typeof e)return{};var i=Array.isArray(t)?t:[t],n={};for(const s in e)e.hasOwnProperty(s)&&!i.includes(s)&&(n[s]=e[s]);return n})(e,["destination","toString","data"]);return t.data=JSON.stringify(e.data,(e,t)=>"function"==typeof t||t instanceof RegExp?t.toString?t.toString():undefined:t),t},n=e=>(e.isResponse=!0,e),o="disconnected",P={lastMessageReceivedAt:0,currentConnectionQuality:o,changeCallbacks:{},evalCallbacks:{}},r=e=>{e!==P.currentConnectionQuality&&(P.currentConnectionQuality=e,t(P.changeCallbacks,e=>{e(P.currentConnectionQuality)}))},B=()=>{var e;0===P.lastMessageReceivedAt?r(o):((e=d()-P.lastMessageReceivedAt)<1e4?r("connected"):1e4<e&&(3e4<e?r("dead_connection"):r(o)),t(P.evalCallbacks,e=>{e(P.currentConnectionQuality)}))};let I;let R=0;const j=()=>{P.currentConnectionQuality=o,P.lastMessageReceivedAt=0},E={appName:undefined,connectionName:undefined,frameId:undefined,pendingRequests:{},topics:{},senderIds:{},originProvider:undefined,destinationProvider:undefined},S=()=>""+E.appName+E.connectionName+`(${E.frameId})`,H=e=>{e.sender||(e.sender=S());var t=e.destination||E.destinationProvider(),i=q(e),n=Q(e.sender),s=K(e.sender);n||s?n?n.postMessage(i):t.postMessage(i,E.originProvider()):(s=new MessageChannel,ee(s.port1,e.sender),t.postMessage(i,E.originProvider(),[s.port2]))},D=(s,o,r=1e3)=>new Promise((e,t)=>{const i=$(s,y,o),n=setTimeout(()=>{t(s+" timeout"),A(i),ie(i)},r);X(i,()=>clearTimeout(n),e,t),H(i)}),z=e=>{var t;return E.senderIds[e]||(t=e,E.senderIds[t])||(E.senderIds[t]={port:undefined,hasTriedToUpgradeToMessageChannel:!1}),E.senderIds[e]},Q=e=>z(e).port,K=e=>z(e).hasTriedToUpgradeToMessageChannel,X=(e,t,i,n)=>{E.pendingRequests[e.requestId]={message:e,clearTimeoutfn:t,resolve:i,reject:n}};const A=e=>{var t=e["requestId"];return E.pendingRequests[t].clearTimeoutfn(),delete E.pendingRequests[t],e};const k="message::ping";var Y;const J=c(e=>{var t=E.pendingRequests[e.requestId];return t&&(t.resolve(e.data),A(e)),e},t=>{var e=E.topics[t.name];return e&&e.forEach(e=>e(t.data)),t},t=>{var e;return t&&!t.isResponse&&(t.name===k?H(n(t)):(e=E.routeHandlerLookup(t.name))?e(t,e=>{t.data=e,H(n(t))}):console.log(S(),"No route handler for "+t.name,t)),t},(Y=()=>{var e;e=d(),P.lastMessageReceivedAt=e},(e,...t)=>(Y(e,...t),e))),V=e=>("*"===E.originProvider()||e.origin===E.originProvider())&&e,Z=e=>{var t=i(e,"data.sender");return!(!t||"string"!=typeof t||!t.includes(E.appName))&&e},ee=(e,t)=>{t=z(t);t.port=e,t.hasTriedToUpgradeToMessageChannel=!0,t.port.onmessage=c(C,J)},te=(e,t)=>{return!z(e.sender).hasTriedToUpgradeToMessageChannel&&t.ports&&t.ports[0]&&ee(t.ports[0],e.sender),e},ie=e=>{e=e.sender;(e=z(e)).port=undefined,e.hasTriedToUpgradeToMessageChannel=!1};let N=()=>{};const ne=()=>{N(),N=()=>{},I&&I(),j()},se=((n,s)=>{let o,r=0,a;return function(...e){var t=d(),i=s-(t-r);return i<=0||s<i?(o&&(clearTimeout(o),o=null),r=t,a=n.apply(this,e)):!o&&0<s&&(o=setTimeout(()=>{r=d(),o=null,a=n.apply(this,e)},i)),a}})(e=>{"connected"!==e&&E.usePingAutoReconnect&&D(k)["catch"](()=>{console.log("message::ping timedout")})},1e3),oe=(e,t,i,n,s,o=!1,r)=>{if(window.addEventListener){E.appName=e,E.frameId=t,E.routeHandlerLookup=i,E.usePingAutoReconnect=o,E.connectionName=r||"",E.originProvider=n||(()=>window.location.origin||"*"),E.destinationProvider=s||(()=>window.parent||window.top);{const d=setInterval(B,100);I=()=>clearInterval(d)}e=se;if(h(e)){const u=R++;P.evalCallbacks[u]=e}const a=c(V,Z,C,te,J);window.addEventListener("message",a),N=()=>window.removeEventListener("message",a)}},re=e=>{if(h(e)){const t=R++;P.changeCallbacks[t]=e}};class ae extends e{type="window";testUrl="";realUrl=undefined;getTitle(){return this.getConfig("title",this.getName())}getName(){return this.getConfig("name","Agent_Application")}open(){return this.router.addRoute("app::windowClosed",()=>{this.app.setProperties({containerType:"frame"}),this.app.stop()}),this.testConnection().then(()=>{this.triggerOpened()})["catch"](()=>{return this.createWindow(),s=this.app,o=1e3,new Promise((e,t)=>{const i=d(),n=()=>{s.getConnectionStatus()?e():d()-i>o?t():setTimeout(n,50)};n()});var s,o})}testConnection(){return this.destination=window.open(this.testUrl,this.getName(),`width=${this.app.state.width},height=${this.app.state.height},resizable=yes,scrollbars=yes,status=yes,location=no`),D("app::reconnect")}createWindow(){this.realUrl&&(this.destination=window.open(this.realUrl,this.getName(),`width=${this.app.state.width},height=${this.app.state.height},resizable=yes,scrollbars=yes,status=yes,location=no`));var e=document.createElement("script");e.src=this.app.PluginAPI.getAssetUrl(this.app.assetName),this.destination.document.body.appendChild(e),this.destination.document.title=this.getTitle()}close(){this.router.removeRoute("app::windowClosed"),this.destination.close(),this.triggerClosed()}}const de=()=>({});class ue{defaultState={containerType:"frame",minimized:!1,height:g.HEIGHT,width:g.WIDTH,left:g.LEFT,top:g.TOP};state={};containerClosedCallbacks=[];container=null;isConnected=!1;constructor(e,t,i,n,s,o=de,r=de){this.appName=e,this.assetName=t,this.assetStorageKey=i,this.connectionName=n,this.frameConfigProvider=o,this.windowConfigProvider=r,s&&Object.assign(this.defaultState,s),this.router=new G}init(e,t){this.pendo=e,this.PluginAPI=t,this.events=t.getEventable(),this.router.addRoute("app::ping",(e,t)=>{t()}),this.router.addRoute("app::setProperties",({data:e})=>{this.setProperties(e)}),this.router.addRoute("app::toggleContainer",()=>{this.setProperties({minimized:!1}),this.toggleContainerType()}),this.router.addRoute("app::windowClosed",()=>{}),this.loadState(),this.prepContainer(),this.start()}prepContainer(){this.container="window"===this.state.containerType?new ae(this,this.windowConfigProvider()):new F(this,this.frameConfigProvider())}setConnectionStatus(e){this.isConnected="connected"===e}getConnectionStatus(){return this.isConnected}setProperties(e){Object.assign(this.state,e),this.writeState()}getDefaultState(){return this.defaultState||{}}loadState(){try{var e=this.PluginAPI.agentStorage.read(this.assetStorageKey);this.state=Object.assign({},this.getDefaultState(),this.state,e)}catch(t){this.PluginAPI.log.error(t),this.state=Object.assign({},this.getDefaultState(),this.state)}}writeState(){this.PluginAPI.agentStorage.write(this.assetStorageKey,this.state)}toggleContainerType(){var e="frame"===this.state.containerType?"window":"frame";this.setProperties({containerType:e}),this.stop(),this.start()}start(){this.container||this.prepContainer();var e=this.PluginAPI.EventTracer.addTracerIds({})["frameId"];oe(this.appName,e,this.router.lookupRouteProvider(),this.container.getOriginProvider(),this.container.getDestinationProvider(),!0,this.connectionName),re(e=>{this.setConnectionStatus(e)}),this.container.open().then(()=>{this.events.trigger("mounted")})["catch"](()=>{"window"===this.state.containerType?(this.setProperties({containerType:"frame"}),this.prepContainer(),this.start()):(this.PluginAPI.log(`Failed to start ${this.appName} in either window or frame.`),this.stop())})}stop(){this.container.close(),this.container=null,this.events.trigger("unmounted"),ne()}}const ce=()=>{try{return performance.getEntries()}catch(e){return[{failedGetEntries:!0,message:e.message,stack:e.stack}]}};class he extends ue{constructor(){super("Debugger","pendo.debugger.min.js","debug-enabled","AgentPlugin",null,()=>({containerId:"pendo-client-debugger"}),()=>({title:"Pendo Debugger"}))}initialize(s,o){o.restartDebugger=this.start.bind(this),super.init(s,o),this.router.addRoute("debugger::connect",(e,t)=>{var i;t({config:o.ConfigReader.audit(),env:{apiKey:(i=s).apiKey,environment:i.debugging.isStagingServer()?"staging":"production",device:i.debugging.isMobileUserAgent()?"mobile":"desktop",browserCookies:window.navigator.cookieEnabled,guideStatus:i.areGuidesDisabled()?"off":i.areGuidesDelayed()?"delayed":"on",foundShadowRoot:!!(i=i.debugging.observer.shadowDom).foundShadowRoots||(i.findShadowRoots(document,Infinity,()=>{}),i.foundShadowRoots)},container:this.state,events:o.store.state["debugger"].eventsCaptured,timeOrigin:performance.timeOrigin})}),this.router.addRoute("debugger::stop",()=>{s.disableDebugging()}),this.router.addRoute("debugger::showGuideById",(e,t)=>{t(s.showGuideById(e.data))}),this.router.addRoute("debugger::toggleGuideLoop",e=>{e.data?s.startGuides():s.stopGuides()}),this.router.addRoute("debugger::tombstoneGuide",e=>{e=s.findGuideById(e.data);o.Tombstone.addGuide(e)}),this.router.addRoute("debugger::openGuidePage",e=>{e=e.data,n=s,t=o.hosts.SERVER;var t,i,n=(i=n.findGuideById(e))&&n._.get(i,"attributes.resourceCenter")?i.attributes.resourceCenter.isTopLevel?`${t}/resource-center/${i.id}/draft`:(n=n.BuildingBlocks.BuildingBlockResourceCenter.getResourceCenter())&&n.id?`${t}/resource-center/${n.id}/module/`+i.id:"":t+"/guides/"+e;n&&window.open(n,"_blank")}),this.router.addRoute("debugger::restore",({data:e})=>{if(e&&e.length){const t=document.createElement("iframe");t.sandbox="allow-same-origin",t.src="about:blank",t.hidden=!0,document.body.appendChild(t),t.contentWindow.ignoreIframeMonitor=!0,e.forEach(e=>{e.id.split(".").reduce((e,t,i,n)=>i===n.length-1?(e.destination[t]=e.source[t],e.destination[t]):(e.destination=e.destination[t],e.source=e.source[t],e),{destination:window,source:t.contentWindow})}),document.body.removeChild(t)}}),this.router.addRoute("debugger::sync",(e,i)=>{const t=o.store.subscribe((e,t)=>{"debugger/eventsCaptured"===e.type&&i({action:"events/eventsCaptured",data:t["debugger"].eventsCaptured})}),n=setInterval(()=>{i({action:"agent/sync",data:o.store.state}),i({action:"environment/validateEnvironment",data:s.validateEnvironment(!0)}),i({action:"performance/sync",data:ce()})},500);this.events.on("unmounted",()=>{clearInterval(n),t()})}),this.router.addRoute("debugger::enableEventLogging",({data:e})=>{this.setProperties({enableEventLogging:e}),o.store.dispatch("debugger/enableEventLogging",e)}),this.router.addRoute("debugger::clearEventsCaptured",()=>{o.store.dispatch("debugger/clearEventsCaptured")}),this.router.addRoute("debugger::checkGuideEligibility",({data:e},t)=>{o.store.dispatch("debugger/checkGuideEligibility",{guideId:e,response:t})}),this.router.addRoute("debugger::testSelector",({data:e},t)=>{var i=()=>(performance&&performance.now?performance:Date).now(),n=i(),e=s.dom(e);t({timing:i()-n,count:e.length})})}teardown(){super.stop(),this.setProperties({enabled:!1,containerType:"frame"})}}var x=new he,ge={initialize(e,t){x.initialize(e,t);const i=e.disableDebugging;e.disableDebugging=()=>{x.teardown(),i(),e.disableDebugging=i}},teardown(){x.teardown()}},pe=document.getElementById("pendo-debugger-plugin");let M="pendo";pe&&(M=pe.getAttribute("data-pendo-global-key")||"pendo"),window[M].addExtension&&window[M].addExtension({name:"Debugger",version:"1.0.0",type:"agent",use:"plugin",uri:ge})}();
4
+ !function(){"use strict";class L{constructor(e,t){this.path=e,this.handler=t}}class G{routes={};addRoute(e,t){this.routes[e]||(this.routes[e]=[]),this.routes[e].unshift(new L(e,t))}removeRoute(e){this.routes[e].shift()}lookupRouteProvider(){return e=>this.routes[e]?this.routes[e][0].handler:undefined}}const u=(...e)=>s=>{return[].concat(e).reduce((e,t,i,n)=>{e=t(e,s);return e||n.splice(i,n.length-i),e},s)};let W=0;const i=(e,t,i)=>{if(!e||"string"!=typeof t)return i;let n=e;for(const s of t.split(".")){if(null==n)return i;n=n[s]}return n===undefined?i:n};const t=(t,i)=>{if(t&&i)if(Array.isArray(t))for(let e=0;e<t.length;e++)i(t[e],e,t);else if("object"==typeof t)for(const e in t)t.hasOwnProperty(e)&&i(t[e],e,t);return t},h=e=>"function"==typeof e,O=e=>!(null==e),d=()=>Date.now();class e{app=null;router=null;destination=window.parent||window.top;origin="*";constructor(e,t={}){this.app=e,this.router=e.router,this.config=t,this.events=e.PluginAPI.getEventable()}getConfig(e,t){return i(this.config,e,t)}getDestinationProvider(){return()=>this.destination}getOriginProvider(){return()=>this.origin}triggerOpened(){this.events.trigger("opened",{containerType:this.type})}triggerClosed(){this.events.trigger("closed",{containerType:this.type})}}var a={padding:"0 !important",margin:"0 !important","box-sizing":"border-box !important",border:"none !important",display:"block !important",visibility:"visible !important"},c=2147483647,p={WINDOW_MARGIN:10,HEADER_HEIGHT:50,TOP:100,LEFT:100,HEIGHT:700,WIDTH:500,MIN_HEIGHT:500,MIN_WIDTH:500};const{MIN_HEIGHT:g,MIN_WIDTH:l,WINDOW_MARGIN:f}=p;function s(t,i,n,s,o){let r=0,a=0,d=0,c=0;function u(e){e.preventDefault(),i.css({visibility:"hidden"}),t.releasePointerCapture(e.pointerId),t.removeEventListener("pointermove",h),o()}function h(e){-1!==e.button||0===e.buttons?u(e):(e.preventDefault(),d=r-e.clientX,c=a-e.clientY,r=e.clientX,a=e.clientY,s(d,c))}t.addEventListener("pointerdown",function(e){0===e.button&&(e.preventDefault(),i.css({visibility:"visible"}),r=e.clientX,a=e.clientY,t.setPointerCapture(e.pointerId),t.addEventListener("pointermove",h),n())}),t.addEventListener("pointerup",u),t.addEventListener("pointerout",u)}function U(e,t){const i=e.handle[0],n=e.container[0];s(i,e.blockout,function(){i.style.cursor="grabbing"},function(e,t){n.style.left=m(n,e)+"px",n.style.top=v(n,t)+"px"},function(){i.style.cursor="grab",t()})}function m(e,t){t=e.offsetLeft-t,e=window.innerWidth-e.offsetWidth-f;return t<f||e<f?f:e<t?e:t}function v(e,t){t=e.offsetTop-t,e=window.innerHeight-e.offsetHeight-f;return t<f||e<f?f:e<t?e:t}function _(e,t){var i=e.resizeHandle[0];const n=e.container[0];s(i,e.blockout,()=>{},function(e,t){n.style.width=b(n,e)+"px",n.style.height=w(n,t)+"px"},t)}function b(e,t){t=e.offsetWidth-t,e=window.innerWidth-e.offsetLeft-f;return e<t?e:t<l?l:t}function w(e,t){t=e.offsetHeight-t,e=window.innerHeight-e.offsetTop-f;return e<t?e:t<g?g:t}class F extends e{type="frame";destination=window.parent||window.top;origin=/^https?:/.test(window.location.protocol)?window.location.origin:"*";constructor(n,e){super(n,e);const{pendo:s,PluginAPI:o}=n;e=this.getConfig("containerId","pendo-client-app");this.container=s.dom(`<div id="${e}" class="pendo-ignore">`).css({...a,height:n.state.height,width:n.state.width,"z-index":c-1,"background-color":"#FFFFFF",position:"fixed","box-shadow":"rgb(136, 136, 136) 0px 0px 20px 0px",overflow:"hidden"}),this.handle=s.dom('<div id="pendo-app-draggable-handle">').css({...a,"z-index":c,height:p.HEADER_HEIGHT,width:"calc(100% - 100px)",position:"absolute",cursor:"grab"}).on("dblclick",()=>{n.state.minimized||(this.container.css({height:p.HEIGHT,width:p.WIDTH,transition:"all 250ms linear"}),setTimeout(()=>{this.container&&(this.container.css({transition:"none"}),this.saveSize())},250))}).appendTo(this.container),this.resizeHandle=s.dom('<div id="pendo-app-resize-handle">').css({...a,"z-index":c,visibility:this.app.state.minimized?"hidden":"visible",height:0,width:0,"border-left":"10px solid transparent","border-bottom":"10px solid rgb(136, 136, 136)",cursor:"nwse-resize",position:"absolute",bottom:0,right:0}).appendTo(this.container),this.frame=s.dom('<iframe id="pendo-agent-application" src="about:blank">').css({...a,height:"100%",width:"100%"}).on("load",()=>{if(o.ConfigReader.get("inlineStyleNonce")){const i=this.frame[0].contentDocument.createElement.bind(this.frame[0].contentDocument);this.frame[0].contentDocument.createElement=(e,...t)=>{t=i(e,...t);return"style"===e&&(e=o.ConfigReader.get("inlineStyleNonce"))&&t.setAttribute("nonce",e),t}}var e,t=document.createElement("script");t.src=((e=s)&&e.trustedTypesPolicy?e.trustedTypesPolicy:{createScriptURL(e){return e}}).createScriptURL(o.getAssetUrl(n.assetName)),this.frame[0].contentDocument.body.appendChild(t),this.frame[0].contentWindow.ignoreIframeMonitor=!0,this.triggerOpened()}).appendTo(this.container),this.blockout=s.dom('<div id="pendo-app-dragging-blockout">').css({"z-index":c-2,position:"absolute",height:"100%",width:"100%",top:0,left:0,visibility:"hidden"}).appendTo(s.dom.getBody()),this.elements=[this.container,this.blockout],this.positionFrame=e=>{var{left:t,top:i,height:n}=e,{minimized:e,width:s}=e,t=t||p.LEFT,i=i||p.TOP,n=e?p.HEADER_HEIGHT:n;t=m({offsetLeft:t,offsetWidth:s},0),i=v({offsetTop:i,offsetHeight:n},0),this.container.css({left:t,top:i,height:n}),this.savePosition()},this.saveSize=()=>{var{offsetHeight:e,offsetWidth:t}=this.container[0];e&&t&&this.app.setProperties({height:e,width:t})},this.savePosition=()=>{var{offsetLeft:e,offsetTop:t}=this.container[0];e&&t&&this.app.setProperties({left:e,top:t})},this.toggleMinimize=()=>{this.app.setProperties({minimized:!this.app.state.minimized}),this.resizeHandle.css({visibility:this.app.state.minimized?"hidden":"visible"}),this.positionFrame(this.app.state)},this.positionFrame(this.app.state),U(this,this.savePosition),_(this,this.saveSize),window.addEventListener("resize",r),this.listeners=[["resize",r]];const t=s._.throttle(()=>{return e=this.container[0],0<(t=e.offsetLeft+e.offsetWidth+f-window.innerWidth)&&(e.style.left=m(e,t)+"px",e.offsetWidth>l)&&(e.style.width=b(e,t)+"px"),void(0<(t=e.offsetTop+e.offsetHeight+f-window.innerHeight)&&(e.style.top=v(e,t)+"px",e.offsetHeight>g)&&(e.style.height=w(e,t)+"px"));var e,t},10),i=s._.debounce(()=>{this.savePosition(),this.saveSize()},1e3);function r(){t(),i()}}open(){return this.router.addRoute("app::toggleMinimize",this.toggleMinimize),this.container.appendTo(this.app.pendo.dom.getBody()),Promise.resolve()}close(){this.router.removeRoute("app::toggleMinimize"),this.listeners.forEach(([e,t])=>window.removeEventListener(e,t)),this.elements.forEach(e=>e.remove()),this.triggerClosed()}}const y="promise";function T(e,t,i){this.name=e,this.type=t,this.data=i}T.prototype.toString=function(){return`Message.${this.type} - `+this.name};const $=(e,t,i)=>{e=new T(e,t,i);return t===y&&(e.requestId=""+(W+=1)),e},C=e=>{try{var{name:t,type:i,isResponse:n,data:s,requestId:o,sender:r}=e.data||{},a=new T(t,i,O(s)?JSON.parse(s):undefined);return a.requestId=o,a.sender=r,a.destination=e.source,a.isResponse=n,a}catch(d){return!1}},q=e=>{var t=((e,t)=>{if(!e||"object"!=typeof e)return{};var i=Array.isArray(t)?t:[t],n={};for(const s in e)e.hasOwnProperty(s)&&!i.includes(s)&&(n[s]=e[s]);return n})(e,["destination","toString","data"]);return t.data=JSON.stringify(e.data,(e,t)=>"function"==typeof t||t instanceof RegExp?t.toString?t.toString():undefined:t),t},n=e=>(e.isResponse=!0,e),o="disconnected",P={lastMessageReceivedAt:0,currentConnectionQuality:o,changeCallbacks:{},evalCallbacks:{}},r=e=>{e!==P.currentConnectionQuality&&(P.currentConnectionQuality=e,t(P.changeCallbacks,e=>{e(P.currentConnectionQuality)}))},B=()=>{var e;0===P.lastMessageReceivedAt?r(o):((e=d()-P.lastMessageReceivedAt)<1e4?r("connected"):1e4<e&&(3e4<e?r("dead_connection"):r(o)),t(P.evalCallbacks,e=>{e(P.currentConnectionQuality)}))};let I;let R=0;const j=()=>{P.currentConnectionQuality=o,P.lastMessageReceivedAt=0},E={appName:undefined,connectionName:undefined,frameId:undefined,pendingRequests:{},topics:{},senderIds:{},originProvider:undefined,destinationProvider:undefined},S=()=>""+E.appName+E.connectionName+`(${E.frameId})`,H=e=>{e.sender||(e.sender=S());var t=e.destination||E.destinationProvider(),i=q(e),n=Q(e.sender),s=K(e.sender);n||s?n?n.postMessage(i):t.postMessage(i,E.originProvider()):(s=new MessageChannel,ee(s.port1,e.sender),t.postMessage(i,E.originProvider(),[s.port2]))},D=(s,o,r=1e3)=>new Promise((e,t)=>{const i=$(s,y,o),n=setTimeout(()=>{t(s+" timeout"),A(i),ie(i)},r);X(i,()=>clearTimeout(n),e,t),H(i)}),z=e=>{var t;return E.senderIds[e]||(t=e,E.senderIds[t])||(E.senderIds[t]={port:undefined,hasTriedToUpgradeToMessageChannel:!1}),E.senderIds[e]},Q=e=>z(e).port,K=e=>z(e).hasTriedToUpgradeToMessageChannel,X=(e,t,i,n)=>{E.pendingRequests[e.requestId]={message:e,clearTimeoutfn:t,resolve:i,reject:n}};const A=e=>{var t=e["requestId"];return E.pendingRequests[t].clearTimeoutfn(),delete E.pendingRequests[t],e};const k="message::ping";var Y;const J=u(e=>{var t=E.pendingRequests[e.requestId];return t&&(t.resolve(e.data),A(e)),e},t=>{var e=E.topics[t.name];return e&&e.forEach(e=>e(t.data)),t},t=>{var e;return t&&!t.isResponse&&(t.name===k?H(n(t)):(e=E.routeHandlerLookup(t.name))?e(t,e=>{t.data=e,H(n(t))}):console.log(S(),"No route handler for "+t.name,t)),t},(Y=()=>{var e;e=d(),P.lastMessageReceivedAt=e},(e,...t)=>(Y(e,...t),e))),V=e=>("*"===E.originProvider()||e.origin===E.originProvider())&&e,Z=e=>{var t=i(e,"data.sender");return!(!t||"string"!=typeof t||!t.includes(E.appName))&&e},ee=(e,t)=>{t=z(t);t.port=e,t.hasTriedToUpgradeToMessageChannel=!0,t.port.onmessage=u(C,J)},te=(e,t)=>{return!z(e.sender).hasTriedToUpgradeToMessageChannel&&t.ports&&t.ports[0]&&ee(t.ports[0],e.sender),e},ie=e=>{e=e.sender;(e=z(e)).port=undefined,e.hasTriedToUpgradeToMessageChannel=!1};let N=()=>{};const ne=()=>{N(),N=()=>{},I&&I(),j()},se=((n,s)=>{let o,r=0,a;return function(...e){var t=d(),i=s-(t-r);return i<=0||s<i?(o&&(clearTimeout(o),o=null),r=t,a=n.apply(this,e)):!o&&0<s&&(o=setTimeout(()=>{r=d(),o=null,a=n.apply(this,e)},i)),a}})(e=>{"connected"!==e&&E.usePingAutoReconnect&&D(k)["catch"](()=>{})},1e3),oe=(e,t,i,n,s,o=!1,r)=>{if(window.addEventListener){E.appName=e,E.frameId=t,E.routeHandlerLookup=i,E.usePingAutoReconnect=o,E.connectionName=r||"",E.originProvider=n||(()=>window.location.origin||"*"),E.destinationProvider=s||(()=>window.parent||window.top);{const d=setInterval(B,100);I=()=>clearInterval(d)}e=se;if(h(e)){const c=R++;P.evalCallbacks[c]=e}const a=u(V,Z,C,te,J);window.addEventListener("message",a),N=()=>window.removeEventListener("message",a)}},re=e=>{if(h(e)){const t=R++;P.changeCallbacks[t]=e}};class ae extends e{type="window";testUrl="";realUrl=undefined;getTitle(){return this.getConfig("title",this.getName())}getName(){return this.getConfig("name","Agent_Application")}open(){return this.router.addRoute("app::windowClosed",()=>{this.app.setProperties({containerType:"frame"}),this.app.stop()}),this.testConnection().then(()=>{this.triggerOpened()})["catch"](()=>{return this.createWindow(),s=this.app,o=1e3,new Promise((e,t)=>{const i=d(),n=()=>{s.getConnectionStatus()?e():d()-i>o?t():setTimeout(n,50)};n()});var s,o})}testConnection(){return this.destination=window.open(this.testUrl,this.getName(),`width=${this.app.state.width},height=${this.app.state.height},resizable=yes,scrollbars=yes,status=yes,location=no`),D("app::reconnect")}createWindow(){this.realUrl&&(this.destination=window.open(this.realUrl,this.getName(),`width=${this.app.state.width},height=${this.app.state.height},resizable=yes,scrollbars=yes,status=yes,location=no`));var e=document.createElement("script");e.src=this.app.PluginAPI.getAssetUrl(this.app.assetName),this.destination.document.body.appendChild(e),this.destination.document.title=this.getTitle()}close(){this.router.removeRoute("app::windowClosed"),this.destination.close(),this.triggerClosed()}}const de=()=>({});class ce{defaultState={containerType:"frame",minimized:!1,height:p.HEIGHT,width:p.WIDTH,left:p.LEFT,top:p.TOP};state={};containerClosedCallbacks=[];container=null;isConnected=!1;constructor(e,t,i,n,s,o=de,r=de){this.appName=e,this.assetName=t,this.assetStorageKey=i,this.connectionName=n,this.frameConfigProvider=o,this.windowConfigProvider=r,s&&Object.assign(this.defaultState,s),this.router=new G}init(e,t){this.pendo=e,this.PluginAPI=t,this.events=t.getEventable(),this.router.addRoute("app::ping",(e,t)=>{t()}),this.router.addRoute("app::setProperties",({data:e})=>{this.setProperties(e)}),this.router.addRoute("app::toggleContainer",()=>{this.setProperties({minimized:!1}),this.toggleContainerType()}),this.router.addRoute("app::windowClosed",()=>{}),this.loadState(),this.prepContainer(),this.start()}prepContainer(){this.container="window"===this.state.containerType?new ae(this,this.windowConfigProvider()):new F(this,this.frameConfigProvider())}setConnectionStatus(e){this.isConnected="connected"===e}getConnectionStatus(){return this.isConnected}setProperties(e){Object.assign(this.state,e),this.writeState()}getDefaultState(){return this.defaultState||{}}loadState(){try{var e=this.PluginAPI.agentStorage.read(this.assetStorageKey);this.state=Object.assign({},this.getDefaultState(),this.state,e)}catch(t){this.PluginAPI.log.error(t),this.state=Object.assign({},this.getDefaultState(),this.state)}}writeState(){this.PluginAPI.agentStorage.write(this.assetStorageKey,this.state)}toggleContainerType(){var e="frame"===this.state.containerType?"window":"frame";this.setProperties({containerType:e}),this.stop(),this.start()}start(){this.container||this.prepContainer();var e=this.PluginAPI.EventTracer.addTracerIds({})["frameId"];oe(this.appName,e,this.router.lookupRouteProvider(),this.container.getOriginProvider(),this.container.getDestinationProvider(),!0,this.connectionName),re(e=>{this.setConnectionStatus(e)}),this.container.open().then(()=>{this.events.trigger("mounted")})["catch"](()=>{"window"===this.state.containerType?(this.setProperties({containerType:"frame"}),this.prepContainer(),this.start()):(this.PluginAPI.log(`Failed to start ${this.appName} in either window or frame.`),this.stop())})}stop(){this.container.close(),this.container=null,this.events.trigger("unmounted"),ne()}}const ue=()=>{try{return performance.getEntries()}catch(e){return[{failedGetEntries:!0,message:e.message,stack:e.stack}]}};class he extends ce{constructor(){super("Debugger","pendo.debugger.min.js","debug-enabled","AgentPlugin",null,()=>({containerId:"pendo-client-debugger"}),()=>({title:"Pendo Debugger"}))}initialize(s,o){o.restartDebugger=this.start.bind(this),super.init(s,o),this.router.addRoute("debugger::connect",(e,t)=>{var i;t({config:o.ConfigReader.audit(),env:{apiKey:(i=s).apiKey,environment:i.debugging.isStagingServer()?"staging":"production",device:i.debugging.isMobileUserAgent()?"mobile":"desktop",browserCookies:window.navigator.cookieEnabled,guideStatus:i.areGuidesDisabled()?"off":i.areGuidesDelayed()?"delayed":"on",foundShadowRoot:!!(i=i.debugging.observer.shadowDom).foundShadowRoots||(i.findShadowRoots(document,Infinity,()=>{}),i.foundShadowRoots)},container:this.state,events:o.store.state["debugger"].eventsCaptured,timeOrigin:performance.timeOrigin})}),this.router.addRoute("debugger::stop",()=>{s.disableDebugging()}),this.router.addRoute("debugger::showGuideById",(e,t)=>{t(s.showGuideById(e.data))}),this.router.addRoute("debugger::toggleGuideLoop",e=>{e.data?s.startGuides():s.stopGuides()}),this.router.addRoute("debugger::tombstoneGuide",e=>{e=s.findGuideById(e.data);o.Tombstone.addGuide(e)}),this.router.addRoute("debugger::openGuidePage",e=>{e=e.data,n=s,t=o.hosts.SERVER;var t,i,n=(i=n.findGuideById(e))&&n._.get(i,"attributes.resourceCenter")?i.attributes.resourceCenter.isTopLevel?`${t}/resource-center/${i.id}/draft`:(n=n.BuildingBlocks.BuildingBlockResourceCenter.getResourceCenter())&&n.id?`${t}/resource-center/${n.id}/module/`+i.id:"":t+"/guides/"+e;n&&window.open(n,"_blank")}),this.router.addRoute("debugger::restore",({data:e})=>{if(e&&e.length){const t=document.createElement("iframe");t.sandbox="allow-same-origin",t.src="about:blank",t.hidden=!0,document.body.appendChild(t),t.contentWindow.ignoreIframeMonitor=!0,e.forEach(e=>{e.id.split(".").reduce((e,t,i,n)=>i===n.length-1?(e.destination[t]=e.source[t],e.destination[t]):(e.destination=e.destination[t],e.source=e.source[t],e),{destination:window,source:t.contentWindow})}),document.body.removeChild(t)}}),this.router.addRoute("debugger::sync",(e,i)=>{const t=o.store.subscribe((e,t)=>{"debugger/eventsCaptured"===e.type&&i({action:"events/eventsCaptured",data:t["debugger"].eventsCaptured})}),n=setInterval(()=>{i({action:"agent/sync",data:o.store.state}),i({action:"environment/validateEnvironment",data:s.validateEnvironment(!0)}),i({action:"performance/sync",data:ue()})},500);this.events.on("unmounted",()=>{clearInterval(n),t()})}),this.router.addRoute("debugger::enableEventLogging",({data:e})=>{this.setProperties({enableEventLogging:e}),o.store.dispatch("debugger/enableEventLogging",e)}),this.router.addRoute("debugger::clearEventsCaptured",()=>{o.store.dispatch("debugger/clearEventsCaptured")}),this.router.addRoute("debugger::checkGuideEligibility",({data:e},t)=>{o.store.dispatch("debugger/checkGuideEligibility",{guideId:e,response:t})}),this.router.addRoute("debugger::testSelector",({data:e},t)=>{o.store.dispatch("debugger/testSelector",{selector:e,response:t})})}teardown(){super.stop(),this.setProperties({enabled:!1,containerType:"frame"})}}var x=new he,pe={initialize(e,t){x.initialize(e,t);const i=e.disableDebugging;e.disableDebugging=()=>{x.teardown(),i(),e.disableDebugging=i}},teardown(){x.teardown()}},ge=document.getElementById("pendo-debugger-plugin");let M="pendo";ge&&(M=ge.getAttribute("data-pendo-global-key")||"pendo"),window[M].addExtension&&window[M].addExtension({name:"Debugger",version:"1.0.0",type:"agent",use:"plugin",uri:pe})}();
package/dist/dom.esm.js CHANGED
@@ -7473,7 +7473,7 @@ function applyMatrix2dRect(matrix2d, rect) {
7473
7473
  return transformedRect;
7474
7474
  }
7475
7475
 
7476
- var VERSION = '2.316.0_';
7476
+ var VERSION = '2.317.1_';
7477
7477
 
7478
7478
  var decodeURIComponent = _.isFunction(window.decodeURIComponent) ? window.decodeURIComponent : _.identity;
7479
7479
 
@@ -7546,7 +7546,8 @@ function createStorageShim(storageAccessor) {
7546
7546
  var pendoLocalStorage = createStorageShim(function () { return window.localStorage; });
7547
7547
  var pendoSessionStorage$1 = createStorageShim(function () { return window.sessionStorage; });
7548
7548
 
7549
- var inMemoryCookies = {};
7549
+ var inMemoryStorage = {};
7550
+ var cookieDomain;
7550
7551
  /*
7551
7552
  * This config setting means persistence is ok as long as it's LocalStorage or
7552
7553
  * anything non cookie based.
@@ -7559,16 +7560,9 @@ var storageIsDisabled = function () {
7559
7560
  return !!ConfigReader.get('disableCookies');
7560
7561
  };
7561
7562
  var getCookie = function (name) {
7562
- var toParse;
7563
- if (storageIsDisabled() || allowLocalStorageOnly()) {
7564
- toParse = inMemoryCookies[name];
7565
- }
7566
- else {
7567
- toParse = document.cookie;
7568
- }
7569
7563
  var result;
7570
7564
  // eslint-disable-next-line no-cond-assign
7571
- return (result = new RegExp('(^|; )' + name + '=([^;]*)').exec(toParse)) ? decodeURIComponent(result[2]) : null;
7565
+ return (result = new RegExp('(^|; )' + name + '=([^;]*)').exec(document.cookie)) ? decodeURIComponent(result[2]) : null;
7572
7566
  };
7573
7567
  var setCookie = function (name, val, millisToExpire, isSecure) {
7574
7568
  if (ConfigReader.get('preventCookieRefresh')) {
@@ -7583,22 +7577,17 @@ var setCookie = function (name, val, millisToExpire, isSecure) {
7583
7577
  var sameSite = canSecure ? 'None' : 'Strict';
7584
7578
  expireDate.setTime(expireDate.getTime() + cookieTTL);
7585
7579
  var cookie = name + '=' + encodeURIComponent(val) + (millisToExpire ? ';expires=' + expireDate.toUTCString() : '') + '; path=/' + (canSecure ? ';secure' : '') + '; SameSite=' + sameSite;
7586
- if (storageIsDisabled() || allowLocalStorageOnly()) {
7587
- inMemoryCookies[name] = cookie;
7588
- }
7589
- else {
7590
- document.cookie = cookie;
7591
- }
7580
+ document.cookie = cookie;
7592
7581
  };
7582
+ function hasCookieDomain() {
7583
+ return !!cookieDomain;
7584
+ }
7593
7585
  function clearCookie(name) {
7594
7586
  document.cookie = name + '=; path=/; expires=Thu, 01 Jan 1970 00:00:00 GMT';
7595
7587
  }
7596
7588
  var getPendoCookieKey = function (name, cookieSuffix) {
7597
7589
  return "_pendo_".concat(name, ".").concat(cookieSuffix || pendo.apiKey);
7598
7590
  };
7599
- var get_pendo_cookie = function (name, cookieSuffix) {
7600
- return getCookie(getPendoCookieKey(name, cookieSuffix));
7601
- };
7602
7591
  var DAY_MS = 24 * 60 * 60 * 1000;
7603
7592
  var DEFAULT_EXPIRE_LEN = 100 * DAY_MS;
7604
7593
  var limitCookieTTL = function (millisToExpire) {
@@ -7607,10 +7596,6 @@ var limitCookieTTL = function (millisToExpire) {
7607
7596
  var maxCookieTTL = maxCookieTTLDays < Infinity ? maxCookieTTLDays * DAY_MS : Infinity;
7608
7597
  return Math.min(millisToExpire, maxCookieTTL);
7609
7598
  };
7610
- var set_pendo_cookie = function (name, val, millisToExpire, isSecure, cookieSuffix) {
7611
- millisToExpire = millisToExpire || DEFAULT_EXPIRE_LEN;
7612
- setCookie(getPendoCookieKey(name, cookieSuffix), val, millisToExpire, isSecure);
7613
- };
7614
7599
  var StorageRegistry = /** @class */ (function () {
7615
7600
  function StorageRegistry() {
7616
7601
  this.keys = {};
@@ -7655,6 +7640,7 @@ var StorageRegistry = /** @class */ (function () {
7655
7640
  duration: null,
7656
7641
  isPlain: false,
7657
7642
  isSecure: false,
7643
+ localStorageOnly: false,
7658
7644
  cookieSuffix: undefined,
7659
7645
  serializer: _.identity,
7660
7646
  deserializer: _.identity
@@ -7694,10 +7680,8 @@ var agentStorage = (function () {
7694
7680
  return writeMethod.apply(this, arguments);
7695
7681
  };
7696
7682
  }
7697
- function canUseLocalStorage() {
7698
- if (storageIsDisabled())
7699
- return false;
7700
- return storageAvailable('localStorage');
7683
+ function shouldUseLocalStorage(keyLocalStorageOnly) {
7684
+ return keyLocalStorageOnly || allowLocalStorageOnly() || !hasCookieDomain();
7701
7685
  }
7702
7686
  // "Borrowed" from https://developer.mozilla.org/en-US/docs/Web/API/Web_Storage_API/Using_the_Web_Storage_API
7703
7687
  // for continued reading: https://gist.github.com/paulirish/5558557
@@ -7738,26 +7722,39 @@ var agentStorage = (function () {
7738
7722
  function read(name, isPlain, cookieSuffix) {
7739
7723
  isPlain = registry.getKeyConfig(name, 'isPlain', isPlain);
7740
7724
  cookieSuffix = registry.getKeyConfig(name, 'cookieSuffix', cookieSuffix);
7725
+ var keyLocalStorageOnly = registry.getKeyConfig(name, 'localStorageOnly', false);
7726
+ var key = !isPlain ? getPendoCookieKey(name, cookieSuffix) : name;
7741
7727
  var rawValue;
7742
7728
  var deserialize = registry.getKeyDeserializer(name);
7743
- if (canUseLocalStorage()) {
7744
- var key = !isPlain ? getPendoCookieKey(name, cookieSuffix) : name;
7745
- try {
7746
- rawValue = ttlApply(localStorage.getItem(key));
7747
- if (rawValue === null) {
7748
- clear(name, isPlain, cookieSuffix);
7729
+ if (storageIsDisabled()) {
7730
+ return deserialize(ttlApply(inMemoryStorage[key]) || null);
7731
+ }
7732
+ if (shouldUseLocalStorage(keyLocalStorageOnly)) {
7733
+ if (storageAvailable('localStorage')) {
7734
+ try {
7735
+ rawValue = ttlApply(localStorage.getItem(key));
7736
+ if (rawValue === null) {
7737
+ clear(name, isPlain, cookieSuffix);
7738
+ }
7739
+ return deserialize(rawValue);
7740
+ }
7741
+ catch (e) {
7742
+ resetCache(storageAvailable);
7749
7743
  }
7750
- return deserialize(rawValue);
7751
- }
7752
- catch (e) {
7753
- resetCache(storageAvailable);
7754
7744
  }
7755
7745
  }
7756
- if (!isPlain) {
7757
- rawValue = get_pendo_cookie(name, cookieSuffix);
7758
- }
7759
7746
  else {
7760
- rawValue = getCookie(name);
7747
+ try {
7748
+ rawValue = getCookie(key);
7749
+ if (rawValue !== null) {
7750
+ return deserialize(rawValue);
7751
+ }
7752
+ }
7753
+ catch (e) { }
7754
+ }
7755
+ rawValue = ttlApply(inMemoryStorage[key] || null);
7756
+ if (rawValue === null) {
7757
+ delete inMemoryStorage[key];
7761
7758
  }
7762
7759
  return deserialize(rawValue);
7763
7760
  }
@@ -7786,24 +7783,33 @@ var agentStorage = (function () {
7786
7783
  isPlain = registry.getKeyConfig(name, 'isPlain', isPlain);
7787
7784
  isSecure = registry.getKeyConfig(name, 'isSecure', isSecure);
7788
7785
  cookieSuffix = registry.getKeyConfig(name, 'cookieSuffix', cookieSuffix);
7786
+ var keyLocalStorageOnly = registry.getKeyConfig(name, 'localStorageOnly', false);
7789
7787
  val = registry.getKeySerializer(name)(val);
7788
+ var key = !isPlain ? getPendoCookieKey(name, cookieSuffix) : name;
7790
7789
  resetCache(storageAvailable);
7791
- if (canUseLocalStorage()) {
7792
- // We'll try to write but if that fails, just fall down to cookies.
7790
+ if (storageIsDisabled()) {
7791
+ inMemoryStorage[key] = ttlWrite(val, duration);
7792
+ return;
7793
+ }
7794
+ if (shouldUseLocalStorage(keyLocalStorageOnly)) {
7795
+ if (storageAvailable('localStorage')) {
7796
+ try {
7797
+ localStorage.setItem(key, ttlWrite(val, duration));
7798
+ return;
7799
+ }
7800
+ catch (e) { }
7801
+ }
7802
+ }
7803
+ else {
7793
7804
  try {
7794
- var key = !isPlain ? getPendoCookieKey(name, cookieSuffix) : name;
7795
- localStorage.setItem(key, ttlWrite(val, duration));
7796
- resetCache(storageAvailable);
7805
+ if (!isPlain)
7806
+ duration = duration || DEFAULT_EXPIRE_LEN;
7807
+ setCookie(key, val, duration, isSecure);
7797
7808
  return;
7798
7809
  }
7799
7810
  catch (e) { }
7800
7811
  }
7801
- if (!isPlain) {
7802
- return set_pendo_cookie(name, val, duration, isSecure, cookieSuffix);
7803
- }
7804
- else {
7805
- setCookie(name, val, duration, isSecure);
7806
- }
7812
+ inMemoryStorage[key] = ttlWrite(val, duration);
7807
7813
  }
7808
7814
  function ttlWrite(value, duration) {
7809
7815
  if (duration === null) {
@@ -7818,11 +7824,29 @@ var agentStorage = (function () {
7818
7824
  function clear(name, isPlain, cookieSuffix) {
7819
7825
  isPlain = registry.getKeyConfig(name, 'isPlain', isPlain);
7820
7826
  cookieSuffix = registry.getKeyConfig(name, 'cookieSuffix', cookieSuffix);
7827
+ var keyLocalStorageOnly = registry.getKeyConfig(name, 'localStorageOnly', false);
7821
7828
  var key = !isPlain ? getPendoCookieKey(name, cookieSuffix) : name;
7822
- if (canUseLocalStorage()) {
7823
- return localStorage.removeItem(key);
7829
+ if (storageIsDisabled()) {
7830
+ delete inMemoryStorage[key];
7831
+ return;
7832
+ }
7833
+ if (shouldUseLocalStorage(keyLocalStorageOnly)) {
7834
+ if (storageAvailable('localStorage')) {
7835
+ try {
7836
+ localStorage.removeItem(key);
7837
+ return;
7838
+ }
7839
+ catch (e) { }
7840
+ }
7841
+ }
7842
+ else {
7843
+ try {
7844
+ clearCookie(key);
7845
+ return;
7846
+ }
7847
+ catch (e) { }
7824
7848
  }
7825
- clearCookie(key);
7849
+ delete inMemoryStorage[key];
7826
7850
  }
7827
7851
  var wrappedPendoSessionStorage = _.extend({}, pendoSessionStorage$1);
7828
7852
  wrappedPendoSessionStorage.setItem = wrapStorageWriteMethod(wrappedPendoSessionStorage.setItem, 'hasSession');