sfc-utils 1.4.163 → 1.4.165

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,6 @@
1
1
  import { getBlueconic } from "../../blueconic";
2
2
  import { getBrands3 } from "../../brands3";
3
- import { appCheck, blendHDN } from "../../index";
3
+ import { appCheck, blendHDN, getSettings } from "../../index";
4
4
 
5
5
  const currentEnv = process.env.GATSBY_DEPLOY_ENV;
6
6
 
@@ -21,7 +21,8 @@ function appendLayoutScripts(
21
21
  isAdRemoved,
22
22
  marketKey,
23
23
  category,
24
- enableBC
24
+ enableBC,
25
+ slug
25
26
  ) {
26
27
  const isApp = appCheck();
27
28
 
@@ -95,6 +96,10 @@ function appendLayoutScripts(
95
96
  if (!category) {
96
97
  category = "news";
97
98
  }
99
+ // Set targeting slug if we have one
100
+ if (slug) {
101
+ window.hnpbid.setTargeting("page", slug);
102
+ }
98
103
  const categoryArray = category.split(",");
99
104
  let i = 1;
100
105
  categoryArray.forEach((cat) => {
@@ -190,4 +195,41 @@ function getFigureWidth(maxWidth) {
190
195
  }
191
196
  }
192
197
 
193
- export { debounce, appendLayoutScripts, formatHDN, getFigureWidth };
198
+ function trackEvent(
199
+ eventType,
200
+ elementName = null,
201
+ elementContent = null,
202
+ elementText = null
203
+ ) {
204
+ 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}`;
208
+ const linkUrl = `${storySettings.PROJECT.SUBFOLDER}/${storySettings.PROJECT.SLUG}`;
209
+ const urlHash = window.HDN.dataLayer.visit.urlHash;
210
+
211
+ let event;
212
+ if (eventType === "Click") {
213
+ event = "hnp_click";
214
+ } else if (eventType === "Impression") {
215
+ event = "hnp_impression";
216
+ }
217
+
218
+ window.dataLayer.push({
219
+ event: event, //REQUIRED; Fixed value
220
+ 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
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
+ export { debounce, appendLayoutScripts, formatHDN, getFigureWidth, trackEvent };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "sfc-utils",
3
- "version": "1.4.163",
3
+ "version": "1.4.165",
4
4
  "author": "ewagstaff <evanjwagstaff@gmail.com>",
5
5
  "dependencies": {
6
6
  "archieml": "^0.4.2",