@meetelise/chat 1.68.0 → 1.69.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/src/MyPubnub.ts CHANGED
@@ -246,6 +246,11 @@ class MyPubnub {
246
246
  this.widgetType = widgetType;
247
247
  }
248
248
 
249
+ /** The /webchat/init session token, once the session exists. */
250
+ getSessionToken(): string | null {
251
+ return this.sessionToken;
252
+ }
253
+
249
254
  async initSession(
250
255
  buildingSlug: string,
251
256
  orgSlug: string,
@@ -38,7 +38,7 @@ export const buildPlanRequest = (choice: ItineraryChoice): PlanRequest => {
38
38
  tour_type: choice.tourType,
39
39
  date: choice.date,
40
40
  start_time: choice.firstStart,
41
- stop_starts: Object.keys(laterStarts).length > 0 ? laterStarts : null,
41
+ stop_starts: laterStarts,
42
42
  fixed_first:
43
43
  fixedEventId === undefined ? null : { calendar_event_id: fixedEventId },
44
44
  };
@@ -92,7 +92,8 @@ export interface PlanRequest {
92
92
  tour_type: TourTypeId;
93
93
  date: string;
94
94
  start_time: string | null;
95
- stop_starts: Record<string, string> | null;
95
+ /** Times picked for later stops, by building id; empty when none are picked. */
96
+ stop_starts: Record<string, string>;
96
97
  fixed_first: { calendar_event_id: number } | null;
97
98
  }
98
99
 
@@ -11,6 +11,8 @@ import {
11
11
  import { StyleInfo, styleMap } from "lit/directives/style-map.js";
12
12
  import { installCallUsWindow } from "../actions/call-us-window";
13
13
  import { TourScheduler } from "../Scheduler/tour-scheduler";
14
+ import "../SchedulerV2/tour-scheduler-v2";
15
+ import type { TourSchedulerV2 } from "../SchedulerV2/tour-scheduler-v2";
14
16
  import { FeeCalculator } from "../FeeCalculator/fee-calculator";
15
17
  import { installFeeCalculator } from "../FeeCalculator";
16
18
  import { LabeledOption } from "../../fetchBuildingInfo";
@@ -159,6 +161,11 @@ export class Launcher extends LitElement {
159
161
  bedroomPreferenceRequired = false;
160
162
  @property({ attribute: false })
161
163
  brokerIntakeEnabled = false;
164
+ /** The building is on the `webchat_tour_scheduler_v2` rollout. */
165
+ @property({ attribute: false })
166
+ tourSchedulerV2 = false;
167
+ @property({ attribute: false })
168
+ getSessionToken: () => string | null = () => null;
162
169
  @property({ attribute: true })
163
170
  hasDynamicSchedulingEnabled = false;
164
171
 
@@ -288,6 +295,12 @@ export class Launcher extends LitElement {
288
295
 
289
296
  emailUsWindowRef: Ref<EmailUsWindow> = createRef();
290
297
  tourSchedulerRef: Ref<TourScheduler> = createRef();
298
+ tourSchedulerV2Ref: Ref<TourSchedulerV2> = createRef();
299
+ /**
300
+ * Which scheduler the open window shows, fixed when it opens so that the
301
+ * rollout answer arriving later can't swap it mid-booking.
302
+ */
303
+ private sstWindowIsV2 = false;
291
304
  calculatorWindowRef: Ref<FeeCalculator> = createRef();
292
305
 
293
306
  willUpdate(changedProperties: PropertyValues<this>): void {
@@ -297,6 +310,9 @@ export class Launcher extends LitElement {
297
310
  ) {
298
311
  this.isSSTWindowOpen = true;
299
312
  }
313
+ if (changedProperties.has("isSSTWindowOpen") && this.isSSTWindowOpen) {
314
+ this.sstWindowIsV2 = this.tourSchedulerV2;
315
+ }
300
316
  }
301
317
 
302
318
  updated = async (): Promise<void> => {
@@ -322,6 +338,10 @@ export class Launcher extends LitElement {
322
338
  };
323
339
 
324
340
  attachOnClickToSSTWindow = (): void => {
341
+ const sstWindowV2 = this.tourSchedulerV2Ref.value;
342
+ if (sstWindowV2) {
343
+ sstWindowV2.onCloseClicked = this.onCloseSSTWindow;
344
+ }
325
345
  const sstWindowRef = this.tourSchedulerRef.value;
326
346
  if (!sstWindowRef) {
327
347
  return;
@@ -389,8 +409,11 @@ export class Launcher extends LitElement {
389
409
  e.stopPropagation();
390
410
  closeRengrataWidget();
391
411
  pushGtmEvent("bookTourClicked", { buildingId: this.buildingId });
392
- resetAvailabilitiesCache();
393
- getRawAvailabilities(this.buildingId);
412
+ // Warms today's scheduler's availabilities; the v2 scheduler asks /plan instead.
413
+ if (!this.tourSchedulerV2) {
414
+ resetAvailabilitiesCache();
415
+ getRawAvailabilities(this.buildingId);
416
+ }
394
417
 
395
418
  this.isSSTWindowOpen = true;
396
419
  };
@@ -1350,7 +1373,44 @@ export class Launcher extends LitElement {
1350
1373
  </email-us-window>
1351
1374
  </div>`
1352
1375
  : ""}
1353
- ${this.isSSTWindowOpen
1376
+ ${this.isSSTWindowOpen && this.sstWindowIsV2
1377
+ ? html`<div
1378
+ class="launcher__window-wrapper"
1379
+ style=${styleMap(overrideStyleWindows)}
1380
+ >
1381
+ <tour-scheduler-v2
1382
+ id="tour-scheduler-window"
1383
+ orgSlug=${this.orgSlug}
1384
+ buildingSlug=${this.buildingSlug}
1385
+ buildingId=${this.buildingId}
1386
+ orgId=${this.orgId}
1387
+ .buildingName=${this.buildingName}
1388
+ sgtUrl=${this.sgtUrl}
1389
+ selfGuidedToursTypeOffered=${this.selfGuidedToursTypeOffered}
1390
+ escortedToursLink=${this.escortedToursLink}
1391
+ .escortedToursTypeOffered=${this.escortedToursTypeOffered}
1392
+ virtualToursLink=${this.virtualToursLink}
1393
+ virtualToursTypeOffered=${this.virtualToursTypeOffered}
1394
+ .tourTypeOptions=${this.tourTypeOptions}
1395
+ .layoutOptions=${this.layoutOptions}
1396
+ currentLeadSource=${this.currentLeadSource}
1397
+ .leadSources=${this.leadSources}
1398
+ featureFlagShowDropdown=${this.featureFlagShowDropdown}
1399
+ .bedroomPreferenceRequired=${this.bedroomPreferenceRequired}
1400
+ .orgLegalName=${this.orgLegalName}
1401
+ .country=${this.country}
1402
+ .buildingState=${this.buildingState}
1403
+ .primaryColor=${this.primaryColor}
1404
+ .foregroundColorOnPrimaryBackgroundColor=${this
1405
+ .foregroundColorOnPrimaryBackgroundColor}
1406
+ .compactDesign=${this.showTourNextToChat}
1407
+ .leadSourceClient=${this.leadSourceClient}
1408
+ .leadSourceMultitouchClient=${this.leadSourceMultitouchClient}
1409
+ .getSessionToken=${this.getSessionToken}
1410
+ ${ref(this.tourSchedulerV2Ref)}
1411
+ ></tour-scheduler-v2>
1412
+ </div>`
1413
+ : this.isSSTWindowOpen
1354
1414
  ? html`<div
1355
1415
  class="launcher__window-wrapper"
1356
1416
  style=${styleMap(overrideStyleWindows)}
@@ -17,6 +17,7 @@ import {
17
17
  fetchFeatureFlagUseOverrideContactUsForm,
18
18
  fetchTrackedRolloutBedroomPreferenceRequired,
19
19
  fetchTrackedRolloutBrokerIntake,
20
+ fetchTrackedRolloutTourSchedulerV2,
20
21
  } from "../fetchFeatureFlag";
21
22
  import { HIDE_DATA_LAYER_PII_ORG_IDS, setGtmPiiRedaction } from "../gtm";
22
23
  import fetchPhoneNumberFromSource, {
@@ -197,6 +198,9 @@ export class MEChat extends LitElement {
197
198
  FeatureFlagsShowDropdown.always;
198
199
  @state()
199
200
  private bedroomPreferenceRequired = false;
201
+ /** The building is on the `webchat_tour_scheduler_v2` rollout. */
202
+ @state()
203
+ private tourSchedulerV2 = false;
200
204
  @state()
201
205
  private brokerIntakeEnabled = false;
202
206
  @state()
@@ -225,6 +229,10 @@ export class MEChat extends LitElement {
225
229
  @state()
226
230
  private myPubnub: MyPubnub | null = null;
227
231
 
232
+ /** For the v2 tour scheduler, which calls the session-authenticated endpoints. */
233
+ private getSessionToken = (): string | null =>
234
+ this.myPubnub?.getSessionToken() ?? null;
235
+
228
236
  @state()
229
237
  private LeadSourceClient: LeadSourceClient | null = null; // DEPRECATED IN FAVOR OF LeadSourceMultitouchClient
230
238
 
@@ -421,6 +429,7 @@ export class MEChat extends LitElement {
421
429
  isAip,
422
430
  bedroomPreferenceRequired,
423
431
  brokerIntakeEnabled,
432
+ tourSchedulerV2,
424
433
  ] = await Promise.all([
425
434
  // Per-building endpoint; org mode has no building to ask about.
426
435
  this.isOrgMode()
@@ -430,6 +439,7 @@ export class MEChat extends LitElement {
430
439
  fetchBuildingAip(this.buildingSlug),
431
440
  fetchTrackedRolloutBedroomPreferenceRequired(this.buildingSlug),
432
441
  fetchTrackedRolloutBrokerIntake(this.buildingSlug),
442
+ fetchTrackedRolloutTourSchedulerV2(this.buildingSlug),
433
443
  ]);
434
444
 
435
445
  if (this.buildingWebchatView) {
@@ -443,6 +453,7 @@ export class MEChat extends LitElement {
443
453
  featureFlagShowDropdown as FeatureFlagsShowDropdown;
444
454
  this.bedroomPreferenceRequired = bedroomPreferenceRequired;
445
455
  this.brokerIntakeEnabled = brokerIntakeEnabled;
456
+ this.tourSchedulerV2 = tourSchedulerV2;
446
457
 
447
458
  // The backend is cached for ~4 hours, so falling back to the existing api request until the cache propagates all the changes
448
459
  // Org-level webchat never offers Text Us, so it needs no number for it.
@@ -1164,6 +1175,8 @@ export class MEChat extends LitElement {
1164
1175
  []}
1165
1176
  .bedroomPreferenceRequired=${this.bedroomPreferenceRequired}
1166
1177
  .brokerIntakeEnabled=${this.brokerIntakeEnabled}
1178
+ .tourSchedulerV2=${this.tourSchedulerV2}
1179
+ .getSessionToken=${this.getSessionToken}
1167
1180
  .launcherStyles=${this.launcherStyles}
1168
1181
  .primaryColor=${this.primaryColor}
1169
1182
  .backgroundColor=${this.backgroundColor}
@@ -155,6 +155,26 @@ export async function fetchTrackedRolloutCoastalCustomTourTypes(
155
155
  }
156
156
  }
157
157
 
158
+ /** Whether the building shows the rebuilt tour scheduler (<tour-scheduler-v2>) instead of today's. */
159
+ export async function fetchTrackedRolloutTourSchedulerV2(
160
+ buildingSlug: string
161
+ ): Promise<boolean> {
162
+ if (!buildingSlug) return false;
163
+ try {
164
+ const response = await axios.get(trackedRolloutEndpoint(buildingSlug), {
165
+ params: {
166
+ rollout_name: "webchat_tour_scheduler_v2",
167
+ default_value: false,
168
+ },
169
+ // Read with the other startup flags; a slow answer means today's scheduler.
170
+ timeout: 3000,
171
+ });
172
+ return response.data === true;
173
+ } catch (_) {
174
+ return false;
175
+ }
176
+ }
177
+
158
178
  /** Whether brokers are on for the building (the broker_rollout rollout), so the email form offers the broker referral fields. */
159
179
  export async function fetchTrackedRolloutBrokerIntake(
160
180
  buildingSlug: string