@meetelise/chat 1.20.60 → 1.20.61
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/package.json +1 -1
- package/public/dist/index.js +106 -106
- package/src/WebComponent/me-chat.ts +18 -12
- package/src/fetchFeatureFlag.ts +31 -4
|
@@ -9,14 +9,18 @@ import Analytics from "../analytics";
|
|
|
9
9
|
import { createChatID, getChatID } from "../chatID";
|
|
10
10
|
import createConversation from "../createConversation";
|
|
11
11
|
import fetchBuildingInfo, { Building } from "../fetchBuildingInfo";
|
|
12
|
-
import
|
|
12
|
+
import {
|
|
13
13
|
FeatureFlagsShowDropdown,
|
|
14
|
+
fetchFeatureFlagShowMarketingSourceDropdown,
|
|
15
|
+
fetchFeatureFlagUsePhoneNumberBySource,
|
|
14
16
|
} from "../fetchFeatureFlag";
|
|
15
17
|
import fetchBuildingABTestType, {
|
|
16
18
|
abTestTypes,
|
|
17
19
|
} from "../fetchBuildingABTestType";
|
|
18
20
|
import fetchCurrentParsedLeadSource from "../fetchCurrentParsedLeadSource";
|
|
19
|
-
import {
|
|
21
|
+
import fetchPhoneNumberFromSource, {
|
|
22
|
+
NumberForSelectedSource,
|
|
23
|
+
} from "../fetchPhoneNumberFromSource";
|
|
20
24
|
import { getTheme, Theme, ThemeIdString } from "../themes";
|
|
21
25
|
import { isMobile } from "../utils";
|
|
22
26
|
import { installLauncher } from "./Launcher";
|
|
@@ -180,30 +184,32 @@ export class MEChat extends LitElement {
|
|
|
180
184
|
building,
|
|
181
185
|
buildingABTest,
|
|
182
186
|
leadSources,
|
|
183
|
-
featureFlagShowDropdown,
|
|
184
187
|
currentLeadSource,
|
|
188
|
+
featureFlagShowDropdown,
|
|
189
|
+
featureFlagUseDNI,
|
|
185
190
|
] = await Promise.all([
|
|
186
191
|
fetchBuildingInfo(this.orgSlug, this.buildingSlug),
|
|
187
192
|
fetchBuildingABTestType(this.buildingSlug),
|
|
188
193
|
fetchLeadSources(this.buildingSlug),
|
|
189
|
-
fetchFeatureFlag(this.buildingSlug),
|
|
190
194
|
fetchCurrentParsedLeadSource(this.buildingSlug, document.referrer),
|
|
195
|
+
fetchFeatureFlagShowMarketingSourceDropdown(this.buildingSlug),
|
|
196
|
+
fetchFeatureFlagUsePhoneNumberBySource(this.buildingSlug),
|
|
191
197
|
]);
|
|
192
198
|
|
|
193
199
|
building.phoneNumber = formatPhoneNumber(building.phoneNumber);
|
|
194
200
|
this.building = building;
|
|
195
201
|
this.buildingABTestType = buildingABTest?.abTestType ?? "";
|
|
196
202
|
this.leadSources = leadSources;
|
|
197
|
-
this.featureFlagShowDropdown = featureFlagShowDropdown;
|
|
198
203
|
this.currentLeadSource = currentLeadSource;
|
|
204
|
+
this.featureFlagShowDropdown = featureFlagShowDropdown;
|
|
199
205
|
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
206
|
+
let phoneNumberForSource = null;
|
|
207
|
+
if (featureFlagUseDNI) {
|
|
208
|
+
phoneNumberForSource = await fetchPhoneNumberFromSource(
|
|
209
|
+
this.buildingSlug,
|
|
210
|
+
this.currentLeadSource
|
|
211
|
+
);
|
|
212
|
+
}
|
|
207
213
|
|
|
208
214
|
// if the building does NOT have IVR setup, we want to use the building's phone number
|
|
209
215
|
if (!phoneNumberForSource) {
|
package/src/fetchFeatureFlag.ts
CHANGED
|
@@ -1,16 +1,22 @@
|
|
|
1
1
|
import axios from "axios";
|
|
2
|
+
|
|
3
|
+
const featureFlagEndpoint = (buildingSlug: string): string => {
|
|
4
|
+
const host = "https://app.meetelise.com";
|
|
5
|
+
return `${host}/platformApi/webchat/${buildingSlug}/chat-ui-feature-flag`;
|
|
6
|
+
};
|
|
7
|
+
|
|
2
8
|
export enum FeatureFlagsShowDropdown {
|
|
3
9
|
onAttributionFailure = "on-attribution-failure",
|
|
4
10
|
never = "never", // note, the dropdown will NOT show up if there are also no lead sources (list)!
|
|
5
11
|
always = "always",
|
|
6
12
|
}
|
|
7
|
-
|
|
13
|
+
|
|
14
|
+
export async function fetchFeatureFlagShowMarketingSourceDropdown(
|
|
8
15
|
buildingSlug: string
|
|
9
16
|
): Promise<FeatureFlagsShowDropdown> {
|
|
10
|
-
const host = "https://app.meetelise.com";
|
|
11
17
|
try {
|
|
12
18
|
const featureFlagResponse = await axios.get(
|
|
13
|
-
|
|
19
|
+
featureFlagEndpoint(buildingSlug),
|
|
14
20
|
{
|
|
15
21
|
params: {
|
|
16
22
|
building_slug: buildingSlug,
|
|
@@ -21,7 +27,6 @@ export default async function fetchFeatureFlag(
|
|
|
21
27
|
},
|
|
22
28
|
}
|
|
23
29
|
);
|
|
24
|
-
|
|
25
30
|
if (featureFlagResponse.data === "on-attribution-failure") {
|
|
26
31
|
return FeatureFlagsShowDropdown.onAttributionFailure;
|
|
27
32
|
}
|
|
@@ -33,3 +38,25 @@ export default async function fetchFeatureFlag(
|
|
|
33
38
|
return FeatureFlagsShowDropdown.always;
|
|
34
39
|
}
|
|
35
40
|
}
|
|
41
|
+
|
|
42
|
+
export async function fetchFeatureFlagUsePhoneNumberBySource(
|
|
43
|
+
buildingSlug: string
|
|
44
|
+
): Promise<boolean> {
|
|
45
|
+
try {
|
|
46
|
+
const featureFlagResponse = await axios.get(
|
|
47
|
+
featureFlagEndpoint(buildingSlug),
|
|
48
|
+
{
|
|
49
|
+
params: {
|
|
50
|
+
building_slug: buildingSlug,
|
|
51
|
+
flag_type: "bool",
|
|
52
|
+
feature_flag: "webchat-use-dni-phone-number-by-source",
|
|
53
|
+
default_str: null,
|
|
54
|
+
default_bool: false,
|
|
55
|
+
},
|
|
56
|
+
}
|
|
57
|
+
);
|
|
58
|
+
return featureFlagResponse.data;
|
|
59
|
+
} catch (_) {
|
|
60
|
+
return false;
|
|
61
|
+
}
|
|
62
|
+
}
|