sfc-utils 1.4.91 → 1.4.92

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.
Files changed (2) hide show
  1. package/package.json +1 -1
  2. package/personalize.js +28 -13
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "sfc-utils",
3
- "version": "1.4.91",
3
+ "version": "1.4.92",
4
4
  "author": "ewagstaff <evanjwagstaff@gmail.com>",
5
5
  "dependencies": {
6
6
  "archieml": "^0.4.2",
package/personalize.js CHANGED
@@ -2,19 +2,34 @@
2
2
  const getProfileProperty = (property) => {
3
3
  return new Promise((resolve, reject) => {
4
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
- }
5
+ let attempts = 0;
6
+ const checkForBlueConic = (innerResolve) => {
7
+ if (window.blueConicClient) {
8
+ const profile = window.blueConicClient.profile.getProfile();
9
+ const properties = [property];
10
+ profile.loadValues(properties, this, function () {
11
+ var value = profile.getValue(property);
12
+ // Return a valid result or null
13
+ value = value || null;
14
+ console.log("getProfileProperty VAL", value);
15
+ innerResolve(value);
16
+ });
17
+ } else {
18
+ attempts++;
19
+ if (attempts < 20) {
20
+ // Check for BlueConic every second
21
+ setTimeout(() => {
22
+ checkForBlueConic(innerResolve);
23
+ }, 1000);
24
+ } else {
25
+ innerResolve(
26
+ "Personalize: No BlueConic client found after many attempts"
27
+ );
28
+ }
29
+ }
30
+ };
31
+ // Kick off check
32
+ checkForBlueConic(resolve);
18
33
  } else {
19
34
  resolve("Personalize: No window found");
20
35
  }