@braze/web-sdk 4.7.2 → 4.8.1

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 (164) hide show
  1. package/index.d.ts +32 -26
  2. package/package.json +1 -1
  3. package/shared-lib/braze-shared-lib.js +5 -5
  4. package/shared-lib/encoding-utils.js +1 -1
  5. package/shared-lib/event-types.js +25 -25
  6. package/shared-lib/guid.js +3 -3
  7. package/shared-lib/indexed-db-adapter.js +74 -74
  8. package/shared-lib/logger.js +18 -18
  9. package/shared-lib/supported-options.js +18 -18
  10. package/src/Card/card-manager-factory.js +2 -2
  11. package/src/Card/card-manager.js +48 -42
  12. package/src/Card/display/card-display.js +70 -67
  13. package/src/Card/log-card-click.js +1 -1
  14. package/src/Card/log-card-dismissal.js +1 -1
  15. package/src/Card/log-card-impressions.js +3 -3
  16. package/src/Card/models/banner.js +3 -2
  17. package/src/Card/models/captioned-image.js +6 -5
  18. package/src/Card/models/card.js +107 -87
  19. package/src/Card/models/classic-card.js +5 -5
  20. package/src/Card/models/control-card.js +5 -21
  21. package/src/Card/types.js +1 -0
  22. package/src/Card/util/card-factory.js +32 -32
  23. package/src/ContentCards/content-cards-provider-factory.js +3 -3
  24. package/src/ContentCards/content-cards-provider.js +283 -175
  25. package/src/ContentCards/content-cards.js +2 -2
  26. package/src/ContentCards/get-cached-content-cards.js +1 -1
  27. package/src/ContentCards/log-content-cards-displayed.js +2 -2
  28. package/src/ContentCards/request-content-cards-refresh.js +1 -1
  29. package/src/ContentCards/subscribe-to-content-cards-updates.js +9 -6
  30. package/src/ContentCards/types.js +1 -0
  31. package/src/ContentCards/ui/hide-content-cards.js +2 -2
  32. package/src/ContentCards/ui/show-content-cards.js +36 -34
  33. package/src/Core/add-sdk-metadata.js +17 -18
  34. package/src/Core/change-user.js +12 -14
  35. package/src/Core/destroy.js +1 -1
  36. package/src/Core/disable-sdk.js +8 -6
  37. package/src/Core/enable-sdk.js +4 -4
  38. package/src/Core/get-device-id.js +7 -6
  39. package/src/Core/get-user.js +1 -1
  40. package/src/Core/handle-braze-action.js +57 -40
  41. package/src/Core/is-disabled.js +2 -2
  42. package/src/Core/log-custom-event.js +22 -15
  43. package/src/Core/log-purchase.js +33 -33
  44. package/src/Core/open-session.js +17 -15
  45. package/src/Core/request-immediate-data-flush.js +4 -2
  46. package/src/Core/set-logger.js +1 -1
  47. package/src/Core/set-sdk-authentication-signature.js +5 -6
  48. package/src/Core/subscribe-to-sdk-authentication-failures.js +3 -1
  49. package/src/Core/toggle-logging.js +1 -1
  50. package/src/Core/types.js +1 -0
  51. package/src/Core/wipe-data.js +11 -10
  52. package/src/FeatureFlags/feature-flag-factory.js +6 -6
  53. package/src/FeatureFlags/feature-flag.js +17 -17
  54. package/src/FeatureFlags/feature-flags-provider-factory.js +2 -2
  55. package/src/FeatureFlags/feature-flags-provider.js +67 -65
  56. package/src/FeatureFlags/get-all-feature-flags.js +3 -3
  57. package/src/FeatureFlags/get-feature-flag.js +4 -4
  58. package/src/FeatureFlags/subscribe-to-feature-flags-updates.js +4 -1
  59. package/src/Feed/feed-provider-factory.js +8 -8
  60. package/src/Feed/feed-provider.js +57 -46
  61. package/src/Feed/feed.js +1 -1
  62. package/src/Feed/get-cached-feed.js +2 -2
  63. package/src/Feed/log-feed-displayed.js +3 -1
  64. package/src/Feed/request-feed-refresh.js +2 -2
  65. package/src/Feed/subscribe-to-feed-updates.js +2 -2
  66. package/src/Feed/types.js +1 -0
  67. package/src/Feed/ui/hide-feed.js +2 -2
  68. package/src/Feed/ui/show-feed.js +41 -37
  69. package/src/InAppMessage/display/html-message-to-html.js +125 -119
  70. package/src/InAppMessage/display/in-app-message-to-html.js +72 -69
  71. package/src/InAppMessage/display/modal-utils.js +18 -13
  72. package/src/InAppMessage/in-app-message-factory.js +9 -8
  73. package/src/InAppMessage/in-app-message-manager-factory.js +7 -7
  74. package/src/InAppMessage/in-app-message-manager.js +130 -110
  75. package/src/InAppMessage/log-in-app-message-button-click.js +10 -10
  76. package/src/InAppMessage/log-in-app-message-click.js +9 -9
  77. package/src/InAppMessage/log-in-app-message-html-click.js +10 -10
  78. package/src/InAppMessage/log-in-app-message-impression.js +5 -5
  79. package/src/InAppMessage/models/control-message.js +4 -1
  80. package/src/InAppMessage/models/full-screen-message.js +35 -37
  81. package/src/InAppMessage/models/html-message.js +34 -33
  82. package/src/InAppMessage/models/in-app-message-button.js +23 -16
  83. package/src/InAppMessage/models/in-app-message.js +147 -105
  84. package/src/InAppMessage/models/modal-message.js +34 -36
  85. package/src/InAppMessage/models/slide-up-message.js +25 -27
  86. package/src/InAppMessage/models/templated-in-app-message.js +12 -7
  87. package/src/InAppMessage/subscribe-to-in-app-message.js +2 -2
  88. package/src/InAppMessage/types.js +1 -0
  89. package/src/InAppMessage/ui/automatically-show-in-app-messages.js +4 -4
  90. package/src/InAppMessage/ui/show-in-app-message.js +95 -89
  91. package/src/InAppMessage/utils/in-app-message-utils.js +1 -0
  92. package/src/Push/is-push-blocked.js +2 -2
  93. package/src/Push/is-push-permission-granted.js +2 -2
  94. package/src/Push/is-push-supported.js +2 -2
  95. package/src/Push/push-manager-factory.js +20 -20
  96. package/src/Push/push-manager.js +193 -174
  97. package/src/Push/request-push-permission.js +4 -3
  98. package/src/Push/types.js +1 -0
  99. package/src/Push/unregister-push.js +2 -2
  100. package/src/Push/utils/push-utils.js +10 -10
  101. package/src/User/types.js +1 -0
  102. package/src/User/user-manager.js +24 -24
  103. package/src/User/user.js +117 -105
  104. package/src/common/base-feed.js +7 -7
  105. package/src/common/base-provider.js +2 -2
  106. package/src/common/constants.js +6 -0
  107. package/src/common/event-logger.js +6 -6
  108. package/src/common/feed-display.js +95 -85
  109. package/src/common/types.js +1 -0
  110. package/src/l10n/l10n-manager-factory.js +10 -10
  111. package/src/l10n/l10n-manager.js +1 -1
  112. package/src/managers/auth-manager.js +37 -34
  113. package/src/managers/braze-instance.js +209 -193
  114. package/src/managers/device-manager.js +43 -38
  115. package/src/managers/network-manager.js +119 -96
  116. package/src/managers/server-config-manager.js +68 -48
  117. package/src/managers/session-manager.js +52 -45
  118. package/src/managers/storage-manager-factory.js +29 -22
  119. package/src/managers/storage-manager.js +288 -273
  120. package/src/managers/subscription-manager.js +9 -6
  121. package/src/managers/types.js +1 -0
  122. package/src/models/backend-errors.js +5 -5
  123. package/src/models/braze-event.js +14 -8
  124. package/src/models/device.js +10 -18
  125. package/src/models/identifier.js +10 -11
  126. package/src/models/push-token.js +17 -12
  127. package/src/models/request-result.js +4 -4
  128. package/src/models/server-config.js +36 -20
  129. package/src/models/types.js +1 -0
  130. package/src/request-controller.js +176 -174
  131. package/src/triggers/models/custom-event-data.js +6 -6
  132. package/src/triggers/models/custom-event-property-data.js +9 -9
  133. package/src/triggers/models/filter-set.js +9 -9
  134. package/src/triggers/models/filter.js +64 -64
  135. package/src/triggers/models/in-app-message-click-data.js +12 -12
  136. package/src/triggers/models/purchase-data.js +3 -3
  137. package/src/triggers/models/purchase-property-data.js +9 -9
  138. package/src/triggers/models/push-click-data.js +7 -7
  139. package/src/triggers/models/trigger-condition.js +57 -57
  140. package/src/triggers/models/trigger-events.js +2 -2
  141. package/src/triggers/models/trigger.js +42 -42
  142. package/src/triggers/triggers-provider-factory.js +8 -8
  143. package/src/triggers/triggers-provider.js +173 -170
  144. package/src/types.js +1 -0
  145. package/src/ui/js/attach-css.js +3 -3
  146. package/src/ui/js/load-font-awesome.js +2 -2
  147. package/src/util/base-device-parser.js +2 -2
  148. package/src/util/braze-actions.js +20 -20
  149. package/src/util/browser-detector.js +22 -22
  150. package/src/util/client-hints-parser.js +7 -7
  151. package/src/util/code-utils.js +1 -1
  152. package/src/util/color-utils.js +2 -2
  153. package/src/util/component-utils.js +2 -2
  154. package/src/util/deprecation-utils.js +1 -1
  155. package/src/util/device-constants.js +3 -3
  156. package/src/util/dom-utils.js +7 -7
  157. package/src/util/error-utils.js +2 -0
  158. package/src/util/key-codes.js +1 -1
  159. package/src/util/net.js +11 -11
  160. package/src/util/request-header-utils.js +23 -0
  161. package/src/util/string-utils.js +1 -1
  162. package/src/util/user-agent-parser.js +21 -21
  163. package/src/util/validation-utils.js +44 -44
  164. package/src/util/window-utils.js +3 -3
@@ -1,305 +1,308 @@
1
1
  import y from "../common/base-provider.js";
2
- import { newInAppMessageFromJson as lt } from "../InAppMessage/in-app-message-factory.js";
2
+ import { newInAppMessageFromJson as pt } from "../InAppMessage/in-app-message-factory.js";
3
3
  import ue from "../models/braze-event.js";
4
4
  import { InAppMessage } from "../InAppMessage/index.js";
5
5
  import {
6
6
  isArray as p,
7
7
  isEqual as ii,
8
- validateValueIsFromEnum as F
8
+ validateValueIsFromEnum as H
9
9
  } from "../util/code-utils.js";
10
- import { STORAGE_KEYS as o } from "../managers/storage-manager.js";
10
+ import { STORAGE_KEYS as i } from "../managers/storage-manager.js";
11
11
  import wt from "../InAppMessage/models/templated-in-app-message.js";
12
- import pt from "./models/trigger.js";
13
- import V from "./models/trigger-events.js";
12
+ import mt from "./models/trigger.js";
13
+ import tt from "./models/trigger-events.js";
14
14
  import r from "../../shared-lib/braze-shared-lib.js";
15
15
  export default class gr extends y {
16
16
  constructor(t, i, s, e, r) {
17
17
  super(),
18
18
  (this.tg = t),
19
- (this.yt = i),
20
- (this.h = s),
21
- (this.Ci = e),
22
- (this.ig = r),
23
- (this.sg = []),
24
- (this.eg = []),
25
- (this.hg = null),
26
- (this.og = {}),
27
- (this.ng = {}),
28
- this.lg(),
29
- this.ag();
19
+ (this.ig = i),
20
+ (this.yh = s),
21
+ (this.sg = e),
22
+ (this.eg = r),
23
+ (this.hg = []),
24
+ (this.og = []),
25
+ (this.ng = null),
26
+ (this.lg = {}),
27
+ (this.ag = {}),
28
+ this.gg(),
29
+ this.fg();
30
30
  }
31
- gg() {
32
- (this.hg = this.h.I(o.q.Na) || this.hg),
33
- (this.og = this.h.I(o.q.va) || this.og),
34
- (this.ng = this.h.I(o.q.Ga) || this.ng);
35
- for (let t = 0; t < this.fg.length; t++) {
36
- const i = this.fg[t];
37
- null != this.ng[i.id] && i.zu(this.ng[i.id]);
31
+ cg() {
32
+ (this.ng = this.yh.v(i.k.Ma) || this.ng),
33
+ (this.lg = this.yh.v(i.k.ya) || this.lg),
34
+ (this.ag = this.yh.v(i.k.Ga) || this.ag);
35
+ for (let t = 0; t < this.ug.length; t++) {
36
+ const i = this.ug[t];
37
+ null != this.ag[i.id] && i.Wu(this.ag[i.id]);
38
38
  }
39
39
  }
40
- lg() {
41
- this.cg = this.h.I(o.q.Da) || 0;
42
- const t = this.h.I(o.q.Ya) || [],
43
- i = [];
44
- for (let s = 0; s < t.length; s++) i.push(pt.Pn(t[s]));
45
- (this.fg = i), this.gg();
40
+ gg() {
41
+ this.dg = this.yh.v(i.k.Ca) || 0;
42
+ const t = this.yh.v(i.k.Na) || [],
43
+ s = [];
44
+ for (let i = 0; i < t.length; i++) s.push(mt.zn(t[i]));
45
+ (this.ug = s), this.cg();
46
46
  }
47
- ag() {
47
+ fg() {
48
48
  const t = this,
49
- i = function(i, s, e, r, h) {
49
+ s = function(i, s, e, r, h) {
50
50
  return function() {
51
- t.ug(i, s, e, r, h);
51
+ t.mg(i, s, e, r, h);
52
52
  };
53
53
  },
54
- s = {};
55
- for (let t = 0; t < this.fg.length; t++) s[this.fg[t].id] = this.fg[t];
56
- let e = !1;
57
- for (let t = 0; t < this.fg.length; t++) {
58
- const r = this.fg[t];
59
- if (null != this.og[r.id]) {
60
- const t = this.og[r.id],
54
+ e = {};
55
+ for (let t = 0; t < this.ug.length; t++) e[this.ug[t].id] = this.ug[t];
56
+ let r = !1;
57
+ for (let t = 0; t < this.ug.length; t++) {
58
+ const i = this.ug[t];
59
+ if (null != this.lg[i.id]) {
60
+ const t = this.lg[i.id],
61
61
  h = [];
62
- for (let e = 0; e < t.length; e++) {
63
- const o = t[e],
64
- n = r.Iu(o.Ui);
62
+ for (let r = 0; r < t.length; r++) {
63
+ const o = t[r],
64
+ n = i.Yu(o.Jr);
65
65
  if (n > 0) {
66
- let t, e;
66
+ let t, r;
67
67
  h.push(o),
68
- null != o.dg && (t = o.dg),
69
- null != o.mg && ue.Fa(o.mg) && (e = ue.Pn(o.mg));
68
+ null != o.pg && (t = o.pg),
69
+ null != o.bg && ue.Qa(o.bg) && (r = ue.zn(o.bg));
70
70
  const l = [];
71
- if (p(o.pg))
72
- for (let t = 0; t < o.pg.length; t++) {
73
- const i = s[o.pg[t]];
71
+ if (p(o.Tg))
72
+ for (let t = 0; t < o.Tg.length; t++) {
73
+ const i = e[o.Tg[t]];
74
74
  null != i && l.push(i);
75
75
  }
76
- this.eg.push(setTimeout(i(r, o.Ui, t, e, l), n));
76
+ this.og.push(setTimeout(s(i, o.Jr, t, r, l), n));
77
77
  }
78
78
  }
79
- this.og[r.id].length > h.length &&
80
- ((this.og[r.id] = h),
81
- (e = !0),
82
- 0 === this.og[r.id].length && delete this.og[r.id]);
79
+ this.lg[i.id].length > h.length &&
80
+ ((this.lg[i.id] = h),
81
+ (r = !0),
82
+ 0 === this.lg[i.id].length && delete this.lg[i.id]);
83
83
  }
84
84
  }
85
- e && this.h.B(o.q.va, this.og);
85
+ r && this.yh.D(i.k.ya, this.lg);
86
86
  }
87
- bg() {
87
+ yg() {
88
88
  const t = [];
89
- for (let i = 0; i < this.fg.length; i++) t.push(this.fg[i].ss());
90
- (this.cg = new Date().valueOf()),
91
- this.h.B(o.q.Ya, t),
92
- this.h.B(o.q.Da, this.cg);
89
+ for (let i = 0; i < this.ug.length; i++) t.push(this.ug[i].ss());
90
+ (this.dg = new Date().valueOf()),
91
+ this.yh.D(i.k.Na, t),
92
+ this.yh.D(i.k.Ca, this.dg);
93
93
  }
94
- Tg() {
95
- (this.h.I(o.q.Da) || 0) > this.cg ? this.lg() : this.gg();
94
+ vg() {
95
+ (this.yh.v(i.k.Ca) || 0) > this.dg ? this.gg() : this.cg();
96
96
  }
97
- Rs(t) {
98
- let i = !1;
97
+ Ts(t) {
98
+ let s = !1;
99
99
  if (null != t && t.triggers) {
100
- this.gg();
101
- const s = {},
102
- e = {};
103
- this.fg = [];
104
- for (let r = 0; r < t.triggers.length; r++) {
105
- const h = pt.fromJson(t.triggers[r]);
106
- null != this.ng[h.id] &&
107
- (h.zu(this.ng[h.id]), (s[h.id] = this.ng[h.id])),
108
- null != this.og[h.id] && (e[h.id] = this.og[h.id]);
109
- for (let t = 0; t < h.Du.length; t++)
110
- if (h.Du[t].ec(V.ks, null)) {
111
- i = !0;
100
+ this.cg();
101
+ const e = {},
102
+ h = {};
103
+ this.ug = [];
104
+ for (let i = 0; i < t.triggers.length; i++) {
105
+ const r = mt.fromJson(t.triggers[i]);
106
+ null != this.ag[r.id] &&
107
+ (r.Wu(this.ag[r.id]), (e[r.id] = this.ag[r.id])),
108
+ null != this.lg[r.id] && (h[r.id] = this.lg[r.id]);
109
+ for (let t = 0; t < r.Pu.length; t++)
110
+ if (r.Pu[t].ec(tt.ks, null)) {
111
+ s = !0;
112
112
  break;
113
113
  }
114
- null != h && this.fg.push(h);
114
+ null != r && this.ug.push(r);
115
115
  }
116
- ii(this.ng, s) || ((this.ng = s), this.h.B(o.q.Ga, this.ng)),
117
- ii(this.og, e) || ((this.og = e), this.h.B(o.q.va, this.og)),
118
- this.bg(),
119
- i &&
120
- (r.D.info("Trigger with test condition found, firing test."),
121
- this.je(V.ks)),
122
- this.je(V.OPEN);
123
- const h = this.sg;
124
- this.sg = [];
125
- for (let t = 0; t < h.length; t++) this.je.apply(this, h[t]);
116
+ ii(this.ag, e) || ((this.ag = e), this.yh.D(i.k.Ga, this.ag)),
117
+ ii(this.lg, h) || ((this.lg = h), this.yh.D(i.k.ya, this.lg)),
118
+ this.yg(),
119
+ s &&
120
+ (r.j.info("Trigger with test condition found, firing test."),
121
+ this.je(tt.ks)),
122
+ this.je(tt.OPEN);
123
+ const o = this.hg;
124
+ this.hg = [];
125
+ for (let t = 0; t < o.length; t++) this.je.apply(this, o[t]);
126
126
  }
127
127
  }
128
- ug(t, i, s, e, h) {
128
+ mg(t, i, s, e, h) {
129
129
  const o = e => {
130
- this.gg();
130
+ this.cg();
131
131
  const h = new Date().valueOf();
132
- if (!t.$u(i))
133
- return !1 === navigator.onLine && t.type === pt.Ki.Ji && e.imageUrl
134
- ? (r.D.info(
132
+ if (!t.Zu(i))
133
+ return !1 === navigator.onLine && t.type === mt.Gr._r && e.imageUrl
134
+ ? (r.j.info(
135
135
  `Not showing ${t.type} trigger action ${t.id} due to offline state.`
136
136
  ),
137
- void this.ig.Ye(t.id, InAppMessage.Me.Dh))
138
- : void (t.vu(h) && this.yg(t, h, s)
139
- ? 0 === this.yt.bu()
140
- ? r.D.info(
137
+ void this.eg.Ye(t.id, InAppMessage.Me.Dh))
138
+ : void (t.Ku(h) && this.wg(t, h, s)
139
+ ? 0 === this.ig.tc()
140
+ ? r.j.info(
141
141
  `Not displaying trigger ${t.id} because neither automaticallyShowInAppMessages() nor subscribeToInAppMessage() were called.`
142
142
  )
143
- : (this.yt.St([e]), this.vg(t, h))
144
- : r.D.info(
143
+ : (this.ig.Et([e]), this.$g(t, h))
144
+ : r.j.info(
145
145
  `Not displaying trigger ${t.id} because display time fell outside of the acceptable time window.`
146
146
  ));
147
- t.type === pt.Ki.Mu
148
- ? this.ig.Ye(t.id, InAppMessage.Me.Ri)
149
- : this.ig.Ye(t.id, InAppMessage.Me.Mh);
147
+ t.type === mt.Gr.td
148
+ ? this.eg.Ye(t.id, InAppMessage.Me.Zi)
149
+ : this.eg.Ye(t.id, InAppMessage.Me.Mh);
150
150
  },
151
151
  n = () => {
152
- this.gg();
152
+ this.cg();
153
153
  const o = h.pop();
154
154
  if (null != o)
155
- if ((this.wg(o, i, s, e, h), o.$u(i))) {
155
+ if ((this.jg(o, i, s, e, h), o.Zu(i))) {
156
156
  let t = `Server aborted in-app message display, but the timeout on fallback trigger ${o.id} has already elapsed.`;
157
157
  h.length > 0 && (t += " Continuing to fall back."),
158
- r.D.info(t),
159
- this.ig.Ye(o.id, InAppMessage.Me.Mh),
158
+ r.j.info(t),
159
+ this.eg.Ye(o.id, InAppMessage.Me.Mh),
160
160
  n();
161
161
  } else {
162
- r.D.info(
162
+ r.j.info(
163
163
  `Server aborted in-app message display. Falling back to lower priority ${o.type} trigger action ${t.id}.`
164
164
  );
165
- const n = 1e3 * o.Pu - (new Date().valueOf() - i);
165
+ const n = 1e3 * o.vu - (new Date().valueOf() - i);
166
166
  n > 0
167
- ? this.eg.push(
167
+ ? this.og.push(
168
168
  setTimeout(() => {
169
- this.ug(o, i, s, e, h);
169
+ this.mg(o, i, s, e, h);
170
170
  }, n)
171
171
  )
172
- : this.ug(o, i, s, e, h);
172
+ : this.mg(o, i, s, e, h);
173
173
  }
174
174
  };
175
175
  let l, a, g;
176
176
  switch (t.type) {
177
- case pt.Ki.Ji:
178
- if (((l = lt(t.data)), null == l)) {
179
- r.D.error(
177
+ case mt.Gr._r:
178
+ if (((l = pt(t.data)), null == l)) {
179
+ r.j.error(
180
180
  `Could not parse trigger data for trigger ${t.id}, ignoring.`
181
181
  ),
182
- this.ig.Ye(t.id, InAppMessage.Me.Li);
182
+ this.eg.Ye(t.id, InAppMessage.Me.Or);
183
183
  break;
184
184
  }
185
- if (((a = this.ig.Bi(l)), a)) {
186
- r.D.error(a), n();
185
+ if (((a = this.eg.Ji(l)), a)) {
186
+ r.j.error(a), n();
187
187
  break;
188
188
  }
189
189
  o(l);
190
190
  break;
191
- case pt.Ki.Mu:
192
- if (((g = wt.fromJson(t.data, o, n, i, t.Vi)), null == g)) {
193
- r.D.error(
191
+ case mt.Gr.td:
192
+ if (((g = wt.fromJson(t.data, o, n, i, t.Kr)), null == g)) {
193
+ r.j.error(
194
194
  `Could not parse trigger data for trigger ${t.id}, ignoring.`
195
195
  ),
196
- this.ig.Ye(t.id, InAppMessage.Me.Li);
196
+ this.eg.Ye(t.id, InAppMessage.Me.Or);
197
197
  break;
198
198
  }
199
- this.ig.qi(g, s, e);
199
+ this.eg.Vi(g, s, e);
200
200
  break;
201
201
  default:
202
- r.D.error(
202
+ r.j.error(
203
203
  `Trigger ${t.id} was of unexpected type ${t.type}, ignoring.`
204
204
  ),
205
- this.ig.Ye(t.id, InAppMessage.Me.Li);
205
+ this.eg.Ye(t.id, InAppMessage.Me.Or);
206
206
  }
207
207
  }
208
208
  je(t, i, s) {
209
- if (!F(V, t, "Cannot fire trigger action.", "TriggerEvents")) return;
210
- if (this.Ci.Ll())
209
+ if (!H(tt, t, "Cannot fire trigger action.", "TriggerEvents")) return;
210
+ if (this.sg.Vh())
211
211
  return (
212
- r.D.info(
212
+ r.j.info(
213
213
  "Trigger sync is currently in progress, awaiting sync completion before firing trigger event."
214
214
  ),
215
- void this.sg.push(arguments)
215
+ void this.hg.push(arguments)
216
216
  );
217
- this.Tg();
217
+ this.vg();
218
218
  const e = new Date().valueOf(),
219
- h = e - this.hg;
219
+ h = e - this.ng;
220
220
  let o = !0,
221
221
  n = !0;
222
222
  const l = [];
223
- for (let s = 0; s < this.fg.length; s++) {
224
- const r = this.fg[s],
225
- h = e + 1e3 * r.Pu;
223
+ for (let s = 0; s < this.ug.length; s++) {
224
+ const r = this.ug[s],
225
+ h = e + 1e3 * r.vu;
226
226
  if (
227
- r.vu(h) &&
227
+ r.Ku(h) &&
228
228
  (null == r.startTime || r.startTime <= e) &&
229
229
  (null == r.endTime || r.endTime >= e)
230
230
  ) {
231
231
  let s = !1;
232
- for (let e = 0; e < r.Du.length; e++)
233
- if (r.Du[e].ec(t, i)) {
232
+ for (let e = 0; e < r.Pu.length; e++)
233
+ if (r.Pu[e].ec(t, i)) {
234
234
  s = !0;
235
235
  break;
236
236
  }
237
- s && ((o = !1), this.yg(r, h, t) && ((n = !1), l.push(r)));
237
+ s && ((o = !1), this.wg(r, h, t) && ((n = !1), l.push(r)));
238
238
  }
239
239
  }
240
240
  if (o)
241
- return void r.D.info(
241
+ return void r.j.info(
242
242
  `Trigger event ${t} did not match any trigger conditions.`
243
243
  );
244
244
  if (n)
245
- return void r.D.info(
245
+ return void r.j.info(
246
246
  `Ignoring ${t} trigger event because a trigger was displayed ${h /
247
247
  1e3}s ago.`
248
248
  );
249
249
  l.sort((t, i) => t.priority - i.priority);
250
250
  const a = l.pop();
251
251
  null != a &&
252
- (r.D.info(
252
+ (r.j.info(
253
253
  `Firing ${a.type} trigger action ${a.id} from trigger event ${t}.`
254
254
  ),
255
- this.wg(a, e, t, s, l),
256
- 0 === a.Pu
257
- ? this.ug(a, e, t, s, l)
258
- : this.eg.push(
255
+ this.jg(a, e, t, s, l),
256
+ 0 === a.vu
257
+ ? this.mg(a, e, t, s, l)
258
+ : this.og.push(
259
259
  setTimeout(() => {
260
- this.ug(a, e, t, s, l);
261
- }, 1e3 * a.Pu)
260
+ this.mg(a, e, t, s, l);
261
+ }, 1e3 * a.vu)
262
262
  ));
263
263
  }
264
264
  changeUser(t) {
265
- if (((this.fg = []), this.h.Xs(o.q.Ya), !t)) {
266
- (this.sg = []), (this.hg = null), (this.ng = {}), (this.og = {});
267
- for (let t = 0; t < this.eg.length; t++) clearTimeout(this.eg[t]);
268
- (this.eg = []), this.h.Xs(o.q.Na), this.h.Xs(o.q.Ga), this.h.Xs(o.q.va);
265
+ if (((this.ug = []), this.yh.ri(i.k.Na), !t)) {
266
+ (this.hg = []), (this.ng = null), (this.ag = {}), (this.lg = {});
267
+ for (let t = 0; t < this.og.length; t++) clearTimeout(this.og[t]);
268
+ (this.og = []),
269
+ this.yh.ri(i.k.Ma),
270
+ this.yh.ri(i.k.Ga),
271
+ this.yh.ri(i.k.ya);
269
272
  }
270
273
  }
271
274
  clearData() {
272
- (this.fg = []), (this.hg = null), (this.ng = {}), (this.og = {});
273
- for (let t = 0; t < this.eg.length; t++) clearTimeout(this.eg[t]);
274
- this.eg = [];
275
+ (this.ug = []), (this.ng = null), (this.ag = {}), (this.lg = {});
276
+ for (let t = 0; t < this.og.length; t++) clearTimeout(this.og[t]);
277
+ this.og = [];
275
278
  }
276
- yg(t, i, s) {
277
- if (null == this.hg) return !0;
278
- if (s === V.ks)
279
+ wg(t, i, s) {
280
+ if (null == this.ng) return !0;
281
+ if (s === tt.ks)
279
282
  return (
280
- r.D.info(
283
+ r.j.info(
281
284
  "Ignoring minimum interval between trigger because it is a test type."
282
285
  ),
283
286
  !0
284
287
  );
285
- let e = t.wu;
286
- return null == e && (e = this.tg), i - this.hg >= 1e3 * e;
288
+ let e = t.Fu;
289
+ return null == e && (e = this.tg), i - this.ng >= 1e3 * e;
287
290
  }
288
- wg(t, i, s, e, r) {
289
- this.gg(), (this.og[t.id] = this.og[t.id] || []);
290
- const h = {};
291
+ jg(t, s, e, r, h) {
292
+ this.cg(), (this.lg[t.id] = this.lg[t.id] || []);
293
+ const o = {};
291
294
  let n;
292
- (h.Ui = i), (h.dg = s), null != e && (n = e.ss()), (h.mg = n);
295
+ (o.Jr = s), (o.pg = e), null != r && (n = r.ss()), (o.bg = n);
293
296
  const l = [];
294
- for (let t = 0; t < r.length; t++) l.push(r[t].id);
295
- (h.pg = l), this.og[t.id].push(h), this.h.B(o.q.va, this.og);
297
+ for (let t = 0; t < h.length; t++) l.push(h[t].id);
298
+ (o.Tg = l), this.lg[t.id].push(o), this.yh.D(i.k.ya, this.lg);
296
299
  }
297
- vg(t, i) {
298
- this.gg(),
299
- t.zu(i),
300
- (this.hg = i),
301
- this.h.B(o.q.Na, i),
302
- (this.ng[t.id] = i),
303
- this.h.B(o.q.Ga, this.ng);
300
+ $g(t, s) {
301
+ this.cg(),
302
+ t.Wu(s),
303
+ (this.ng = s),
304
+ this.yh.D(i.k.Ma, s),
305
+ (this.ag[t.id] = s),
306
+ this.yh.D(i.k.Ga, this.ag);
304
307
  }
305
308
  }
package/src/types.js ADDED
@@ -0,0 +1 @@
1
+ export {};
@@ -1,12 +1,12 @@
1
- import e, { OPTIONS as T } from "../../managers/braze-instance.js";
1
+ import e, { OPTIONS as L } from "../../managers/braze-instance.js";
2
2
  export function attachCSS(n, t, o) {
3
3
  const c = n || document.querySelector("head"),
4
- s = `ab-${t}-css-definitions-${"4.7.2".replace(/\./g, "-")}`,
4
+ s = `ab-${t}-css-definitions-${"4.8.1".replace(/\./g, "-")}`,
5
5
  a = c.ownerDocument || document;
6
6
  if (null == a.getElementById(s)) {
7
7
  const n = a.createElement("style");
8
8
  (n.innerHTML = o), (n.id = s);
9
- const t = e.nn(T.ao);
9
+ const t = e.nn(L.lo);
10
10
  null != t && n.setAttribute("nonce", t), c.appendChild(n);
11
11
  }
12
12
  }
@@ -1,6 +1,6 @@
1
- import e, { OPTIONS as T } from "../../managers/braze-instance.js";
1
+ import e, { OPTIONS as L } from "../../managers/braze-instance.js";
2
2
  export function loadFontAwesome() {
3
- if (e.nn(T.wo)) return;
3
+ if (e.nn(L.Lo)) return;
4
4
  const t = "https://use.fontawesome.com/7f85a56ba4.css";
5
5
  if (
6
6
  !(null !== document.querySelector('link[rel=stylesheet][href="' + t + '"]'))
@@ -1,9 +1,9 @@
1
1
  import { isArray as p } from "./code-utils.js";
2
- export default class Oe {
2
+ export default class ge {
3
3
  constructor() {}
4
4
  tf() {}
5
5
  ef() {}
6
- Yo(t) {}
6
+ Zo(t) {}
7
7
  static rf(t, e) {
8
8
  if (t && e)
9
9
  if (((t = t.toLowerCase()), p(e.if))) {
@@ -1,13 +1,13 @@
1
1
  import r from "../../shared-lib/braze-shared-lib.js";
2
2
  import { decodeBrazeActions as to } from "./string-utils.js";
3
3
  import {
4
- BRAZE_ACTION_URI_REGEX as J,
5
- isValidBrazeActionType as oo,
6
- isValidBrazeActionJson as O
4
+ BRAZE_ACTION_URI_REGEX as X,
5
+ isValidBrazeActionType as ro,
6
+ isValidBrazeActionJson as Y
7
7
  } from "./validation-utils.js";
8
8
  export const BRAZE_ACTIONS = {
9
9
  types: {
10
- ue: "container",
10
+ le: "container",
11
11
  logCustomEvent: "logCustomEvent",
12
12
  setEmailNotificationSubscriptionType:
13
13
  "setEmailNotificationSubscriptionType",
@@ -21,17 +21,17 @@ export const BRAZE_ACTIONS = {
21
21
  de: "openLink",
22
22
  pe: "openLinkInWebView"
23
23
  },
24
- properties: { type: "type", me: "steps", fe: "args" }
24
+ properties: { type: "type", ce: "steps", me: "args" }
25
25
  };
26
26
  export const INELIGIBLE_BRAZE_ACTION_URL_ERROR_TYPES = {
27
- Ei: "unknownBrazeAction",
28
- Ni: "noPushPrompt"
27
+ Ki: "unknownBrazeAction",
28
+ Qi: "noPushPrompt"
29
29
  };
30
30
  export const ineligibleBrazeActionURLErrorMessage = (t, o) => {
31
31
  switch (t) {
32
- case INELIGIBLE_BRAZE_ACTION_URL_ERROR_TYPES.Ei:
32
+ case INELIGIBLE_BRAZE_ACTION_URL_ERROR_TYPES.Ki:
33
33
  return `${o} contains an unknown braze action type and will not be displayed.`;
34
- case INELIGIBLE_BRAZE_ACTION_URL_ERROR_TYPES.Ni:
34
+ case INELIGIBLE_BRAZE_ACTION_URL_ERROR_TYPES.Qi:
35
35
  return `${o} contains a push prompt braze action, but is not eligible for a push prompt. Ignoring.`;
36
36
  default:
37
37
  return "";
@@ -39,23 +39,23 @@ export const ineligibleBrazeActionURLErrorMessage = (t, o) => {
39
39
  };
40
40
  export function getDecodedBrazeAction(t) {
41
41
  try {
42
- let o = t.match(J)[0].length;
42
+ let o = t.match(X)[0].length;
43
43
  const e = t.substring(o);
44
44
  if (o > t.length - 1 || !e)
45
- return void r.D.error(
45
+ return void r.j.error(
46
46
  `Did not find base64 encoded brazeAction in url to process : ${t}`
47
47
  );
48
48
  const n = to(e);
49
49
  return n
50
50
  ? JSON.parse(n)
51
- : void r.D.error(`Failed to decode base64 encoded brazeAction: ${e}`);
51
+ : void r.j.error(`Failed to decode base64 encoded brazeAction: ${e}`);
52
52
  } catch (o) {
53
- return void r.D.error(
53
+ return void r.j.error(
54
54
  `Failed to process brazeAction URL ${t} : ${o.message}`
55
55
  );
56
56
  }
57
57
  }
58
- function ro(t, o) {
58
+ function eo(t, o) {
59
59
  let r = !1;
60
60
  for (const e of o) if (((r = r || t(e)), r)) return !0;
61
61
  return !1;
@@ -63,17 +63,17 @@ function ro(t, o) {
63
63
  export function containsUnknownBrazeAction(t) {
64
64
  try {
65
65
  const o = t[BRAZE_ACTIONS.properties.type];
66
- return o === BRAZE_ACTIONS.types.ue
67
- ? ro(containsUnknownBrazeAction, t[BRAZE_ACTIONS.properties.me])
68
- : !oo(o);
66
+ return o === BRAZE_ACTIONS.types.le
67
+ ? eo(containsUnknownBrazeAction, t[BRAZE_ACTIONS.properties.ce])
68
+ : !ro(o);
69
69
  } catch (t) {
70
70
  return !0;
71
71
  }
72
72
  }
73
73
  export function containsPushPrimerBrazeAction(t) {
74
- if (!O(t)) return !1;
74
+ if (!Y(t)) return !1;
75
75
  const o = t[BRAZE_ACTIONS.properties.type];
76
- return o === BRAZE_ACTIONS.types.ue
77
- ? ro(containsPushPrimerBrazeAction, t[BRAZE_ACTIONS.properties.me])
76
+ return o === BRAZE_ACTIONS.types.le
77
+ ? eo(containsPushPrimerBrazeAction, t[BRAZE_ACTIONS.properties.ce])
78
78
  : o === BRAZE_ACTIONS.types.requestPushPermission;
79
79
  }