sfc-utils 1.4.164 → 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
|
|
|
@@ -195,4 +195,41 @@ function getFigureWidth(maxWidth) {
|
|
|
195
195
|
}
|
|
196
196
|
}
|
|
197
197
|
|
|
198
|
-
|
|
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 };
|