@braze/web-sdk 5.3.2 → 5.5.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 (96) hide show
  1. package/index.d.ts +20 -4
  2. package/package.json +1 -1
  3. package/shared-lib/event-types.js +12 -12
  4. package/shared-lib/indexed-db-adapter.js +14 -14
  5. package/shared-lib/logger.js +2 -2
  6. package/shared-lib/supported-options.js +10 -9
  7. package/src/Card/card-manager.js +46 -42
  8. package/src/Card/display/card-display.js +59 -58
  9. package/src/Card/models/card.js +61 -55
  10. package/src/Card/models/classic-card.js +1 -1
  11. package/src/Card/models/control-card.js +1 -1
  12. package/src/Card/models/image-only.js +1 -1
  13. package/src/Card/util/card-factory.js +20 -20
  14. package/src/ContentCards/content-cards-provider.js +140 -140
  15. package/src/ContentCards/get-cached-content-cards.js +1 -1
  16. package/src/ContentCards/request-content-cards-refresh.js +1 -1
  17. package/src/ContentCards/subscribe-to-content-cards-updates.js +4 -4
  18. package/src/ContentCards/ui/show-content-cards.js +3 -3
  19. package/src/Core/disable-sdk.js +2 -2
  20. package/src/Core/enable-sdk.js +2 -2
  21. package/src/Core/index.js +1 -0
  22. package/src/Core/is-initialized.js +4 -0
  23. package/src/Core/log-custom-event.js +14 -14
  24. package/src/Core/log-purchase.js +8 -8
  25. package/src/Core/open-session.js +4 -4
  26. package/src/Core/wipe-data.js +2 -2
  27. package/src/FeatureFlags/feature-flag-factory.js +5 -5
  28. package/src/FeatureFlags/feature-flag.js +1 -1
  29. package/src/FeatureFlags/feature-flags-provider.js +74 -74
  30. package/src/FeatureFlags/get-all-feature-flags.js +2 -2
  31. package/src/FeatureFlags/get-feature-flag.js +2 -2
  32. package/src/FeatureFlags/log-feature-flag-impression.js +12 -12
  33. package/src/FeatureFlags/subscribe-to-feature-flags-updates.js +2 -2
  34. package/src/Feed/feed-provider.js +29 -29
  35. package/src/Feed/get-cached-feed.js +1 -1
  36. package/src/Feed/request-feed-refresh.js +1 -1
  37. package/src/Feed/subscribe-to-feed-updates.js +1 -1
  38. package/src/Feed/ui/show-feed.js +1 -1
  39. package/src/InAppMessage/display/in-app-message-to-html.js +64 -62
  40. package/src/InAppMessage/in-app-message-manager.js +63 -63
  41. package/src/InAppMessage/log-in-app-message-button-click.js +2 -2
  42. package/src/InAppMessage/log-in-app-message-click.js +2 -2
  43. package/src/InAppMessage/log-in-app-message-html-click.js +2 -2
  44. package/src/InAppMessage/log-in-app-message-impression.js +1 -1
  45. package/src/InAppMessage/models/full-screen-message.js +10 -10
  46. package/src/InAppMessage/models/html-message.js +13 -13
  47. package/src/InAppMessage/models/in-app-message-button.js +4 -4
  48. package/src/InAppMessage/models/in-app-message.js +59 -59
  49. package/src/InAppMessage/models/modal-message.js +9 -9
  50. package/src/InAppMessage/models/slide-up-message.js +11 -11
  51. package/src/InAppMessage/models/templated-in-app-message.js +8 -8
  52. package/src/InAppMessage/ui/show-in-app-message.js +42 -40
  53. package/src/Push/push-manager-factory.js +5 -4
  54. package/src/Push/push-manager.js +77 -89
  55. package/src/Push/utils/push-utils.js +4 -4
  56. package/src/User/user-manager.js +8 -8
  57. package/src/User/user.js +29 -29
  58. package/src/common/base-provider.js +1 -1
  59. package/src/common/event-logger.js +11 -11
  60. package/src/common/feed-display.js +18 -17
  61. package/src/l10n/l10n-manager-factory.js +7 -7
  62. package/src/l10n/l10n-manager.js +15 -5
  63. package/src/managers/auth-manager.js +9 -9
  64. package/src/managers/braze-instance.js +89 -87
  65. package/src/managers/device-manager.js +17 -17
  66. package/src/managers/network-manager.js +130 -130
  67. package/src/managers/server-config-manager.js +24 -24
  68. package/src/managers/session-manager.js +12 -12
  69. package/src/managers/storage-manager-factory.js +1 -1
  70. package/src/managers/storage-manager.js +31 -31
  71. package/src/managers/subscription-manager.js +2 -2
  72. package/src/models/backend-errors.js +5 -5
  73. package/src/models/braze-event.js +4 -4
  74. package/src/models/device.js +2 -2
  75. package/src/models/request-result.js +1 -1
  76. package/src/models/server-config.js +5 -5
  77. package/src/request-controller.js +130 -130
  78. package/src/triggers/models/filter.js +9 -9
  79. package/src/triggers/models/in-app-message-click-data.js +8 -8
  80. package/src/triggers/models/push-click-data.js +3 -3
  81. package/src/triggers/models/trigger-condition.js +27 -27
  82. package/src/triggers/models/trigger-events.js +1 -1
  83. package/src/triggers/models/trigger.js +7 -7
  84. package/src/triggers/triggers-provider.js +29 -29
  85. package/src/ui/js/attach-css.js +1 -1
  86. package/src/ui/js/feed-css.js +1 -1
  87. package/src/ui/js/iam-css.js +1 -1
  88. package/src/util/base-device-parser.js +7 -7
  89. package/src/util/braze-actions.js +4 -4
  90. package/src/util/browser-detector.js +21 -21
  91. package/src/util/client-hints-parser.js +3 -3
  92. package/src/util/component-utils.js +13 -12
  93. package/src/util/net.js +4 -4
  94. package/src/util/request-header-utils.js +17 -17
  95. package/src/util/user-agent-parser.js +3 -3
  96. package/src/util/window-utils.js +1 -1
@@ -6,13 +6,13 @@ import { FEED_ANIMATION_DURATION as E } from "../../common/constants.js";
6
6
  import T from "../../managers/subscription-manager.js";
7
7
  import r from "../../../shared-lib/logger.js";
8
8
  export default class Card {
9
- constructor(t, i, s, h, l, n, e, r, u, E, o, T, I, a, N, c) {
9
+ constructor(t, i, s, h, n, l, e, r, u, E, o, T, I, a, c, N) {
10
10
  (this.id = t),
11
11
  (this.viewed = i),
12
12
  (this.title = s),
13
13
  (this.imageUrl = h),
14
- (this.description = l),
15
- (this.created = n),
14
+ (this.description = n),
15
+ (this.created = l),
16
16
  (this.updated = e),
17
17
  (this.categories = r),
18
18
  (this.expiresAt = u),
@@ -21,14 +21,14 @@ export default class Card {
21
21
  (this.aspectRatio = T),
22
22
  (this.extras = I),
23
23
  (this.pinned = a),
24
- (this.dismissible = N),
25
- (this.clicked = c),
24
+ (this.dismissible = c),
25
+ (this.clicked = N),
26
26
  (this.id = t),
27
27
  (this.viewed = i || !1),
28
28
  (this.title = s || ""),
29
29
  (this.imageUrl = h),
30
- (this.description = l || ""),
31
- (this.created = n || null),
30
+ (this.description = n || ""),
31
+ (this.created = l || null),
32
32
  (this.updated = e || null),
33
33
  (this.categories = r || []),
34
34
  (this.expiresAt = u || null),
@@ -40,25 +40,26 @@ export default class Card {
40
40
  (this.aspectRatio = isNaN(T) ? null : T)),
41
41
  (this.extras = I || {}),
42
42
  (this.pinned = a || !1),
43
- (this.dismissible = N || !1),
43
+ (this.dismissible = c || !1),
44
44
  (this.dismissed = !1),
45
- (this.clicked = c || !1),
45
+ (this.clicked = N || !1),
46
46
  (this.isControl = !1),
47
47
  (this.test = !1),
48
48
  (this.Et = null),
49
- (this.Tt = null);
49
+ (this.Tt = null),
50
+ (this.It = null);
50
51
  }
51
52
  subscribeToClickedEvent(t) {
52
- return this.Nt().It(t);
53
+ return this.St().Nt(t);
53
54
  }
54
55
  subscribeToDismissedEvent(t) {
55
- return this.St().It(t);
56
+ return this.At().Nt(t);
56
57
  }
57
58
  removeSubscription(t) {
58
- this.Nt().removeSubscription(t), this.St().removeSubscription(t);
59
+ this.St().removeSubscription(t), this.At().removeSubscription(t);
59
60
  }
60
61
  removeAllSubscriptions() {
61
- this.Nt().removeAllSubscriptions(), this.St().removeAllSubscriptions();
62
+ this.St().removeAllSubscriptions(), this.At().removeAllSubscriptions();
62
63
  }
63
64
  dismissCard() {
64
65
  if (!this.dismissible || this.dismissed) return;
@@ -75,65 +76,69 @@ export default class Card {
75
76
  (t.style.margin = "0"),
76
77
  setTimeout(function () {
77
78
  t && t.parentNode && t.parentNode.removeChild(t);
78
- }, Card.At));
79
+ }, Card.Dt));
79
80
  }, E));
80
81
  }
81
- Nt() {
82
+ St() {
82
83
  return null == this.Et && (this.Et = new T()), this.Et;
83
84
  }
84
- St() {
85
+ At() {
85
86
  return null == this.Tt && (this.Tt = new T()), this.Tt;
86
87
  }
87
88
  K() {
88
- this.viewed = !0;
89
+ const t = new Date().valueOf();
90
+ return (
91
+ !(null != this.It && t - this.It < Card.Ct) &&
92
+ ((this.It = t), (this.viewed = !0), !0)
93
+ );
89
94
  }
90
95
  p() {
91
- (this.viewed = !0), (this.clicked = !0), this.Nt().Dt();
96
+ (this.viewed = !0), (this.clicked = !0), this.St().Rt();
92
97
  }
93
98
  N() {
94
99
  return (
95
100
  !(!this.dismissible || this.dismissed) &&
96
- ((this.dismissed = !0), this.St().Dt(), !0)
101
+ ((this.dismissed = !0), this.At().Rt(), !0)
97
102
  );
98
103
  }
99
- Ct(t) {
100
- if (null == t || t[Card.Rt.ht] !== this.id) return !0;
101
- if (t[Card.Rt.Lt]) return !1;
104
+ Lt(t) {
105
+ if (null == t || t[Card._t.ht] !== this.id) return !0;
106
+ if (t[Card._t.Ot]) return !1;
102
107
  if (
103
- null != t[Card.Rt.nt] &&
108
+ null != t[Card._t.nt] &&
104
109
  null != this.updated &&
105
- parseInt(t[Card.Rt.nt]) < h(this.updated.valueOf())
110
+ parseInt(t[Card._t.nt]) < h(this.updated.valueOf())
106
111
  )
107
112
  return !0;
108
113
  if (
109
- (t[Card.Rt.et] && !this.viewed && (this.viewed = !0),
110
- t[Card.Rt.zt] && !this.clicked && (this.clicked = t[Card.Rt.zt]),
111
- null != t[Card.Rt.rt] && (this.title = t[Card.Rt.rt]),
112
- null != t[Card.Rt.ot] && (this.imageUrl = t[Card.Rt.ot]),
113
- null != t[Card.Rt.ct] && (this.description = t[Card.Rt.ct]),
114
- null != t[Card.Rt.nt])
114
+ (t[Card._t.et] && !this.viewed && (this.viewed = !0),
115
+ t[Card._t.zt] && !this.clicked && (this.clicked = t[Card._t.zt]),
116
+ null != t[Card._t.rt] && (this.title = t[Card._t.rt]),
117
+ null != t[Card._t.ot] && (this.imageUrl = t[Card._t.ot]),
118
+ null != t[Card._t.ct] && (this.description = t[Card._t.ct]),
119
+ null != t[Card._t.nt])
115
120
  ) {
116
- const i = l(t[Card.Rt.nt]);
121
+ const i = l(t[Card._t.nt]);
117
122
  null != i && (this.updated = i);
118
123
  }
119
- if (null != t[Card.Rt.lt]) {
124
+ if (null != t[Card._t.lt]) {
120
125
  let i;
121
- (i = t[Card.Rt.lt] === Card._t ? null : l(t[Card.Rt.lt])),
126
+ (i = t[Card._t.lt] === Card.Mt ? null : l(t[Card._t.lt])),
122
127
  (this.expiresAt = i);
123
128
  }
124
129
  if (
125
- (null != t[Card.Rt.URL] && (this.url = t[Card.Rt.URL]),
126
- null != t[Card.Rt.ft] && (this.linkText = t[Card.Rt.ft]),
127
- null != t[Card.Rt.xt])
130
+ (null != t[Card._t.URL] && (this.url = t[Card._t.URL]),
131
+ null != t[Card._t.ft] && (this.linkText = t[Card._t.ft]),
132
+ null != t[Card._t.xt])
128
133
  ) {
129
- const i = parseFloat(t[Card.Rt.xt].toString());
134
+ const i = parseFloat(t[Card._t.xt].toString());
130
135
  this.aspectRatio = isNaN(i) ? null : i;
131
136
  }
132
137
  return (
133
- null != t[Card.Rt.bt] && (this.extras = t[Card.Rt.bt]),
134
- null != t[Card.Rt.gt] && (this.pinned = t[Card.Rt.gt]),
135
- null != t[Card.Rt.jt] && (this.dismissible = t[Card.Rt.jt]),
136
- null != t[Card.Rt.kt] && (this.test = t[Card.Rt.kt]),
138
+ null != t[Card._t.bt] && (this.extras = t[Card._t.bt]),
139
+ null != t[Card._t.gt] && (this.pinned = t[Card._t.gt]),
140
+ null != t[Card._t.jt] && (this.dismissible = t[Card._t.jt]),
141
+ null != t[Card._t.kt] && (this.test = t[Card._t.kt]),
137
142
  !0
138
143
  );
139
144
  }
@@ -141,12 +146,12 @@ export default class Card {
141
146
  r.error("Must be implemented in a subclass");
142
147
  }
143
148
  }
144
- (Card._t = -1),
145
- (Card.Rt = {
149
+ (Card.Mt = -1),
150
+ (Card._t = {
146
151
  ht: "id",
147
152
  et: "v",
148
153
  jt: "db",
149
- Lt: "r",
154
+ Ot: "r",
150
155
  nt: "ca",
151
156
  gt: "p",
152
157
  lt: "ea",
@@ -163,10 +168,10 @@ export default class Card {
163
168
  }),
164
169
  (Card.it = {
165
170
  st: "captioned_image",
166
- Ot: "text_announcement",
167
- Mt: "short_news",
168
- Pt: "banner_image",
169
- Ut: "control",
171
+ Pt: "text_announcement",
172
+ Ut: "short_news",
173
+ Gt: "banner_image",
174
+ Xt: "control",
170
175
  }),
171
176
  (Card.tt = {
172
177
  ht: "id",
@@ -188,10 +193,11 @@ export default class Card {
188
193
  zt: "cl",
189
194
  kt: "s",
190
195
  }),
191
- (Card.Gt = {
192
- Xt: "ADVERTISING",
193
- vt: "ANNOUNCEMENTS",
194
- Vt: "NEWS",
195
- Wt: "SOCIAL",
196
+ (Card.vt = {
197
+ Vt: "ADVERTISING",
198
+ Wt: "ANNOUNCEMENTS",
199
+ wt: "NEWS",
200
+ Ft: "SOCIAL",
196
201
  }),
197
- (Card.At = 400);
202
+ (Card.Dt = 400),
203
+ (Card.Ct = 1e4);
@@ -8,7 +8,7 @@ export default class ClassicCard extends Card {
8
8
  Y() {
9
9
  const s = {};
10
10
  return (
11
- (s[Card.tt.Z] = Card.it.Mt),
11
+ (s[Card.tt.Z] = Card.it.Ut),
12
12
  (s[Card.tt.ht] = this.id),
13
13
  (s[Card.tt.et] = this.viewed),
14
14
  (s[Card.tt.rt] = this.title),
@@ -9,7 +9,7 @@ export default class ControlCard extends Card {
9
9
  Y() {
10
10
  const l = {};
11
11
  return (
12
- (l[Card.tt.Z] = Card.it.Ut),
12
+ (l[Card.tt.Z] = Card.it.Xt),
13
13
  (l[Card.tt.ht] = this.id),
14
14
  (l[Card.tt.et] = this.viewed),
15
15
  (l[Card.tt.nt] = this.updated),
@@ -9,7 +9,7 @@ export default class ImageOnly extends Card {
9
9
  Y() {
10
10
  const s = {};
11
11
  return (
12
- (s[Card.tt.Z] = Card.it.Pt),
12
+ (s[Card.tt.Z] = Card.it.Gt),
13
13
  (s[Card.tt.ht] = this.id),
14
14
  (s[Card.tt.et] = this.viewed),
15
15
  (s[Card.tt.ot] = this.imageUrl),
@@ -12,31 +12,31 @@ import {
12
12
  import { logger as r } from "../../../shared-lib/index.js";
13
13
  export function newCard(n, e, t, o, i, l, u, d, a, w, f, s, m, C, p, c, x, F) {
14
14
  let j;
15
- if (e === Card.it.Ot || e === Card.it.Mt)
15
+ if (e === Card.it.Pt || e === Card.it.Ut)
16
16
  j = new ClassicCard(n, t, o, i, l, u, d, a, w, f, s, m, C, p, c, x);
17
17
  else if (e === Card.it.st)
18
18
  j = new CaptionedImage(n, t, o, i, l, u, d, a, w, f, s, m, C, p, c, x);
19
- else if (e === Card.it.Pt)
19
+ else if (e === Card.it.Gt)
20
20
  j = new ImageOnly(n, t, i, u, d, a, w, f, s, m, C, p, c, x);
21
21
  else {
22
- if (e !== Card.it.Ut)
22
+ if (e !== Card.it.Xt)
23
23
  return r.error("Ignoring card with unknown type " + e), null;
24
24
  j = new ControlCard(n, t, d, w, C, p);
25
25
  }
26
26
  return F && (j.test = F), j;
27
27
  }
28
28
  export function newCardFromContentCardsJson(n) {
29
- if (n[Card.Rt.Lt]) return null;
30
- const e = n[Card.Rt.ht],
31
- r = n[Card.Rt.Z],
32
- t = n[Card.Rt.et],
33
- o = n[Card.Rt.rt],
34
- i = n[Card.Rt.ot],
35
- u = n[Card.Rt.ct],
36
- d = l(n[Card.Rt.nt]),
29
+ if (n[Card._t.Ot]) return null;
30
+ const e = n[Card._t.ht],
31
+ r = n[Card._t.Z],
32
+ t = n[Card._t.et],
33
+ o = n[Card._t.rt],
34
+ i = n[Card._t.ot],
35
+ u = n[Card._t.ct],
36
+ d = l(n[Card._t.nt]),
37
37
  a = d;
38
38
  let w;
39
- w = n[Card.Rt.lt] === Card._t ? null : l(n[Card.Rt.lt]);
39
+ w = n[Card._t.lt] === Card.Mt ? null : l(n[Card._t.lt]);
40
40
  return newCard(
41
41
  e,
42
42
  r,
@@ -48,14 +48,14 @@ export function newCardFromContentCardsJson(n) {
48
48
  d,
49
49
  null,
50
50
  w,
51
- n[Card.Rt.URL],
52
- n[Card.Rt.ft],
53
- n[Card.Rt.xt],
54
- n[Card.Rt.bt],
55
- n[Card.Rt.gt],
56
- n[Card.Rt.jt],
57
- n[Card.Rt.zt],
58
- n[Card.Rt.kt] || !1,
51
+ n[Card._t.URL],
52
+ n[Card._t.ft],
53
+ n[Card._t.xt],
54
+ n[Card._t.bt],
55
+ n[Card._t.gt],
56
+ n[Card._t.jt],
57
+ n[Card._t.zt],
58
+ n[Card._t.kt] || !1,
59
59
  );
60
60
  }
61
61
  export function newCardFromFeedJson(n) {