@meetelise/chat 1.50.1 → 1.50.3

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.
@@ -869,6 +869,7 @@ export class TourScheduler extends LitElement {
869
869
  leadSources.find((i) => i !== "property-website") || null,
870
870
  layout: selectedLayout,
871
871
  unit: selectedUnit,
872
+ conversationTrackingId: this.leadSourceClient?.chatId ?? null,
872
873
  });
873
874
  const data = {
874
875
  referrer: document.referrer,
@@ -507,6 +507,7 @@ const createTextWithUs = async (
507
507
  phone: formattedPhoneNumber,
508
508
  originatingSource:
509
509
  leadSources.find((i) => i !== "property-website") || null,
510
+ conversationTrackingId: chatId ?? null,
510
511
  });
511
512
  await axios.post(
512
513
  "https://app.meetelise.com/platformApi/state/create/textMe",
@@ -569,6 +569,7 @@ const createEmail = async (
569
569
  message,
570
570
  originatingSource:
571
571
  leadSources.find((i) => i !== "property-website") || null,
572
+ conversationTrackingId: chatId ?? null,
572
573
  });
573
574
  await axios.post(
574
575
  "https://app.meetelise.com/platformApi/state/create/emailMe",
@@ -15,6 +15,7 @@ import {
15
15
  fetchFeatureFlagUseApplicationsLinkReplacement,
16
16
  fetchFeatureFlagUseOverrideContactUsForm,
17
17
  } from "../fetchFeatureFlag";
18
+ import { HIDE_DATA_LAYER_PII_ORG_IDS, setGtmPiiRedaction } from "../gtm";
18
19
  import fetchPhoneNumberFromSource, {
19
20
  NumberForSelectedSource,
20
21
  } from "../fetchPhoneNumberFromSource";
@@ -355,6 +356,10 @@ export class MEChat extends LitElement {
355
356
  const featureFlagReplaceScheduleTourCtaWebsite =
356
357
  buildingDetails.featureFlagWebchatReplaceAnyScheduleTourCtaWebsite;
357
358
 
359
+ setGtmPiiRedaction(
360
+ HIDE_DATA_LAYER_PII_ORG_IDS.includes(buildingDetails.orgId)
361
+ );
362
+
358
363
  const [leadSources, featureFlagUseApplicationsLinkReplacement, isAip] =
359
364
  await Promise.all([
360
365
  fetchLeadSources(this.orgSlug, this.buildingSlug),
@@ -0,0 +1,74 @@
1
+ import { expect } from "@esm-bundle/chai";
2
+ import { pushGtmEvent, setGtmPiiRedaction } from "./gtm";
3
+
4
+ afterEach(() => {
5
+ setGtmPiiRedaction(false);
6
+ window.dataLayer = [];
7
+ });
8
+
9
+ it("pushes the full payload when PII redaction is off", () => {
10
+ window.dataLayer = [];
11
+
12
+ pushGtmEvent("scheduleTourSubmitted", {
13
+ email: "lead@example.com",
14
+ phone: "+12125555555",
15
+ firstName: "Ada",
16
+ lastName: "Lovelace",
17
+ tourType: "in-person",
18
+ conversationTrackingId: "chat-123",
19
+ });
20
+
21
+ expect(window.dataLayer).to.deep.equal([
22
+ {
23
+ event: "scheduleTourSubmitted",
24
+ email: "lead@example.com",
25
+ phone: "+12125555555",
26
+ firstName: "Ada",
27
+ lastName: "Lovelace",
28
+ tourType: "in-person",
29
+ conversationTrackingId: "chat-123",
30
+ },
31
+ ]);
32
+ });
33
+
34
+ it("strips PII keys but keeps the rest when PII redaction is on", () => {
35
+ window.dataLayer = [];
36
+ setGtmPiiRedaction(true);
37
+
38
+ pushGtmEvent("scheduleTourSubmitted", {
39
+ email: "lead@example.com",
40
+ phone: "+12125555555",
41
+ firstName: "Ada",
42
+ lastName: "Lovelace",
43
+ message: "Hi, is the 2BR still available?",
44
+ tourDetails: { tourTime: "2026-08-01T09:00:00-07:00" },
45
+ tourType: "in-person",
46
+ originatingSource: null,
47
+ conversationTrackingId: "chat-123",
48
+ });
49
+
50
+ expect(window.dataLayer).to.deep.equal([
51
+ {
52
+ event: "scheduleTourSubmitted",
53
+ tourType: "in-person",
54
+ originatingSource: null,
55
+ conversationTrackingId: "chat-123",
56
+ },
57
+ ]);
58
+ });
59
+
60
+ it("does not mutate the caller's event object when redacting", () => {
61
+ window.dataLayer = [];
62
+ setGtmPiiRedaction(true);
63
+ const event: Record<string, unknown> = {
64
+ email: "lead@example.com",
65
+ tourType: "in-person",
66
+ };
67
+
68
+ pushGtmEvent("scheduleTourSubmitted", event);
69
+
70
+ expect(event).to.deep.equal({
71
+ email: "lead@example.com",
72
+ tourType: "in-person",
73
+ });
74
+ });
package/src/gtm.ts CHANGED
@@ -5,13 +5,39 @@ declare global {
5
5
  }
6
6
  }
7
7
 
8
+ // MAA (org 57), the MAA test org (2575), and org 2332 asked us not to push
9
+ // lead PII into the host page's dataLayer
10
+ export const HIDE_DATA_LAYER_PII_ORG_IDS = [57, 2575, 2332];
11
+
12
+ const GTM_PII_KEYS = [
13
+ "email",
14
+ "phone",
15
+ "firstName",
16
+ "lastName",
17
+ "message",
18
+ "tourDetails",
19
+ ];
20
+
21
+ let hideDataLayerPii = false;
22
+
23
+ export const setGtmPiiRedaction = (enabled: boolean): void => {
24
+ hideDataLayerPii = enabled;
25
+ };
26
+
8
27
  export const pushGtmEvent = (
9
28
  eventName: string,
10
29
  event: Record<string, unknown> = {}
11
30
  ): void => {
12
31
  window.dataLayer = window.dataLayer || [];
32
+ let eventToPush = event;
33
+ if (hideDataLayerPii) {
34
+ eventToPush = { ...event };
35
+ for (const piiKey of GTM_PII_KEYS) {
36
+ delete eventToPush[piiKey];
37
+ }
38
+ }
13
39
  window.dataLayer.push({
14
40
  event: eventName,
15
- ...event,
41
+ ...eventToPush,
16
42
  });
17
43
  };