sfc-utils 1.4.145 → 1.4.146

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.
@@ -2,6 +2,8 @@ import { getBlueconic } from "../../blueconic";
2
2
  import { getBrands3 } from "../../brands3";
3
3
  import { appCheck, blendHDN } from "../../index";
4
4
 
5
+ const currentEnv = process.env.GATSBY_DEPLOY_ENV;
6
+
5
7
  /** Used for resizing the WCM Image */
6
8
  function debounce(fn, ms) {
7
9
  let timer;
@@ -14,8 +16,9 @@ function debounce(fn, ms) {
14
16
  };
15
17
  }
16
18
 
17
- function appendLayoutScripts(isEmbedded, isAdRemoved, marketKey) {
19
+ function appendLayoutScripts(isEmbedded, isAdRemoved, marketKey, category) {
18
20
  const isApp = appCheck();
21
+ console.log("utils current env", currentEnv);
19
22
 
20
23
  // React Helmet is actually terrible and runs these scripts twice, so we are including them async ourselves
21
24
  // Run analytics and resizing scripts right away so we take care of that
@@ -38,11 +41,48 @@ function appendLayoutScripts(isEmbedded, isAdRemoved, marketKey) {
38
41
  }
39
42
 
40
43
  if (!isEmbedded && !isAdRemoved) {
41
- let script = document.createElement("script");
42
- script.type = "text/javascript";
43
- script.id = "adPositionManagerScriptTag";
44
- script.src = "https://aps.hearstnp.com/Scripts/loadAds.js";
45
- document.body.appendChild(script);
44
+ // If category is passed, that means we're supporting HTL
45
+ if (category) {
46
+ // Set ad params
47
+ if (typeof window.HDN !== "undefined") {
48
+ window.HDN.dataLayer.visit = window.HDN.dataLayer.visit || {};
49
+ window.HDN.dataLayer.visit.urlHash = window.location.hash;
50
+ }
51
+ // Get the domain off the URL
52
+ const domain = window.location.origin;
53
+ const fullURL = window.location.href;
54
+ const shortDomain = domain.replace("https://www.", "");
55
+ const script = document.createElement("script");
56
+ script.type = "text/javascript";
57
+ script.src = `https://htlbid.com/v3/${shortDomain}/hnpbid.js`;
58
+ document.body.appendChild(script);
59
+ // Add stylesheet
60
+ const link = document.createElement("link");
61
+ link.rel = "stylesheet";
62
+ link.href = `https://htlbid.com/v3/${shortDomain}/hnpbid.css`;
63
+ document.head.appendChild(link);
64
+ // Add vars
65
+ window.hnpbid = window.hnpbid || {};
66
+ window.hnpbid.cmd = window.hnpbid.cmd || [];
67
+ window.hnpbid.cmd.push(() => {
68
+ window.hnpbid.setTargeting(
69
+ "is_testing",
70
+ currentEnv === "production" ? "no" : "yes"
71
+ ); // Set to "no" for production
72
+ window.hnpbid.setTargeting("is_home", "no"); // Set to "yes" on the homepage
73
+ window.hnpbid.setTargeting("post_id", `${fullURL}`);
74
+ window.hnpbid.setTargeting("category", category || "news");
75
+ // init
76
+ window.hnpbid.layout();
77
+ });
78
+ } else {
79
+ // If no category, this is the old version and we're supporting Juice (expires in Nov 2024)
80
+ let script = document.createElement("script");
81
+ script.type = "text/javascript";
82
+ script.id = "adPositionManagerScriptTag";
83
+ script.src = "https://aps.hearstnp.com/Scripts/loadAds.js";
84
+ document.body.appendChild(script);
85
+ }
46
86
  }
47
87
 
48
88
  // Wait a beat, then add to body so it doesn't mess with the head (which Helmet seems to want to manage)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "sfc-utils",
3
- "version": "1.4.145",
3
+ "version": "1.4.146",
4
4
  "author": "ewagstaff <evanjwagstaff@gmail.com>",
5
5
  "dependencies": {
6
6
  "archieml": "^0.4.2",