@salesforcedevs/dx-components 1.3.183 → 1.3.186

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/lwc.config.json CHANGED
@@ -88,6 +88,7 @@
88
88
  "dx/toast",
89
89
  "dx/toc",
90
90
  "dx/tooltip",
91
+ "dx/trafficLabeler",
91
92
  "dx/tree",
92
93
  "dx/typeBadge",
93
94
  "dx/vimeoPlayer",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@salesforcedevs/dx-components",
3
- "version": "1.3.183",
3
+ "version": "1.3.186",
4
4
  "description": "DX Lightning web components",
5
5
  "license": "MIT",
6
6
  "engines": {
@@ -41,5 +41,5 @@
41
41
  "eventsourcemock": "^2.0.0",
42
42
  "luxon": "^3.1.0"
43
43
  },
44
- "gitHead": "cdfd81bf3dd2b43b54f949f5f265716b52ca7f6a"
44
+ "gitHead": "b6fed79dc4289f3cc19a3c9dc623d19e24465d66"
45
45
  }
@@ -16,14 +16,12 @@ export const stepsData = [
16
16
  '<p class="dx-text-display-7">You\'re almost done! Please review your information and agree to the Journey to Salesforce program terms and conditions.</p>',
17
17
  formData: {
18
18
  countriesWithReferralInput: ["IN"],
19
- countriesWithRequiredJobRole: ["CA"],
20
19
  formId: "j2s-form",
21
20
  j2sTerms:
22
21
  'I agree to the Journey to Salesforce Program Terms, subject to the <a href="http://www.google.com">Salesforce Program Agreement</a>.',
23
22
  notAvailableAlertInfo: {
24
23
  title: "Not Available",
25
- body:
26
- 'The Journey to Salesforce program is not currently available in your country. See the <a href="https://www.google.com/">program FAQs</a> for a list of participating countries.'
24
+ body: 'The Journey to Salesforce program is not currently available in your country. See the <a href="https://www.google.com/">program FAQs</a> for a list of participating countries.'
27
25
  },
28
26
  participatingCountryCodes: ["US", "CA", "IN"]
29
27
  },
@@ -0,0 +1 @@
1
+ <template></template>
@@ -0,0 +1,71 @@
1
+ import { LightningElement, api } from "lwc";
2
+
3
+ const REDUNDANT_INSTANCE_ERROR_MESSAGE =
4
+ "Multiple <dx-traffic-labeler>s detected, this should never be the case.";
5
+
6
+ declare module globalThis {
7
+ let singletonTrafficLabelerConnected: boolean;
8
+ }
9
+
10
+ export default class TrafficLabeler extends LightningElement {
11
+ @api internalIps?: string;
12
+ @api clearbitPublicKey?: string;
13
+
14
+ connectedCallback(): void {
15
+ if (!globalThis.singletonTrafficLabelerConnected) {
16
+ globalThis.singletonTrafficLabelerConnected = true;
17
+ if (this.clearbitPublicKey) {
18
+ this.loadClearBitData();
19
+ }
20
+ if (this.internalIps) {
21
+ this.evaluateVPNAddress();
22
+ }
23
+ } else {
24
+ console.error(REDUNDANT_INSTANCE_ERROR_MESSAGE);
25
+ }
26
+ }
27
+
28
+ async loadClearBitData() {
29
+ try {
30
+ const result = await fetch(
31
+ `https://reveal.clearbit.com/v1/companies/reveal?authorization=${this.clearbitPublicKey}`
32
+ );
33
+ const json = await result.json();
34
+ if (json?.company?.name?.toLowerCase().includes("salesforce")) {
35
+ this.setTrafficType("internal");
36
+ }
37
+ } catch (error) {
38
+ console.error("fetch failed ", error);
39
+ }
40
+ }
41
+
42
+ async evaluateVPNAddress() {
43
+ try {
44
+ const ipifyResult = await fetch(
45
+ "https://api.ipify.org/?format=json"
46
+ );
47
+ const result = await ipifyResult.json();
48
+
49
+ const internalIps = this.internalIps?.split(",");
50
+
51
+ const isInternal = internalIps?.some((value) => {
52
+ const regex = new RegExp(value);
53
+ return regex.test(result.ip);
54
+ });
55
+
56
+ if (isInternal) {
57
+ this.setTrafficType("internal");
58
+ }
59
+ } catch (error) {
60
+ console.error("fetch failed ", error);
61
+ }
62
+ }
63
+
64
+ setTrafficType(trafficType: "internal" | "external") {
65
+ // @ts-ignore)
66
+ const dataLayer = (window.dataLayer = window.dataLayer || []);
67
+ dataLayer.push({
68
+ traffic_type: trafficType
69
+ });
70
+ }
71
+ }