@braze/web-sdk 5.9.1 → 6.1.0

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 (176) hide show
  1. package/index.d.ts +209 -283
  2. package/package.json +1 -1
  3. package/shared-lib/encoding-utils.js +1 -1
  4. package/shared-lib/event-types.js +27 -29
  5. package/shared-lib/guid.js +3 -3
  6. package/shared-lib/indexed-db-adapter.js +22 -22
  7. package/shared-lib/logger.js +18 -18
  8. package/shared-lib/supported-options.js +22 -23
  9. package/src/Banner/banner-factory.js +2 -1
  10. package/src/Banner/banner-provider-factory.js +7 -7
  11. package/src/Banner/banner-provider.js +92 -98
  12. package/src/Banner/banner.js +21 -18
  13. package/src/Banner/display/banner-to-html.js +18 -30
  14. package/src/Banner/display/detect-banner-impressions.js +11 -11
  15. package/src/Banner/get-all-banners.js +5 -5
  16. package/src/Banner/get-banner.js +7 -7
  17. package/src/Banner/index.js +0 -1
  18. package/src/Banner/log-banner-click.js +7 -7
  19. package/src/Banner/log-banner-impressions.js +9 -9
  20. package/src/Banner/request-banners-refresh.js +23 -27
  21. package/src/Banner/subscribe-to-banners-updates.js +9 -9
  22. package/src/Banner/ui/insert-banner.js +10 -10
  23. package/src/Card/card-manager-factory.js +7 -7
  24. package/src/Card/card-manager.js +45 -47
  25. package/src/Card/display/card-display.js +76 -74
  26. package/src/Card/index.js +0 -2
  27. package/src/Card/log-card-dismissal.js +4 -4
  28. package/src/Card/log-content-card-click.js +9 -2
  29. package/src/Card/log-content-card-impressions.js +11 -2
  30. package/src/Card/models/captioned-image.js +21 -21
  31. package/src/Card/models/card.js +116 -110
  32. package/src/Card/models/classic-card.js +21 -21
  33. package/src/Card/models/control-card.js +15 -15
  34. package/src/Card/models/image-only.js +20 -21
  35. package/src/Card/util/card-factory.js +58 -79
  36. package/src/ContentCards/content-cards-provider-factory.js +13 -13
  37. package/src/ContentCards/content-cards-provider.js +148 -148
  38. package/src/ContentCards/content-cards.js +21 -13
  39. package/src/ContentCards/get-cached-content-cards.js +2 -2
  40. package/src/ContentCards/request-content-cards-refresh.js +2 -2
  41. package/src/ContentCards/subscribe-to-content-cards-updates.js +8 -8
  42. package/src/ContentCards/ui/hide-content-cards.js +5 -5
  43. package/src/ContentCards/ui/show-content-cards.js +35 -35
  44. package/src/Core/add-sdk-metadata.js +5 -5
  45. package/src/Core/change-user.js +7 -7
  46. package/src/Core/destroy.js +2 -2
  47. package/src/Core/disable-sdk.js +10 -10
  48. package/src/Core/enable-sdk.js +7 -7
  49. package/src/Core/get-device-id.js +4 -4
  50. package/src/Core/get-user.js +1 -1
  51. package/src/Core/handle-braze-action.js +10 -10
  52. package/src/Core/is-disabled.js +2 -2
  53. package/src/Core/is-initialized.js +1 -1
  54. package/src/Core/log-custom-event.js +18 -18
  55. package/src/Core/log-purchase.js +19 -19
  56. package/src/Core/open-session.js +13 -13
  57. package/src/Core/request-immediate-data-flush.js +1 -1
  58. package/src/Core/set-logger.js +2 -2
  59. package/src/Core/toggle-logging.js +2 -2
  60. package/src/Core/wipe-data.js +9 -9
  61. package/src/FeatureFlags/feature-flag-factory.js +10 -10
  62. package/src/FeatureFlags/feature-flag.js +20 -71
  63. package/src/FeatureFlags/feature-flags-provider-factory.js +7 -7
  64. package/src/FeatureFlags/feature-flags-provider.js +86 -86
  65. package/src/FeatureFlags/get-all-feature-flags.js +3 -3
  66. package/src/FeatureFlags/get-feature-flag.js +3 -3
  67. package/src/FeatureFlags/log-feature-flag-impression.js +8 -8
  68. package/src/FeatureFlags/refresh-feature-flags.js +1 -1
  69. package/src/FeatureFlags/subscribe-to-feature-flags-updates.js +3 -3
  70. package/src/InAppMessage/defer-in-app-message.js +4 -4
  71. package/src/InAppMessage/display/html-message-to-html.js +41 -41
  72. package/src/InAppMessage/display/in-app-message-to-html.js +145 -139
  73. package/src/InAppMessage/display/modal-utils.js +40 -42
  74. package/src/InAppMessage/get-deferred-in-app-message.js +1 -1
  75. package/src/InAppMessage/in-app-message-factory.js +24 -16
  76. package/src/InAppMessage/in-app-message-manager-factory.js +5 -5
  77. package/src/InAppMessage/in-app-message-manager.js +124 -122
  78. package/src/InAppMessage/log-in-app-message-button-click.js +12 -12
  79. package/src/InAppMessage/log-in-app-message-click.js +9 -9
  80. package/src/InAppMessage/log-in-app-message-html-click.js +11 -11
  81. package/src/InAppMessage/log-in-app-message-impression.js +4 -4
  82. package/src/InAppMessage/models/control-message.js +5 -5
  83. package/src/InAppMessage/models/full-screen-message.js +41 -35
  84. package/src/InAppMessage/models/html-message.js +28 -26
  85. package/src/InAppMessage/models/in-app-message-button.js +5 -5
  86. package/src/InAppMessage/models/in-app-message.js +156 -152
  87. package/src/InAppMessage/models/modal-message.js +40 -34
  88. package/src/InAppMessage/models/slide-up-message.js +38 -32
  89. package/src/InAppMessage/models/templated-in-app-message.js +8 -8
  90. package/src/InAppMessage/subscribe-to-in-app-message.js +1 -1
  91. package/src/InAppMessage/ui/automatically-show-in-app-messages.js +3 -3
  92. package/src/InAppMessage/ui/show-in-app-message.js +68 -74
  93. package/src/Push/is-push-blocked.js +2 -2
  94. package/src/Push/is-push-permission-granted.js +2 -2
  95. package/src/Push/is-push-supported.js +2 -2
  96. package/src/Push/push-manager-factory.js +17 -17
  97. package/src/Push/push-manager.js +127 -127
  98. package/src/Push/request-push-permission.js +1 -1
  99. package/src/Push/utils/push-utils.js +25 -15
  100. package/src/User/user-manager.js +20 -20
  101. package/src/User/user.js +60 -61
  102. package/src/common/base-provider.js +1 -1
  103. package/src/common/content-cards-display.js +211 -0
  104. package/src/common/event-logger.js +12 -12
  105. package/src/common/properties-base.js +56 -0
  106. package/src/index.js +0 -1
  107. package/src/l10n/l10n-manager-factory.js +10 -10
  108. package/src/l10n/l10n-manager.js +7 -7
  109. package/src/managers/auth-manager.js +36 -36
  110. package/src/managers/braze-instance.js +184 -185
  111. package/src/managers/device-manager.js +26 -26
  112. package/src/managers/network-manager.js +194 -193
  113. package/src/managers/server-config-manager.js +75 -75
  114. package/src/managers/session-manager.js +29 -29
  115. package/src/managers/storage-manager-factory.js +13 -13
  116. package/src/managers/storage-manager.js +162 -164
  117. package/src/managers/subscription-manager.js +12 -12
  118. package/src/managers/utils.js +1 -1
  119. package/src/models/backend-errors.js +5 -5
  120. package/src/models/braze-event.js +16 -16
  121. package/src/models/device.js +3 -3
  122. package/src/models/identifier.js +8 -8
  123. package/src/models/push-token.js +10 -10
  124. package/src/models/request-result.js +4 -4
  125. package/src/models/server-config.js +33 -33
  126. package/src/request-controller.js +193 -192
  127. package/src/triggers/models/custom-event-data.js +7 -7
  128. package/src/triggers/models/custom-event-property-data.js +8 -8
  129. package/src/triggers/models/filter-set.js +8 -8
  130. package/src/triggers/models/filter.js +43 -43
  131. package/src/triggers/models/in-app-message-click-data.js +4 -4
  132. package/src/triggers/models/purchase-data.js +2 -2
  133. package/src/triggers/models/purchase-property-data.js +6 -6
  134. package/src/triggers/models/push-click-data.js +2 -2
  135. package/src/triggers/models/trigger-condition.js +52 -52
  136. package/src/triggers/models/trigger-events.js +4 -4
  137. package/src/triggers/models/trigger.js +19 -19
  138. package/src/triggers/triggers-provider-factory.js +14 -14
  139. package/src/triggers/triggers-provider.js +70 -70
  140. package/src/ui/js/attach-css.js +3 -3
  141. package/src/ui/js/banner-css.js +1 -1
  142. package/src/ui/js/iam-css.js +1 -1
  143. package/src/ui/js/load-font-awesome.js +2 -2
  144. package/src/util/base-device-parser.js +4 -4
  145. package/src/util/braze-actions.js +12 -18
  146. package/src/util/browser-detector.js +27 -20
  147. package/src/util/client-hints-parser.js +8 -8
  148. package/src/util/code-utils.js +2 -2
  149. package/src/util/component-utils.js +14 -14
  150. package/src/util/deprecation-utils.js +2 -2
  151. package/src/util/device-constants.js +5 -5
  152. package/src/util/dom-utils.js +9 -9
  153. package/src/util/html-display-utils.js +38 -38
  154. package/src/util/key-codes.js +1 -1
  155. package/src/util/net.js +12 -12
  156. package/src/util/request-header-utils.js +22 -22
  157. package/src/util/string-utils.js +2 -2
  158. package/src/util/user-agent-parser.js +17 -17
  159. package/src/util/validation-utils.js +28 -28
  160. package/src/util/window-utils.js +2 -2
  161. package/src/Card/log-card-click.js +0 -11
  162. package/src/Card/log-card-impressions.js +0 -13
  163. package/src/Feed/feed-provider-factory.js +0 -18
  164. package/src/Feed/feed-provider.js +0 -90
  165. package/src/Feed/feed.js +0 -20
  166. package/src/Feed/get-cached-feed.js +0 -5
  167. package/src/Feed/index.js +0 -8
  168. package/src/Feed/log-feed-displayed.js +0 -7
  169. package/src/Feed/request-feed-refresh.js +0 -5
  170. package/src/Feed/subscribe-to-feed-updates.js +0 -5
  171. package/src/Feed/types.js +0 -1
  172. package/src/Feed/ui/hide-feed.js +0 -7
  173. package/src/Feed/ui/show-feed.js +0 -96
  174. package/src/Feed/ui/toggle-feed.js +0 -8
  175. package/src/common/base-feed.js +0 -29
  176. package/src/common/feed-display.js +0 -211
@@ -1,8 +1,8 @@
1
- import Oe from "./base-device-parser.js";
2
- import { Browsers as oi, OperatingSystems as so } from "./device-constants.js";
3
- export default class gi extends Oe {
1
+ import ge from "./base-device-parser.js";
2
+ import { Browsers as gi, OperatingSystems as so } from "./device-constants.js";
3
+ export default class oi extends ge {
4
4
  constructor() {
5
- super(), (this.fd = gi.Bc(navigator.userAgent || ""));
5
+ super(), (this.fd = oi.gc(navigator.userAgent || ""));
6
6
  }
7
7
  ef() {
8
8
  return this.fd[0] || "Unknown Browser";
@@ -10,19 +10,19 @@ export default class gi extends Oe {
10
10
  ff() {
11
11
  return this.fd[1] || "Unknown Version";
12
12
  }
13
- ec(r) {
13
+ Ja(r) {
14
14
  for (let n = 0; n < r.length; n++) {
15
15
  const e = r[n].string;
16
- let i = gi.nf(e, r[n]);
16
+ let i = oi.nf(e, r[n]);
17
17
  if (i)
18
18
  return (
19
- i === so.Pg && navigator.maxTouchPoints > 1 && (i = so.ao),
19
+ i === so.Og && navigator.maxTouchPoints > 1 && (i = so.co),
20
20
  Promise.resolve(i)
21
21
  );
22
22
  }
23
23
  return Promise.resolve(navigator.platform);
24
24
  }
25
- static Bc(r) {
25
+ static gc(r) {
26
26
  let n,
27
27
  e =
28
28
  r.match(
@@ -41,37 +41,37 @@ export default class gi extends Oe {
41
41
  if (r.match(/\b(Roku)\b/)) return ["Roku", null];
42
42
  if (r.match(/\bAFTM\b/)) return ["Amazon Fire Stick", null];
43
43
  if (
44
- e[1] === oi.rO &&
44
+ e[1] === gi.rO &&
45
45
  ((n = r.match(/\b(OPR|Edge|EdgA|Edg|UCBrowser)\/(\.?\d+(\.\d+)*)/)),
46
46
  null != n)
47
47
  )
48
48
  return (
49
49
  (n = n.slice(1)),
50
- (n[0] = n[0].replace("OPR", oi.oO)),
51
- (n[0] = n[0].replace("EdgA", oi.eO)),
52
- "Edg" === n[0] && (n[0] = oi.eO),
50
+ (n[0] = n[0].replace("OPR", gi.oO)),
51
+ (n[0] = n[0].replace("EdgA", gi.eO)),
52
+ "Edg" === n[0] && (n[0] = gi.eO),
53
53
  [n[0], n[1]]
54
54
  );
55
55
  if (
56
- e[1] === oi.Bg &&
56
+ e[1] === gi.xg &&
57
57
  ((n = r.match(/\b(EdgiOS)\/(\.?\d+(\.\d+)*)/)), null != n)
58
58
  )
59
59
  return (
60
- (n = n.slice(1)), (n[0] = n[0].replace("EdgiOS", oi.eO)), [n[0], n[1]]
60
+ (n = n.slice(1)), (n[0] = n[0].replace("EdgiOS", gi.eO)), [n[0], n[1]]
61
61
  );
62
62
  if (
63
63
  ((e = e[2] ? [e[1], e[2]] : [null, null]),
64
- e[0] === oi.Bg &&
64
+ e[0] === gi.xg &&
65
65
  null != (n = r.match(/version\/(\.?\d+(\.\d+)*)/i)) &&
66
66
  e.splice(1, 1, n[1]),
67
67
  null != (n = r.match(/\b(UCBrowser)\/(\.?\d+(\.\d+)*)/)) &&
68
68
  e.splice(1, 1, n[2]),
69
- e[0] === oi.oO && null != (n = r.match(/mini\/(\.?\d+(\.\d+)*)/i)))
69
+ e[0] === gi.oO && null != (n = r.match(/mini\/(\.?\d+(\.\d+)*)/i)))
70
70
  )
71
71
  return ["Opera Mini", n[1] || ""];
72
72
  if (e[0]) {
73
73
  const r = e[0].toLowerCase();
74
- "crios" === r && (e[0] = oi.rO),
74
+ "crios" === r && (e[0] = gi.rO),
75
75
  "tizen" === r && ((e[0] = "Samsung Smart TV"), (e[1] = null)),
76
76
  "samsungbrowser" === r && (e[0] = "Samsung Browser");
77
77
  }
@@ -1,14 +1,14 @@
1
1
  import {
2
- isArray as z,
2
+ isArray as D,
3
3
  isDate as Nt,
4
- isObject as yt,
4
+ isObject as It,
5
5
  keys as C,
6
6
  } from "./code-utils.js";
7
7
  import { getByteLength as er } from "./string-utils.js";
8
- import { logger as N } from "../../shared-lib/index.js";
9
- import { toValidBackendTimeString as Ft } from "./date-utils.js";
8
+ import { logger as E } from "../../shared-lib/index.js";
9
+ import { toValidBackendTimeString as Lt } from "./date-utils.js";
10
10
  import { BRAZE_ACTIONS as oo } from "./braze-actions.js";
11
- import { SET_CUSTOM_USER_ATTRIBUTE_STRING as Dt } from "../common/constants.js";
11
+ import { SET_CUSTOM_USER_ATTRIBUTE_STRING as Ft } from "../common/constants.js";
12
12
  export const CUSTOM_DATA_REGEX = /^[^\x00-\x1F\x22]+$/;
13
13
  export const CUSTOM_ATTRIBUTE_SPECIAL_CHARS_REGEX = /[$.]/;
14
14
  export const CUSTOM_ATTRIBUTE_RESERVED_OPERATORS = [
@@ -35,14 +35,14 @@ export function validateCustomString(t, e, r) {
35
35
  null != t &&
36
36
  "string" == typeof t &&
37
37
  ("" === t || null != t.match(CUSTOM_DATA_REGEX));
38
- return n || N.error(`Cannot ${e} because ${r} "${t}" is invalid.`), n;
38
+ return n || E.error(`Cannot ${e} because ${r} "${t}" is invalid.`), n;
39
39
  }
40
40
  export function validateCustomAttributeKey(t) {
41
41
  return (
42
42
  null != t &&
43
43
  t.match(CUSTOM_ATTRIBUTE_SPECIAL_CHARS_REGEX) &&
44
44
  -1 === CUSTOM_ATTRIBUTE_RESERVED_OPERATORS.indexOf(t) &&
45
- N.warn("Custom attribute keys cannot contain '$' or '.'"),
45
+ E.warn("Custom attribute keys cannot contain '$' or '.'"),
46
46
  validateCustomString(t, "set custom user attribute", "the given key")
47
47
  );
48
48
  }
@@ -55,22 +55,22 @@ export function validatePropertyType(t) {
55
55
  export function _validateNestedProperties(t, e, r) {
56
56
  const n = -1 !== r;
57
57
  if (n && r > 50)
58
- return N.error("Nested attributes cannot be more than 50 levels deep."), !1;
58
+ return E.error("Nested attributes cannot be more than 50 levels deep."), !1;
59
59
  const o = n ? r + 1 : -1;
60
- if (z(t) && z(e)) {
60
+ if (D(t) && D(e)) {
61
61
  for (let r = 0; r < t.length && r < e.length; r++)
62
62
  if (
63
- (Nt(t[r]) && (e[r] = Ft(t[r])),
63
+ (Nt(t[r]) && (e[r] = Lt(t[r])),
64
64
  !_validateNestedProperties(t[r], e[r], o))
65
65
  )
66
66
  return !1;
67
67
  } else {
68
- if (!yt(t)) return validatePropertyType(t);
68
+ if (!It(t)) return validatePropertyType(t);
69
69
  for (const r of C(t)) {
70
70
  const i = t[r];
71
71
  if (n && !validateCustomAttributeKey(r)) return !1;
72
72
  if (Nt(i)) {
73
- e[r] = Ft(i);
73
+ e[r] = Lt(i);
74
74
  }
75
75
  if (!_validateNestedProperties(i, e[r], o)) return !1;
76
76
  }
@@ -81,29 +81,29 @@ export function _validateEventPropertyValue(t, e, r, n, o) {
81
81
  let i;
82
82
  return (
83
83
  (i =
84
- yt(t) || z(t)
84
+ It(t) || D(t)
85
85
  ? _validateNestedProperties(t, e, o ? 1 : -1)
86
86
  : validatePropertyType(t)),
87
- i || N.error(`Cannot ${r} because ${n} "${t}" is invalid.`),
87
+ i || E.error(`Cannot ${r} because ${n} "${t}" is invalid.`),
88
88
  i
89
89
  );
90
90
  }
91
91
  export function validateStandardString(t, e, r, n = !1) {
92
92
  const o = "string" == typeof t || (null === t && n);
93
- return o || N.error(`Cannot ${e} because ${r} "${t}" is invalid.`), o;
93
+ return o || E.error(`Cannot ${e} because ${r} "${t}" is invalid.`), o;
94
94
  }
95
95
  export function validateCustomProperties(t, e, r, n, o) {
96
- if ((null == t && (t = {}), "object" != typeof t || z(t)))
96
+ if ((null == t && (t = {}), "object" != typeof t || D(t)))
97
97
  return (
98
- N.error(`${e} requires that ${r} be an object. Ignoring ${o}.`),
98
+ E.error(`${e} requires that ${r} be an object. Ignoring ${o}.`),
99
99
  [!1, null]
100
100
  );
101
101
  let i, a;
102
- e === Dt ? ((i = 76800), (a = "75KB")) : ((i = 51200), (a = "50KB"));
102
+ e === Ft ? ((i = 76800), (a = "75KB")) : ((i = 51200), (a = "50KB"));
103
103
  const s = JSON.stringify(t);
104
104
  if (er(s) > i)
105
105
  return (
106
- N.error(
106
+ E.error(
107
107
  `Could not ${n} because ${r} was greater than the max size of ${a}.`,
108
108
  ),
109
109
  [!1, null]
@@ -113,27 +113,27 @@ export function validateCustomProperties(t, e, r, n, o) {
113
113
  u = JSON.parse(s);
114
114
  } catch (t) {
115
115
  return (
116
- N.error(`Could not ${n} because ${r} did not contain valid JSON.`),
116
+ E.error(`Could not ${n} because ${r} did not contain valid JSON.`),
117
117
  [!1, null]
118
118
  );
119
119
  }
120
120
  for (const r in t) {
121
- if (e === Dt && !validateCustomAttributeKey(r)) return [!1, null];
121
+ if (e === Ft && !validateCustomAttributeKey(r)) return [!1, null];
122
122
  if (!validateCustomString(r, n, `the ${o} property name`))
123
123
  return [!1, null];
124
124
  const i = t[r];
125
- if (e !== Dt && null == i) {
125
+ if (e !== Ft && null == i) {
126
126
  delete t[r], delete u[r];
127
127
  continue;
128
128
  }
129
- Nt(i) && (u[r] = Ft(i));
129
+ Nt(i) && (u[r] = Lt(i));
130
130
  if (
131
131
  !_validateEventPropertyValue(
132
132
  i,
133
133
  u[r],
134
134
  n,
135
135
  `the ${o} property "${r}"`,
136
- e === Dt,
136
+ e === Ft,
137
137
  )
138
138
  )
139
139
  return [!1, null];
@@ -144,7 +144,7 @@ export function validateCustomAttributeArrayType(t, e) {
144
144
  let r = !1,
145
145
  n = !1;
146
146
  const o = () => {
147
- N.error(
147
+ E.error(
148
148
  "Custom attribute arrays must be either string arrays or object arrays.",
149
149
  );
150
150
  };
@@ -161,12 +161,12 @@ export function validateCustomAttributeArrayType(t, e) {
161
161
  return [!1, !1];
162
162
  r = !0;
163
163
  } else {
164
- if (!yt(i)) return o(), [!1, !1];
164
+ if (!It(i)) return o(), [!1, !1];
165
165
  if (r) return o(), [!1, !1];
166
166
  if (
167
167
  !validateCustomProperties(
168
168
  i,
169
- Dt,
169
+ Ft,
170
170
  "attribute value",
171
171
  `set custom user attribute "${t}"`,
172
172
  "custom user attribute",
@@ -196,8 +196,8 @@ export function isValidBrazeActionJson(t) {
196
196
  case oo.types.removeFromSubscriptionGroup:
197
197
  case oo.types.addToCustomAttributeArray:
198
198
  case oo.types.removeFromCustomAttributeArray:
199
- case oo.types.co:
200
199
  case oo.types.mo:
200
+ case oo.types.uo:
201
201
  if (oo.properties.so in t) return !0;
202
202
  break;
203
203
  case oo.types.requestPushPermission:
@@ -29,6 +29,6 @@ export function _getCurrentUrl() {
29
29
  export const WindowUtils = {
30
30
  openUri: _openUri,
31
31
  Uo: _isPhone,
32
- No: _getOrientation,
33
- $a: _getCurrentUrl,
32
+ $o: _getOrientation,
33
+ Ca: _getCurrentUrl,
34
34
  };
@@ -1,11 +0,0 @@
1
- import { Card } from "./models/index.js";
2
- import _ from "./card-manager-factory.js";
3
- import { MUST_BE_CARD_WARNING_SUFFIX as L } from "../common/constants.js";
4
- import r from "../managers/braze-instance.js";
5
- import { logger as N } from "../../shared-lib/index.js";
6
- export function logCardClick(o, m) {
7
- return (
8
- !!r.rr() &&
9
- (o instanceof Card ? _.ea().logClick(o, m).tt : (N.error("card " + L), !1))
10
- );
11
- }
@@ -1,13 +0,0 @@
1
- import { Card } from "./models/index.js";
2
- import _ from "./card-manager-factory.js";
3
- import r from "../managers/braze-instance.js";
4
- import { isArray as z } from "../util/code-utils.js";
5
- import { MUST_BE_CARD_WARNING_SUFFIX as L } from "../common/constants.js";
6
- import { logger as N } from "../../shared-lib/index.js";
7
- export function logCardImpressions(o, n) {
8
- if (!r.rr()) return !1;
9
- if (!z(o)) return N.error("cards must be an array"), !1;
10
- for (const r of o)
11
- if (!(r instanceof Card)) return N.error(`Each card in cards ${L}`), !1;
12
- return _.ea().Xt(o, n).tt;
13
- }
@@ -1,18 +0,0 @@
1
- import r from "../managers/braze-instance.js";
2
- import re from "./feed-provider.js";
3
- const ie = {
4
- l: !1,
5
- provider: null,
6
- m: () => (
7
- ie.p(),
8
- ie.provider || ((ie.provider = new re(r.j(), r.rn())), r._(ie.provider)),
9
- ie.provider
10
- ),
11
- p: () => {
12
- ie.l || (r.h(ie), (ie.l = !0));
13
- },
14
- destroy: () => {
15
- (ie.provider = null), (ie.l = !1);
16
- },
17
- };
18
- export default ie;
@@ -1,90 +0,0 @@
1
- import t from "../common/base-provider.js";
2
- import r from "../managers/braze-instance.js";
3
- import Feed from "./feed.js";
4
- import {
5
- newCardFromFeedJson as lt,
6
- newCardFromSerializedValue as tt,
7
- } from "../Card/util/card-factory.js";
8
- import { rehydrateDateAfterJsonization as V } from "../util/date-utils.js";
9
- import { STORAGE_KEYS as s } from "../managers/storage-manager.js";
10
- import u from "../managers/subscription-manager.js";
11
- export default class re extends t {
12
- constructor(t, s) {
13
- super(),
14
- (this.C = t),
15
- (this.Fi = s),
16
- (this.cards = []),
17
- (this.xi = null),
18
- (this.C = t),
19
- (this.Fi = s),
20
- (this.Ts = new u()),
21
- r.F(this.Ts),
22
- this.Ds();
23
- }
24
- Ds() {
25
- let t = [];
26
- this.C && (t = this.C.ft(s.gt.qi) || []);
27
- const i = [];
28
- for (let s = 0; s < t.length; s++) {
29
- const e = tt(t[s]);
30
- null != e && i.push(e);
31
- }
32
- (this.cards = i), this.C && (this.xi = V(this.C.ft(s.gt.zi)));
33
- }
34
- Ui(t) {
35
- const i = [];
36
- let e = null,
37
- r = {};
38
- this.C && (r = this.C.ft(s.gt.Zt) || {});
39
- const h = {};
40
- for (let s = 0; s < t.length; s++) {
41
- e = t[s];
42
- const o = lt(e);
43
- if (null != o) {
44
- const t = o.id;
45
- t && r[t] && ((o.viewed = !0), (h[t] = !0)), i.push(o);
46
- }
47
- }
48
- (this.cards = i),
49
- this.Ws(),
50
- (this.xi = new Date()),
51
- this.C && (this.C.Bt(s.gt.Zt, h), this.C.Bt(s.gt.zi, this.xi));
52
- }
53
- Ws() {
54
- var t;
55
- const i = [];
56
- for (let t = 0; t < this.cards.length; t++) i.push(this.cards[t].bt());
57
- null === (t = this.C) || void 0 === t || t.Bt(s.gt.qi, i);
58
- }
59
- U(t) {
60
- null != t &&
61
- t.feed &&
62
- (this.Ds(),
63
- this.Ui(t.feed),
64
- this.Ts.X(new Feed(this.cards.slice(), this.xi)));
65
- }
66
- ki() {
67
- this.Ds();
68
- const t = [],
69
- s = new Date();
70
- for (let i = 0; i < this.cards.length; i++) {
71
- const e = this.cards[i].expiresAt;
72
- let r = !0;
73
- null != e && (r = e >= s), r && t.push(this.cards[i]);
74
- }
75
- return new Feed(t, this.xi);
76
- }
77
- bi() {
78
- this.Fi && this.Fi.requestFeedRefresh();
79
- }
80
- qt(t) {
81
- return this.Ts.Dt(t);
82
- }
83
- clearData(t) {
84
- null == t && (t = !1),
85
- (this.cards = []),
86
- (this.xi = null),
87
- t && this.C && (this.C.Ut(s.gt.qi), this.C.Ut(s.gt.zi)),
88
- this.Ts.X(new Feed(this.cards.slice(), this.xi));
89
- }
90
- }
package/src/Feed/feed.js DELETED
@@ -1,20 +0,0 @@
1
- import rr from "../common/base-feed.js";
2
- import { logCardClick, logCardImpressions } from "../Card/index.js";
3
- import { requestFeedRefresh } from "./request-feed-refresh.js";
4
- export default class Feed extends rr {
5
- constructor(r, e) {
6
- super(r, e);
7
- }
8
- logCardImpressions(r) {
9
- logCardImpressions(r, !1);
10
- }
11
- logCardClick(r) {
12
- return logCardClick(r, !1);
13
- }
14
- sr() {
15
- requestFeedRefresh();
16
- }
17
- nr() {
18
- return !1;
19
- }
20
- }
@@ -1,5 +0,0 @@
1
- import r from "../managers/braze-instance.js";
2
- import ie from "./feed-provider-factory.js";
3
- export function getCachedFeed() {
4
- if (r.rr()) return ie.m().ki();
5
- }
package/src/Feed/index.js DELETED
@@ -1,8 +0,0 @@
1
- export { default as Feed } from "./feed.js";
2
- export { getCachedFeed } from "./get-cached-feed.js";
3
- export { destroyFeed } from "./ui/hide-feed.js";
4
- export { logFeedDisplayed } from "./log-feed-displayed.js";
5
- export { requestFeedRefresh } from "./request-feed-refresh.js";
6
- export { showFeed } from "./ui/show-feed.js";
7
- export { subscribeToFeedUpdates } from "./subscribe-to-feed-updates.js";
8
- export { toggleFeed } from "./ui/toggle-feed.js";
@@ -1,7 +0,0 @@
1
- import r from "../managers/braze-instance.js";
2
- import { InternalEventTypes as dr } from "../../shared-lib/index.js";
3
- export function logFeedDisplayed() {
4
- var e;
5
- if (r.rr())
6
- return null === (e = r.g()) || void 0 === e ? void 0 : e.zr(dr.Fr).tt;
7
- }
@@ -1,5 +0,0 @@
1
- import r from "../managers/braze-instance.js";
2
- import ie from "./feed-provider-factory.js";
3
- export function requestFeedRefresh() {
4
- if (r.rr()) return ie.m().bi();
5
- }
@@ -1,5 +0,0 @@
1
- import r from "../managers/braze-instance.js";
2
- import ie from "./feed-provider-factory.js";
3
- export function subscribeToFeedUpdates(e) {
4
- if (r.rr()) return ie.m().qt(e);
5
- }
package/src/Feed/types.js DELETED
@@ -1 +0,0 @@
1
- export {};
@@ -1,7 +0,0 @@
1
- import r from "../../managers/braze-instance.js";
2
- import { destroyFeedHtml as ee } from "../../common/feed-display.js";
3
- export function destroyFeed() {
4
- if (!r.rr()) return;
5
- const e = document.querySelectorAll(".ab-feed");
6
- for (let o = 0; o < e.length; o++) ee(e[o]);
7
- }
@@ -1,96 +0,0 @@
1
- import r, { OPTIONS as w } from "../../managers/braze-instance.js";
2
- import {
3
- destroyFeedHtml as ee,
4
- detectFeedImpressions as nn,
5
- feedToHtml as tn,
6
- LAST_REQUESTED_REFRESH_DATA_ATTRIBUTE as en,
7
- refreshFeed as on,
8
- registerFeedSubscriptionId as rn,
9
- updateFeedCards as an,
10
- } from "../../common/feed-display.js";
11
- import { Feed, logFeedDisplayed, subscribeToFeedUpdates } from "../index.js";
12
- import ie from "../feed-provider-factory.js";
13
- import { intersection as te } from "../../util/code-utils.js";
14
- import { setCardHeight as sn } from "../../Card/display/card-display.js";
15
- import { setupFeedUI as fn } from "../../ui/js/index.js";
16
- import { logger as N } from "../../../shared-lib/index.js";
17
- export function showFeed(e, t, n) {
18
- if (!r.rr()) return;
19
- fn();
20
- const o = (e, t) => {
21
- if (null == t) return e;
22
- const n = [];
23
- for (let e = 0; e < t.length; e++) n.push(t[e].toLowerCase());
24
- const o = [];
25
- for (let t = 0; t < e.length; t++) {
26
- const r = [],
27
- i = e[t].categories || [];
28
- for (let e = 0; e < i.length; e++) r.push(i[e].toLowerCase());
29
- te(r, n).length > 0 && o.push(e[t]);
30
- }
31
- return o;
32
- },
33
- i = r.ee(w.tn) || r.ee(w.en) || !1;
34
- let s = !1;
35
- null == e && ((e = document.body), (s = !0));
36
- let l,
37
- f = !1;
38
- null == t
39
- ? ((l = ie.m().ki()),
40
- an(l, o(l.cards, n), l.lastUpdated, null, i),
41
- (f = !0))
42
- : (l = new Feed(o(t, n), new Date()));
43
- const a = tn(l, i, s);
44
- if (f) {
45
- (null == l.lastUpdated ||
46
- new Date().valueOf() - l.lastUpdated.valueOf() > Feed.dr) &&
47
- (N.info(
48
- `Cached feed was older than max TTL of ${Feed.dr} ms, requesting an update from the server.`,
49
- ),
50
- on(l, a));
51
- const e = new Date().valueOf(),
52
- t = subscribeToFeedUpdates(function (t) {
53
- const r = a.querySelectorAll(".ab-refresh-button")[0];
54
- if (null != r) {
55
- let t = 500;
56
- t -= new Date().valueOf() - e;
57
- const n = a.getAttribute(en);
58
- if (n) {
59
- const e = parseInt(n);
60
- isNaN(e) || (t -= new Date().valueOf() - e);
61
- }
62
- setTimeout(
63
- function () {
64
- r.className = r.className.replace(/fa-spin/g, "");
65
- },
66
- Math.max(t, 0),
67
- );
68
- }
69
- an(l, o(t.cards, n), t.lastUpdated, a, i);
70
- });
71
- rn(t, a);
72
- }
73
- const u = (e) => {
74
- const t = e.querySelectorAll(".ab-feed");
75
- let n = null;
76
- for (let o = 0; o < t.length; o++) t[o].parentNode === e && (n = t[o]);
77
- null != n
78
- ? (ee(n), n.parentNode && n.parentNode.replaceChild(a, n))
79
- : e.appendChild(a),
80
- setTimeout(function () {
81
- a.className = a.className.replace("ab-hide", "ab-show");
82
- }, 0),
83
- s && a.focus(),
84
- logFeedDisplayed(),
85
- nn(l, a),
86
- l && sn(l.cards, e);
87
- };
88
- var d;
89
- null != e
90
- ? u(e)
91
- : (window.onload =
92
- ((d = window.onload),
93
- function () {
94
- "function" == typeof d && d(new Event("oldLoad")), u(document.body);
95
- }));
96
- }
@@ -1,8 +0,0 @@
1
- import r from "../../managers/braze-instance.js";
2
- import { destroyFeed, showFeed } from "../index.js";
3
- export function toggleFeed(e, o, n) {
4
- r.rr() &&
5
- (document.querySelectorAll(".ab-feed").length > 0
6
- ? destroyFeed()
7
- : showFeed(e, o, n));
8
- }
@@ -1,29 +0,0 @@
1
- import { logger as N } from "../../shared-lib/index.js";
2
- import { ControlCard } from "../Card/index.js";
3
- export const FEED_ANIMATION_DURATION = 500;
4
- export default class rr {
5
- constructor(s, e) {
6
- (this.cards = s),
7
- (this.lastUpdated = e),
8
- (this.cards = s),
9
- (this.lastUpdated = e);
10
- }
11
- getUnreadCardCount() {
12
- let s = 0;
13
- for (const e of this.cards) e.viewed || e instanceof ControlCard || s++;
14
- return s;
15
- }
16
- nr() {
17
- N.error("Must be implemented in a subclass");
18
- }
19
- logCardImpressions(s) {
20
- N.error("Must be implemented in a subclass");
21
- }
22
- logCardClick(s) {
23
- N.error("Must be implemented in a subclass");
24
- }
25
- sr() {
26
- N.error("Must be implemented in a subclass");
27
- }
28
- }
29
- (rr.dr = 6e4), (rr.Ih = 500), (rr.Ro = 1e4);