@salesforcedevs/dx-components 0.16.3 → 0.17.0

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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@salesforcedevs/dx-components",
3
- "version": "0.16.3",
3
+ "version": "0.17.0",
4
4
  "description": "DX Lightning web components",
5
5
  "license": "MIT",
6
6
  "engines": {
@@ -29,5 +29,5 @@
29
29
  "@types/debounce": "^1.2.0",
30
30
  "@types/lodash.get": "^4.4.6"
31
31
  },
32
- "gitHead": "82ca0f75d4bdd801e08aab4af8ab0f6aec92a6cb"
32
+ "gitHead": "b7a26c9e46cee9298b3ebc7cbea85930320b83a0"
33
33
  }
@@ -21,6 +21,7 @@
21
21
  >
22
22
  <template for:each={options} for:item="option">
23
23
  <dx-dropdown-option
24
+ analytics-event={analyticsEvent}
24
25
  active={option.active}
25
26
  key-value={option.keyValue}
26
27
  if:false={option.options}
@@ -39,6 +40,7 @@
39
40
  <span class="menu_heading">{option.label}</span>
40
41
  <template for:each={option.options} for:item="suboption">
41
42
  <dx-dropdown-option
43
+ analytics-event={analyticsEvent}
42
44
  active={suboption.active}
43
45
  key={suboption.id}
44
46
  key-value={suboption.keyValue}
@@ -29,8 +29,10 @@ export default class Dropdown extends LightningElement {
29
29
  @api small?: boolean = false;
30
30
  @api openOnHover?: boolean = false; // dropdown opens/closes with hover
31
31
  @api width?: string | null = null;
32
- @api fullWidth?: boolean | null;
33
- @api navItemLabel: string | null = null;
32
+ @api fullWidth?: boolean | null; @api navItemLabel: string | null = null;
33
+
34
+ // props forwarded to dropdown option
35
+ @api analyticsEvent: string | null = null
34
36
 
35
37
  @api
36
38
  get options() {
@@ -14,6 +14,12 @@ import { track } from "dx/instrumentation";
14
14
  const createNewsletterSignupHref = (email: string): string =>
15
15
  `/newsletter?subscriberEmail=${email}`;
16
16
 
17
+ const ANALYTICS_INFO = {
18
+ itemTitle: "Newsletter Sign Up Footer",
19
+ elementType: "button",
20
+ destinationType: "internal",
21
+ ctaClick: true
22
+ };
17
23
  export default class Footer extends LightningElement {
18
24
  @api locale: string | null = null;
19
25
  @api
@@ -85,7 +91,13 @@ export default class Footer extends LightningElement {
85
91
 
86
92
  private onSubmitEmail = async (e: CustomEvent) => {
87
93
  const href = createNewsletterSignupHref(e.detail);
88
- track(e.currentTarget, "custEv_newsletterSubscriptionStart");
94
+
95
+ track(e.currentTarget, "custEv_ctaButtonClick", {
96
+ ...ANALYTICS_INFO,
97
+ clickText: e.detail,
98
+ clickUrl: href,
99
+ });
100
+
89
101
  window.location.assign(href);
90
102
  };
91
103
 
@@ -9,23 +9,20 @@ import {
9
9
  mockPropsNoNavigation
10
10
  } from "./mockProps";
11
11
  import { track } from "dx/instrumentation";
12
+ import { ANALYTICS_INFO } from "utils/headerBase";
12
13
 
13
14
  const TAG = "dx-header";
14
15
  const render = createRenderComponent(TAG, Header);
15
16
 
16
17
  jest.mock("dx/instrumentation");
17
18
 
18
- const GTM_EVENT_NAME = "custEv_signupStart";
19
- const SIGN_UP_LABEL = "Sign Up";
20
-
21
19
  describe("dx-header", () => {
22
20
  it("renders", () => {
23
21
  const subtitle = "testsubtitle";
24
22
  const element = render({ ...mockPropsDevelopers, subtitle });
25
23
  const subtitleEl = element.shadowRoot.querySelector(".subtitle");
26
- const buttons: Array<HTMLElement> = element.shadowRoot.querySelectorAll(
27
- "dx-button"
28
- );
24
+ const buttons: Array<HTMLElement> =
25
+ element.shadowRoot.querySelectorAll("dx-button");
29
26
  const dropdown = element.shadowRoot.querySelector("dx-dropdown");
30
27
  const headerEl = element.shadowRoot.querySelector("dx-header-nav");
31
28
 
@@ -88,9 +85,8 @@ describe("dx-header", () => {
88
85
  ...mockPropsDevelopers,
89
86
  versions: JSON.stringify([version])
90
87
  });
91
- const dropdown: Dropdown = element.shadowRoot.querySelector(
92
- "dx-dropdown"
93
- );
88
+ const dropdown: Dropdown =
89
+ element.shadowRoot.querySelector("dx-dropdown");
94
90
  expect(dropdown).not.toBeNull();
95
91
  expect(dropdown.options).toHaveLength(1);
96
92
 
@@ -180,9 +176,8 @@ describe("dx-header", () => {
180
176
  bailLabel: "test",
181
177
  signupLink: "/"
182
178
  });
183
- const buttons: Array<Button> = element.shadowRoot.querySelectorAll(
184
- "dx-button"
185
- );
179
+ const buttons: Array<Button> =
180
+ element.shadowRoot.querySelectorAll("dx-button");
186
181
 
187
182
  expect(buttons[0].href).toEqual("/");
188
183
  expect(buttons[2].href).toEqual("test");
@@ -194,26 +189,25 @@ describe("dx-header", () => {
194
189
  subtitle: mockPropsDevelopers.subtitle,
195
190
  navItems: mockPropsDevelopers.navItems
196
191
  });
197
- const headerSearch = element.shadowRoot.querySelector(
198
- "dx-header-search"
199
- );
192
+ const headerSearch =
193
+ element.shadowRoot.querySelector("dx-header-search");
200
194
 
201
195
  expect(headerSearch).toBeNull();
202
196
  return expect(element).toBeAccessible();
203
197
  });
204
198
 
205
- it("signup button track is beign called", () => {
199
+ it("signup button track is being called", () => {
206
200
  const element = render(mockPropsDevelopers);
207
201
 
208
- const button: HTMLElement = element.shadowRoot.querySelector(
209
- "dx-button"
210
- );
202
+ const button: HTMLElement =
203
+ element.shadowRoot.querySelector("dx-button");
211
204
 
212
205
  button.click();
213
206
 
214
207
  expect(track).toBeCalledTimes(1);
215
- expect(track).toBeCalledWith(button, GTM_EVENT_NAME, {
216
- clickText: SIGN_UP_LABEL
208
+ expect(track).toBeCalledWith(button, "custEv_signupStart", {
209
+ ...ANALYTICS_INFO,
210
+ clickUrl: "/sign-up"
217
211
  });
218
212
  });
219
213
 
@@ -13,6 +13,7 @@
13
13
 
14
14
  <!-- DESKTOP "MORE CONTENT" NAV ITEM -->
15
15
  <dx-dropdown
16
+ analytics-event="custEv_topNavLinkClick"
16
17
  if:true={navItem.options}
17
18
  nav-item-label={navItem.label}
18
19
  open-on-hover
@@ -2,6 +2,18 @@ import { LightningElement, api } from "lwc";
2
2
  import { track } from "dx/instrumentation";
3
3
  import { CountryOptions, CheckboxTextSet } from "typings/custom";
4
4
 
5
+ const ANALYTICS_INFO = {
6
+ itemTitle: "newsletter sign up submit",
7
+ formName: "newsletter",
8
+ formType: "newsletter",
9
+ method: "email",
10
+ destinationType: "internal",
11
+ clickText: "Subscribe Now",
12
+ clickUrl: "/newsletter/success",
13
+ elementType: "button",
14
+ ctaClick: true
15
+ };
16
+
5
17
  export default class Form extends LightningElement {
6
18
  @api checkboxTextSet: string = "";
7
19
  @api countries: string = "";
@@ -134,16 +146,13 @@ export default class Form extends LightningElement {
134
146
  submitButtonEl.textContent = "...Processing request";
135
147
 
136
148
  try {
137
- const res = await fetch(
138
- "/pages/pardot/footer_optin",
139
- {
140
- method: "POST",
141
- headers: {
142
- "Content-Type": "application/json"
143
- },
144
- body: JSON.stringify(formData)
145
- }
146
- );
149
+ const res = await fetch("/pages/pardot/footer_optin", {
150
+ method: "POST",
151
+ headers: {
152
+ "Content-Type": "application/json"
153
+ },
154
+ body: JSON.stringify(formData)
155
+ });
147
156
 
148
157
  if (!res.ok) {
149
158
  throw new Error(errorMsg);
@@ -156,7 +165,7 @@ export default class Form extends LightningElement {
156
165
  }
157
166
 
158
167
  // GTM event
159
- track(submitButtonEl, "custEv_newsletterSubscription");
168
+ track(submitButtonEl, "custEv_formCompletion", ANALYTICS_INFO);
160
169
 
161
170
  window.location.assign("/newsletter/success");
162
171
  } catch (error) {
@@ -18,7 +18,14 @@ const VALID_BRANDS = [
18
18
  "service",
19
19
  "success"
20
20
  ];
21
- const SIGN_UP_LABEL = "Sign Up";
21
+
22
+ export const ANALYTICS_INFO = {
23
+ clickText: "Sign Up",
24
+ itemTitle: "Sign Up Header Button",
25
+ elementType: "button",
26
+ destinationType: "internal",
27
+ ctaClick: true
28
+ };
22
29
 
23
30
  export abstract class HeaderBase extends LightningElement {
24
31
  @api bailHref?: string | null = null;
@@ -185,7 +192,8 @@ export abstract class HeaderBase extends LightningElement {
185
192
 
186
193
  private handleSignUpClick(e: PointerEvent) {
187
194
  track(e.currentTarget!, "custEv_signupStart", {
188
- clickText: SIGN_UP_LABEL
195
+ ...ANALYTICS_INFO,
196
+ clickUrl: this.signupLink,
189
197
  });
190
198
  }
191
199