@meetelise/chat 1.59.4 → 1.60.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/src/WebComponent/Scheduler/tour-scheduler.d.ts +6 -0
- package/dist/src/WebComponent/actions/email-us-window.d.ts +6 -0
- package/package.json +1 -1
- package/public/dist/index.js +5 -5
- package/src/WebComponent/Scheduler/tour-scheduler.ts +17 -5
- package/src/WebComponent/actions/email-us-window.ts +17 -5
- package/src/brokerReferralSubmission.test.ts +66 -0
- package/src/main/MEChat.test.ts +24 -0
- package/src/main/MEChat.ts +4 -1
|
@@ -159,6 +159,12 @@ export declare class TourScheduler extends LitElement {
|
|
|
159
159
|
})[];
|
|
160
160
|
renderBrokerToggle: () => TemplateResult;
|
|
161
161
|
renderBrokerSection(): TemplateResult;
|
|
162
|
+
/**
|
|
163
|
+
* Whether to ask "How did you hear about us?". Not on a broker referral: the broker's client gets the building's
|
|
164
|
+
* broker source. Not rendered, the select isn't read on submit either (selectedLeadSource queries it), so a source
|
|
165
|
+
* picked before the broker switch was turned on isn't sent.
|
|
166
|
+
*/
|
|
167
|
+
showLeadSourceSelect(): boolean;
|
|
162
168
|
userInfoAndLayoutMenu(): TemplateResult;
|
|
163
169
|
confirmationMessage(): TemplateResult;
|
|
164
170
|
/** The broker isn't the one touring: the client gets the confirmation email. */
|
|
@@ -81,6 +81,12 @@ export declare class EmailUsWindow extends LitElement {
|
|
|
81
81
|
validateFormFields: () => void;
|
|
82
82
|
onClick: () => Promise<void>;
|
|
83
83
|
getNumErrors: () => number;
|
|
84
|
+
/**
|
|
85
|
+
* Whether to ask "How did you hear about us?". Not on a broker referral: the broker's client gets the building's
|
|
86
|
+
* broker source. Not rendered, the select isn't read on submit either (selectedLeadSource queries it), so a source
|
|
87
|
+
* picked before the broker switch was turned on isn't sent.
|
|
88
|
+
*/
|
|
89
|
+
showLeadSourceSelect(): boolean;
|
|
84
90
|
renderBrokerToggle: () => TemplateResult;
|
|
85
91
|
renderBrokerSection: () => TemplateResult;
|
|
86
92
|
render: () => TemplateResult;
|
package/package.json
CHANGED
package/public/dist/index.js
CHANGED
|
@@ -3044,7 +3044,7 @@ xmlns="http://www.w3.org/2000/svg"
|
|
|
3044
3044
|
</div>
|
|
3045
3045
|
${this.renderBrokerToggle()}
|
|
3046
3046
|
<div class="section-label">Your client</div>
|
|
3047
|
-
`}userInfoAndLayoutMenu(){var e;const t=this.brokerIntakeEnabled&&this.isBrokerReferral;return H`<h2 class="journey-header">Your Information</h2>
|
|
3047
|
+
`}showLeadSourceSelect(){return!(this.brokerIntakeEnabled&&this.isBrokerReferral)&&this.leadSources.length>0&&(this.featureFlagShowDropdown===bo.always||this.featureFlagShowDropdown===bo.onAttributionFailure&&0===this.currentLeadSource.length)}userInfoAndLayoutMenu(){var e;const t=this.brokerIntakeEnabled&&this.isBrokerReferral;return H`<h2 class="journey-header">Your Information</h2>
|
|
3048
3048
|
<div id="yourInformationMenu">
|
|
3049
3049
|
${t?this.renderBrokerSection():""}
|
|
3050
3050
|
<div id="namesWrapper" class="namesWrapper">
|
|
@@ -3111,7 +3111,7 @@ xmlns="http://www.w3.org/2000/svg"
|
|
|
3111
3111
|
@change=${()=>{var e;const t=(null===(e=this.selectedUnitEl)||void 0===e?void 0:e.value)||"";this.selectedUnitValue=t,t&&Eo("tourUnitSelected",{unit:t,buildingId:this.buildingId})}}
|
|
3112
3112
|
>
|
|
3113
3113
|
</me-select>`:""}
|
|
3114
|
-
${this.
|
|
3114
|
+
${this.showLeadSourceSelect()?H` <me-select
|
|
3115
3115
|
id="leadSource"
|
|
3116
3116
|
value="${this.currentLeadSource}"
|
|
3117
3117
|
placeholder="How did you hear about us?"
|
|
@@ -4523,7 +4523,7 @@ xmlns="http://www.w3.org/2000/svg"
|
|
|
4523
4523
|
<div class="email-us__vertical-spacer"></div>
|
|
4524
4524
|
${this.brokerIntakeEnabled&&!this.isBrokerReferral?H`${this.renderBrokerToggle()}
|
|
4525
4525
|
<div class="email-us__vertical-spacer"></div>`:""}
|
|
4526
|
-
${this.
|
|
4526
|
+
${this.showLeadSourceSelect()?H`
|
|
4527
4527
|
<me-select
|
|
4528
4528
|
id="leadSource"
|
|
4529
4529
|
placeholder="How did you hear about us?"
|
|
@@ -4555,7 +4555,7 @@ xmlns="http://www.w3.org/2000/svg"
|
|
|
4555
4555
|
|
|
4556
4556
|
${Vo({buildingName:this.buildingName,phoneNumberInput:this.phoneNumber,emailInput:this.email,orgLegalName:this.orgLegalName,orgSlug:this.orgSlug,country:this.country,buildingState:this.buildingState,clickingButtonText:"send"})}
|
|
4557
4557
|
</details-window>
|
|
4558
|
-
`}}connectedCallback(){super.connectedCallback(),this.addEventListener("keydown",this.trapOverlayTab)}disconnectedCallback(){this.removeEventListener("keydown",this.trapOverlayTab),super.disconnectedCallback()}updated(){this.movedFocusInside||nu(this)&&(this.movedFocusInside=!0)}};Au.styles=[p`
|
|
4558
|
+
`}}connectedCallback(){super.connectedCallback(),this.addEventListener("keydown",this.trapOverlayTab)}disconnectedCallback(){this.removeEventListener("keydown",this.trapOverlayTab),super.disconnectedCallback()}updated(){this.movedFocusInside||nu(this)&&(this.movedFocusInside=!0)}showLeadSourceSelect(){return!(this.brokerIntakeEnabled&&this.isBrokerReferral)&&this.leadSources.length>0&&(this.featureFlagShowDropdown===bo.always||this.featureFlagShowDropdown===bo.onAttributionFailure&&0===this.currentLeadSource.length)}};Au.styles=[p`
|
|
4559
4559
|
.email-us__name-input,
|
|
4560
4560
|
.email-us__contact_input,
|
|
4561
4561
|
.email-us_message-input {
|
|
@@ -8137,4 +8137,4 @@ xmlns="http://www.w3.org/2000/svg"
|
|
|
8137
8137
|
line-height: 150%;
|
|
8138
8138
|
font-size: 16px;
|
|
8139
8139
|
}
|
|
8140
|
-
`,ph([pe({type:String})],fh.prototype,"orgSlug",void 0),ph([pe({type:Number})],fh.prototype,"right",void 0),ph([pe({type:Number})],fh.prototype,"bottom",void 0),ph([pe({type:Number})],fh.prototype,"top",void 0),ph([pe({type:Number})],fh.prototype,"left",void 0),ph([fe()],fh.prototype,"launcher",void 0),ph([fe()],fh.prototype,"currentLeadSource",void 0),ph([fe()],fh.prototype,"displayPubnubChat",void 0),ph([fe()],fh.prototype,"myPubnub",void 0),ph([fe()],fh.prototype,"requiresConsent",void 0),ph([fe()],fh.prototype,"privacyPolicyUrl",void 0),ph([fe()],fh.prototype,"isLoading",void 0),fh=ph([ce("utilities-chat")],fh);const gh=async e=>{const t=window.location.href,n=`https://app.meetelise.com/platformApi/webchat/microsite_slug?uri=${encodeURIComponent(t)}`,i=await r().get(n,{headers:{"org-slug":e}});return Math.random()<.2&&na({logType:i&&i.data?ta.info:ta.warn,logTitle:`[BUILDING_SLUG_CALCULATED_${i?"SUCCESS":"FAILURE"}]`,logData:{calculatedBuildingSlug:i.data,url:t,orgSlug:e,givenBuildingSlug:null,reason:i&&i.data?null:"No match found"}}),i.data},mh=async(e,t=5e3)=>new Promise((n,i)=>{const r=new MutationObserver((t,i)=>{const r=document.getElementById(e);r&&(i.disconnect(),n(r))});r.observe(document.body,{childList:!0,subtree:!0});const o=setTimeout(()=>{r.disconnect(),i(new Error(`Element ${e} did not appear within ${t}ms`))},t),a=document.querySelector(e);a&&(clearTimeout(o),r.disconnect(),n(a))});class bh{static healthcareStart(e,t=!0){var n,i,r,o;t&&(this.healthcareId=e.id,this.overridePlacement={right:e.right,bottom:e.bottom,top:e.top,left:e.left}),Ch();const a=document.createElement("health-chat");a.setAttribute("class","health-chat"),a.setAttribute("role","region"),a.setAttribute("aria-label","EliseAI Healthcare Widget"),a.setAttribute("healthcareId",e.id),a.setAttribute("right",(null===(n=e.right)||void 0===n?void 0:n.toString())||"unset"),a.setAttribute("bottom",(null===(i=e.bottom)||void 0===i?void 0:i.toString())||"unset"),a.setAttribute("top",(null===(r=e.top)||void 0===r?void 0:r.toString())||"unset"),a.setAttribute("left",(null===(o=e.left)||void 0===o?void 0:o.toString())||"unset"),document.body.appendChild(a),bh.healthChat=a}static start(e,t=!0){var n,i,r,o,a,s,l,u;if(window.location.pathname.includes("residentservices")||window.location.pathname.includes("onlineleasing"))return;if(t&&(this.orgSlug="Pacific Urban Residential"===e.organization?"cbc11aba-21c4-4571-bc43-ff9d86a029e3":e.organization||"",this.hasBuildingSlug=!!e.building,this.overridePlacement={right:null===(n=null==e?void 0:e.position)||void 0===n?void 0:n.right,bottom:null===(i=null==e?void 0:e.position)||void 0===i?void 0:i.bottom,top:null===(r=null==e?void 0:e.position)||void 0===r?void 0:r.top,left:null===(o=null==e?void 0:e.position)||void 0===o?void 0:o.left}),Ch(),e.studio&&!e.building)return void this.handleStudioContext(e);let d=null;switch(e.widgetType){case wh.Healthcare:throw new Error("Healthcare widget is not supported yet, please use the healthcareStart method instead.");case wh.Default:d=document.createElement("me-chat");break;case wh.Utilities:d=document.createElement("utilities-chat");break;default:d=document.createElement("me-chat")}if(!d)throw new Error("Invalid widget type");d.setAttribute("orgSlug","Pacific Urban Residential"===e.organization?"cbc11aba-21c4-4571-bc43-ff9d86a029e3":e.organization||""),d.setAttribute("widgetType",e.widgetType||wh.Default),d.setAttribute("class","meetelise-chat"),d.setAttribute("role","region"),d.setAttribute("aria-label","EliseAI Widget"),e.brandColor&&(this.brandColor=e.brandColor,d.setAttribute("primaryColor",((e,t)=>{const n=ei(e),i=0,r=0,o=0,a={r:n.r+Math.round((i-n.r)*t),g:n.g+Math.round((r-n.g)*t),b:n.b+Math.round((o-n.b)*t)};return ti(a.r,a.g,a.b)})(e.brandColor,.3))),e.backgroundColor&&(this.backgroundColor=e.backgroundColor),d instanceof rh&&(e.centralConvo?(d.setAttribute("centralConvo","true"),e.building&&d.setAttribute("declaredBuildingSlug",e.building)):this.handleBuildingslug(d,e.organization,e.building,e),e.launcherStyles&&(d.launcherStyles=e.launcherStyles),e.mobileStyles&&(d.mobileStyles=e.mobileStyles),e.onWidgetLoaded&&(d.onWidgetLoaded=e.onWidgetLoaded),e.overrideRentgrata&&((async()=>{const e=await mh("rg-widget-compact");e&&e.setAttribute("style","display: none")})(),d.overrideRentgrata=!0),e.onSstClose&&(d.onSstClose=e.onSstClose)),e.position&&(d.setAttribute("right",(null===(a=e.position.right)||void 0===a?void 0:a.toString())||"unset"),d.setAttribute("bottom",(null===(s=e.position.bottom)||void 0===s?void 0:s.toString())||"unset"),d.setAttribute("top",(null===(l=e.position.top)||void 0===l?void 0:l.toString())||"unset"),d.setAttribute("left",(null===(u=e.position.left)||void 0===u?void 0:u.toString())||"unset")),window.eliseAi={},document.body.appendChild(d),d instanceof rh&&(bh.meChat=d),d instanceof fh&&(bh.utilitiesChat=d)}static async restartConversation(){this.meChat&&await this.meChat.restartConversation()}static async remove(){this.studioUpdateToken+=1,await this.removeWidget(),this.activeStudioOrgSlug="",this.activeStudioBuildingSlug="",this.activeStudioSessionScopeKey="",this.activeStudioOptions=null}static async removeWidget(){var e;if(!this.meChat)return;const t=this.meChat;await t.remove(),null===(e=t.parentNode)||void 0===e||e.removeChild(t),bh.meChat=null}static handleStudioContext(e){e.studio&&(this.activeStudioOptions=e)}static updateStudioContext(e){var t;const n=this.activeStudioOptions;if(!(null==n?void 0:n.studio))return;const i=++this.studioUpdateToken;if(e.siteId&&e.siteId!==n.studio.siteId)return void na({logType:ta.warn,logTitle:"[STUDIO_WEBCHAT_CONTEXT_SITE_MISMATCH]",logData:{activeSiteId:n.studio.siteId,contextSiteId:e.siteId,url:window.location.href}});if("org"===(null===(t=e.sessionScope)||void 0===t?void 0:t.type))return void this.updateStudioOrgContext(e,n,i);const r=yh(e.organization),o=yh(e.building);if(!r||!o)return void this.clearStudioContext({source:"elise_studio",reason:"missing_context",preserveCache:!0});const a=function(e,t){if(!(null==e?void 0:e.key))return`building:${t}`;return e.key}(e.sessionScope,o),s=vh(r);this.activeStudioOrgSlug===s&&this.activeStudioBuildingSlug===o&&this.activeStudioSessionScopeKey===a||this.removeWidget().then(()=>{i===this.studioUpdateToken&&(this.activeStudioOrgSlug=s,this.activeStudioBuildingSlug=o,this.activeStudioSessionScopeKey=a,this.orgSlug=s,this.start({...n,organization:r,building:o},!1))})}static updateStudioOrgContext(e,t,n){var i;const r=yh(e.organization);if(!r)return void this.clearStudioContext({source:"elise_studio",reason:"missing_context",preserveCache:!0});const o=vh(r),a=(null===(i=e.sessionScope)||void 0===i?void 0:i.key)||`org:${r}`,s=function(e){const t="string"==typeof e?Number(e):e;return"number"==typeof t&&Number.isInteger(t)&&t>0?t:null}(e.declaredBuildingId);!this.meChat||this.activeStudioOrgSlug!==o||this.activeStudioBuildingSlug||this.activeStudioSessionScopeKey!==a?this.removeWidget().then(()=>{var e;n===this.studioUpdateToken&&(this.activeStudioOrgSlug=o,this.activeStudioBuildingSlug="",this.activeStudioSessionScopeKey=a,this.orgSlug=o,this.start({...t,studio:void 0,organization:r,building:void 0,centralConvo:!0},!1),null===(e=this.meChat)||void 0===e||e.setDeclaredBuildingId(s))}):this.meChat.setDeclaredBuildingId(s)}static clearStudioContext(e){this.studioUpdateToken+=1,this.activeStudioOrgSlug="",this.activeStudioBuildingSlug="",this.activeStudioSessionScopeKey="",this.removeWidget()}static async handleBuildingslug(e,t,n,i){if(n)return void e.setAttribute("buildingSlug",n);if(this.mutationObserver)return;if(!t)return;const r=await gh(t);if(r){const e={...i,organization:t,building:r};this.start(e,!1)}this.previousUrl=window.location.href,document.body.addEventListener("click",()=>{requestAnimationFrame(()=>{this.previousUrl===window.location.href||this.hasBuildingSlug||(this.previousUrl=window.location.href,gh(t).then(e=>{if(!e)return;const n={...i,organization:t,building:e};this.start(n,!1)}))})},!0)}static async handleSingleFamilyUrl(){if(this.hasBuildingSlug)return;this.remove();const e=window.location.href,t=`https://app.meetelise.com/platformApi/webchat/microsite_slug?uri=${encodeURIComponent(e)}`,n=await r().get(t,{headers:{"org-slug":this.orgSlug}});if(Math.random()<.2&&na({logType:n&&n.data?ta.info:ta.warn,logTitle:`[BUILDING_SLUG_CALCULATED_${n?"SUCCESS":"FAILURE"}]`,logData:{calculatedBuildingSlug:n.data,url:e,orgSlug:this.orgSlug,givenBuildingSlug:null,reason:n&&n.data?null:"No match found"}}),!n||!n.data)return;const i={organization:this.orgSlug,building:n.data,brandColor:this.brandColor,backgroundColor:this.backgroundColor};this.start(i,!1)}static async calculateBuildingSlugForLogging(e){const t=window.location.href,n=`https://app.meetelise.com/platformApi/webchat/microsite_slug?uri=${encodeURIComponent(t)}`,i=await r().get(n,{headers:{"org-slug":this.orgSlug}});Math.random()<.2&&na({logType:i&&i.data===e?ta.info:ta.warn,logTitle:`[BUILDING_SLUG_CALCULATED_${i&&i.data===e?"SUCCESS":"FAILURE"}]`,logData:{calculatedBuildingSlug:i.data,url:t,orgSlug:this.orgSlug,givenBuildingSlug:e,reason:i&&i.data===e?null:i&&!i.data?"No match found":i&&i.data!==e?"Mismatch":"No match found"}}),i&&i.data}}function yh(e){return"string"!=typeof e?"":e.trim()}function vh(e){return"Pacific Urban Residential"===e?"cbc11aba-21c4-4571-bc43-ff9d86a029e3":e}var wh;bh.meChat=null,bh.healthChat=null,bh.utilitiesChat=null,bh.orgSlug="",bh.mutationObserver=null,bh.previousUrl="",bh.hasBuildingSlug=null,bh.brandColor="",bh.backgroundColor="",bh.healthcareId="",bh.activeStudioOrgSlug="",bh.activeStudioBuildingSlug="",bh.activeStudioSessionScopeKey="",bh.activeStudioOptions=null,bh.studioUpdateToken=0,bh.overridePlacement={},function(e){e.Default="default",e.Healthcare="healthcare",e.Utilities="utilities"}(wh||(wh={}));const Ch=()=>{const e=document.createElement("link");e.setAttribute("rel","stylesheet"),e.setAttribute("type","text/css"),document.head.appendChild(e)};export{wh as WidgetType,bh as default};
|
|
8140
|
+
`,ph([pe({type:String})],fh.prototype,"orgSlug",void 0),ph([pe({type:Number})],fh.prototype,"right",void 0),ph([pe({type:Number})],fh.prototype,"bottom",void 0),ph([pe({type:Number})],fh.prototype,"top",void 0),ph([pe({type:Number})],fh.prototype,"left",void 0),ph([fe()],fh.prototype,"launcher",void 0),ph([fe()],fh.prototype,"currentLeadSource",void 0),ph([fe()],fh.prototype,"displayPubnubChat",void 0),ph([fe()],fh.prototype,"myPubnub",void 0),ph([fe()],fh.prototype,"requiresConsent",void 0),ph([fe()],fh.prototype,"privacyPolicyUrl",void 0),ph([fe()],fh.prototype,"isLoading",void 0),fh=ph([ce("utilities-chat")],fh);const gh=async e=>{const t=window.location.href,n=`https://app.meetelise.com/platformApi/webchat/microsite_slug?uri=${encodeURIComponent(t)}`,i=await r().get(n,{headers:{"org-slug":e}});return Math.random()<.2&&na({logType:i&&i.data?ta.info:ta.warn,logTitle:`[BUILDING_SLUG_CALCULATED_${i?"SUCCESS":"FAILURE"}]`,logData:{calculatedBuildingSlug:i.data,url:t,orgSlug:e,givenBuildingSlug:null,reason:i&&i.data?null:"No match found"}}),i.data},mh=async(e,t=5e3)=>new Promise((n,i)=>{const r=new MutationObserver((t,i)=>{const r=document.getElementById(e);r&&(i.disconnect(),n(r))});r.observe(document.body,{childList:!0,subtree:!0});const o=setTimeout(()=>{r.disconnect(),i(new Error(`Element ${e} did not appear within ${t}ms`))},t),a=document.querySelector(e);a&&(clearTimeout(o),r.disconnect(),n(a))});class bh{static healthcareStart(e,t=!0){var n,i,r,o;t&&(this.healthcareId=e.id,this.overridePlacement={right:e.right,bottom:e.bottom,top:e.top,left:e.left}),Ch();const a=document.createElement("health-chat");a.setAttribute("class","health-chat"),a.setAttribute("role","region"),a.setAttribute("aria-label","EliseAI Healthcare Widget"),a.setAttribute("healthcareId",e.id),a.setAttribute("right",(null===(n=e.right)||void 0===n?void 0:n.toString())||"unset"),a.setAttribute("bottom",(null===(i=e.bottom)||void 0===i?void 0:i.toString())||"unset"),a.setAttribute("top",(null===(r=e.top)||void 0===r?void 0:r.toString())||"unset"),a.setAttribute("left",(null===(o=e.left)||void 0===o?void 0:o.toString())||"unset"),document.body.appendChild(a),bh.healthChat=a}static start(e,t=!0){var n,i,r,o,a,s,l,u;if(window.location.pathname.includes("residentservices")||window.location.pathname.includes("onlineleasing"))return;if(t&&(this.orgSlug="Pacific Urban Residential"===e.organization?"cbc11aba-21c4-4571-bc43-ff9d86a029e3":e.organization||"",this.hasBuildingSlug=!!e.building,this.overridePlacement={right:null===(n=null==e?void 0:e.position)||void 0===n?void 0:n.right,bottom:null===(i=null==e?void 0:e.position)||void 0===i?void 0:i.bottom,top:null===(r=null==e?void 0:e.position)||void 0===r?void 0:r.top,left:null===(o=null==e?void 0:e.position)||void 0===o?void 0:o.left}),Ch(),e.studio&&!e.building)return void this.handleStudioContext(e);let d=null;switch(e.widgetType){case wh.Healthcare:throw new Error("Healthcare widget is not supported yet, please use the healthcareStart method instead.");case wh.Default:d=document.createElement("me-chat");break;case wh.Utilities:d=document.createElement("utilities-chat");break;default:d=document.createElement("me-chat")}if(!d)throw new Error("Invalid widget type");d.setAttribute("orgSlug","Pacific Urban Residential"===e.organization?"cbc11aba-21c4-4571-bc43-ff9d86a029e3":e.organization||""),d.setAttribute("widgetType",e.widgetType||wh.Default),d.setAttribute("class","meetelise-chat"),d.setAttribute("role","region"),d.setAttribute("aria-label","EliseAI Widget"),e.brandColor&&(this.brandColor=e.brandColor,d.setAttribute("primaryColor",((e,t)=>{const n=ei(e),i=0,r=0,o=0,a={r:n.r+Math.round((i-n.r)*t),g:n.g+Math.round((r-n.g)*t),b:n.b+Math.round((o-n.b)*t)};return ti(a.r,a.g,a.b)})(e.brandColor,.3))),e.backgroundColor&&(this.backgroundColor=e.backgroundColor),d instanceof rh&&(e.centralConvo?(d.setAttribute("centralConvo","true"),e.building&&d.setAttribute("declaredBuildingSlug",e.building)):this.handleBuildingslug(d,e.organization,e.building,e),e.launcherStyles&&(d.launcherStyles=e.launcherStyles),e.mobileStyles&&(d.mobileStyles=e.mobileStyles),e.onWidgetLoaded&&(d.onWidgetLoaded=e.onWidgetLoaded),e.overrideRentgrata&&((async()=>{const e=await mh("rg-widget-compact");e&&e.setAttribute("style","display: none")})(),d.overrideRentgrata=!0),e.onSstClose&&(d.onSstClose=e.onSstClose)),e.position&&(d.setAttribute("right",(null===(a=e.position.right)||void 0===a?void 0:a.toString())||"unset"),d.setAttribute("bottom",(null===(s=e.position.bottom)||void 0===s?void 0:s.toString())||"unset"),d.setAttribute("top",(null===(l=e.position.top)||void 0===l?void 0:l.toString())||"unset"),d.setAttribute("left",(null===(u=e.position.left)||void 0===u?void 0:u.toString())||"unset")),window.eliseAi={},document.body.appendChild(d),d instanceof rh&&(bh.meChat=d),d instanceof fh&&(bh.utilitiesChat=d)}static async restartConversation(){this.meChat&&await this.meChat.restartConversation()}static async remove(){this.studioUpdateToken+=1,await this.removeWidget(),this.activeStudioOrgSlug="",this.activeStudioBuildingSlug="",this.activeStudioSessionScopeKey="",this.activeStudioOptions=null}static async removeWidget(){var e;if(!this.meChat)return;const t=this.meChat;await t.remove(),null===(e=t.parentNode)||void 0===e||e.removeChild(t),bh.meChat===t&&(bh.meChat=null)}static handleStudioContext(e){e.studio&&(this.activeStudioOptions=e)}static updateStudioContext(e){var t;const n=this.activeStudioOptions;if(!(null==n?void 0:n.studio))return;const i=++this.studioUpdateToken;if(e.siteId&&e.siteId!==n.studio.siteId)return void na({logType:ta.warn,logTitle:"[STUDIO_WEBCHAT_CONTEXT_SITE_MISMATCH]",logData:{activeSiteId:n.studio.siteId,contextSiteId:e.siteId,url:window.location.href}});if("org"===(null===(t=e.sessionScope)||void 0===t?void 0:t.type))return void this.updateStudioOrgContext(e,n,i);const r=yh(e.organization),o=yh(e.building);if(!r||!o)return void this.clearStudioContext({source:"elise_studio",reason:"missing_context",preserveCache:!0});const a=function(e,t){if(!(null==e?void 0:e.key))return`building:${t}`;return e.key}(e.sessionScope,o),s=vh(r);this.activeStudioOrgSlug===s&&this.activeStudioBuildingSlug===o&&this.activeStudioSessionScopeKey===a||this.removeWidget().then(()=>{i===this.studioUpdateToken&&(this.activeStudioOrgSlug=s,this.activeStudioBuildingSlug=o,this.activeStudioSessionScopeKey=a,this.orgSlug=s,this.start({...n,organization:r,building:o},!1))})}static updateStudioOrgContext(e,t,n){var i;const r=yh(e.organization);if(!r)return void this.clearStudioContext({source:"elise_studio",reason:"missing_context",preserveCache:!0});const o=vh(r),a=(null===(i=e.sessionScope)||void 0===i?void 0:i.key)||`org:${r}`,s=function(e){const t="string"==typeof e?Number(e):e;return"number"==typeof t&&Number.isInteger(t)&&t>0?t:null}(e.declaredBuildingId);!this.meChat||this.activeStudioOrgSlug!==o||this.activeStudioBuildingSlug||this.activeStudioSessionScopeKey!==a?this.removeWidget().then(()=>{var e;n===this.studioUpdateToken&&(this.activeStudioOrgSlug=o,this.activeStudioBuildingSlug="",this.activeStudioSessionScopeKey=a,this.orgSlug=o,this.start({...t,studio:void 0,organization:r,building:void 0,centralConvo:!0},!1),null===(e=this.meChat)||void 0===e||e.setDeclaredBuildingId(s))}):this.meChat.setDeclaredBuildingId(s)}static clearStudioContext(e){this.studioUpdateToken+=1,this.activeStudioOrgSlug="",this.activeStudioBuildingSlug="",this.activeStudioSessionScopeKey="",this.removeWidget()}static async handleBuildingslug(e,t,n,i){if(n)return void e.setAttribute("buildingSlug",n);if(this.mutationObserver)return;if(!t)return;const r=await gh(t);if(r){const e={...i,organization:t,building:r};this.start(e,!1)}this.previousUrl=window.location.href,document.body.addEventListener("click",()=>{requestAnimationFrame(()=>{this.previousUrl===window.location.href||this.hasBuildingSlug||(this.previousUrl=window.location.href,gh(t).then(e=>{if(!e)return;const n={...i,organization:t,building:e};this.start(n,!1)}))})},!0)}static async handleSingleFamilyUrl(){if(this.hasBuildingSlug)return;this.remove();const e=window.location.href,t=`https://app.meetelise.com/platformApi/webchat/microsite_slug?uri=${encodeURIComponent(e)}`,n=await r().get(t,{headers:{"org-slug":this.orgSlug}});if(Math.random()<.2&&na({logType:n&&n.data?ta.info:ta.warn,logTitle:`[BUILDING_SLUG_CALCULATED_${n?"SUCCESS":"FAILURE"}]`,logData:{calculatedBuildingSlug:n.data,url:e,orgSlug:this.orgSlug,givenBuildingSlug:null,reason:n&&n.data?null:"No match found"}}),!n||!n.data)return;const i={organization:this.orgSlug,building:n.data,brandColor:this.brandColor,backgroundColor:this.backgroundColor};this.start(i,!1)}static async calculateBuildingSlugForLogging(e){const t=window.location.href,n=`https://app.meetelise.com/platformApi/webchat/microsite_slug?uri=${encodeURIComponent(t)}`,i=await r().get(n,{headers:{"org-slug":this.orgSlug}});Math.random()<.2&&na({logType:i&&i.data===e?ta.info:ta.warn,logTitle:`[BUILDING_SLUG_CALCULATED_${i&&i.data===e?"SUCCESS":"FAILURE"}]`,logData:{calculatedBuildingSlug:i.data,url:t,orgSlug:this.orgSlug,givenBuildingSlug:e,reason:i&&i.data===e?null:i&&!i.data?"No match found":i&&i.data!==e?"Mismatch":"No match found"}}),i&&i.data}}function yh(e){return"string"!=typeof e?"":e.trim()}function vh(e){return"Pacific Urban Residential"===e?"cbc11aba-21c4-4571-bc43-ff9d86a029e3":e}var wh;bh.meChat=null,bh.healthChat=null,bh.utilitiesChat=null,bh.orgSlug="",bh.mutationObserver=null,bh.previousUrl="",bh.hasBuildingSlug=null,bh.brandColor="",bh.backgroundColor="",bh.healthcareId="",bh.activeStudioOrgSlug="",bh.activeStudioBuildingSlug="",bh.activeStudioSessionScopeKey="",bh.activeStudioOptions=null,bh.studioUpdateToken=0,bh.overridePlacement={},function(e){e.Default="default",e.Healthcare="healthcare",e.Utilities="utilities"}(wh||(wh={}));const Ch=()=>{const e=document.createElement("link");e.setAttribute("rel","stylesheet"),e.setAttribute("type","text/css"),document.head.appendChild(e)};export{wh as WidgetType,bh as default};
|
|
@@ -1500,6 +1500,22 @@ export class TourScheduler extends LitElement {
|
|
|
1500
1500
|
`;
|
|
1501
1501
|
}
|
|
1502
1502
|
|
|
1503
|
+
/**
|
|
1504
|
+
* Whether to ask "How did you hear about us?". Not on a broker referral: the broker's client gets the building's
|
|
1505
|
+
* broker source. Not rendered, the select isn't read on submit either (selectedLeadSource queries it), so a source
|
|
1506
|
+
* picked before the broker switch was turned on isn't sent.
|
|
1507
|
+
*/
|
|
1508
|
+
showLeadSourceSelect(): boolean {
|
|
1509
|
+
return (
|
|
1510
|
+
!(this.brokerIntakeEnabled && this.isBrokerReferral) &&
|
|
1511
|
+
this.leadSources.length > 0 &&
|
|
1512
|
+
(this.featureFlagShowDropdown === FeatureFlagsShowDropdown.always ||
|
|
1513
|
+
(this.featureFlagShowDropdown ===
|
|
1514
|
+
FeatureFlagsShowDropdown.onAttributionFailure &&
|
|
1515
|
+
this.currentLeadSource.length === 0))
|
|
1516
|
+
);
|
|
1517
|
+
}
|
|
1518
|
+
|
|
1503
1519
|
userInfoAndLayoutMenu(): TemplateResult {
|
|
1504
1520
|
const isReferral = this.brokerIntakeEnabled && this.isBrokerReferral;
|
|
1505
1521
|
return html`<h2 class="journey-header">Your Information</h2>
|
|
@@ -1639,11 +1655,7 @@ export class TourScheduler extends LitElement {
|
|
|
1639
1655
|
>
|
|
1640
1656
|
</me-select>`
|
|
1641
1657
|
: ""}
|
|
1642
|
-
${this.
|
|
1643
|
-
(this.featureFlagShowDropdown === FeatureFlagsShowDropdown.always ||
|
|
1644
|
-
(this.featureFlagShowDropdown ===
|
|
1645
|
-
FeatureFlagsShowDropdown.onAttributionFailure &&
|
|
1646
|
-
this.currentLeadSource.length === 0))
|
|
1658
|
+
${this.showLeadSourceSelect()
|
|
1647
1659
|
? html` <me-select
|
|
1648
1660
|
id="leadSource"
|
|
1649
1661
|
value="${this.currentLeadSource}"
|
|
@@ -566,6 +566,22 @@ export class EmailUsWindow extends LitElement {
|
|
|
566
566
|
].filter((v) => v).length;
|
|
567
567
|
};
|
|
568
568
|
|
|
569
|
+
/**
|
|
570
|
+
* Whether to ask "How did you hear about us?". Not on a broker referral: the broker's client gets the building's
|
|
571
|
+
* broker source. Not rendered, the select isn't read on submit either (selectedLeadSource queries it), so a source
|
|
572
|
+
* picked before the broker switch was turned on isn't sent.
|
|
573
|
+
*/
|
|
574
|
+
showLeadSourceSelect(): boolean {
|
|
575
|
+
return (
|
|
576
|
+
!(this.brokerIntakeEnabled && this.isBrokerReferral) &&
|
|
577
|
+
this.leadSources.length > 0 &&
|
|
578
|
+
(this.featureFlagShowDropdown === FeatureFlagsShowDropdown.always ||
|
|
579
|
+
(this.featureFlagShowDropdown ===
|
|
580
|
+
FeatureFlagsShowDropdown.onAttributionFailure &&
|
|
581
|
+
this.currentLeadSource.length === 0))
|
|
582
|
+
);
|
|
583
|
+
}
|
|
584
|
+
|
|
569
585
|
renderBrokerToggle = (): TemplateResult => html`
|
|
570
586
|
<label class="email-us__broker-toggle">
|
|
571
587
|
<span>Are you a broker or locator?</span>
|
|
@@ -794,11 +810,7 @@ export class EmailUsWindow extends LitElement {
|
|
|
794
810
|
? html`${this.renderBrokerToggle()}
|
|
795
811
|
<div class="email-us__vertical-spacer"></div>`
|
|
796
812
|
: ""}
|
|
797
|
-
${this.
|
|
798
|
-
(this.featureFlagShowDropdown === FeatureFlagsShowDropdown.always ||
|
|
799
|
-
(this.featureFlagShowDropdown ===
|
|
800
|
-
FeatureFlagsShowDropdown.onAttributionFailure &&
|
|
801
|
-
this.currentLeadSource.length === 0))
|
|
813
|
+
${this.showLeadSourceSelect()
|
|
802
814
|
? html`
|
|
803
815
|
<me-select
|
|
804
816
|
id="leadSource"
|
|
@@ -568,3 +568,69 @@ it("moves what a broker typed on the tour form into their own details when they
|
|
|
568
568
|
]);
|
|
569
569
|
expect(tour.brokerEmail).to.equal("");
|
|
570
570
|
});
|
|
571
|
+
|
|
572
|
+
const leadSourceFields = {
|
|
573
|
+
leadSources: ["Zillow", "Apartments.com"],
|
|
574
|
+
featureFlagShowDropdown: "always",
|
|
575
|
+
};
|
|
576
|
+
|
|
577
|
+
const leadSourceSelect = async (emailUs: EmailUsWindow) => {
|
|
578
|
+
await emailUs.updateComplete;
|
|
579
|
+
return emailUs.shadowRoot?.querySelector("me-select#leadSource") ?? null;
|
|
580
|
+
};
|
|
581
|
+
|
|
582
|
+
it("doesn't ask a broker how they heard about us; anyone else is still asked", async () => {
|
|
583
|
+
const emailUs = createForm({
|
|
584
|
+
brokerIntakeEnabled: true,
|
|
585
|
+
...leadSourceFields,
|
|
586
|
+
});
|
|
587
|
+
document.body.appendChild(emailUs);
|
|
588
|
+
|
|
589
|
+
expect(await leadSourceSelect(emailUs)).not.to.equal(null);
|
|
590
|
+
|
|
591
|
+
emailUs.isBrokerReferral = true;
|
|
592
|
+
expect(await leadSourceSelect(emailUs)).to.equal(null);
|
|
593
|
+
|
|
594
|
+
// Broker intake off: the switch is ignored, so the question stays.
|
|
595
|
+
emailUs.brokerIntakeEnabled = false;
|
|
596
|
+
expect(await leadSourceSelect(emailUs)).not.to.equal(null);
|
|
597
|
+
emailUs.remove();
|
|
598
|
+
});
|
|
599
|
+
|
|
600
|
+
it("doesn't send a source picked before the broker switch was turned on", async () => {
|
|
601
|
+
const requests = captureRequests();
|
|
602
|
+
const emailUs = createForm({
|
|
603
|
+
brokerIntakeEnabled: true,
|
|
604
|
+
...leadSourceFields,
|
|
605
|
+
});
|
|
606
|
+
document.body.appendChild(emailUs);
|
|
607
|
+
const select = (await leadSourceSelect(emailUs)) as HTMLElement & {
|
|
608
|
+
value?: string;
|
|
609
|
+
};
|
|
610
|
+
select.value = "Zillow";
|
|
611
|
+
|
|
612
|
+
Object.assign(emailUs, { isBrokerReferral: true, ...brokerFields });
|
|
613
|
+
await emailUs.updateComplete;
|
|
614
|
+
const submission = emailUs.onClick();
|
|
615
|
+
// Answer the request before asserting, so a failure can't leave the submission waiting.
|
|
616
|
+
requests[0]?.respond(200, { "Content-Type": "application/json" }, "{}");
|
|
617
|
+
await submission;
|
|
618
|
+
|
|
619
|
+
expect(requests).to.have.length(1);
|
|
620
|
+
const body = JSON.parse(requests[0].requestBody ?? "{}");
|
|
621
|
+
expect(JSON.stringify(body.lead_sources)).not.to.contain("Zillow");
|
|
622
|
+
emailUs.remove();
|
|
623
|
+
});
|
|
624
|
+
|
|
625
|
+
it("doesn't ask on the tour form either when a broker is referring a client", () => {
|
|
626
|
+
const asked = (fields: Record<string, unknown>) =>
|
|
627
|
+
createTour({ ...leadSourceFields, ...fields }).showLeadSourceSelect();
|
|
628
|
+
|
|
629
|
+
expect(asked({ brokerIntakeEnabled: true })).to.equal(true);
|
|
630
|
+
expect(asked({ brokerIntakeEnabled: true, isBrokerReferral: true })).to.equal(
|
|
631
|
+
false
|
|
632
|
+
);
|
|
633
|
+
expect(
|
|
634
|
+
asked({ brokerIntakeEnabled: false, isBrokerReferral: true })
|
|
635
|
+
).to.equal(true);
|
|
636
|
+
});
|
package/src/main/MEChat.test.ts
CHANGED
|
@@ -68,6 +68,30 @@ it("does not throw when removing a widget that already detached itself", async f
|
|
|
68
68
|
).removeWidget();
|
|
69
69
|
});
|
|
70
70
|
|
|
71
|
+
it("keeps a widget started before an un-awaited remove() finishes", async function () {
|
|
72
|
+
const statics = MEChat as unknown as { meChat: HTMLElement | null };
|
|
73
|
+
// No organization, so the widget makes no API calls.
|
|
74
|
+
const opts = { building: "unit-test-building" };
|
|
75
|
+
MEChat.start(opts, false);
|
|
76
|
+
const oldWidget = statics.meChat;
|
|
77
|
+
|
|
78
|
+
// A single-page site switches buildings without awaiting remove().
|
|
79
|
+
const removing = MEChat.remove();
|
|
80
|
+
MEChat.start(opts, false);
|
|
81
|
+
const newWidget = statics.meChat;
|
|
82
|
+
await removing;
|
|
83
|
+
|
|
84
|
+
// Booleans only: a failing assertion that holds a widget element hangs the runner.
|
|
85
|
+
expect(oldWidget?.isConnected).to.equal(false);
|
|
86
|
+
expect(newWidget?.isConnected).to.equal(true);
|
|
87
|
+
expect(statics.meChat === newWidget).to.equal(true);
|
|
88
|
+
|
|
89
|
+
await MEChat.remove();
|
|
90
|
+
|
|
91
|
+
expect(newWidget?.isConnected).to.equal(false);
|
|
92
|
+
expect(statics.meChat === null).to.equal(true);
|
|
93
|
+
});
|
|
94
|
+
|
|
71
95
|
it.skip("shows the launcher", async function () {
|
|
72
96
|
// Given an API that returns this building theme
|
|
73
97
|
stub(window, "fetch").resolves(stubResponse);
|
package/src/main/MEChat.ts
CHANGED
|
@@ -302,7 +302,10 @@ export default class MEChat {
|
|
|
302
302
|
const meChat = this.meChat;
|
|
303
303
|
await meChat.remove();
|
|
304
304
|
meChat.parentNode?.removeChild(meChat);
|
|
305
|
-
|
|
305
|
+
// A host that calls start() without awaiting remove() has already set a new widget.
|
|
306
|
+
if (MEChat.meChat === meChat) {
|
|
307
|
+
MEChat.meChat = null;
|
|
308
|
+
}
|
|
306
309
|
}
|
|
307
310
|
|
|
308
311
|
static handleStudioContext(opts: Options): void {
|