sfc-utils 1.4.86 → 1.4.88

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,17 +1,17 @@
1
- import { getBlueconic } from "../../blueconic"
2
- import { getBrands3 } from "../../brands3"
3
- import { appCheck, blendHDN } from "../../index"
1
+ import { getBlueconic } from "../../blueconic";
2
+ import { getBrands3 } from "../../brands3";
3
+ import { appCheck, blendHDN } from "../../index";
4
4
 
5
5
  /** Used for resizing the WCM Image */
6
6
  function debounce(fn, ms) {
7
- let timer
8
- return _ => {
9
- clearTimeout(timer)
10
- timer = setTimeout(_ => {
11
- timer = null
12
- fn.apply(this, arguments)
13
- }, ms)
14
- }
7
+ let timer;
8
+ return (_) => {
9
+ clearTimeout(timer);
10
+ timer = setTimeout((_) => {
11
+ timer = null;
12
+ fn.apply(this, arguments);
13
+ }, ms);
14
+ };
15
15
  }
16
16
 
17
17
  function appendLayoutScripts(isEmbedded, isAdRemoved, marketKey) {
@@ -20,41 +20,44 @@ function appendLayoutScripts(isEmbedded, isAdRemoved, marketKey) {
20
20
  // React Helmet is actually terrible and runs these scripts twice, so we are including them async ourselves
21
21
  // Run analytics and resizing scripts right away so we take care of that
22
22
  if (!isEmbedded) {
23
- let script = document.createElement('script');
24
- script.type = 'text/javascript';
25
- script.src = 'https://nexus.ensighten.com/hearst/news/Bootstrap.js';
23
+ let script = document.createElement("script");
24
+ script.type = "text/javascript";
25
+ script.src = "https://nexus.ensighten.com/hearst/news/Bootstrap.js";
26
26
  document.body.appendChild(script);
27
27
  } else {
28
- let script = document.createElement('script');
29
- script.type = 'text/javascript';
30
- script.src = 'https://projects.sfchronicle.com/shared/js/responsive-child.js';
28
+ let script = document.createElement("script");
29
+ script.type = "text/javascript";
30
+ script.src =
31
+ "https://projects.sfchronicle.com/shared/js/responsive-child.js";
31
32
  document.body.appendChild(script);
32
33
  }
33
34
 
34
35
  if (!isEmbedded && !isAdRemoved) {
35
- let script = document.createElement('script');
36
- script.type = 'text/javascript';
37
- script.id = 'adPositionManagerScriptTag';
38
- script.src = 'https://aps.hearstnp.com/Scripts/loadAds.js';
36
+ let script = document.createElement("script");
37
+ script.type = "text/javascript";
38
+ script.id = "adPositionManagerScriptTag";
39
+ script.src = "https://aps.hearstnp.com/Scripts/loadAds.js";
39
40
  document.body.appendChild(script);
40
41
  }
41
42
 
42
43
  // Wait a beat, then add to body so it doesn't mess with the head (which Helmet seems to want to manage)
43
44
  setTimeout(() => {
44
45
  if (!isEmbedded && !isApp) {
45
- let blueconicURL = getBlueconic(window.location.origin)
46
- let script = document.createElement('script')
47
- script.type = 'text/javascript'
48
- script.defer = true
49
- script.src = blueconicURL
50
- document.body.appendChild(script)
46
+ let blueconicURL = getBlueconic(window.location.origin);
47
+ let script = document.createElement("script");
48
+ script.type = "text/javascript";
49
+ script.defer = true;
50
+ script.src = blueconicURL;
51
+ document.body.appendChild(script);
51
52
 
52
53
  // Init sailthru
53
54
  if (window && window.Sailthru && marketKey) {
54
- window.Sailthru.init({ customerId: getBrands3(marketKey).attributes.sailCustomer })
55
+ window.Sailthru.init({
56
+ customerId: getBrands3(marketKey).attributes.sailCustomer,
57
+ });
55
58
  }
56
59
  }
57
- }, 5000)
60
+ }, 1000);
58
61
  }
59
62
 
60
63
  function formatHDN(isEmbedded, url_add, meta) {
@@ -62,21 +65,21 @@ function formatHDN(isEmbedded, url_add, meta) {
62
65
  const thisBrand = getBrands3(meta.PROJECT.MARKET_KEY);
63
66
 
64
67
  // Combine our settings with what Hearst puts on page
65
- let stringHDN = ''
68
+ let stringHDN = "";
66
69
  if (!isEmbedded) {
67
70
  // Put url_add into a new meta object to pass in
68
- const metaHDN = Object.assign({}, meta)
69
- metaHDN.URL_ADD = url_add
71
+ const metaHDN = Object.assign({}, meta);
72
+ metaHDN.URL_ADD = url_add;
70
73
  // Add sailthru var
71
74
  metaHDN.SAIL_CUST = thisBrand.attributes.sailCustomer;
72
75
  // Make sure this is free on app
73
76
  if (isApp) {
74
- metaHDN.PAYWALL_SETTING = "free"
77
+ metaHDN.PAYWALL_SETTING = "free";
75
78
  }
76
79
  // Allow gift button to appear next to sharebuttons
77
- metaHDN.GIFT_ENABLED = true
78
- let blended = blendHDN(metaHDN)
79
- stringHDN = blended.stringHDN
80
+ metaHDN.GIFT_ENABLED = true;
81
+ let blended = blendHDN(metaHDN);
82
+ stringHDN = blended.stringHDN;
80
83
  }
81
84
  return stringHDN;
82
85
  }
@@ -102,4 +105,4 @@ function getFigureWidth(maxWidth) {
102
105
  }
103
106
  }
104
107
 
105
- export { debounce, appendLayoutScripts, formatHDN, getFigureWidth }
108
+ export { debounce, appendLayoutScripts, formatHDN, getFigureWidth };
@@ -100,7 +100,7 @@ const LayoutHelmet = ({
100
100
  "https://www.seattlepi.com/sites/seattlepi/apple-touch-icon-196x196.png";
101
101
  } else if (MARKET_KEY === "SFC") {
102
102
  favHref =
103
- "https://www.sfchronicle.com/sites/premiumsfgate/apple-touch-icon-152x152.png";
103
+ "https://www.sfchronicle.com/sites/premiumsfgate/favicon-32x32.png";
104
104
  } else if (MARKET_KEY === "Houston") {
105
105
  // NOTE: HC is cursed with a tiny favicon until product can fix the higher res one
106
106
  favHref =
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "sfc-utils",
3
- "version": "1.4.86",
3
+ "version": "1.4.88",
4
4
  "author": "ewagstaff <evanjwagstaff@gmail.com>",
5
5
  "dependencies": {
6
6
  "archieml": "^0.4.2",
package/personalize.js CHANGED
@@ -1,20 +1,23 @@
1
- //
2
1
  // NOTE: This will only work on a deployed URL!
3
2
  const getProfileProperty = (property) => {
4
- if (window) {
5
- if (window.blueConicClient) {
6
- const profile = window.blueConicClient.profile.getProfile();
7
- const properties = [property];
8
- profile.loadValues(properties, this, function () {
9
- var value = profile.getValue(property);
10
- // Return a valid result or null
11
- value = value || null;
12
- return value;
13
- });
14
- } else {
15
- return "Personalize: No BlueConic client found";
3
+ return new Promise((resolve, reject) => {
4
+ if (window) {
5
+ if (window.blueConicClient) {
6
+ const profile = window.blueConicClient.profile.getProfile();
7
+ const properties = [property];
8
+ profile.loadValues(properties, this, function () {
9
+ var value = profile.getValue(property);
10
+ // Return a valid result or null
11
+ value = value || null;
12
+ console.log("getProfileProperty VAL", value);
13
+ resolve(value);
14
+ });
15
+ } else {
16
+ resolve("Personalize: No BlueConic client found");
17
+ }
18
+ resolve("Personalize: No window found");
16
19
  }
17
- }
20
+ });
18
21
  };
19
22
 
20
23
  const setProfileProperty = (property, value) => {