sfc-utils 1.4.168 → 1.4.170
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/accountswap.js +13 -11
- package/components/geocoder.mjs +4 -1
- package/components/helpers/utilfunctions.mjs +41 -65
- package/package.json +1 -1
package/accountswap.js
CHANGED
|
@@ -10,17 +10,19 @@ const pollForAccount = async function (i, isNav) {
|
|
|
10
10
|
// Start the iterator
|
|
11
11
|
if (!i) {
|
|
12
12
|
i = 0;
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
13
|
+
// Add a click event to signin
|
|
14
|
+
if (isNav) {
|
|
15
|
+
const signinButton = document.querySelector(".hnp-signin");
|
|
16
|
+
if (signinButton) {
|
|
17
|
+
console.log("Found signin button");
|
|
18
|
+
// Add event listener to signin button
|
|
19
|
+
signinButton.onclick = function (e) {
|
|
20
|
+
console.log("Clicked signin button");
|
|
21
|
+
window.treg.realm.core.login();
|
|
22
|
+
e.preventDefault();
|
|
23
|
+
e.stopPropagation();
|
|
24
|
+
};
|
|
25
|
+
}
|
|
24
26
|
}
|
|
25
27
|
}
|
|
26
28
|
// Safecheck for treg since it might not be global yet
|
package/components/geocoder.mjs
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import React, { useRef, useState, useEffect } from "react";
|
|
2
|
+
import { trackEvent } from "./helpers/utilfunctions.mjs";
|
|
2
3
|
import * as geocoderStyles from "../styles/modules/geocoder.module.less";
|
|
3
4
|
|
|
4
5
|
// This is a singleton event listener that we can use to add/remove event listeners
|
|
@@ -23,9 +24,9 @@ const Geocoder = ({
|
|
|
23
24
|
filterRegion, // You need to test results, but could also pass in a neighbourhood, district, city, county, state or administrative area
|
|
24
25
|
market, // Will filter by the market's state if no filterRegion provided
|
|
25
26
|
resultFunc,
|
|
26
|
-
// buttonTrackingId, // To be used for analytics once system is more finalized
|
|
27
27
|
placeholder,
|
|
28
28
|
inputValueOverride, // Used to clear/change the input value from the parent component
|
|
29
|
+
buttonTrackingId = "SelectAnAddress", // A string sent as part of the onClick tracking event - can be used as an 'id' of sorts (e.g. "ScriptTool")
|
|
29
30
|
}) => {
|
|
30
31
|
// Show a loader when we're requesting
|
|
31
32
|
const [loading, setLoading] = useState(false);
|
|
@@ -148,6 +149,7 @@ const Geocoder = ({
|
|
|
148
149
|
if (resultFunc) {
|
|
149
150
|
resultFunc(selectedLocation);
|
|
150
151
|
}
|
|
152
|
+
trackEvent("Click", "Dropdown", "Geocoder", buttonTrackingId);
|
|
151
153
|
}
|
|
152
154
|
// Hide the list now
|
|
153
155
|
setLocData(null);
|
|
@@ -227,6 +229,7 @@ const Geocoder = ({
|
|
|
227
229
|
if (resultFunc) {
|
|
228
230
|
resultFunc(locData[i]);
|
|
229
231
|
}
|
|
232
|
+
trackEvent("Click", "Dropdown", "Geocoder", buttonTrackingId);
|
|
230
233
|
}}
|
|
231
234
|
>
|
|
232
235
|
<button
|
|
@@ -202,12 +202,11 @@ function trackEvent(
|
|
|
202
202
|
elementContent = null,
|
|
203
203
|
elementText = null
|
|
204
204
|
) {
|
|
205
|
+
// all of these variables are used regardless of if it's an embed
|
|
205
206
|
const storySettings = getSettings();
|
|
206
207
|
const systemSettingsObj = systemSettings[0];
|
|
207
208
|
const elementVariant = `${systemSettingsObj.Repo}|${systemSettingsObj.Project_Type}`;
|
|
208
209
|
const linkUrl = `${storySettings.PROJECT.SUBFOLDER}/${storySettings.PROJECT.SLUG}`;
|
|
209
|
-
const urlHash = window.HDN.dataLayer.visit.urlHash;
|
|
210
|
-
|
|
211
210
|
let event;
|
|
212
211
|
if (eventType === "Click") {
|
|
213
212
|
event = "hnp_click";
|
|
@@ -215,70 +214,47 @@ function trackEvent(
|
|
|
215
214
|
event = "hnp_impression";
|
|
216
215
|
}
|
|
217
216
|
|
|
218
|
-
window.dataLayer
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
element_content: elementContent, //REQUIRED; One of a list of subtypes of element types (e.g. Button) on the page (e.g. Geocoder, Searchbar, Prev/Next). TO DO: create a consistent list of this, maybe
|
|
222
|
-
element_variant: elementVariant, //REQUIRED; Template type (e.g. custom-repo-name|gatsby) (top-list|plat)
|
|
223
|
-
element_text: elementText, //REQUIRED; What was the actual text or alt-text of the thing that was clicked (InnerHTML or id specific to that element)
|
|
224
|
-
component_type: null, //OPTIONAL; If BC components uses Storybook components: Organism or molecule from storybook (whatever the highest level component from storybook that the clicked on item belongs to)
|
|
225
|
-
component_subtype: null, //OPTIONAL; If BC components uses Storybook components: Variant of the component_type from storybook
|
|
226
|
-
component_detail: null, //OPTIONAL; If BC components uses Storybook components: WCM TITLE|Position|Atom from storybook. This pipe-delimited structure is required. When values are not available for a given position, leave the position blank so the order of information doesn't change. e.g. something|| or something||something_else
|
|
227
|
-
zone: null, // OPTIONAL; For WCM components. The WCM zone the component was displayed in.
|
|
228
|
-
link_url: linkUrl, //REQUIRED; What is the slug of the project?
|
|
229
|
-
url_hash: urlHash, // REQUIRED;
|
|
230
|
-
outbound: false, //REQUIRED; Boolean indicating whether the link that was clicked took the user to a different domain.
|
|
231
|
-
source_system: "devhub", //REQUIRED; What platform powered the element? One of cookie, blueconic, realm, castle, devhub, treg, legacy obits, sailthru, casper, wordpress, hnp-jwplayer, event_data_service (other options required discussion with BI/DE)
|
|
232
|
-
});
|
|
233
|
-
}
|
|
234
|
-
|
|
235
|
-
const trackEmbedEvent = (
|
|
236
|
-
eventType,
|
|
237
|
-
elementName = null,
|
|
238
|
-
elementContent = null,
|
|
239
|
-
elementText = null
|
|
240
|
-
) => {
|
|
241
|
-
const storySettings = getSettings();
|
|
242
|
-
const systemSettingsObj = systemSettings[0];
|
|
243
|
-
const elementVariant = `${systemSettingsObj.Repo}|${systemSettingsObj.Project_Type}`;
|
|
244
|
-
const linkUrl = `${storySettings.Year}/${storySettings.Slug}`;
|
|
245
|
-
|
|
246
|
-
let event;
|
|
247
|
-
if (eventType === "Click") {
|
|
248
|
-
event = "hnp_click";
|
|
249
|
-
} else if (eventType === "Impression") {
|
|
250
|
-
event = "hnp_impression";
|
|
251
|
-
}
|
|
217
|
+
if (window.dataLayer) {
|
|
218
|
+
// this is NOT an embed, so push to the dataLayer
|
|
219
|
+
const urlHash = window.HDN.dataLayer.visit.urlHash;
|
|
252
220
|
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
221
|
+
window.dataLayer.push({
|
|
222
|
+
event: event, //REQUIRED; Fixed value
|
|
223
|
+
element_name: elementName, //REQUIRED; One of a list of tags/types of elements on the page (e.g. Button, Map, Tooltip, ToggleButton, Dropdown). TO DO: create a consistent list of this
|
|
224
|
+
element_content: elementContent, //REQUIRED; One of a list of subtypes of element types (e.g. Button) on the page (e.g. Geocoder, Searchbar, Prev/Next). TO DO: create a consistent list of this, maybe
|
|
225
|
+
element_variant: elementVariant, //REQUIRED; Template type (e.g. custom-repo-name|gatsby) (top-list|plat)
|
|
226
|
+
element_text: elementText, //REQUIRED; What was the actual text or alt-text of the thing that was clicked (InnerHTML or id specific to that element)
|
|
227
|
+
component_type: null, //OPTIONAL; If BC components uses Storybook components: Organism or molecule from storybook (whatever the highest level component from storybook that the clicked on item belongs to)
|
|
228
|
+
component_subtype: null, //OPTIONAL; If BC components uses Storybook components: Variant of the component_type from storybook
|
|
229
|
+
component_detail: null, //OPTIONAL; If BC components uses Storybook components: WCM TITLE|Position|Atom from storybook. This pipe-delimited structure is required. When values are not available for a given position, leave the position blank so the order of information doesn't change. e.g. something|| or something||something_else
|
|
230
|
+
zone: null, // OPTIONAL; For WCM components. The WCM zone the component was displayed in.
|
|
231
|
+
link_url: linkUrl, //REQUIRED; What is the slug of the project?
|
|
232
|
+
url_hash: urlHash, // REQUIRED;
|
|
233
|
+
outbound: false, //REQUIRED; Boolean indicating whether the link that was clicked took the user to a different domain.
|
|
234
|
+
source_system: "devhub", //REQUIRED; What platform powered the element? One of cookie, blueconic, realm, castle, devhub, treg, legacy obits, sailthru, casper, wordpress, hnp-jwplayer, event_data_service (other options required discussion with BI/DE)
|
|
235
|
+
});
|
|
236
|
+
} else {
|
|
237
|
+
// this IS an embed, so use this special logic
|
|
238
|
+
var embed_event = {
|
|
239
|
+
event: event, //REQUIRED; Fixed value
|
|
240
|
+
element_name: elementName, //REQUIRED; One of a list of tags/types of elements on the page (e.g. Button, Map, Tooltip, ToggleButton, Dropdown). TO DO: create a consistent list of this
|
|
241
|
+
element_content: elementContent, //REQUIRED; One of a list of subtypes of element types (e.g. Button) on the page (e.g. Geocoder, Searchbar, Prev/Next). TO DO: create a consistent list of this, maybe
|
|
242
|
+
element_variant: elementVariant, //REQUIRED; Template type (e.g. custom-repo-name|gatsby) (top-list|plat)
|
|
243
|
+
element_text: elementText, //REQUIRED; What was the actual text or alt-text of the thing that was clicked (InnerHTML or id specific to that element)
|
|
244
|
+
component_type: null, //OPTIONAL; If BC components uses Storybook components: Organism or molecule from storybook (whatever the highest level component from storybook that the clicked on item belongs to)
|
|
245
|
+
component_subtype: null, //OPTIONAL; If BC components uses Storybook components: Variant of the component_type from storybook
|
|
246
|
+
component_detail: null, //OPTIONAL; If BC components uses Storybook components: WCM TITLE|Position|Atom from storybook. This pipe-delimited structure is required. When values are not available for a given position, leave the position blank so the order of information doesn't change. e.g. something|| or something||something_else
|
|
247
|
+
zone: null, // OPTIONAL; For WCM components. The WCM zone the component was displayed in.
|
|
248
|
+
link_url: linkUrl, //REQUIRED; What is the slug of the project?
|
|
249
|
+
outbound: false, //REQUIRED; Boolean indicating whether the link that was clicked took the user to a different domain.
|
|
250
|
+
source_system: "devhub", //REQUIRED; What platform powered the element? One of cookie, blueconic, realm, castle, devhub, treg, legacy obits, sailthru, casper, wordpress, hnp-jwplayer, event_data_service (other options required discussion with BI/DE)
|
|
251
|
+
iframe_event: true,
|
|
252
|
+
};
|
|
268
253
|
|
|
269
|
-
|
|
270
|
-
|
|
254
|
+
if (typeof window !== "undefined") {
|
|
255
|
+
window.parent.postMessage(embed_event, "*"); // Sends event to parent page
|
|
256
|
+
}
|
|
271
257
|
}
|
|
258
|
+
}
|
|
272
259
|
|
|
273
|
-
|
|
274
|
-
//window.addEventListener("message", (message) => {if (message.data.iframe_event) {var event = message.data;dataLayer.push(event);}});
|
|
275
|
-
};
|
|
276
|
-
|
|
277
|
-
export {
|
|
278
|
-
debounce,
|
|
279
|
-
appendLayoutScripts,
|
|
280
|
-
formatHDN,
|
|
281
|
-
getFigureWidth,
|
|
282
|
-
trackEvent,
|
|
283
|
-
trackEmbedEvent,
|
|
284
|
-
};
|
|
260
|
+
export { debounce, appendLayoutScripts, formatHDN, getFigureWidth, trackEvent };
|