sfc-utils 1.4.165 → 1.4.167

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.
@@ -1,6 +1,7 @@
1
1
  import { getBlueconic } from "../../blueconic";
2
2
  import { getBrands3 } from "../../brands3";
3
3
  import { appCheck, blendHDN, getSettings } from "../../index";
4
+ import systemSettings from "../../../../src/data/system_settings.sheet.json";
4
5
 
5
6
  const currentEnv = process.env.GATSBY_DEPLOY_ENV;
6
7
 
@@ -202,9 +203,8 @@ function trackEvent(
202
203
  elementText = null
203
204
  ) {
204
205
  const storySettings = getSettings();
205
- // [systemSettings] = require("../../../../src/data/story_settings.sheet.json");
206
- const systemSettings = require("../../../../src/data/system_settings.sheet.json");
207
- const elementVariant = `${systemSettings.Repo}|${systemSettings.Project_Type}`;
206
+ const systemSettingsObj = systemSettings[0];
207
+ const elementVariant = `${systemSettingsObj.Repo}|${systemSettingsObj.Project_Type}`;
208
208
  const linkUrl = `${storySettings.PROJECT.SUBFOLDER}/${storySettings.PROJECT.SLUG}`;
209
209
  const urlHash = window.HDN.dataLayer.visit.urlHash;
210
210
 
@@ -232,4 +232,53 @@ function trackEvent(
232
232
  });
233
233
  }
234
234
 
235
- export { debounce, appendLayoutScripts, formatHDN, getFigureWidth, trackEvent };
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
+ }
252
+
253
+ var embed_event = {
254
+ event: event, //REQUIRED; Fixed value
255
+ 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
256
+ 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
257
+ element_variant: elementVariant, //REQUIRED; Template type (e.g. custom-repo-name|gatsby) (top-list|plat)
258
+ 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)
259
+ 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)
260
+ component_subtype: null, //OPTIONAL; If BC components uses Storybook components: Variant of the component_type from storybook
261
+ 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
262
+ zone: null, // OPTIONAL; For WCM components. The WCM zone the component was displayed in.
263
+ link_url: linkUrl, //REQUIRED; What is the slug of the project?
264
+ outbound: false, //REQUIRED; Boolean indicating whether the link that was clicked took the user to a different domain.
265
+ 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)
266
+ iframe_event: true,
267
+ };
268
+
269
+ if (typeof window !== "undefined") {
270
+ window.parent.postMessage(embed_event, "*"); // Sends event to parent page
271
+ }
272
+
273
+ //TO TEST: I think this needs to go directly into the iframe embed code?
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
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "sfc-utils",
3
- "version": "1.4.165",
3
+ "version": "1.4.167",
4
4
  "author": "ewagstaff <evanjwagstaff@gmail.com>",
5
5
  "dependencies": {
6
6
  "archieml": "^0.4.2",