@sprig-technologies/sprig-browser 2.30.0 → 2.30.2
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/dist/core-BTd5RhnR.cjs +12 -0
- package/dist/core-BzwoEbTD.js +12 -0
- package/dist/core.cjs +1 -0
- package/dist/core.d.ts +2972 -0
- package/dist/core.js +1 -0
- package/dist/index.cjs +1 -1
- package/dist/index.d.ts +46 -94
- package/dist/index.js +1 -1
- package/dist/metricsReporter-B6Yx0G8b.js +2 -0
- package/dist/metricsReporter-BIT_adF4.cjs +2 -0
- package/dist/replay.cjs +7 -0
- package/dist/replay.d.ts +2 -0
- package/dist/replay.js +7 -0
- package/dist/view-4ILgM5Tw.cjs +685 -0
- package/dist/view-C5kHSC2Q.js +685 -0
- package/package.json +12 -2
- package/dist/index-DCzsCvvC.cjs +0 -19
- package/dist/index-Del4rEas.js +0 -19
- package/dist/view-BeigWq26.js +0 -685
- package/dist/view-XkUymOdH.cjs +0 -685
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
"use strict";var $e=Object.defineProperty;var qe=(t,r,n)=>r in t?$e(t,r,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[r]=n;var F=(t,r,n)=>(qe(t,typeof r!="symbol"?r+"":r,n),n);const i=require("./metricsReporter-BIT_adF4.cjs"),Ge='.ul-loading-spinner-container{font-size:1.8rem;flex-grow:1;width:100%;height:100%;display:flex;align-items:center;justify-content:center}.ul-loading-spinner{display:inline-block;position:relative;width:6rem;height:6rem}.ul-loading-spinner div{box-sizing:border-box;display:block;position:absolute;width:80%;height:80%;margin:5px;border:5px solid #152e3e;border-radius:50%;animation:lds-ring 1.2s cubic-bezier(.5,0,.5,1) infinite;border-color:#152e3e transparent transparent transparent}.ul-loading-spinner .first{animation-delay:-.45s}.ul-loading-spinner .second{animation-delay:-.3s}.ul-loading-spinner .third{animation-delay:-.15s}@keyframes lds-ring{0%{transform:rotate(0)}to{transform:rotate(360deg)}}.fade-in-transition{animation:fadeIn .4s ease-in}@keyframes fadeIn{0%{opacity:0}to{opacity:1}}#sprig-feedback-button{border-left:0;border-radius:0 8px 8px 0;display:grid;padding:8px;text-align:center;transition:all ease-in-out 1s;z-index:inherit}#sprig-feedback-button:hover{cursor:pointer}.sprig-feedback-button-label{writing-mode:vertical-lr;text-orientation:sideways}.sprig-feedback-button-right{transform:rotate(180deg)}.sprig-feedback-button-bottom{align-self:flex-end;margin-bottom:20px}.sprig-feedback-button-light{background:#efefee;color:#000;border:1px solid #e2e3e1}.sprig-feedback-button-dark{background:#000;color:#fff;border:1px solid #000000}#sprig-feedback-container{display:flex;align-items:center;position:fixed;transition:right .2s linear,left .2s linear;z-index:2147483646}.sprig-feedback-container-left{flex-flow:row-reverse}.sprig-feedback-container-center{top:50%;transform:translateY(-50%)}.sprig-feedback-container-bottom{bottom:0%;margin-bottom:15px}.sprig-feedback-loading-container{align-items:center;background-color:#fff;border:2px solid var(--feedback-border);display:flex;max-height:90vh;max-width:90vw;min-width:0px}.sprig-feedback-loading-container-left{border-left:none;border-radius:0 8px 8px 0}.sprig-feedback-loading-container-right{border-right:none;border-radius:8px 0 0 8px}#sprig-feedback-error-container{margin:auto;text-align:center;width:360px}.sprig-feedback-error-text{font-weight:400;font-family:-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Helvetica,Arial,sans-serif,"Apple Color Emoji","Segoe UI Emoji",Segoe UI Symbol}#sprig-feedback-loading-container .ul-container{position:relative;max-height:inherit}#sprig-feedback-loading-animation{position:absolute}.sprig-feedback-loading-container-previews iframe{max-height:inherit!important}',Ee="360px",Ke="ul-app",Je="#e6e6e6",Qe="#bd282a",Ye=500,Xe=1030,Ue=()=>{try{return window.parent.Intercom}catch{return null}},Ze=()=>{const t=Ue();t&&(t.ul_wasVisible&&t("update",{hide_default_launcher:!1}),delete t.ul_wasVisible)},et=()=>{const t=Ue();t&&(t.ul_wasVisible=!!document.querySelector("iframe.intercom-launcher-frame"),t.ul_wasVisible&&t("update",{hide_default_launcher:!0}))},tt=Object.freeze(Object.defineProperty({__proto__:null,disable:et,enable:Ze},Symbol.toStringTag,{value:"Module"})),ve=[tt];class Ie{static disable(){ve.forEach(r=>r.disable())}static enable(){ve.forEach(r=>r.enable())}}const he="ul-view-sdk-script",rt=["ios","android"],O="visitors",x="environments";async function R(t,r){var o,a,l;const{shouldDropOnRateLimit:n,...s}=r;s.headers=Object.assign(i.getHttpHeaders(window.UserLeap),s.headers);const e=await i.sprigFetch(t,{...s,shouldDropOnRateLimit:n});if(e.ok){const d=(o=e.headers)==null?void 0:o.get("Authorization"),p=d?d.split(" "):void 0,c=p&&p.length===2?p[1]:void 0,u=(a=e.headers)==null?void 0:a.get("x-ul-visitor-id");c&&u&&(u!==window.UserLeap.visitorId||window.UserLeap.token!==c)&&(U("token",c),U("vid",u),i.eventEmitter.emit(i.SprigEvent.VisitorIDUpdated,{visitorId:u}),window.UserLeap.token=c,window.UserLeap.visitorId=u)}return(l=e.json)!=null&&l.logMessage&&console.warn(`[Sprig] ${e.json.logMessage}`),e}function U(t,r){const n=i.localStorageHelper.getItem("userleap.ids");let s={};if(n)try{s=JSON.parse(n)}catch(o){o instanceof Error&&(o.stack=n,window.UserLeap.reportError("Failed to parse local storage credentials",o)),console.warn("[Sprig] (ERR-427) Failed to lookup saved ids",o)}let e=s[window.UserLeap.envId];e?e[t]=r:e={[t]:r},s[window.UserLeap.envId]=e;try{i.localStorageHelper.setItem("userleap.ids",JSON.stringify(s))}catch(o){o instanceof Error&&console.warn(`[Sprig] (ERR-426) Unable to write to Local Storage:: ${o.message}`)}}function se(){return window.previewMode?"0":window.UserLeap.visitorId??""}function I(t,r,n){const s=[window.UserLeap._API_URL,"sdk",t];return r&&r.forEach(e=>{s.push(e),e===x?s.push(window.UserLeap.envId):e===O&&s.push(se())}),n&&s.push(n),s.join("/")}const N=async(t,r)=>{var fe,me,ye;const{context:n,forceBrandedLogo:s,endCard:e,isFeedback:o=!1,heatmap:a,locale:l,previewMode:d,productConfig:p,questions:c,responseGroupUid:u,surveyId:w,uuid:m,vid:g,sessionReplay:y,studyType:A}=t,b=i.getHttpHeaders(window.UserLeap),S=de(b),L=ae(b);if(i.info(`Attempting to display survey: ${w}`),y)if(i.info("Survey has replay attached"),S)i.eventEmitter.emit(i.SprigEvent.ReplayCapture,{responseGroupUid:u,hasQuestions:!!(c!=null&&c.length),surveyId:w,uploadId:y.uploadId,replayType:y.replayDurationType??"before",seconds:y.replayDurationSeconds,generateVideoUploadUrlPayload:{mediaRecordingUid:i.v4(),mediaType:"screen",questionId:1,responseGroupUid:u,surveyId:w,updatedAt:new Date().toISOString(),visitorId:window.UserLeap.visitorId,isReplay:!0}});else{if(!i.modules.replay)return window.UserLeap.reportError("displayQuestions",new Error("Replay module not registered")),{success:!1,message:"Replay module not registered",surveyState:"no survey"};i.modules.replay.scheduleOrCaptureReplay({responseGroupId:u,surveyId:w,visitorId:g,replayParams:y,completeUploadHeaders:b,apiUrl:window.UserLeap._API_URL,triggerTimestamp:Date.now(),isStandalone:c.length===0})}if(a){if(!i.modules.replay)return window.UserLeap.reportError("displayQuestions",new Error("Replay module not registered")),{success:!1,message:"Replay module not registered",surveyState:"no survey"};const{eventId:h,replayParams:Y,responseGroupUid:je,surveyId:ze}=a;await i.modules.replay.initializeReplay({viewDocument:window.document,maxReplayDurationSeconds:300,replayNonce:window.UserLeap.replayNonce,maxInflightRequests:window.UserLeap.maxInflightReplayRequests,teardownAfter:!0}),i.modules.replay.scheduleCapture({apiUrl:window.UserLeap._API_URL,completeUploadHeaders:b,eventId:h,isHeatmap:!0,replayParams:Y,responseGroupId:je,surveyId:ze,triggerTimestamp:Date.now(),visitorId:g})}if(g==null||!(c!=null&&c.length))return i.info(`Not displaying survey: vid: ${g} / questions: ${c}`),{success:!1,message:"[Sprig] no survey found",surveyState:"no survey"};if(window.UserLeap.container){i.info("Already displaying a survey");const h="[Sprig] (ERR-409) Found an existing Survey container, aborting rendering of this survey";return console.warn(h),{success:!1,message:h,surveyState:"no survey"}}if(g!==window.UserLeap.visitorId&&m!==window.UserLeap.visitorId&&!window.previewMode){const h="Attempted to display survey to a different visitor";return i.info(h),window.UserLeap.reportError("DisplaySurvey",new Error(h)),{success:!1,message:h,surveyState:"no survey"}}i.info(`Showing survey: ${w}`),(fe=i.modules.replay)==null||fe.RecordSurveyShown({id:w,userAgent:window.navigator.userAgent}),Ie.disable(),i.eventEmitter.emit(i.SprigEvent.SurveyWillPresent,{name:i.SprigEvent.SurveyWillPresent,"survey.id":w});let D,k=document.createElement("div"),E,v,M;const ue=h=>{const{"view.version":Y}=h;Y!==b["x-ul-sdk-version"]&&Re(),i.eventEmitter.removeListener("verify.view.version",ue)};i.eventEmitter.on("verify.view.version",ue),window.UserLeap.useMobileStyling=L,i.shouldDirectEmbed(b)?(D="ul-direct-embeded-frame",E=document.head,v=window,M=!1,S&&(ke(o),k.id=D,window.UserLeap.container.appendChild(k),_e(),i.eventEmitter.emit(i.SprigEvent.SurveyLifeCycle,{state:"presented"}),i.eventEmitter.emit(i.SprigEvent.SurveyPresented,{name:i.SprigEvent.SurveyPresented,"survey.id":w}))):{frameId:D,contentWinDocHead:E,contentWindow:v,hasOverlay:M,iframe:k}=at({productConfig:p,useMobileStyling:L,surveyId:w,isFeedback:o}),window.UserLeap.frameId=D;const Be=h=>{i.eventEmitter.once(i.SprigEvent.CloseSurveyOnOverlayClick,h)},C={apiURL:window.UserLeap._API_URL,cards:c,configureExitOnOverlayClick:Be,context:n,endCard:e,envId:window.UserLeap.envId,eventEmitFn:i.eventEmitter.emit.bind(i.eventEmitter),fontFamily:window.UserLeap.fontFamily,fontFamilyURL:window.UserLeap.fontFamilyURL,forceBrandedLogo:s,frame:k,headers:b,locale:l,mobileSDKVersion:window.UserLeap.mobileSDKVersion,previewKey:i.localStorageHelper.getItem("sprig.previewKey"),previewMode:d,productConfig:{framePosition:p==null?void 0:p.framePosition,desktopDisplay:p==null?void 0:p.desktopDisplay,placement:p==null?void 0:p.placement},responseGroupUid:u,startingQuestionIdx:(me=window.UserLeap.config)==null?void 0:me.startingQuestionIdx,studyType:A,styleNonce:window.UserLeap.styleNonce,surveyId:w,tabTitle:document.title,trackPageViewUrl:r,ulEvents:i.EVENTS,upchunkLibraryURL:window.UserLeap.upchunkLibraryURL,useMobileStyling:L,userId:m,viewDocument:v==null?void 0:v.document,viewWindow:v,visitorAttributes:{externalUserId:window.UserLeap.userId,email:window.UserLeap.email},...window.UserLeap._config};(ye=window.UserLeap._config)!=null&&ye.startingQuestionIdx&&(window.UserLeap._config={...window.UserLeap._config,startingQuestionIdx:null});const Ne=(o?window.UserLeap.feedbackCustomStyles:window.UserLeap.customStyles)??p.customStyles;C.customStyles=Ne,v&&(v.__cfg=C);function We(){const h=document.createElement("script");return window.UserLeap.nonce&&h.setAttribute("nonce",window.UserLeap.nonce),h.id=he,h}const J=window.UserLeap.viewSDKURL?window.UserLeap.viewSDKURL:C.path,we=document.getElementById(he);we&&we.remove();const Q=We(),ge=()=>{window.UserLeap.container&&Object.assign(window.UserLeap.container.style,{display:"flex"})};if(C.installationMethod==="web-npm"||C.installationMethod==="web-npm-bundled"){const{default:h}=await Promise.resolve().then(()=>require("./view-4ILgM5Tw.cjs"));h.configure(C),M&&window.UserLeap.container&&ge()}else J&&(Q.src=J,M&&Q.addEventListener("load",()=>{window.UserLeap.container&&ge()}),v==null||v.addEventListener("error",h=>{h.target instanceof HTMLScriptElement&&h.target.src===J&&window.UserLeap.reportError("loadFrameScript",new Error("Frame script failed to load"))},{capture:!0,once:!0}));return E==null||E.appendChild(Q),{success:!0,surveyState:"ready",surveyId:w,responseGroupUid:u}};function ae(t){var n;if(window.UserLeap.useMobileStyling!==void 0)return window.UserLeap.useMobileStyling;const r=((n=window.UserLeap.windowDimensions)==null?void 0:n.width)??document.body.clientWidth;return de(t)||r>10&&r<Ye}function de(t){return rt.includes(t["userleap-platform"])}const le="ul-frame";window.UserLeap&&window.Sprig&&(window.Sprig._gtm?window.Sprig=window.UserLeap:window.UserLeap=window.Sprig);window.UserLeap||(window.UserLeap=window.Sprig);window.Sprig||(window.Sprig=window.UserLeap);const it="rgba(255,255,255, 0.95)",nt="rgba(0,0,0,0.9)",X="0px",ke=(t,r)=>{window.UserLeap.container=document.createElement("div"),window.UserLeap.container.className=`ul-container ${t&&"ul-container-feedback"}`;const n=Oe();r&&n&&!window.UserLeap.useMobileStyling?n.appendChild(window.UserLeap.container):document.body.appendChild(window.UserLeap.container)},Re=(t,r)=>{var s;lt();const n=window.UserLeap.container;if(n)try{(s=n.parentNode)==null||s.removeChild(n),window.UserLeap.container=null,U("trackStartUrl",null),i.eventEmitter.emit(i.SprigEvent.SurveyLifeCycle,{state:"dismissed"}),i.eventEmitter.emit(i.SprigEvent.SurveyClosed,{name:i.SprigEvent.SurveyClosed,initiator:t,studyType:r})}catch(e){console.warn(`[Sprig] (ERR-412) Error removing UserLeap container by ${t} `+n),e instanceof Error&&window.UserLeap.reportError("dismissActiveSurvey",e)}},_e=()=>{i.eventEmitter.once(i.SprigEvent.SurveyWillClose,({initiator:t,studyType:r})=>{i.eventEmitter.removeAllListeners(i.SprigEvent.CloseSurveyOnOverlayClick),Re(t,r)})},ot=(t,r)=>{const s={...{position:"fixed",overflow:"auto",top:"0px",left:"0px",display:"none",height:"100%",width:"100%",transition:"background-color 0.3s ease-out",zIndex:2147483646}},e=r?t.overlayStyleMobile:t.overlayStyle;s["background-color"]=e==="light"?it:nt,r||(s.margin="auto"),window.UserLeap.container&&Object.assign(window.UserLeap.container.style,s)},st=(t,r,n,s)=>{var c,u;const e={position:"fixed",bottom:"0px",right:X,border:0,backgroundColor:"rgba(0,0,0,0)",zIndex:2147483646,transition:"width 0.2s ease-in-out, height 0.2s ease-in-out",maxWidth:"100%"},o=Object.assign({},r,window.UserLeap),{desktopDisplay:a}=r||{},l=a==="center-modal";l&&(o.framePosition="center");let d,p=!1;if(n)(c=window.UserLeap.windowDimensions)!=null&&c.width?e.width=`${window.UserLeap.windowDimensions.width}px`:e.width="100%",(u=window.UserLeap.windowDimensions)!=null&&u.height?e.maxHeight=`${window.UserLeap.windowDimensions.height-20}px`:window.UserLeap.maxHeight?e.maxHeight=window.UserLeap.maxHeight:e.maxHeight=`${document.body.clientHeight-20}px`,["light","dark"].includes(o.overlayStyleMobile)&&(p=!0);else{e.width=Ee,e.maxHeight=window.UserLeap.maxHeight||"66vh";const w=()=>{p=!0,d={margin:"auto",position:"static"}};if(s)l?w():d={position:"relative",height:"300px"};else switch(o.framePosition){case"bottomLeft":d={left:X};break;case"topLeft":d={left:X,top:0};break;case"topRight":d={top:0};break;case"center":w();break}}return p&&ot(o,n),Object.assign(t.style,e,d),p},at=({productConfig:t,useMobileStyling:r,surveyId:n,isFeedback:s})=>{var w,m;const e=le,o=s&&t.desktopDisplay==="slider";ke(s,o),dt();const a=document.createElement("iframe");a.id=e,a.setAttribute("title","Sprig User Feedback Dialog");const l=st(a,t,r,s);_e();let d=!1;a.setHeight=g=>{(parseInt(a.style.height)!=g||!d)&&(d=!0,a.style.height=`${g}px`,i.eventEmitter.emit(i.SprigEvent.SurveyHeight,{name:i.SprigEvent.SurveyHeight,contentFrameHeight:g}))};let p=!1;a.setWidth=g=>{(parseInt(a.style.width)!=g||!p)&&(p=!0,a.style.width=`${g}px`,i.eventEmitter.emit(i.SprigEvent.SurveyWidth,{name:i.SprigEvent.SurveyWidth,contentFrameWidth:g}))},(w=window.UserLeap.container)==null||w.appendChild(a),t&&(r?t.exitOnOverlayClickMobile:t.exitOnOverlayClick)&&window.UserLeap.container&&(window.UserLeap.container.onclick=()=>{i.eventEmitter.emit(i.SprigEvent.CloseSurveyOnOverlayClick)}),i.eventEmitter.emit(i.SprigEvent.SurveyLifeCycle,{state:"presented"}),i.eventEmitter.emit(i.SprigEvent.SurveyPresented,{name:i.SprigEvent.SurveyPresented,"survey.id":n});const c=(m=a.contentWindow)==null?void 0:m.document;if(c&&(c.open("text/html","replace"),c.write("<!doctype html><head></head><body></body></html>"),c.close(),!r)){const g=c.body;g.style.display="flex",g.style.alignItems="center"}const u=c==null?void 0:c.head;return{frameId:e,contentWinDocHead:u,contentWindow:a.contentWindow,hasOverlay:l,iframe:a}},Ae={[i.SprigEvent.SurveyFadingOut]:()=>{window.UserLeap.container&&Object.assign(window.UserLeap.container.style,{"background-color":"rgba(0,0,0,0)"})}},dt=()=>{Object.entries(Ae).forEach(([t,r])=>{i.eventEmitter.on(t,r)})},lt=()=>{Object.entries(Ae).forEach(([t,r])=>{i.eventEmitter.off(t,r)})},ct=1,Se=t=>t instanceof HTMLElement||t instanceof SVGElement,$=(t,r,n)=>{const s="ul-custom-style",e=t.getElementById(s);if(e){e.textContent=r;return}const o=t.createElement("style");n&&(o.nonce=n),o.textContent=r,o.id=s,t.head.appendChild(o)},De=t=>{const r=t.querySelector(".ul-card__container");let n=600,s=360;if(r){n=r.scrollHeight;const e=getComputedStyle(r),o=parseFloat(e.marginTop)+parseFloat(e.marginBottom),a=parseFloat(e.borderTopWidth)+parseFloat(e.borderBottomWidth),l=parseFloat(e.paddingTop)+parseFloat(e.paddingBottom);n+=o+a+l;const d=r.querySelector(".ul-card--matrix_grid");s=d?d.scrollWidth:r.scrollWidth;const p=parseFloat(e.paddingLeft)+parseFloat(e.paddingRight),c=parseFloat(e.marginLeft)+parseFloat(e.marginRight),u=parseFloat(e.borderLeftWidth)+parseFloat(e.borderRightWidth);s+=c+u+p}return[n+ct,s]},pt=t=>{const r=t.querySelector(".ul-card__container");r&&(r.scrollTop=0)},Oe=()=>f,H=()=>document.getElementById("sprig-feedback-container"),ce=()=>document.getElementById("sprig-feedback-loading-animation"),ut=()=>{if(ce())return;const t=document.createElement("div");return t.className="ul-loading-spinner-container",t.id="sprig-feedback-loading-animation",t.role="progressbar",t.setAttribute("aria-live","polite"),t.setAttribute("aria-busy","true"),t.setAttribute("aria-label","Processing..."),t.innerHTML=`
|
|
2
|
+
<div class="ul-loading-spinner">
|
|
3
|
+
<div class="first"></div>
|
|
4
|
+
<div class="second"></div>
|
|
5
|
+
<div class="third"></div>
|
|
6
|
+
<div class="fourth"></div>
|
|
7
|
+
</div>
|
|
8
|
+
`,t},xe=()=>!!document.getElementById(le);let Le=!1,f=null,_=null,pe=!1,W=null,T=null;const wt=["bottom-left","bottom-right","center-left","center-right"],gt=t=>{if(H()||!wt.includes(t))return;const[r,n]=t.split("-"),s=document.createElement("div");s.id="sprig-feedback-container",s.classList.add(`sprig-feedback-container-${n}`,`sprig-feedback-container-${r}`),document.body.appendChild(s)},K=()=>{var r;const t=window.UserLeap.container;return((r=t==null?void 0:t.parentElement)==null?void 0:r.id)==="sprig-feedback-loading-container"},Te=()=>document.getElementById("sprig-feedback-error-container"),Pe=()=>{if(!f)return 0;const t=f==null?void 0:f.clientWidth,r=window.getComputedStyle(f),n=parseInt(r.borderRightWidth||"0"),s=parseInt(r.borderLeftWidth||"0");return t+n+s},q=t=>{const r=H();r&&(T!=null&&T.endsWith("right")?r.style.right=`${t}px`:T!=null&&T.endsWith("left")&&(r.style.left=`${t}px`))},Z=()=>{if(f&&(K()||Te())){i.eventEmitter.off(i.SprigEvent.SurveyAppeared,B),te();const t=Pe();return q(-t),!0}return!1},B=()=>{if(!f||!_)return;const t=ce();t&&t.remove(),f.style.height="auto",f.style.width="auto",_.disabled=!1,pe=!1},te=()=>{if(!f)return;if(!ce()){const r=ut();r&&(f.style.height="300px",f.style.width="360px",f.appendChild(r))}},be=()=>{!f||!_||(q(0),_.disabled=!0,pe=!0)},ft=async t=>{const r=await R(I("1",[O],"startFeedbackStudy"),{body:JSON.stringify({surveyUuid:t}),method:"POST"});return r.ok?r.json:null},Ce=async(t,r,n)=>{const{buttonTheme:s,customStyles:e,eventId:o,placement:a,desktopDisplay:l,feedbackLabel:d,surveyUuid:p,surveyId:c}=t;window.UserLeap.feedbackCustomStyles=void 0;let u=H();if(u){if(!r&&o===W)return;u.remove(),i.eventEmitter.off(i.EVENTS.SURVEY_FADING_OUT,Z)}if(W=o,!document.getElementById("sprig-feedback-style")){const{head:S}=document,L=document.createElement("style");L.id="sprig-feedback-style",L.textContent=Ge,L.nonce=window.UserLeap.styleNonce,S.appendChild(L)}$(document,e??"",window.UserLeap.styleNonce),Le=l==="center-modal",T=a;const[m,g]=a.split("-");gt(a),u=H(),_=document.createElement("button");const y=document.createElement("div");y.className="sprig-feedback-button-label",y.innerText=d,_.appendChild(y),_.id="sprig-feedback-button",_.classList.add(`sprig-feedback-button-${g}`,`sprig-feedback-button-${m}`,`sprig-feedback-button-${s}`,"fade-in-transition"),i.eventEmitter.on(i.EVENTS.SURVEY_FADING_OUT,Z),_.addEventListener("click",async()=>{const S=document.getElementById("sprig-feedback-error-container");if(xe()||Te()){if(Z()){i.eventEmitter.emit(i.SprigEvent.SurveyWillClose,{name:i.SprigEvent.SurveyWillClose,initiator:i.DismissReason.FeedbackClosed,studyType:"feedbackButton"});const E=H();S&&E&&(E.remove(),W=null,f=null)}return}const L=i.getHttpHeaders(window.UserLeap);if(!ae(L)&&!pe&&be(),r){f&&f.classList.add("sprig-feedback-loading-container-previews"),await N(r),B();return}const k=await ft(p);if(k)i.eventEmitter.once(i.SprigEvent.SurveyAppeared,B),N({...k,studyType:"feedbackButton"},n);else if(f){const E=yt();f.appendChild(E),B(),f.style.height="300px",f.style.width="360px"}}),u==null||u.appendChild(_),i.eventEmitter.emit(i.SprigEvent.FeedbackButtonLoaded,{name:i.SprigEvent.FeedbackButtonLoaded,"survey.id":c});const{useMobileStyling:A,_config:{border:b}}=window.UserLeap;if(!Le&&!A){const S=document.createElement("div");S.id="sprig-feedback-loading-container",S.className=`sprig-feedback-loading-container sprig-feedback-loading-container-${g}`,S.style.setProperty("--feedback-border",b),f=S,te(),u==null||u.appendChild(S);const L=Pe();q(-L)}else q(0);window.UserLeap._config.isOnQuestionsTab&&r&&!K()&&f&&(be(),te(),f&&f.classList.add("sprig-feedback-loading-container-previews"),N(r),B())},mt=()=>{if(K())return;const t=H();if(!t)return;i.checkUrlStillMatching(W)||(t.remove(),W=null,f=null)},yt=()=>{const t=document.createElement("div");t.id="sprig-feedback-error-container",t.innerHTML=`<svg xmlns="http://www.w3.org/2000/svg" width="40" height="40" viewBox="0 0 40 40" fill="none">
|
|
9
|
+
<circle cx="20" cy="20" r="14.5" stroke="#B0B5B7" stroke-width="3"/>
|
|
10
|
+
<path d="M20 12L20 21.6" stroke="#B0B5B7" stroke-width="3" stroke-linecap="round"/>
|
|
11
|
+
<circle cx="19.9984" cy="27.6" r="1.6" fill="#B0B5B7"/>
|
|
12
|
+
</svg>`;const r=document.createElement("h3");return r.className="sprig-feedback-error-text",r.innerText="There was an error while loading the survey",t.appendChild(r),t},vt="!launch_darkly_";class ht{constructor(){F(this,"_ldData",{})}getAllLaunchDarklyVariations(){return this._ldData}setLDFlagsVariations(r){try{return!r||typeof r!="object"||Array.isArray(r)?!1:(Object.keys(this._ldData).forEach(n=>{delete this._ldData[n]}),Object.keys(r).forEach(n=>this._ldData[`${vt}${n}`]=(r[n]??0)+1),!0)}catch(n){return n instanceof Error&&window.UserLeap.reportError("setAllLDFlagsVariations",n),console.warn("[Sprig] An issue had occured when setting LaunchDarkly flags and variations."),!1}}}const re=new ht;Object.freeze(re);const St="!optimizely_experiments_";class Lt{constructor(){F(this,"_optimizelyData",{})}setOptimizelyExperiment(r,n=!0){if(!r||typeof r!="object")return!1;const{experiments:s}=r;try{return n&&Object.keys(this._optimizelyData).map(e=>{delete this._optimizelyData[e]}),s&&s.map(e=>{const{id:o,variation:a}=e,l=this.transformExperimentId(o);a&&typeof a=="string"&&(this._optimizelyData[l]=a)}),!0}catch(e){return e instanceof Error&&window.UserLeap.reportError("setOptimizelyExperiment",e),!1}}getAllOptimizelyExperiments(){return this._optimizelyData}getOptimizelyVariationName(r){return this._optimizelyData[this.transformExperimentId(r)]}transformExperimentId(r){return St+r}getAndSetWebOptimizelyExperiments(){var r;try{if(window&&window.optimizely&&typeof window.optimizely.get=="function"){const n=(r=window.optimizely.get("state"))==null?void 0:r.getExperimentStates({isActive:!0});if(n){const s=Object.keys(n).map(e=>{var o,a;return(o=n[e].variation)!=null&&o.name?{id:e,variation:(a=n[e].variation)==null?void 0:a.name}:{id:e,variation:"Original"}});return this.setOptimizelyExperiment({experiments:s},!1),!0}return!1}return!1}catch(n){return n instanceof Error&&window.UserLeap.reportError("getAndSetWebOptimizely",n),!1}}}const z=new Lt;Object.freeze(z);class bt{constructor(r,n){F(this,"paused");F(this,"queue");F(this,"ul");this.ul=r,this.paused=!1,this.queue=[],this.flush(n)}flush(r){const n=r.length;if(n)for(let s=0;s<n;s++)this.push(r[s])}isPaused(){return this.paused}pause(){this.paused=!0}unpause(){this.paused=!1;const r=this.queue.slice();this.empty(),this.flush(r)}push(r){if(this.paused)this.queue.push(r);else if(r instanceof Function)r();else{const n=Array.prototype.slice.call(r,1),s=r[0],e=this.ul[s];e instanceof Function?e.apply(this.ul,n):s&&console.warn("[Sprig] (ERR-100) No valid UserLeap action called",s)}}perform(r){if(this.paused){let n=()=>{};const s=new Promise(function(e){n=function(){e(r())}});return this.queue.push(n),s}else return r()}empty(){this.queue.length=0}}const ie=(t,r)=>{const n=performance.now();document.hidden?setTimeout(()=>ie(t,r),t):setTimeout(()=>{const s=performance.now()-n;r.report(s/1e3),setTimeout(()=>ie(t,r),t)},0)},Et=(t=1e3)=>{const r=i.registerMetric("sdk_event_queue_latency_seconds");ie(t,r)},Ut=({webMetricsEnabled:t,reportingIntervalSeconds:r,thresholds:n,postMetrics:s})=>{i.registerThresholds(n,(e,o)=>{var a,l;if((a=i.modules.replay)!=null&&a.isReplayRecording()){const d=`Value: ${e} on ${o.metric} violated threshold of ${o.type} ${o.value}`;(l=i.modules.replay)==null||l.disableRecording("Threshold violated",new Error(d),{reportError:!1}),i.disableThresholdChecking()}}),i.initPerformanceReporting({reportingIntervalSeconds:r,postMetrics:s}),t&&Et()},It={test:"test"},kt=["popState","pushState","replaceState"],V="!email",ne="pageUrl";function Rt(t,r){const{pageUrlEvents:n,interactiveEvents:s,dismissOnPageChange:e}=window.UserLeap._config;if(!e)return!0;const o=[];n&&n.length&&o.push(...n),s&&s.length&&o.push(...s);const a=t&&o.find(l=>l.id===t);return a?i.checkUrlMatch(a,window.location.href):r===window.location.href}function j(t){var l;const{pageUrlEvents:r,interactiveEvents:n,dismissOnPageChange:s,platform:e}=window.UserLeap._config;if(e&&e!=="web")return;const o=P("trackStartUrl"),a=o?String(o):null;r&&Ve(window.location.href),n&&(He(),_t()),Oe()&&mt(),i.sessionStorageHelper.getItem("sprig.isCapturingHeatmap")&&((l=i.modules.replay)==null||l.checkPendingHeatmapsUrl()),!K()&&s&&a&&a!==window.location.href&&t&&kt.includes(t.type)&&window.UserLeap("dismissActiveSurvey",i.DismissReason.PageChange)}const Fe={capture:!0},_t=()=>{const r=window.UserLeap._config.interactiveEvents.filter(s=>i.checkUrlMatch(s,window.location.href)).map(s=>{const{name:e,properties:o}=s,{selector:a,innerText:l}=o;return a?d=>{if(Se(d.target))try{d.target.closest(a)&&window.UserLeap("track",e)}catch{}return!1}:d=>(Se(d.target)&&d.target.innerText===l&&window.UserLeap("track",e),!1)}),n=s=>r.forEach(e=>e(s));window.UserLeap._config.interactiveEventsHandler=n,window.addEventListener("click",n,Fe)},He=()=>{window.UserLeap._config.interactiveEventsHandler&&window.removeEventListener("click",window.UserLeap._config.interactiveEventsHandler,Fe),delete window.UserLeap._config.interactiveEventsHandler};function At(){["hashchange","popstate"].forEach(t=>window.addEventListener(t,j,!0))}function Dt(){["hashchange","popstate"].forEach(t=>window.removeEventListener(t,j,!0)),window.UserLeap._config.interactiveEvents&&He()}function Ot(t){const r=new URL(I("1",[x],"questions"));return Object.entries(t||{}).forEach(([n,s])=>{s&&r.searchParams.append(n,String(s))}),r.toString()}function P(t){const r=i.localStorageHelper.getItem("userleap.ids");if(r)try{const s=JSON.parse(r)[window.UserLeap.envId];return s&&s[t]||null}catch(n){n instanceof Error&&(n.stack=r,window.UserLeap.reportError("Failed to parse local storage credentials",n)),console.warn("[Sprig] (ERR-427) Failed to lookup saved ids",n)}return null}function Me(){window.previewMode||(window.UserLeap.visitorId=i.v4(),i.info(`Generating new vid: ${window.UserLeap.visitorId}`),U("vid",window.UserLeap.visitorId),i.eventEmitter.emit(i.SprigEvent.VisitorIDUpdated,{visitorId:window.UserLeap.visitorId}))}function Ve(t,r,n,s){var w,m,g;if(t.endsWith("mock_snippet.html"))return;i.info(`Tracking page view: ${t}`);const e=window.UserLeap._config.pageUrlEvents;let o=!1;if(e&&e.length)for(let y=0;y<e.length&&(o=i.checkUrlMatch(e[y],t),!o);y++);if(!o)return;window.UserLeap.debugMode&&console.info("[DEBUG] Sprig trackPageView",t);const a=10,l=1;let d=[];const p={viewedAt:Date.now(),location:t},c={url:t};s&&(c.trackPageView=!0);const u=i.localStorageHelper.getItem("userleap.pageviews");try{if(d=u?JSON.parse(u):[],Array.isArray(d)||(d=[]),d.length>0){const y=d[d.length-1],A=(Date.now()-y.viewedAt)/1e3;if(y.location!=t&&A>l){const b=(w=document==null?void 0:document.querySelector('meta[name="description"]'))==null?void 0:w.getAttribute("content");(m=i.modules.replay)==null||m.RecordPageView({...b&&{description:b},url:t,referrer:document.referrer,pageTitle:document.title})}(y.location!=t&&A>l||A>a)&&(window.UserLeap._queue.push(["track",ne,r,c,n]),d.push(p))}else window.UserLeap._queue.push(["track",ne,r,c,n]),d.push(p),(g=i.modules.replay)==null||g.RecordPageView({url:t});d.length>5&&d.splice(0,d.length-5),i.localStorageHelper.setItem("userleap.pageviews",JSON.stringify(d))}catch(y){y instanceof Error&&window.UserLeap.reportError("trackPageView",y,{pageViewsStorage:u}),console.warn("[Sprig] (ERR-425) Failed to update page views in local storage")}}function xt(){const t="Backbone"in window&&window.Backbone&&window.Backbone.history?window.Backbone.history:window.history;"pushState"in t&&(t.pushState=(r=>function(...s){const e=r.apply(this,s),o=new Event("pushState");return window.dispatchEvent(o),j(o),e})(t.pushState)),"replaceState"in t&&(t.replaceState=(r=>function(...s){const e=r.apply(this,s),o=new Event("replaceState");return window.dispatchEvent(o),j(o),e})(t.replaceState)),At()}async function ee(t,r){const n=se();t&&!r&&(window.UserLeap._config.mode=It.test);const s=i.getHttpHeaders(window.UserLeap),e=ae(s),o=await R(Ot({desktopDisplay:window.UserLeap._config.desktopDisplay,isMobile:e,previewLanguage:window.UserLeap._config.previewLanguage,surveyid:t==null?void 0:t.surveyId,surveytemplateid:t==null?void 0:t.surveyTemplateId,vid:n}),{shouldDropOnRateLimit:!0});if(!o.ok)return o.reportError&&o.error&&(console.warn("[Sprig] (ERR-414) Failed to request questions from the server",o.error),window.UserLeap.reportError("getQuestions",o.error)),{success:!1,surveyState:"no survey"};if(o.json.delay&&await i.delay(o.json.delay),o.json.isFeedback){const{feedbackLabel:a,productConfig:l,surveyUuid:d,feedbackCustomStyles:p}=o.json,{buttonTheme:c,placement:u,desktopDisplay:w}=l,m={customStyles:p,buttonTheme:c,desktopDisplay:w,eventId:0,feedbackLabel:a,placement:u,surveyUuid:d,surveyId:t==null?void 0:t.surveyId};Ce(m,o.json)}else return N(o.json)}function Tt(t){let r=t.length;for(;r;){const n=Math.floor(Math.random()*r);r-=1;const s=t[r];t[r]=t[n],t[n]=s}}function Pt(t){if(!t)return;window.UserLeap._config=t,t.mute&&window.UserLeap._queue.pause();const{interactiveEvents:r,pageUrlEvents:n,dismissOnPageChange:s}=t;r&&Tt(r),(r||n||s)&&(xt(),j())}async function Ct(t,r){var s,e;let n=!0;return r&&((s=t==null?void 0:t.json)!=null&&s.surveyId)&&(window.UserLeap.delayingSurvey=!0,n=await r(t.json.surveyId),window.UserLeap.delayingSurvey=!1,!n)?!1:((e=t==null?void 0:t.json)!=null&&e.delay&&(window.UserLeap.delayingSurvey=!0,await i.delay(t.json.delay),window.UserLeap.delayingSurvey=!1),n)}const Ft=function(t){if(!window.UserLeap)return;const r=async(e={})=>{var S,L,D,k,E;const{userId:o,anonymousId:a,metadata:l={},properties:d,showSurveyCallback:p}=e;let{eventName:c}=e;if(window.UserLeap.debugMode&&c!==ne&&console.info("[DEBUG] Sprig track",e),t.mode==="test")return;const u=i.localStorageHelper.getItem("sprig.previewKey")??void 0;if(t.requireUserIdForTracking&&!window.UserLeap.userId&&!o){const v="[Sprig] - Skipping tracking without userId";return console.warn(v),{success:!1,message:v,surveyState:"no survey"}}if(!c||c.trim().length===0){c=c?String(c):"";const v="[Sprig] - Invalid event name "+c;return console.warn(v),{success:!1,message:v,surveyState:"no survey"}}const w=window.location.href;if(l.url||(l.url=w),U("trackStartUrl",w),(L=(S=window.UserLeap)==null?void 0:S._config)!=null&&L.optimizelyEnabled){const v=i.getHttpHeaders(window.UserLeap);de(v)||z.getAndSetWebOptimizelyExperiments(),l.optimizelyExperiments=Object.assign({},z.getAllOptimizelyExperiments())}(k=(D=window.UserLeap)==null?void 0:D._config)!=null&&k.launchDarklyEnabled&&(l.launchDarklyFlags=re.getAllLaunchDarklyVariations()),o&&(window.UserLeap.userId=o),a&&(window.UserLeap.partnerAnonymousId=a),d&&(l.eventProperties=d),(E=i.modules.replay)==null||E.RecordEvent({name:c,url:l.url}),i.info(`Tracking event: ${c}`);const m=window.UserLeap.delayingSurvey||xe()?await R(I("1",[O],"events/batch"),{body:JSON.stringify({events:[{event:c,metadata:l}],previewKey:u}),method:"POST",shouldDropOnRateLimit:!0}):await R(I("1",[O],"events"),{body:JSON.stringify({event:c,metadata:l,previewKey:u}),method:"POST",shouldDropOnRateLimit:!0});if(!m.ok){const v="[Sprig] (ERR-421) Failed to track event";return m.reportError&&(console.warn(v,m.error),m.error&&window.UserLeap.reportError("track",m.error)),{success:!1,message:v,error:m.error,surveyState:"no survey"}}o&&U("uid",o),a&&U("aid",a);const g=m.json;g.invalidPreviewKey&&i.localStorageHelper.removeItem("sprig.previewKey");const y=l.trackPageView?l.url:void 0;return!!(g!=null&&g.feedbackButton)&&Ce(g.feedbackButton,void 0,y),await Ct(m,p)?Rt(g.eventId,w)?N(g,y):{success:!1,message:"Study should not be displayed after page navigation",surveyState:"no survey"}:{success:!1,message:"[Sprig] Callback returned false, aborting rendering of survey",surveyState:"no survey"}},n=(e,o)=>{var l;const a=(l=e==null?void 0:e.querySelector(`[id="${le}"]`))==null?void 0:l.contentDocument;a&&$(a,o)},s={async displaySurvey(e){return console.warn("[Sprig] displaySurvey should only be used to debug your studies; not intended for production usage."),window.UserLeap("dismissActiveSurvey",i.DismissReason.Override),ee({surveyId:e},!0)},_previewSurvey(e){window.UserLeap("dismissActiveSurvey",i.DismissReason.Override),ee({surveyTemplateId:e},!1)},_reviewSurvey(e){window.UserLeap("dismissActiveSurvey",i.DismissReason.Override),ee({surveyId:e},!1)},previewSurvey(e){s._previewSurvey(e)},reviewSurvey(e){s._reviewSurvey(e)},mute(){window.UserLeap._queue.pause()},unmute(){window.UserLeap._queue.unpause()},setVisitorToken(){console.warn("[Sprig] setVisitorToken is deprecated.")},dismissActiveSurvey(e=i.DismissReason.API){i.eventEmitter.emit(i.SprigEvent.SurveyWillClose,{name:i.SprigEvent.SurveyWillClose,initiator:e})},async setAttribute(e,o){if(!e||!o&&o!==0&&o!==!1){const a="[Sprig] - Disregarding empty attribute / value provided";return console.warn(a),{success:!1,message:a}}return this.setAttributes({[e]:o})},async setAttributes(e){if(e==null||Object.keys(e).length===0){const o="[Sprig] - Disregarding empty attributes provided";return console.warn(o),{success:!1,message:o}}return this.identifyAndSetAttributes({attributes:e})},async identifyAndSetAttributes(e){if(window.UserLeap.debugMode&&console.info("[DEBUG] Sprig identifyAndSetAttributes",e),t.mode==="test")return;if(e===null||typeof e!="object"||!(e.userId||e.anonymousId||e.attributes)){const c="[Sprig] - Disregarding empty payload provided";return console.warn(c),{success:!1,message:c}}const{userId:o,anonymousId:a,attributes:l}=e;if(t.requireUserIdForTracking&&!window.UserLeap.userId&&!o){const c="[Sprig] - Skipping tracking without userId";return console.warn(c),{success:!1,message:c}}if(!l&&(!o||window.UserLeap.userId===o)&&(!a||window.UserLeap.partnerAnonymousId===a))return{success:!0};const d={};o&&(d.userId=window.UserLeap.userId=o),a&&(d.partnerAnonymousId=window.UserLeap.partnerAnonymousId=a);let p;return l?(l.email&&!Object.prototype.hasOwnProperty.call(l,V)&&(l[V]=l.email,delete l.email),i.info(`Setting attributes: ${JSON.stringify(l)}`),p=await R(I("1",[x,O],"attributes"),{body:JSON.stringify(l),method:"PUT"}),!p.ok&&p.reportError&&(console.warn("[Sprig] (ERR-432) identifyAndSetAttributes failed",p.error),p.error&&window.UserLeap.reportError("identifyAndSetAttributes",p.error))):p=await R(I("1",[x,O]),{body:JSON.stringify(d),method:"PUT"}),l&&l[V]&&(window.UserLeap.email=l[V]),p.ok&&(o&&U("uid",o),a&&U("aid",a)),{success:!!p.ok}},async removeAttributes(e){if(window.UserLeap.debugMode&&console.info("[DEBUG] Sprig removeAttributes",e),t.mode==="test")return;if(e==null||e.length===0){const a="[Sprig] - Disregarding empty attributes provided";return console.warn(a),{success:!1,message:a}}if(t.requireUserIdForTracking&&!window.UserLeap.userId){const a="[Sprig] - Skipping tracking without userId";return console.warn(a),{success:!1,message:a}}const o=await R(I("1",[x,O],"attributes"),{body:JSON.stringify({delete:e}),method:"DELETE"});return!o.ok&&o.reportError&&(console.warn("[Sprig] (ERR-433) Remove attributes failed",o.error),o.error&&window.UserLeap.reportError("removeAttributes",o.error)),{success:!!o.ok}},async addSurveyListener(e){i.eventEmitter.on(i.SprigEvent.SurveyLifeCycle,e)},async removeSurveyListener(e){i.eventEmitter.removeListener(i.SprigEvent.SurveyLifeCycle,e)},async addListener(e,o){i.eventEmitter.on(e,o)},async removeListener(e,o){i.eventEmitter.removeListener(e,o)},async removeAllListeners(){i.eventEmitter.removeAllListeners()},setPreviewKey(e){!e||typeof e!="string"||i.localStorageHelper.isStorageAvailable&&e&&i.localStorageHelper.setItem("sprig.previewKey",e)},async setUserId(e){var l;if(window.UserLeap.debugMode&&console.info("[DEBUG] Sprig setUserId",e),e==null){const d=`[Sprig] - Invalid userId ${e}`;return console.warn(d),{success:!1,message:d}}if(t.mode==="test"||e===window.UserLeap.userId)return;window.UserLeap.userId=e;const o=window.UserLeap.visitorId,a=await R(I("1",[x,O]),{body:JSON.stringify({userId:e}),method:"PUT"});if(!a.ok){a.reportError&&(console.warn("[Sprig] (ERR-420) Failed to set user id",a.error),a.error&&window.UserLeap.reportError("setUserId",a.error));return}o!==window.UserLeap.visitorId&&((l=i.modules.replay)==null||l.clearUserReplayData()),U("uid",e)},async setPartnerAnonymousId(e){if(window.UserLeap.debugMode&&console.info("[DEBUG] Sprig setPartnerAnonymousId",e),e==null){const o=`[Sprig] - Invalid partnerAnonymousId ${e}`;return console.warn(o),{success:!1,message:o}}return window.UserLeap.partnerAnonymousId=e,U("aid",e),{success:!0}},async track(e,o,a={},l=void 0){return r({eventName:e,properties:o,metadata:a,showSurveyCallback:l})},async identifyAndTrack(e){return await r(e)},trackPageView(e,o=void 0,a=void 0,l=!0){Ve(e,o,a,l)},applyFeedbackStyles({button:e="",view:o=""}){window.UserLeap.feedbackCustomStyles=o,document.getElementById("sprig-feedback-style")&&$(document,e,window.UserLeap.styleNonce),n(document.querySelector(".ul-container-feedback"),o)},applyStyles(e){window.UserLeap.customStyles=e,n(window.UserLeap.container,e)},setWindowDimensions(e,o){var p,c;const a=typeof e=="string"?parseInt(e,10):e,l=typeof o=="string"?parseInt(o,10):o;if(!isNaN(a)&&!isNaN(l)&&(window.UserLeap.windowDimensions={width:a,height:l}),!window.UserLeap.frameId)return;const d=document.getElementById(window.UserLeap.frameId);d&&(window.UserLeap.useMobileStyling&&((p=window.UserLeap.windowDimensions)!=null&&p.width&&(d.style.width=`${window.UserLeap.windowDimensions.width}px`),(c=window.UserLeap.windowDimensions)!=null&&c.height&&(d.style.maxHeight=`${window.UserLeap.windowDimensions.height-20}px`),d.contentDocument&&(d.style.height=String(De(d.contentDocument)[0])+"px")),i.eventEmitter.emit(i.SprigEvent.SurveyDimensions,{name:i.SprigEvent.SurveyDimensions,contentFrameWidth:d.clientWidth,contentFrameHeight:d.clientHeight}))},logoutUser(){var e;window.UserLeap.debugMode&&console.info("[DEBUG] Sprig logout"),i.info(`Logging out user: ${window.UserLeap.userId} / vid: ${window.UserLeap.visitorId}`),window.UserLeap.visitorId=null,window.UserLeap.userId=null,window.UserLeap.partnerAnonymousId=null,window.UserLeap.token=null,window.UserLeap.email=null,i.localStorageHelper.removeItem("userleap.ids"),i.localStorageHelper.removeItem("userleap.pageviews"),window.UserLeap._queue.isPaused()&&window.UserLeap._queue.empty(),Me(),(e=i.modules.replay)==null||e.clearUserReplayData(),window.UserLeap._queue.unpause()},teardown(){Dt(),window.UserLeap("dismissActiveSurvey",i.DismissReason.API),delete window.UserLeap,delete window.Sprig,delete window._Sprig},integrateOptimizely(e,o=!0){var a,l;if(!((l=(a=window.UserLeap)==null?void 0:a._config)!=null&&l.optimizelyEnabled)){console.warn("[SPRIG] Optimizely integration is currently not enabled for your product.");return}try{const d=typeof e=="string"?JSON.parse(e):e;z.setOptimizelyExperiment(d,o)}catch(d){console.warn("[Sprig] Error with integrating Optimizely data"),d instanceof Error&&window.UserLeap.reportError("integrateOptimizely",d)}},integrateOptimizelyClient(e){var a,l;if(!((l=(a=window.UserLeap)==null?void 0:a._config)!=null&&l.optimizelyEnabled)){console.warn("[SPRIG] Optimizely integration is currently not enabled for your product.");return}const o=({experiment:d,variation:p})=>{const c={experiments:[{id:d.id,variation:p.key}]};window.UserLeap("integrateOptimizely",c,!1)};e.notificationCenter.addNotificationListener("ACTIVATE:experiment, user_id,attributes, variation, event",o)},importLaunchDarklyData(e){var o,a;if(!((a=(o=window.UserLeap)==null?void 0:o._config)!=null&&a.launchDarklyEnabled)){console.warn("[SPRIG] LaunchDarkly integration is currently not enabled for your product.");return}re.setLDFlagsVariations(e)},setVisitorAttribute(e,o){return console.warn("[Sprig] setVisitorAttribute is deprecated. Please use setAttribute"),s.setAttribute(e,o)},async setEmail(e){return s.setAttribute(V,e)},async setVisitorEmail(e){return console.warn("[Sprig] setVisitorEmail is deprecated. Please use setEmail"),s.setEmail(e)},async _generateVideoUploadUrl(e){return Bt(e)},_reportMetric(e,o){i.reportAndRegister(e,o)},async _completeSessionReplay({surveyId:e,responseGroupUuid:o,eventDigest:a}){var l;return i.modules.replay?(l=i.modules.replay)==null?void 0:l._completeSessionReplay({surveyId:e,responseGroupUuid:o,eventDigest:a,headers:i.getHttpHeaders(window.UserLeap)}):(window.UserLeap.reportError("_completeSessionReplay",new Error("Replay module not registered")),!1)}};Object.assign(window.UserLeap,s)};async function Ht(t){const r=i.getHttpHeaders(window.UserLeap);document.addEventListener("securitypolicyviolation",i.cspViolationHandler);const n=await i.sprigFetch(I("1",[x],"config"),{headers:r}),s="TypeError";if(window.UserLeap.error=n.error,!n.ok&&n.error&&n.error.name===s?(window.UserLeap._API_URL="https://api.sprig.com",window.UserLeap.reportError("sprigDomainRequest",n.error)):document.removeEventListener("securitypolicyviolation",i.cspViolationHandler),!n.ok)return n.reportError&&(console.warn("[Sprig] (ERR-422) Failed to load configuration",n.error),n.error&&window.UserLeap.reportError("applyRemoteConfig",n.error)),i.killNetworkRequests("Disabled: failed to fetch configuration"),t;const e=n.json;return e!=null&&e.disabled?(i.killNetworkRequests(`Disabled: ${e.disabled}`),{disabled:e.disabled}):Object.assign({},e,t)}const Mt=t=>typeof t=="object"&&t&&"inner"in t&&!!t.inner&&typeof t.inner=="object";async function Vt(t,r,n={}){var u,w;const s=window.__cfg&&window.__cfg.mode,e=se(),o=window.UserLeap.envId,a=window.document.documentElement,l=Mt(r)?{inner:{message:(u=r.inner)==null?void 0:u.message,stack:(w=r.inner)==null?void 0:w.stack}}:{},d={mode:s,screenWidth:window.screen.width,screenHeight:window.screen.height,clientWidth:a.clientWidth,clientHeight:a.clientHeight,location:window.location.href,language:window.navigator.language,...n,...l},p={action:t,err:{message:r.message,stack:r.stack},meta:d,vid:e,envId:o},c=await R(I("1",null,"errors"),{method:"POST",headers:{"x-ul-error":window.btoa(`userleap-${Date.now()}-error`)},body:JSON.stringify(p),shouldDropOnRateLimit:!0});if(!c.ok)console.warn("[Sprig] (ERR-444) Failed to report error to API",r);else{const{presignedUrl:m}=c.json;i.uploadLogfile(m)}}async function Bt(t){var n;if(!t)return;const r=`${window.UserLeap._API_URL}/2/environments/integrations/upload`;try{const s=await fetch(r,{method:"POST",cache:"no-cache",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)});if(s.ok){const e=await s.json();return(n=e==null?void 0:e.upload)==null?void 0:n.url}else return null}catch(s){console.warn("[Sprig] Error with generating video upload url"),s instanceof Error&&window.UserLeap.reportError("generateVideoUploadUrl",s)}}function Nt(t={}){const r=new URLSearchParams(window.location.search).get("sprigPreviewKey")??"";window.UserLeap.UPDATES=i.EVENTS,window.UserLeap("setPreviewKey",r);async function n(){var l;if(window.UserLeap.loaded)return;if(i.info("Loading sprig on page load"),window.UserLeap.reportError=Vt,window.UserLeap.loaded=!0,window.UserLeap._config=Object.assign({},t,window.UserLeap.config),window.UserLeap.delayingSurvey=!1,window.UserLeap._config&&typeof window.UserLeap._config=="object")for(const d in window.UserLeap._config)window.UserLeap[d]=window.UserLeap._config[d];if(!window.UserLeap.envId)if(window.UserLeap.appId)window.UserLeap.envId=window.UserLeap.appId;else throw new Error("Missing Environment id");window.UserLeap.debugMode&&console.info("[DEBUG] Sprig debug mode enabled");const s=window.UserLeap.sampleRate;if(s){let d=P("sampled");if(d===null&&(d=Math.random()<s,U("sampled",d)),!d)return}else P("sampled")!==null&&U("sampled",null);window.UserLeap._API_URL||(window.UserLeap._API_URL="https://api.sprig.com");const e=[...window.UserLeap._queue];window.UserLeap._queue=new bt(window.UserLeap,[]),window.UserLeap._queue.pause();for(let d=0;d<e.length;d++)window.UserLeap._queue.push(e[d]);const o=P("token");o?(window.UserLeap.token=o,window.UserLeap.visitorId=P("vid"),window.UserLeap.userId=P("uid"),window.UserLeap.partnerAnonymousId=P("aid")):(i.localStorageHelper.removeItem("userleap.ids"),Me());const a=await Ht(t);Ut({webMetricsEnabled:a.metricsReportingEnabled,reportingIntervalSeconds:a.metricsReportingEnabled||a.mobileMetricsReportingEnabled?a.metricsReportingIntervalSeconds:0,thresholds:a.metricThresholds,postMetrics:async d=>{var p;await R(I("1",[x],"metrics"),{body:d,method:"POST",headers:{"x-ul-replay-enabled":`${!!((p=i.modules.replay)!=null&&p.isReplayRecording())}`},shouldDropOnRateLimit:!0})}}),(l=i.modules.replay)==null||l.initializeReplay({viewDocument:window.document,maxReplayDurationSeconds:a.maxReplayDurationSeconds,replayNonce:window.UserLeap.replayNonce,maxInflightRequests:window.UserLeap.maxInflightReplayRequests??2,replaySettings:a.replaySettings}),i.configureLogger(a.logBufferLimit,a.logLevel),Ft(a),await Pt(a),window.UserLeap._queue.unpause(),i.eventEmitter.emit(i.SprigEvent.SDKReady,{mobileMetricsReportingEnabled:!!a.mobileMetricsReportingEnabled,metricsReportingInterval:a.metricsReportingIntervalSeconds||0,metricsThresholds:a.metricThresholds||[],maxMobileReplayDurationSeconds:a.maxMobileReplayDurationSeconds,mobileReplaySettings:a.mobileReplaySettings}),i.eventEmitter.emit(i.SprigEvent.VisitorIDUpdated,{visitorId:window.UserLeap.visitorId})}document.readyState==="complete"?n():window.attachEvent?window.attachEvent("onload",n):window.addEventListener("load",()=>{n()},!1)}class G{constructor(){this.UPDATES=i.EVENTS}displaySurvey(r){window.Sprig("displaySurvey",r)}mute(){window.Sprig("mute")}unmute(){window.Sprig("unmute")}dismissActiveSurvey(){window.Sprig("dismissActiveSurvey")}setAttribute(r,n){window.Sprig("setAttribute",r,n)}setAttributes(r){window.Sprig("setAttributes",r)}identifyAndSetAttributes(r){window.Sprig("identifyAndSetAttributes",r)}removeAttributes(r){window.Sprig("removeAttributes",r)}addListener(r,n){window.Sprig("addListener",r,n)}removeListener(r,n){window.Sprig("removeListener",r,n)}removeAllListeners(){window.Sprig("removeAllListeners")}setEmail(r){window.Sprig("setAttribute","!email",r)}setUserId(r){window.Sprig("setUserId",r)}setPartnerAnonymousId(r){window.Sprig("setPartnerAnonymousId",r)}track(r,n={},s={}){window.Sprig("track",r,n,s)}identifyAndTrack(r){window.Sprig("identifyAndTrack",r)}trackPageView(r,n,s){window.Sprig("trackPageView",r,n,s)}applyStyles(r){window.Sprig("applyStyles",r)}setWindowDimensions(r,n){window.Sprig("setWindowDimensions",r,n)}logoutUser(){window.Sprig("logoutUser")}teardown(){window.Sprig("teardown")}}const oe={configure:t=>{if(!t.envId&&!t.environmentId)throw new Error("Initialization Error: Sprig configure requires an environmentId");if(t.envId||(t.envId=t.environmentId??""),t.installationMethod="web-npm",window.Sprig)return window.Sprig;window.Sprig=function(){window.Sprig._queue.push(arguments)},Object.getOwnPropertyNames(G.prototype).map(n=>{n!=="constructor"&&(window.Sprig[n]=G.prototype[n])});const r=window.Sprig;return r.appId=t.envId,r._queue=[],window.UserLeap=r,Nt(t),window.Sprig}},Wt={sprig:oe,SprigAPI:G,configure:oe.configure};exports.APP_ID=Ke;exports.ConflictingWidgets=Ie;exports.DEFAULT_BORDER_COLOR=Je;exports.DEFAULT_WIDTH=Ee;exports.EMBED_MOBILE_MAX_WIDTH=Xe;exports.ERROR_BORDER_COLOR=Qe;exports.SprigAPI=G;exports.calculateFrameDimensions=De;exports.core=Wt;exports.overrideStyles=$;exports.resetScrollPosition=pt;exports.sprig=oe;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
var it=Object.defineProperty,ot=(t,e,n)=>e in t?it(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[e]=n,B=(t,e,n)=>(ot(t,typeof e!="symbol"?e+"":e,n),n);import{h as F,s as Ee,f as w,S as g,l as k,i as x,v as xe,m as U,j as st,E as N,D as j,c as at,r as dt,k as lt,n as ct,o as pt,p as ut,q as _e,t as Ae,u as wt,a as gt,x as de,b as yt,y as Re}from"./metricsReporter-B6Yx0G8b.js";const mt='.ul-loading-spinner-container{font-size:1.8rem;flex-grow:1;width:100%;height:100%;display:flex;align-items:center;justify-content:center}.ul-loading-spinner{display:inline-block;position:relative;width:6rem;height:6rem}.ul-loading-spinner div{box-sizing:border-box;display:block;position:absolute;width:80%;height:80%;margin:5px;border:5px solid #152e3e;border-radius:50%;animation:lds-ring 1.2s cubic-bezier(.5,0,.5,1) infinite;border-color:#152e3e transparent transparent transparent}.ul-loading-spinner .first{animation-delay:-.45s}.ul-loading-spinner .second{animation-delay:-.3s}.ul-loading-spinner .third{animation-delay:-.15s}@keyframes lds-ring{0%{transform:rotate(0)}to{transform:rotate(360deg)}}.fade-in-transition{animation:fadeIn .4s ease-in}@keyframes fadeIn{0%{opacity:0}to{opacity:1}}#sprig-feedback-button{border-left:0;border-radius:0 8px 8px 0;display:grid;padding:8px;text-align:center;transition:all ease-in-out 1s;z-index:inherit}#sprig-feedback-button:hover{cursor:pointer}.sprig-feedback-button-label{writing-mode:vertical-lr;text-orientation:sideways}.sprig-feedback-button-right{transform:rotate(180deg)}.sprig-feedback-button-bottom{align-self:flex-end;margin-bottom:20px}.sprig-feedback-button-light{background:#efefee;color:#000;border:1px solid #e2e3e1}.sprig-feedback-button-dark{background:#000;color:#fff;border:1px solid #000000}#sprig-feedback-container{display:flex;align-items:center;position:fixed;transition:right .2s linear,left .2s linear;z-index:2147483646}.sprig-feedback-container-left{flex-flow:row-reverse}.sprig-feedback-container-center{top:50%;transform:translateY(-50%)}.sprig-feedback-container-bottom{bottom:0%;margin-bottom:15px}.sprig-feedback-loading-container{align-items:center;background-color:#fff;border:2px solid var(--feedback-border);display:flex;max-height:90vh;max-width:90vw;min-width:0px}.sprig-feedback-loading-container-left{border-left:none;border-radius:0 8px 8px 0}.sprig-feedback-loading-container-right{border-right:none;border-radius:8px 0 0 8px}#sprig-feedback-error-container{margin:auto;text-align:center;width:360px}.sprig-feedback-error-text{font-weight:400;font-family:-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Helvetica,Arial,sans-serif,"Apple Color Emoji","Segoe UI Emoji",Segoe UI Symbol}#sprig-feedback-loading-container .ul-container{position:relative;max-height:inherit}#sprig-feedback-loading-animation{position:absolute}.sprig-feedback-loading-container-previews iframe{max-height:inherit!important}',De="360px",vt="ul-app",ft="#e6e6e6",ht="#bd282a",bt=500,Lt=1030,Oe=()=>{try{return window.parent.Intercom}catch{return null}},Ut=()=>{const t=Oe();t&&(t.ul_wasVisible&&t("update",{hide_default_launcher:!1}),delete t.ul_wasVisible)},St=()=>{const t=Oe();t&&(t.ul_wasVisible=!!document.querySelector("iframe.intercom-launcher-frame"),t.ul_wasVisible&&t("update",{hide_default_launcher:!0}))},It=Object.freeze(Object.defineProperty({__proto__:null,disable:St,enable:Ut},Symbol.toStringTag,{value:"Module"})),Pe=[It];class Ce{static disable(){Pe.forEach(e=>e.disable())}static enable(){Pe.forEach(e=>e.enable())}}const Te="ul-view-sdk-script",kt=["ios","android"],C="visitors",T="environments";async function D(t,e){var n,o,r;const{shouldDropOnRateLimit:i,...a}=e;a.headers=Object.assign(F(window.UserLeap),a.headers);const s=await Ee(t,{...a,shouldDropOnRateLimit:i});if(s.ok){const d=(n=s.headers)==null?void 0:n.get("Authorization"),p=d?d.split(" "):void 0,l=p&&p.length===2?p[1]:void 0,c=(o=s.headers)==null?void 0:o.get("x-ul-visitor-id");l&&c&&(c!==window.UserLeap.visitorId||window.UserLeap.token!==l)&&(E("token",l),E("vid",c),w.emit(g.VisitorIDUpdated,{visitorId:c}),window.UserLeap.token=l,window.UserLeap.visitorId=c)}return(r=s.json)!=null&&r.logMessage&&console.warn(`[Sprig] ${s.json.logMessage}`),s}function E(t,e){const n=k.getItem("userleap.ids");let o={};if(n)try{o=JSON.parse(n)}catch(i){i instanceof Error&&(i.stack=n,window.UserLeap.reportError("Failed to parse local storage credentials",i)),console.warn("[Sprig] (ERR-427) Failed to lookup saved ids",i)}let r=o[window.UserLeap.envId];r?r[t]=e:r={[t]:e},o[window.UserLeap.envId]=r;try{k.setItem("userleap.ids",JSON.stringify(o))}catch(i){i instanceof Error&&console.warn(`[Sprig] (ERR-426) Unable to write to Local Storage:: ${i.message}`)}}function le(){return window.previewMode?"0":window.UserLeap.visitorId??""}function R(t,e,n){const o=[window.UserLeap._API_URL,"sdk",t];return e&&e.forEach(r=>{o.push(r),r===T?o.push(window.UserLeap.envId):r===C&&o.push(le())}),n&&o.push(n),o.join("/")}const W=async(t,e)=>{var n,o,r;const{context:i,forceBrandedLogo:a,endCard:s,isFeedback:d=!1,heatmap:p,locale:l,previewMode:c,productConfig:u,questions:f,responseGroupUid:m,surveyId:y,uuid:_,vid:b,sessionReplay:h,studyType:A}=t,S=F(window.UserLeap),I=pe(S),ie=ce(S);if(x(`Attempting to display survey: ${y}`),h)if(x("Survey has replay attached"),I)w.emit(g.ReplayCapture,{responseGroupUid:m,hasQuestions:!!(f!=null&&f.length),surveyId:y,uploadId:h.uploadId,replayType:h.replayDurationType??"before",seconds:h.replayDurationSeconds,generateVideoUploadUrlPayload:{mediaRecordingUid:xe(),mediaType:"screen",questionId:1,responseGroupUid:m,surveyId:y,updatedAt:new Date().toISOString(),visitorId:window.UserLeap.visitorId,isReplay:!0}});else{if(!U.replay)return window.UserLeap.reportError("displayQuestions",new Error("Replay module not registered")),{success:!1,message:"Replay module not registered",surveyState:"no survey"};U.replay.scheduleOrCaptureReplay({responseGroupId:m,surveyId:y,visitorId:b,replayParams:h,completeUploadHeaders:S,apiUrl:window.UserLeap._API_URL,triggerTimestamp:Date.now(),isStandalone:f.length===0})}if(p){if(!U.replay)return window.UserLeap.reportError("displayQuestions",new Error("Replay module not registered")),{success:!1,message:"Replay module not registered",surveyState:"no survey"};const{eventId:L,replayParams:ae,responseGroupUid:rt,surveyId:nt}=p;await U.replay.initializeReplay({viewDocument:window.document,maxReplayDurationSeconds:300,replayNonce:window.UserLeap.replayNonce,maxInflightRequests:window.UserLeap.maxInflightReplayRequests,teardownAfter:!0}),U.replay.scheduleCapture({apiUrl:window.UserLeap._API_URL,completeUploadHeaders:S,eventId:L,isHeatmap:!0,replayParams:ae,responseGroupId:rt,surveyId:nt,triggerTimestamp:Date.now(),visitorId:b})}if(b==null||!(f!=null&&f.length))return x(`Not displaying survey: vid: ${b} / questions: ${f}`),{success:!1,message:"[Sprig] no survey found",surveyState:"no survey"};if(window.UserLeap.container){x("Already displaying a survey");const L="[Sprig] (ERR-409) Found an existing Survey container, aborting rendering of this survey";return console.warn(L),{success:!1,message:L,surveyState:"no survey"}}if(b!==window.UserLeap.visitorId&&_!==window.UserLeap.visitorId&&!window.previewMode){const L="Attempted to display survey to a different visitor";return x(L),window.UserLeap.reportError("DisplaySurvey",new Error(L)),{success:!1,message:L,surveyState:"no survey"}}x(`Showing survey: ${y}`),(n=U.replay)==null||n.RecordSurveyShown({id:y,userAgent:window.navigator.userAgent}),Ce.disable(),w.emit(g.SurveyWillPresent,{name:g.SurveyWillPresent,"survey.id":y});let K,Q=document.createElement("div"),Y,P,X;const Se=L=>{const{"view.version":ae}=L;ae!==S["x-ul-sdk-version"]&&je(),w.removeListener("verify.view.version",Se)};w.on("verify.view.version",Se),window.UserLeap.useMobileStyling=ie,st(S)?(K="ul-direct-embeded-frame",Y=document.head,P=window,X=!1,I&&(Fe(d),Q.id=K,window.UserLeap.container.appendChild(Q),Me(),w.emit(g.SurveyLifeCycle,{state:"presented"}),w.emit(g.SurveyPresented,{name:g.SurveyPresented,"survey.id":y}))):{frameId:K,contentWinDocHead:Y,contentWindow:P,hasOverlay:X,iframe:Q}=Rt({productConfig:u,useMobileStyling:ie,surveyId:y,isFeedback:d}),window.UserLeap.frameId=K;const Ze=L=>{w.once(g.CloseSurveyOnOverlayClick,L)},q={apiURL:window.UserLeap._API_URL,cards:f,configureExitOnOverlayClick:Ze,context:i,endCard:s,envId:window.UserLeap.envId,eventEmitFn:w.emit.bind(w),fontFamily:window.UserLeap.fontFamily,fontFamilyURL:window.UserLeap.fontFamilyURL,forceBrandedLogo:a,frame:Q,headers:S,locale:l,mobileSDKVersion:window.UserLeap.mobileSDKVersion,previewKey:k.getItem("sprig.previewKey"),previewMode:c,productConfig:{framePosition:u?.framePosition,desktopDisplay:u?.desktopDisplay,placement:u?.placement},responseGroupUid:m,startingQuestionIdx:(o=window.UserLeap.config)==null?void 0:o.startingQuestionIdx,studyType:A,styleNonce:window.UserLeap.styleNonce,surveyId:y,tabTitle:document.title,trackPageViewUrl:e,ulEvents:N,upchunkLibraryURL:window.UserLeap.upchunkLibraryURL,useMobileStyling:ie,userId:_,viewDocument:P?.document,viewWindow:P,visitorAttributes:{externalUserId:window.UserLeap.userId,email:window.UserLeap.email},...window.UserLeap._config};(r=window.UserLeap._config)!=null&&r.startingQuestionIdx&&(window.UserLeap._config={...window.UserLeap._config,startingQuestionIdx:null});const et=(d?window.UserLeap.feedbackCustomStyles:window.UserLeap.customStyles)??u.customStyles;q.customStyles=et,P&&(P.__cfg=q);function tt(){const L=document.createElement("script");return window.UserLeap.nonce&&L.setAttribute("nonce",window.UserLeap.nonce),L.id=Te,L}const oe=window.UserLeap.viewSDKURL?window.UserLeap.viewSDKURL:q.path,Ie=document.getElementById(Te);Ie&&Ie.remove();const se=tt(),ke=()=>{window.UserLeap.container&&Object.assign(window.UserLeap.container.style,{display:"flex"})};if(q.installationMethod==="web-npm"||q.installationMethod==="web-npm-bundled"){const{default:L}=await import("./view-C5kHSC2Q.js");L.configure(q),X&&window.UserLeap.container&&ke()}else oe&&(se.src=oe,X&&se.addEventListener("load",()=>{window.UserLeap.container&&ke()}),P?.addEventListener("error",L=>{L.target instanceof HTMLScriptElement&&L.target.src===oe&&window.UserLeap.reportError("loadFrameScript",new Error("Frame script failed to load"))},{capture:!0,once:!0}));return Y?.appendChild(se),{success:!0,surveyState:"ready",surveyId:y,responseGroupUid:m}};function ce(t){var e;if(window.UserLeap.useMobileStyling!==void 0)return window.UserLeap.useMobileStyling;const n=((e=window.UserLeap.windowDimensions)==null?void 0:e.width)??document.body.clientWidth;return pe(t)||n>10&&n<bt}function pe(t){return kt.includes(t["userleap-platform"])}const ue="ul-frame";window.UserLeap&&window.Sprig&&(window.Sprig._gtm?window.Sprig=window.UserLeap:window.UserLeap=window.Sprig),window.UserLeap||(window.UserLeap=window.Sprig),window.Sprig||(window.Sprig=window.UserLeap);const Et="rgba(255,255,255, 0.95)",xt="rgba(0,0,0,0.9)",we="0px",Fe=(t,e)=>{window.UserLeap.container=document.createElement("div"),window.UserLeap.container.className=`ul-container ${t&&"ul-container-feedback"}`;const n=Ne();e&&n&&!window.UserLeap.useMobileStyling?n.appendChild(window.UserLeap.container):document.body.appendChild(window.UserLeap.container)},je=(t,e)=>{var n;Ot();const o=window.UserLeap.container;if(o)try{(n=o.parentNode)==null||n.removeChild(o),window.UserLeap.container=null,E("trackStartUrl",null),w.emit(g.SurveyLifeCycle,{state:"dismissed"}),w.emit(g.SurveyClosed,{name:g.SurveyClosed,initiator:t,studyType:e})}catch(r){console.warn(`[Sprig] (ERR-412) Error removing UserLeap container by ${t} `+o),r instanceof Error&&window.UserLeap.reportError("dismissActiveSurvey",r)}},Me=()=>{w.once(g.SurveyWillClose,({initiator:t,studyType:e})=>{w.removeAllListeners(g.CloseSurveyOnOverlayClick),je(t,e)})},_t=(t,e)=>{const n={position:"fixed",overflow:"auto",top:"0px",left:"0px",display:"none",height:"100%",width:"100%",transition:"background-color 0.3s ease-out",zIndex:2147483646},o=e?t.overlayStyleMobile:t.overlayStyle;n["background-color"]=o==="light"?Et:xt,e||(n.margin="auto"),window.UserLeap.container&&Object.assign(window.UserLeap.container.style,n)},At=(t,e,n,o)=>{var r,i;const a={position:"fixed",bottom:"0px",right:we,border:0,backgroundColor:"rgba(0,0,0,0)",zIndex:2147483646,transition:"width 0.2s ease-in-out, height 0.2s ease-in-out",maxWidth:"100%"},s=Object.assign({},e,window.UserLeap),{desktopDisplay:d}=e||{},p=d==="center-modal";p&&(s.framePosition="center");let l,c=!1;if(n)(r=window.UserLeap.windowDimensions)!=null&&r.width?a.width=`${window.UserLeap.windowDimensions.width}px`:a.width="100%",(i=window.UserLeap.windowDimensions)!=null&&i.height?a.maxHeight=`${window.UserLeap.windowDimensions.height-20}px`:window.UserLeap.maxHeight?a.maxHeight=window.UserLeap.maxHeight:a.maxHeight=`${document.body.clientHeight-20}px`,["light","dark"].includes(s.overlayStyleMobile)&&(c=!0);else{a.width=De,a.maxHeight=window.UserLeap.maxHeight||"66vh";const u=()=>{c=!0,l={margin:"auto",position:"static"}};if(o)p?u():l={position:"relative",height:"300px"};else switch(s.framePosition){case"bottomLeft":l={left:we};break;case"topLeft":l={left:we,top:0};break;case"topRight":l={top:0};break;case"center":u();break}}return c&&_t(s,n),Object.assign(t.style,a,l),c},Rt=({productConfig:t,useMobileStyling:e,surveyId:n,isFeedback:o})=>{var r,i;const a=ue,s=o&&t.desktopDisplay==="slider";Fe(o,s),Dt();const d=document.createElement("iframe");d.id=a,d.setAttribute("title","Sprig User Feedback Dialog");const p=At(d,t,e,o);Me();let l=!1;d.setHeight=m=>{(parseInt(d.style.height)!=m||!l)&&(l=!0,d.style.height=`${m}px`,w.emit(g.SurveyHeight,{name:g.SurveyHeight,contentFrameHeight:m}))};let c=!1;d.setWidth=m=>{(parseInt(d.style.width)!=m||!c)&&(c=!0,d.style.width=`${m}px`,w.emit(g.SurveyWidth,{name:g.SurveyWidth,contentFrameWidth:m}))},(r=window.UserLeap.container)==null||r.appendChild(d),t&&(e?t.exitOnOverlayClickMobile:t.exitOnOverlayClick)&&window.UserLeap.container&&(window.UserLeap.container.onclick=()=>{w.emit(g.CloseSurveyOnOverlayClick)}),w.emit(g.SurveyLifeCycle,{state:"presented"}),w.emit(g.SurveyPresented,{name:g.SurveyPresented,"survey.id":n});const u=(i=d.contentWindow)==null?void 0:i.document;if(u&&(u.open("text/html","replace"),u.write("<!doctype html><head></head><body></body></html>"),u.close(),!e)){const m=u.body;m.style.display="flex",m.style.alignItems="center"}const f=u?.head;return{frameId:a,contentWinDocHead:f,contentWindow:d.contentWindow,hasOverlay:p,iframe:d}},qe={[g.SurveyFadingOut]:()=>{window.UserLeap.container&&Object.assign(window.UserLeap.container.style,{"background-color":"rgba(0,0,0,0)"})}},Dt=()=>{Object.entries(qe).forEach(([t,e])=>{w.on(t,e)})},Ot=()=>{Object.entries(qe).forEach(([t,e])=>{w.off(t,e)})},Pt=1,ze=t=>t instanceof HTMLElement||t instanceof SVGElement,Z=(t,e,n)=>{const o="ul-custom-style",r=t.getElementById(o);if(r){r.textContent=e;return}const i=t.createElement("style");n&&(i.nonce=n),i.textContent=e,i.id=o,t.head.appendChild(i)},Be=t=>{const e=t.querySelector(".ul-card__container");let n=600,o=360;if(e){n=e.scrollHeight;const r=getComputedStyle(e),i=parseFloat(r.marginTop)+parseFloat(r.marginBottom),a=parseFloat(r.borderTopWidth)+parseFloat(r.borderBottomWidth),s=parseFloat(r.paddingTop)+parseFloat(r.paddingBottom);n+=i+a+s;const d=e.querySelector(".ul-card--matrix_grid");o=d?d.scrollWidth:e.scrollWidth;const p=parseFloat(r.paddingLeft)+parseFloat(r.paddingRight),l=parseFloat(r.marginLeft)+parseFloat(r.marginRight),c=parseFloat(r.borderLeftWidth)+parseFloat(r.borderRightWidth);o+=l+c+p}return[n+Pt,o]},Ct=t=>{const e=t.querySelector(".ul-card__container");e&&(e.scrollTop=0)},Ne=()=>v,z=()=>document.getElementById("sprig-feedback-container"),ge=()=>document.getElementById("sprig-feedback-loading-animation"),Tt=()=>{if(ge())return;const t=document.createElement("div");return t.className="ul-loading-spinner-container",t.id="sprig-feedback-loading-animation",t.role="progressbar",t.setAttribute("aria-live","polite"),t.setAttribute("aria-busy","true"),t.setAttribute("aria-label","Processing..."),t.innerHTML=`
|
|
2
|
+
<div class="ul-loading-spinner">
|
|
3
|
+
<div class="first"></div>
|
|
4
|
+
<div class="second"></div>
|
|
5
|
+
<div class="third"></div>
|
|
6
|
+
<div class="fourth"></div>
|
|
7
|
+
</div>
|
|
8
|
+
`,t},We=()=>!!document.getElementById(ue);let $e=!1,v=null,O=null,ye=!1,$=null,V=null;const Ft=["bottom-left","bottom-right","center-left","center-right"],jt=t=>{if(z()||!Ft.includes(t))return;const[e,n]=t.split("-"),o=document.createElement("div");o.id="sprig-feedback-container",o.classList.add(`sprig-feedback-container-${n}`,`sprig-feedback-container-${e}`),document.body.appendChild(o)},ee=()=>{var t;const e=window.UserLeap.container;return((t=e?.parentElement)==null?void 0:t.id)==="sprig-feedback-loading-container"},Ve=()=>document.getElementById("sprig-feedback-error-container"),He=()=>{if(!v)return 0;const t=v?.clientWidth,e=window.getComputedStyle(v),n=parseInt(e.borderRightWidth||"0"),o=parseInt(e.borderLeftWidth||"0");return t+n+o},te=t=>{const e=z();e&&(V!=null&&V.endsWith("right")?e.style.right=`${t}px`:V!=null&&V.endsWith("left")&&(e.style.left=`${t}px`))},me=()=>{if(v&&(ee()||Ve())){w.off(g.SurveyAppeared,H),ve();const t=He();return te(-t),!0}return!1},H=()=>{if(!v||!O)return;const t=ge();t&&t.remove(),v.style.height="auto",v.style.width="auto",O.disabled=!1,ye=!1},ve=()=>{if(v&&!ge()){const t=Tt();t&&(v.style.height="300px",v.style.width="360px",v.appendChild(t))}},Ge=()=>{!v||!O||(te(0),O.disabled=!0,ye=!0)},Mt=async t=>{const e=await D(R("1",[C],"startFeedbackStudy"),{body:JSON.stringify({surveyUuid:t}),method:"POST"});return e.ok?e.json:null},Je=async(t,e,n)=>{const{buttonTheme:o,customStyles:r,eventId:i,placement:a,desktopDisplay:s,feedbackLabel:d,surveyUuid:p,surveyId:l}=t;window.UserLeap.feedbackCustomStyles=void 0;let c=z();if(c){if(!e&&i===$)return;c.remove(),w.off(N.SURVEY_FADING_OUT,me)}if($=i,!document.getElementById("sprig-feedback-style")){const{head:b}=document,h=document.createElement("style");h.id="sprig-feedback-style",h.textContent=mt,h.nonce=window.UserLeap.styleNonce,b.appendChild(h)}Z(document,r??"",window.UserLeap.styleNonce),$e=s==="center-modal",V=a;const[u,f]=a.split("-");jt(a),c=z(),O=document.createElement("button");const m=document.createElement("div");m.className="sprig-feedback-button-label",m.innerText=d,O.appendChild(m),O.id="sprig-feedback-button",O.classList.add(`sprig-feedback-button-${f}`,`sprig-feedback-button-${u}`,`sprig-feedback-button-${o}`,"fade-in-transition"),w.on(N.SURVEY_FADING_OUT,me),O.addEventListener("click",async()=>{const b=document.getElementById("sprig-feedback-error-container");if(We()||Ve()){if(me()){w.emit(g.SurveyWillClose,{name:g.SurveyWillClose,initiator:j.FeedbackClosed,studyType:"feedbackButton"});const S=z();b&&S&&(S.remove(),$=null,v=null)}return}const h=F(window.UserLeap);if(!ce(h)&&!ye&&Ge(),e){v&&v.classList.add("sprig-feedback-loading-container-previews"),await W(e),H();return}const A=await Mt(p);if(A)w.once(g.SurveyAppeared,H),W({...A,studyType:"feedbackButton"},n);else if(v){const S=zt();v.appendChild(S),H(),v.style.height="300px",v.style.width="360px"}}),c?.appendChild(O),w.emit(g.FeedbackButtonLoaded,{name:g.FeedbackButtonLoaded,"survey.id":l});const{useMobileStyling:y,_config:{border:_}}=window.UserLeap;if(!$e&&!y){const b=document.createElement("div");b.id="sprig-feedback-loading-container",b.className=`sprig-feedback-loading-container sprig-feedback-loading-container-${f}`,b.style.setProperty("--feedback-border",_),v=b,ve(),c?.appendChild(b);const h=He();te(-h)}else te(0);window.UserLeap._config.isOnQuestionsTab&&e&&!ee()&&v&&(Ge(),ve(),v&&v.classList.add("sprig-feedback-loading-container-previews"),W(e),H())},qt=()=>{if(ee())return;const t=z();t&&(at($)||(t.remove(),$=null,v=null))},zt=()=>{const t=document.createElement("div");t.id="sprig-feedback-error-container",t.innerHTML=`<svg xmlns="http://www.w3.org/2000/svg" width="40" height="40" viewBox="0 0 40 40" fill="none">
|
|
9
|
+
<circle cx="20" cy="20" r="14.5" stroke="#B0B5B7" stroke-width="3"/>
|
|
10
|
+
<path d="M20 12L20 21.6" stroke="#B0B5B7" stroke-width="3" stroke-linecap="round"/>
|
|
11
|
+
<circle cx="19.9984" cy="27.6" r="1.6" fill="#B0B5B7"/>
|
|
12
|
+
</svg>`;const e=document.createElement("h3");return e.className="sprig-feedback-error-text",e.innerText="There was an error while loading the survey",t.appendChild(e),t},Bt="!launch_darkly_";class Nt{constructor(){B(this,"_ldData",{})}getAllLaunchDarklyVariations(){return this._ldData}setLDFlagsVariations(e){try{return!e||typeof e!="object"||Array.isArray(e)?!1:(Object.keys(this._ldData).forEach(n=>{delete this._ldData[n]}),Object.keys(e).forEach(n=>this._ldData[`${Bt}${n}`]=(e[n]??0)+1),!0)}catch(n){return n instanceof Error&&window.UserLeap.reportError("setAllLDFlagsVariations",n),console.warn("[Sprig] An issue had occured when setting LaunchDarkly flags and variations."),!1}}}const fe=new Nt;Object.freeze(fe);const Wt="!optimizely_experiments_";class $t{constructor(){B(this,"_optimizelyData",{})}setOptimizelyExperiment(e,n=!0){if(!e||typeof e!="object")return!1;const{experiments:o}=e;try{return n&&Object.keys(this._optimizelyData).map(r=>{delete this._optimizelyData[r]}),o&&o.map(r=>{const{id:i,variation:a}=r,s=this.transformExperimentId(i);a&&typeof a=="string"&&(this._optimizelyData[s]=a)}),!0}catch(r){return r instanceof Error&&window.UserLeap.reportError("setOptimizelyExperiment",r),!1}}getAllOptimizelyExperiments(){return this._optimizelyData}getOptimizelyVariationName(e){return this._optimizelyData[this.transformExperimentId(e)]}transformExperimentId(e){return Wt+e}getAndSetWebOptimizelyExperiments(){var e;try{if(window&&window.optimizely&&typeof window.optimizely.get=="function"){const n=(e=window.optimizely.get("state"))==null?void 0:e.getExperimentStates({isActive:!0});if(n){const o=Object.keys(n).map(r=>{var i,a;return(i=n[r].variation)!=null&&i.name?{id:r,variation:(a=n[r].variation)==null?void 0:a.name}:{id:r,variation:"Original"}});return this.setOptimizelyExperiment({experiments:o},!1),!0}return!1}return!1}catch(n){return n instanceof Error&&window.UserLeap.reportError("getAndSetWebOptimizely",n),!1}}}const re=new $t;Object.freeze(re);class Vt{constructor(e,n){B(this,"paused"),B(this,"queue"),B(this,"ul"),this.ul=e,this.paused=!1,this.queue=[],this.flush(n)}flush(e){const n=e.length;if(n)for(let o=0;o<n;o++)this.push(e[o])}isPaused(){return this.paused}pause(){this.paused=!0}unpause(){this.paused=!1;const e=this.queue.slice();this.empty(),this.flush(e)}push(e){if(this.paused)this.queue.push(e);else if(e instanceof Function)e();else{const n=Array.prototype.slice.call(e,1),o=e[0],r=this.ul[o];r instanceof Function?r.apply(this.ul,n):o&&console.warn("[Sprig] (ERR-100) No valid UserLeap action called",o)}}perform(e){if(this.paused){let n=()=>{};const o=new Promise(function(r){n=function(){r(e())}});return this.queue.push(n),o}else return e()}empty(){this.queue.length=0}}const he=(t,e)=>{const n=performance.now();document.hidden?setTimeout(()=>he(t,e),t):setTimeout(()=>{const o=performance.now()-n;e.report(o/1e3),setTimeout(()=>he(t,e),t)},0)},Ht=(t=1e3)=>{const e=dt("sdk_event_queue_latency_seconds");he(t,e)},Gt=({webMetricsEnabled:t,reportingIntervalSeconds:e,thresholds:n,postMetrics:o})=>{lt(n,(r,i)=>{var a,s;if((a=U.replay)!=null&&a.isReplayRecording()){const d=`Value: ${r} on ${i.metric} violated threshold of ${i.type} ${i.value}`;(s=U.replay)==null||s.disableRecording("Threshold violated",new Error(d),{reportError:!1}),pt()}}),ct({reportingIntervalSeconds:e,postMetrics:o}),t&&Ht()},Jt={test:"test"},Kt=["popState","pushState","replaceState"],G="!email",be="pageUrl";function Qt(t,e){const{pageUrlEvents:n,interactiveEvents:o,dismissOnPageChange:r}=window.UserLeap._config;if(!r)return!0;const i=[];n&&n.length&&i.push(...n),o&&o.length&&i.push(...o);const a=t&&i.find(s=>s.id===t);return a?de(a,window.location.href):e===window.location.href}function J(t){var e;const{pageUrlEvents:n,interactiveEvents:o,dismissOnPageChange:r,platform:i}=window.UserLeap._config;if(i&&i!=="web")return;const a=M("trackStartUrl"),s=a?String(a):null;n&&Xe(window.location.href),o&&(Qe(),Yt()),Ne()&&qt(),gt.getItem("sprig.isCapturingHeatmap")&&((e=U.replay)==null||e.checkPendingHeatmapsUrl()),!ee()&&r&&s&&s!==window.location.href&&t&&Kt.includes(t.type)&&window.UserLeap("dismissActiveSurvey",j.PageChange)}const Ke={capture:!0},Yt=()=>{const t=window.UserLeap._config.interactiveEvents.filter(n=>de(n,window.location.href)).map(n=>{const{name:o,properties:r}=n,{selector:i,innerText:a}=r;return i?s=>{if(ze(s.target))try{s.target.closest(i)&&window.UserLeap("track",o)}catch{}return!1}:s=>(ze(s.target)&&s.target.innerText===a&&window.UserLeap("track",o),!1)}),e=n=>t.forEach(o=>o(n));window.UserLeap._config.interactiveEventsHandler=e,window.addEventListener("click",e,Ke)},Qe=()=>{window.UserLeap._config.interactiveEventsHandler&&window.removeEventListener("click",window.UserLeap._config.interactiveEventsHandler,Ke),delete window.UserLeap._config.interactiveEventsHandler};function Xt(){["hashchange","popstate"].forEach(t=>window.addEventListener(t,J,!0))}function Zt(){["hashchange","popstate"].forEach(t=>window.removeEventListener(t,J,!0)),window.UserLeap._config.interactiveEvents&&Qe()}function er(t){const e=new URL(R("1",[T],"questions"));return Object.entries(t||{}).forEach(([n,o])=>{o&&e.searchParams.append(n,String(o))}),e.toString()}function M(t){const e=k.getItem("userleap.ids");if(e)try{const n=JSON.parse(e)[window.UserLeap.envId];return n&&n[t]||null}catch(n){n instanceof Error&&(n.stack=e,window.UserLeap.reportError("Failed to parse local storage credentials",n)),console.warn("[Sprig] (ERR-427) Failed to lookup saved ids",n)}return null}function Ye(){window.previewMode||(window.UserLeap.visitorId=xe(),x(`Generating new vid: ${window.UserLeap.visitorId}`),E("vid",window.UserLeap.visitorId),w.emit(g.VisitorIDUpdated,{visitorId:window.UserLeap.visitorId}))}function Xe(t,e,n,o){var r,i,a;if(t.endsWith("mock_snippet.html"))return;x(`Tracking page view: ${t}`);const s=window.UserLeap._config.pageUrlEvents;let d=!1;if(s&&s.length)for(let y=0;y<s.length&&(d=de(s[y],t),!d);y++);if(!d)return;window.UserLeap.debugMode&&console.info("[DEBUG] Sprig trackPageView",t);const p=10,l=1;let c=[];const u={viewedAt:Date.now(),location:t},f={url:t};o&&(f.trackPageView=!0);const m=k.getItem("userleap.pageviews");try{if(c=m?JSON.parse(m):[],Array.isArray(c)||(c=[]),c.length>0){const y=c[c.length-1],_=(Date.now()-y.viewedAt)/1e3;if(y.location!=t&&_>l){const b=(r=document?.querySelector('meta[name="description"]'))==null?void 0:r.getAttribute("content");(i=U.replay)==null||i.RecordPageView({...b&&{description:b},url:t,referrer:document.referrer,pageTitle:document.title})}(y.location!=t&&_>l||_>p)&&(window.UserLeap._queue.push(["track",be,e,f,n]),c.push(u))}else window.UserLeap._queue.push(["track",be,e,f,n]),c.push(u),(a=U.replay)==null||a.RecordPageView({url:t});c.length>5&&c.splice(0,c.length-5),k.setItem("userleap.pageviews",JSON.stringify(c))}catch(y){y instanceof Error&&window.UserLeap.reportError("trackPageView",y,{pageViewsStorage:m}),console.warn("[Sprig] (ERR-425) Failed to update page views in local storage")}}function tr(){const t="Backbone"in window&&window.Backbone&&window.Backbone.history?window.Backbone.history:window.history;"pushState"in t&&(t.pushState=(e=>function(...n){const o=e.apply(this,n),r=new Event("pushState");return window.dispatchEvent(r),J(r),o})(t.pushState)),"replaceState"in t&&(t.replaceState=(e=>function(...n){const o=e.apply(this,n),r=new Event("replaceState");return window.dispatchEvent(r),J(r),o})(t.replaceState)),Xt()}async function Le(t,e){const n=le();t&&!e&&(window.UserLeap._config.mode=Jt.test);const o=F(window.UserLeap),r=ce(o),i=await D(er({desktopDisplay:window.UserLeap._config.desktopDisplay,isMobile:r,previewLanguage:window.UserLeap._config.previewLanguage,surveyid:t?.surveyId,surveytemplateid:t?.surveyTemplateId,vid:n}),{shouldDropOnRateLimit:!0});if(!i.ok)return i.reportError&&i.error&&(console.warn("[Sprig] (ERR-414) Failed to request questions from the server",i.error),window.UserLeap.reportError("getQuestions",i.error)),{success:!1,surveyState:"no survey"};if(i.json.delay&&await Re(i.json.delay),i.json.isFeedback){const{feedbackLabel:a,productConfig:s,surveyUuid:d,feedbackCustomStyles:p}=i.json,{buttonTheme:l,placement:c,desktopDisplay:u}=s,f={customStyles:p,buttonTheme:l,desktopDisplay:u,eventId:0,feedbackLabel:a,placement:c,surveyUuid:d,surveyId:t?.surveyId};Je(f,i.json)}else return W(i.json)}function rr(t){let e=t.length;for(;e;){const n=Math.floor(Math.random()*e);e-=1;const o=t[e];t[e]=t[n],t[n]=o}}function nr(t){if(!t)return;window.UserLeap._config=t,t.mute&&window.UserLeap._queue.pause();const{interactiveEvents:e,pageUrlEvents:n,dismissOnPageChange:o}=t;e&&rr(e),(e||n||o)&&(tr(),J())}async function ir(t,e){var n,o;let r=!0;return e&&(n=t?.json)!=null&&n.surveyId&&(window.UserLeap.delayingSurvey=!0,r=await e(t.json.surveyId),window.UserLeap.delayingSurvey=!1,!r)?!1:((o=t?.json)!=null&&o.delay&&(window.UserLeap.delayingSurvey=!0,await Re(t.json.delay),window.UserLeap.delayingSurvey=!1),r)}const or=function(t){if(!window.UserLeap)return;const e=async(r={})=>{var i,a,s,d,p;const{userId:l,anonymousId:c,metadata:u={},properties:f,showSurveyCallback:m}=r;let{eventName:y}=r;if(window.UserLeap.debugMode&&y!==be&&console.info("[DEBUG] Sprig track",r),t.mode==="test")return;const _=k.getItem("sprig.previewKey")??void 0;if(t.requireUserIdForTracking&&!window.UserLeap.userId&&!l){const I="[Sprig] - Skipping tracking without userId";return console.warn(I),{success:!1,message:I,surveyState:"no survey"}}if(!y||y.trim().length===0){y=y?String(y):"";const I="[Sprig] - Invalid event name "+y;return console.warn(I),{success:!1,message:I,surveyState:"no survey"}}const b=window.location.href;if(u.url||(u.url=b),E("trackStartUrl",b),(a=(i=window.UserLeap)==null?void 0:i._config)!=null&&a.optimizelyEnabled){const I=F(window.UserLeap);pe(I)||re.getAndSetWebOptimizelyExperiments(),u.optimizelyExperiments=Object.assign({},re.getAllOptimizelyExperiments())}(d=(s=window.UserLeap)==null?void 0:s._config)!=null&&d.launchDarklyEnabled&&(u.launchDarklyFlags=fe.getAllLaunchDarklyVariations()),l&&(window.UserLeap.userId=l),c&&(window.UserLeap.partnerAnonymousId=c),f&&(u.eventProperties=f),(p=U.replay)==null||p.RecordEvent({name:y,url:u.url}),x(`Tracking event: ${y}`);const h=window.UserLeap.delayingSurvey||We()?await D(R("1",[C],"events/batch"),{body:JSON.stringify({events:[{event:y,metadata:u}],previewKey:_}),method:"POST",shouldDropOnRateLimit:!0}):await D(R("1",[C],"events"),{body:JSON.stringify({event:y,metadata:u,previewKey:_}),method:"POST",shouldDropOnRateLimit:!0});if(!h.ok){const I="[Sprig] (ERR-421) Failed to track event";return h.reportError&&(console.warn(I,h.error),h.error&&window.UserLeap.reportError("track",h.error)),{success:!1,message:I,error:h.error,surveyState:"no survey"}}l&&E("uid",l),c&&E("aid",c);const A=h.json;A.invalidPreviewKey&&k.removeItem("sprig.previewKey");const S=u.trackPageView?u.url:void 0;return A!=null&&A.feedbackButton&&Je(A.feedbackButton,void 0,S),await ir(h,m)?Qt(A.eventId,b)?W(A,S):{success:!1,message:"Study should not be displayed after page navigation",surveyState:"no survey"}:{success:!1,message:"[Sprig] Callback returned false, aborting rendering of survey",surveyState:"no survey"}},n=(r,i)=>{var a;const s=(a=r?.querySelector(`[id="${ue}"]`))==null?void 0:a.contentDocument;s&&Z(s,i)},o={async displaySurvey(r){return console.warn("[Sprig] displaySurvey should only be used to debug your studies; not intended for production usage."),window.UserLeap("dismissActiveSurvey",j.Override),Le({surveyId:r},!0)},_previewSurvey(r){window.UserLeap("dismissActiveSurvey",j.Override),Le({surveyTemplateId:r},!1)},_reviewSurvey(r){window.UserLeap("dismissActiveSurvey",j.Override),Le({surveyId:r},!1)},previewSurvey(r){o._previewSurvey(r)},reviewSurvey(r){o._reviewSurvey(r)},mute(){window.UserLeap._queue.pause()},unmute(){window.UserLeap._queue.unpause()},setVisitorToken(){console.warn("[Sprig] setVisitorToken is deprecated.")},dismissActiveSurvey(r=j.API){w.emit(g.SurveyWillClose,{name:g.SurveyWillClose,initiator:r})},async setAttribute(r,i){if(!r||!i&&i!==0&&i!==!1){const a="[Sprig] - Disregarding empty attribute / value provided";return console.warn(a),{success:!1,message:a}}return this.setAttributes({[r]:i})},async setAttributes(r){if(r==null||Object.keys(r).length===0){const i="[Sprig] - Disregarding empty attributes provided";return console.warn(i),{success:!1,message:i}}return this.identifyAndSetAttributes({attributes:r})},async identifyAndSetAttributes(r){if(window.UserLeap.debugMode&&console.info("[DEBUG] Sprig identifyAndSetAttributes",r),t.mode==="test")return;if(r===null||typeof r!="object"||!(r.userId||r.anonymousId||r.attributes)){const l="[Sprig] - Disregarding empty payload provided";return console.warn(l),{success:!1,message:l}}const{userId:i,anonymousId:a,attributes:s}=r;if(t.requireUserIdForTracking&&!window.UserLeap.userId&&!i){const l="[Sprig] - Skipping tracking without userId";return console.warn(l),{success:!1,message:l}}if(!s&&(!i||window.UserLeap.userId===i)&&(!a||window.UserLeap.partnerAnonymousId===a))return{success:!0};const d={};i&&(d.userId=window.UserLeap.userId=i),a&&(d.partnerAnonymousId=window.UserLeap.partnerAnonymousId=a);let p;return s?(s.email&&!Object.prototype.hasOwnProperty.call(s,G)&&(s[G]=s.email,delete s.email),x(`Setting attributes: ${JSON.stringify(s)}`),p=await D(R("1",[T,C],"attributes"),{body:JSON.stringify(s),method:"PUT"}),!p.ok&&p.reportError&&(console.warn("[Sprig] (ERR-432) identifyAndSetAttributes failed",p.error),p.error&&window.UserLeap.reportError("identifyAndSetAttributes",p.error))):p=await D(R("1",[T,C]),{body:JSON.stringify(d),method:"PUT"}),s&&s[G]&&(window.UserLeap.email=s[G]),p.ok&&(i&&E("uid",i),a&&E("aid",a)),{success:!!p.ok}},async removeAttributes(r){if(window.UserLeap.debugMode&&console.info("[DEBUG] Sprig removeAttributes",r),t.mode==="test")return;if(r==null||r.length===0){const a="[Sprig] - Disregarding empty attributes provided";return console.warn(a),{success:!1,message:a}}if(t.requireUserIdForTracking&&!window.UserLeap.userId){const a="[Sprig] - Skipping tracking without userId";return console.warn(a),{success:!1,message:a}}const i=await D(R("1",[T,C],"attributes"),{body:JSON.stringify({delete:r}),method:"DELETE"});return!i.ok&&i.reportError&&(console.warn("[Sprig] (ERR-433) Remove attributes failed",i.error),i.error&&window.UserLeap.reportError("removeAttributes",i.error)),{success:!!i.ok}},async addSurveyListener(r){w.on(g.SurveyLifeCycle,r)},async removeSurveyListener(r){w.removeListener(g.SurveyLifeCycle,r)},async addListener(r,i){w.on(r,i)},async removeListener(r,i){w.removeListener(r,i)},async removeAllListeners(){w.removeAllListeners()},setPreviewKey(r){!r||typeof r!="string"||k.isStorageAvailable&&r&&k.setItem("sprig.previewKey",r)},async setUserId(r){var i;if(window.UserLeap.debugMode&&console.info("[DEBUG] Sprig setUserId",r),r==null){const d=`[Sprig] - Invalid userId ${r}`;return console.warn(d),{success:!1,message:d}}if(t.mode==="test"||r===window.UserLeap.userId)return;window.UserLeap.userId=r;const a=window.UserLeap.visitorId,s=await D(R("1",[T,C]),{body:JSON.stringify({userId:r}),method:"PUT"});if(!s.ok){s.reportError&&(console.warn("[Sprig] (ERR-420) Failed to set user id",s.error),s.error&&window.UserLeap.reportError("setUserId",s.error));return}a!==window.UserLeap.visitorId&&((i=U.replay)==null||i.clearUserReplayData()),E("uid",r)},async setPartnerAnonymousId(r){if(window.UserLeap.debugMode&&console.info("[DEBUG] Sprig setPartnerAnonymousId",r),r==null){const i=`[Sprig] - Invalid partnerAnonymousId ${r}`;return console.warn(i),{success:!1,message:i}}return window.UserLeap.partnerAnonymousId=r,E("aid",r),{success:!0}},async track(r,i,a={},s=void 0){return e({eventName:r,properties:i,metadata:a,showSurveyCallback:s})},async identifyAndTrack(r){return await e(r)},trackPageView(r,i=void 0,a=void 0,s=!0){Xe(r,i,a,s)},applyFeedbackStyles({button:r="",view:i=""}){window.UserLeap.feedbackCustomStyles=i,document.getElementById("sprig-feedback-style")&&Z(document,r,window.UserLeap.styleNonce),n(document.querySelector(".ul-container-feedback"),i)},applyStyles(r){window.UserLeap.customStyles=r,n(window.UserLeap.container,r)},setWindowDimensions(r,i){var a,s;const d=typeof r=="string"?parseInt(r,10):r,p=typeof i=="string"?parseInt(i,10):i;if(!isNaN(d)&&!isNaN(p)&&(window.UserLeap.windowDimensions={width:d,height:p}),!window.UserLeap.frameId)return;const l=document.getElementById(window.UserLeap.frameId);l&&(window.UserLeap.useMobileStyling&&((a=window.UserLeap.windowDimensions)!=null&&a.width&&(l.style.width=`${window.UserLeap.windowDimensions.width}px`),(s=window.UserLeap.windowDimensions)!=null&&s.height&&(l.style.maxHeight=`${window.UserLeap.windowDimensions.height-20}px`),l.contentDocument&&(l.style.height=String(Be(l.contentDocument)[0])+"px")),w.emit(g.SurveyDimensions,{name:g.SurveyDimensions,contentFrameWidth:l.clientWidth,contentFrameHeight:l.clientHeight}))},logoutUser(){var r;window.UserLeap.debugMode&&console.info("[DEBUG] Sprig logout"),x(`Logging out user: ${window.UserLeap.userId} / vid: ${window.UserLeap.visitorId}`),window.UserLeap.visitorId=null,window.UserLeap.userId=null,window.UserLeap.partnerAnonymousId=null,window.UserLeap.token=null,window.UserLeap.email=null,k.removeItem("userleap.ids"),k.removeItem("userleap.pageviews"),window.UserLeap._queue.isPaused()&&window.UserLeap._queue.empty(),Ye(),(r=U.replay)==null||r.clearUserReplayData(),window.UserLeap._queue.unpause()},teardown(){Zt(),window.UserLeap("dismissActiveSurvey",j.API),delete window.UserLeap,delete window.Sprig,delete window._Sprig},integrateOptimizely(r,i=!0){var a,s;if(!((s=(a=window.UserLeap)==null?void 0:a._config)!=null&&s.optimizelyEnabled)){console.warn("[SPRIG] Optimizely integration is currently not enabled for your product.");return}try{const d=typeof r=="string"?JSON.parse(r):r;re.setOptimizelyExperiment(d,i)}catch(d){console.warn("[Sprig] Error with integrating Optimizely data"),d instanceof Error&&window.UserLeap.reportError("integrateOptimizely",d)}},integrateOptimizelyClient(r){var i,a;if(!((a=(i=window.UserLeap)==null?void 0:i._config)!=null&&a.optimizelyEnabled)){console.warn("[SPRIG] Optimizely integration is currently not enabled for your product.");return}const s=({experiment:d,variation:p})=>{const l={experiments:[{id:d.id,variation:p.key}]};window.UserLeap("integrateOptimizely",l,!1)};r.notificationCenter.addNotificationListener("ACTIVATE:experiment, user_id,attributes, variation, event",s)},importLaunchDarklyData(r){var i,a;if(!((a=(i=window.UserLeap)==null?void 0:i._config)!=null&&a.launchDarklyEnabled)){console.warn("[SPRIG] LaunchDarkly integration is currently not enabled for your product.");return}fe.setLDFlagsVariations(r)},setVisitorAttribute(r,i){return console.warn("[Sprig] setVisitorAttribute is deprecated. Please use setAttribute"),o.setAttribute(r,i)},async setEmail(r){return o.setAttribute(G,r)},async setVisitorEmail(r){return console.warn("[Sprig] setVisitorEmail is deprecated. Please use setEmail"),o.setEmail(r)},async _generateVideoUploadUrl(r){return lr(r)},_reportMetric(r,i){yt(r,i)},async _completeSessionReplay({surveyId:r,responseGroupUuid:i,eventDigest:a}){var s;return U.replay?(s=U.replay)==null?void 0:s._completeSessionReplay({surveyId:r,responseGroupUuid:i,eventDigest:a,headers:F(window.UserLeap)}):(window.UserLeap.reportError("_completeSessionReplay",new Error("Replay module not registered")),!1)}};Object.assign(window.UserLeap,o)};async function sr(t){const e=F(window.UserLeap);document.addEventListener("securitypolicyviolation",_e);const n=await Ee(R("1",[T],"config"),{headers:e}),o="TypeError";if(window.UserLeap.error=n.error,!n.ok&&n.error&&n.error.name===o?(window.UserLeap._API_URL="https://api.sprig.com",window.UserLeap.reportError("sprigDomainRequest",n.error)):document.removeEventListener("securitypolicyviolation",_e),!n.ok)return n.reportError&&(console.warn("[Sprig] (ERR-422) Failed to load configuration",n.error),n.error&&window.UserLeap.reportError("applyRemoteConfig",n.error)),Ae("Disabled: failed to fetch configuration"),t;const r=n.json;return r!=null&&r.disabled?(Ae(`Disabled: ${r.disabled}`),{disabled:r.disabled}):Object.assign({},r,t)}const ar=t=>typeof t=="object"&&t&&"inner"in t&&!!t.inner&&typeof t.inner=="object";async function dr(t,e,n={}){var o,r;const i=window.__cfg&&window.__cfg.mode,a=le(),s=window.UserLeap.envId,d=window.document.documentElement,p=ar(e)?{inner:{message:(o=e.inner)==null?void 0:o.message,stack:(r=e.inner)==null?void 0:r.stack}}:{},l={mode:i,screenWidth:window.screen.width,screenHeight:window.screen.height,clientWidth:d.clientWidth,clientHeight:d.clientHeight,location:window.location.href,language:window.navigator.language,...n,...p},c={action:t,err:{message:e.message,stack:e.stack},meta:l,vid:a,envId:s},u=await D(R("1",null,"errors"),{method:"POST",headers:{"x-ul-error":window.btoa(`userleap-${Date.now()}-error`)},body:JSON.stringify(c),shouldDropOnRateLimit:!0});if(!u.ok)console.warn("[Sprig] (ERR-444) Failed to report error to API",e);else{const{presignedUrl:f}=u.json;wt(f)}}async function lr(t){var e;if(!t)return;const n=`${window.UserLeap._API_URL}/2/environments/integrations/upload`;try{const o=await fetch(n,{method:"POST",cache:"no-cache",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)});if(o.ok){const r=await o.json();return(e=r?.upload)==null?void 0:e.url}else return null}catch(o){console.warn("[Sprig] Error with generating video upload url"),o instanceof Error&&window.UserLeap.reportError("generateVideoUploadUrl",o)}}function cr(t={}){const e=new URLSearchParams(window.location.search).get("sprigPreviewKey")??"";window.UserLeap.UPDATES=N,window.UserLeap("setPreviewKey",e);async function n(){var o;if(window.UserLeap.loaded)return;if(x("Loading sprig on page load"),window.UserLeap.reportError=dr,window.UserLeap.loaded=!0,window.UserLeap._config=Object.assign({},t,window.UserLeap.config),window.UserLeap.delayingSurvey=!1,window.UserLeap._config&&typeof window.UserLeap._config=="object")for(const d in window.UserLeap._config)window.UserLeap[d]=window.UserLeap._config[d];if(!window.UserLeap.envId)if(window.UserLeap.appId)window.UserLeap.envId=window.UserLeap.appId;else throw new Error("Missing Environment id");window.UserLeap.debugMode&&console.info("[DEBUG] Sprig debug mode enabled");const r=window.UserLeap.sampleRate;if(r){let d=M("sampled");if(d===null&&(d=Math.random()<r,E("sampled",d)),!d)return}else M("sampled")!==null&&E("sampled",null);window.UserLeap._API_URL||(window.UserLeap._API_URL="https://api.sprig.com");const i=[...window.UserLeap._queue];window.UserLeap._queue=new Vt(window.UserLeap,[]),window.UserLeap._queue.pause();for(let d=0;d<i.length;d++)window.UserLeap._queue.push(i[d]);const a=M("token");a?(window.UserLeap.token=a,window.UserLeap.visitorId=M("vid"),window.UserLeap.userId=M("uid"),window.UserLeap.partnerAnonymousId=M("aid")):(k.removeItem("userleap.ids"),Ye());const s=await sr(t);Gt({webMetricsEnabled:s.metricsReportingEnabled,reportingIntervalSeconds:s.metricsReportingEnabled||s.mobileMetricsReportingEnabled?s.metricsReportingIntervalSeconds:0,thresholds:s.metricThresholds,postMetrics:async d=>{var p;await D(R("1",[T],"metrics"),{body:d,method:"POST",headers:{"x-ul-replay-enabled":`${!!((p=U.replay)!=null&&p.isReplayRecording())}`},shouldDropOnRateLimit:!0})}}),(o=U.replay)==null||o.initializeReplay({viewDocument:window.document,maxReplayDurationSeconds:s.maxReplayDurationSeconds,replayNonce:window.UserLeap.replayNonce,maxInflightRequests:window.UserLeap.maxInflightReplayRequests??2,replaySettings:s.replaySettings}),ut(s.logBufferLimit,s.logLevel),or(s),await nr(s),window.UserLeap._queue.unpause(),w.emit(g.SDKReady,{mobileMetricsReportingEnabled:!!s.mobileMetricsReportingEnabled,metricsReportingInterval:s.metricsReportingIntervalSeconds||0,metricsThresholds:s.metricThresholds||[],maxMobileReplayDurationSeconds:s.maxMobileReplayDurationSeconds,mobileReplaySettings:s.mobileReplaySettings}),w.emit(g.VisitorIDUpdated,{visitorId:window.UserLeap.visitorId})}document.readyState==="complete"?n():window.attachEvent?window.attachEvent("onload",n):window.addEventListener("load",()=>{n()},!1)}class ne{constructor(){this.UPDATES=N}displaySurvey(e){window.Sprig("displaySurvey",e)}mute(){window.Sprig("mute")}unmute(){window.Sprig("unmute")}dismissActiveSurvey(){window.Sprig("dismissActiveSurvey")}setAttribute(e,n){window.Sprig("setAttribute",e,n)}setAttributes(e){window.Sprig("setAttributes",e)}identifyAndSetAttributes(e){window.Sprig("identifyAndSetAttributes",e)}removeAttributes(e){window.Sprig("removeAttributes",e)}addListener(e,n){window.Sprig("addListener",e,n)}removeListener(e,n){window.Sprig("removeListener",e,n)}removeAllListeners(){window.Sprig("removeAllListeners")}setEmail(e){window.Sprig("setAttribute","!email",e)}setUserId(e){window.Sprig("setUserId",e)}setPartnerAnonymousId(e){window.Sprig("setPartnerAnonymousId",e)}track(e,n={},o={}){window.Sprig("track",e,n,o)}identifyAndTrack(e){window.Sprig("identifyAndTrack",e)}trackPageView(e,n,o){window.Sprig("trackPageView",e,n,o)}applyStyles(e){window.Sprig("applyStyles",e)}setWindowDimensions(e,n){window.Sprig("setWindowDimensions",e,n)}logoutUser(){window.Sprig("logoutUser")}teardown(){window.Sprig("teardown")}}const Ue={configure:t=>{if(!t.envId&&!t.environmentId)throw new Error("Initialization Error: Sprig configure requires an environmentId");if(t.envId||(t.envId=t.environmentId??""),t.installationMethod="web-npm",window.Sprig)return window.Sprig;window.Sprig=function(){window.Sprig._queue.push(arguments)},Object.getOwnPropertyNames(ne.prototype).map(n=>{n!=="constructor"&&(window.Sprig[n]=ne.prototype[n])});const e=window.Sprig;return e.appId=t.envId,e._queue=[],window.UserLeap=e,cr(t),window.Sprig}},pr={sprig:Ue,SprigAPI:ne,configure:Ue.configure};export{vt as A,Ce as C,De as D,Lt as E,ne as S,Be as a,ht as b,pr as c,ft as d,Z as o,Ct as r,Ue as s};
|
package/dist/core.cjs
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const r=require("./metricsReporter-BIT_adF4.cjs"),e=require("./core-BTd5RhnR.cjs");exports.DismissReason=r.DismissReason;exports.SprigEvent=r.SprigEvent;exports.SprigAPI=e.SprigAPI;exports.default=e.core;exports.sprig=e.sprig;
|