@braze/web-sdk 6.12.0 → 6.13.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 (149) hide show
  1. package/index.d.ts +240 -3
  2. package/package.json +1 -1
  3. package/shared-lib/event-types.js +18 -18
  4. package/shared-lib/indexed-db-adapter.js +58 -58
  5. package/shared-lib/logger.js +7 -7
  6. package/shared-lib/supported-options.js +25 -24
  7. package/src/ConversationalChat/automatically-manage-chat.js +5 -0
  8. package/src/ConversationalChat/chat-message-factory.js +25 -0
  9. package/src/ConversationalChat/chat-message.js +33 -0
  10. package/src/ConversationalChat/constants.js +1 -0
  11. package/src/ConversationalChat/conversational-chat-provider-factory.js +26 -0
  12. package/src/ConversationalChat/conversational-chat-provider.js +372 -0
  13. package/src/ConversationalChat/display/chat-widget-manager.js +113 -0
  14. package/src/ConversationalChat/display/chat-widget-to-html.js +58 -0
  15. package/src/ConversationalChat/get-chat-messages.js +7 -0
  16. package/src/ConversationalChat/index.js +12 -0
  17. package/src/ConversationalChat/is-chat-conversation-ended.js +7 -0
  18. package/src/ConversationalChat/is-chat-turn-errored.js +7 -0
  19. package/src/ConversationalChat/is-chat-turn-in-progress.js +7 -0
  20. package/src/ConversationalChat/register-chat-action-handler.js +10 -0
  21. package/src/ConversationalChat/reset-chat-conversation.js +5 -0
  22. package/src/ConversationalChat/retrieve-chat-config.js +7 -0
  23. package/src/ConversationalChat/send-chat-message.js +17 -0
  24. package/src/ConversationalChat/subscribe-to-chat-action.js +5 -0
  25. package/src/ConversationalChat/subscribe-to-chat-conversation-updated.js +5 -0
  26. package/src/ConversationalChat/subscribe-to-chat-message-received.js +5 -0
  27. package/src/ConversationalChat/trigger-chat-action.js +11 -0
  28. package/src/ConversationalChat/types.js +1 -0
  29. package/src/Core/add-sdk-metadata.js +5 -5
  30. package/src/Core/change-user.js +6 -6
  31. package/src/Core/disable-sdk.js +6 -6
  32. package/src/Core/enable-sdk.js +3 -3
  33. package/src/Core/get-device-id.js +2 -2
  34. package/src/Core/handle-braze-action.js +20 -13
  35. package/src/Core/is-disabled.js +1 -1
  36. package/src/Core/is-initialized.js +1 -1
  37. package/src/Core/log-custom-event.js +9 -9
  38. package/src/Core/log-ecommerce-event.js +4 -4
  39. package/src/Core/log-purchase.js +14 -14
  40. package/src/Core/open-session.js +8 -8
  41. package/src/Core/set-sdk-authentication-signature.js +3 -3
  42. package/src/Core/subscribe-to-sdk-authentication-failures.js +1 -1
  43. package/src/Core/wipe-data.js +1 -1
  44. package/src/DUST/dust-config-store.js +35 -35
  45. package/src/DUST/dust-message-dedup.js +3 -3
  46. package/src/DUST/dust-provider-factory.js +10 -10
  47. package/src/DUST/dust-provider.js +234 -234
  48. package/src/DUST/subscribe-to-dust.js +7 -7
  49. package/src/FeatureFlags/feature-flag-factory.js +2 -2
  50. package/src/FeatureFlags/feature-flag.js +4 -4
  51. package/src/FeatureFlags/feature-flags-provider-factory.js +11 -11
  52. package/src/FeatureFlags/feature-flags-provider.js +38 -38
  53. package/src/FeatureFlags/get-all-feature-flags.js +3 -3
  54. package/src/FeatureFlags/get-feature-flag.js +3 -3
  55. package/src/FeatureFlags/log-feature-flag-impression.js +4 -4
  56. package/src/FeatureFlags/refresh-feature-flags.js +5 -5
  57. package/src/FeatureFlags/subscribe-to-feature-flags-updates.js +3 -3
  58. package/src/InAppMessage/defer-in-app-message.js +1 -1
  59. package/src/InAppMessage/display/html-message-display-utils.js +4 -4
  60. package/src/InAppMessage/display/html-message-to-html.js +13 -13
  61. package/src/InAppMessage/display/in-app-message-to-html.js +20 -20
  62. package/src/InAppMessage/display/modal-utils.js +7 -7
  63. package/src/InAppMessage/in-app-message-factory.js +6 -6
  64. package/src/InAppMessage/in-app-message-manager.js +92 -92
  65. package/src/InAppMessage/log-in-app-message-button-click.js +9 -9
  66. package/src/InAppMessage/log-in-app-message-click.js +7 -7
  67. package/src/InAppMessage/log-in-app-message-html-click.js +6 -6
  68. package/src/InAppMessage/log-in-app-message-impression.js +3 -3
  69. package/src/InAppMessage/models/full-screen-message.js +39 -39
  70. package/src/InAppMessage/models/html-message.js +20 -20
  71. package/src/InAppMessage/models/in-app-message-button.js +2 -2
  72. package/src/InAppMessage/models/in-app-message.js +102 -102
  73. package/src/InAppMessage/models/modal-message.js +38 -38
  74. package/src/InAppMessage/models/slide-up-message.js +34 -34
  75. package/src/InAppMessage/models/templated-in-app-message.js +8 -8
  76. package/src/InAppMessage/subscribe-to-in-app-message.js +1 -1
  77. package/src/InAppMessage/ui/automatically-show-in-app-messages.js +3 -3
  78. package/src/InAppMessage/ui/remove-all-visible-in-app-messages.js +3 -3
  79. package/src/InAppMessage/ui/show-in-app-message.js +27 -24
  80. package/src/Push/is-push-blocked.js +2 -2
  81. package/src/Push/is-push-permission-granted.js +2 -2
  82. package/src/Push/is-push-supported.js +2 -2
  83. package/src/Push/push-manager-factory.js +15 -15
  84. package/src/Push/push-manager.js +13 -13
  85. package/src/Push/register-push.js +2 -2
  86. package/src/Push/request-push-permission.js +2 -2
  87. package/src/Push/unregister-push-token-on-server.js +3 -3
  88. package/src/Push/unregister-push.js +3 -3
  89. package/src/Push/utils/push-utils.js +15 -15
  90. package/src/User/user-manager.js +9 -9
  91. package/src/User/user.js +50 -50
  92. package/src/common/constants.js +1 -1
  93. package/src/common/content-cards-display.js +22 -22
  94. package/src/common/event-logger.js +3 -3
  95. package/src/index.js +2 -9
  96. package/src/l10n/l10n-manager-factory.js +4 -4
  97. package/src/l10n/l10n-manager.js +6 -6
  98. package/src/managers/auth-manager.js +28 -28
  99. package/src/managers/braze-action-manager.js +14 -0
  100. package/src/managers/braze-instance.js +159 -151
  101. package/src/managers/device-manager.js +26 -26
  102. package/src/managers/network-manager.js +120 -120
  103. package/src/managers/server-config-manager.js +95 -86
  104. package/src/managers/session-manager.js +25 -25
  105. package/src/managers/storage-manager-factory.js +12 -12
  106. package/src/managers/storage-manager.js +129 -124
  107. package/src/managers/subscription-manager.js +8 -8
  108. package/src/models/backend-errors.js +5 -5
  109. package/src/models/braze-event.js +5 -5
  110. package/src/models/device.js +2 -2
  111. package/src/models/identifier.js +8 -8
  112. package/src/models/push-token.js +6 -6
  113. package/src/models/request-result.js +2 -2
  114. package/src/models/server-config.js +27 -27
  115. package/src/request-controller.js +117 -117
  116. package/src/standard-index.js +9 -0
  117. package/src/triggers/models/custom-event-data.js +4 -4
  118. package/src/triggers/models/custom-event-property-data.js +5 -5
  119. package/src/triggers/models/filter-set.js +5 -5
  120. package/src/triggers/models/filter.js +31 -31
  121. package/src/triggers/models/in-app-message-click-data.js +9 -9
  122. package/src/triggers/models/purchase-data.js +1 -1
  123. package/src/triggers/models/purchase-property-data.js +5 -5
  124. package/src/triggers/models/push-click-data.js +4 -4
  125. package/src/triggers/models/trigger-condition.js +35 -35
  126. package/src/triggers/models/trigger-events.js +3 -3
  127. package/src/triggers/models/trigger.js +36 -36
  128. package/src/triggers/triggers-provider-factory.js +5 -5
  129. package/src/triggers/triggers-provider.js +128 -128
  130. package/src/types.js +2 -2
  131. package/src/ui/js/attach-css.js +1 -1
  132. package/src/ui/js/chat-widget-css.js +11 -0
  133. package/src/ui/js/load-font-awesome.js +1 -1
  134. package/src/util/base-device-parser.js +7 -7
  135. package/src/util/braze-actions.js +5 -5
  136. package/src/util/browser-detector.js +41 -41
  137. package/src/util/client-hints-parser.js +10 -10
  138. package/src/util/component-utils.js +1 -1
  139. package/src/util/date-utils.js +2 -2
  140. package/src/util/device-constants.js +5 -5
  141. package/src/util/dom-utils.js +8 -8
  142. package/src/util/ecommerce-event-validation.js +13 -13
  143. package/src/util/html-display-utils.js +6 -6
  144. package/src/util/key-codes.js +1 -1
  145. package/src/util/net.js +82 -44
  146. package/src/util/request-header-utils.js +26 -24
  147. package/src/util/user-agent-parser.js +21 -21
  148. package/src/util/validation-utils.js +29 -21
  149. package/src/util/window-utils.js +3 -3
@@ -2,88 +2,88 @@ import { STORAGE_KEYS as s } from "../managers/storage-manager.js";
2
2
  import { Guid as V, logger as b } from "../../shared-lib/index.js";
3
3
  export const REFRESH_LOCK_TTL_MS = 2e3;
4
4
  export const CONFIG_POLL_INTERVAL_MS = 100;
5
- const ht = [s.It._i, s.It.Oi, s.It.Gi, s.It.Hi];
5
+ const wt = [s.It.Re, s.It._e, s.It.Fe, s.It.Me];
6
6
  export function isConfigExpired(t) {
7
7
  return !!t && Math.floor(new Date().valueOf() / 1e3) >= t;
8
8
  }
9
9
  export function isConfigUsable(t) {
10
- return Boolean(t.Ki && t.host) && !isConfigExpired(t.expiration);
10
+ return Boolean(t.Oe && t.host) && !isConfigExpired(t.expiration);
11
11
  }
12
- export default class lt {
12
+ export default class xt {
13
13
  constructor(t) {
14
- (this.j = t), (this.j = t), (this.Vi = null), (this.Wi = null);
14
+ (this.j = t), (this.j = t), (this.Ue = null), (this.Ge = null);
15
15
  }
16
16
  read() {
17
17
  return this.j
18
18
  ? {
19
- Ki: this.j.St(s.It._i),
20
- host: this.j.St(s.It.Oi),
21
- Qi: this.j.St(s.It.Gi),
22
- expiration: this.j.St(s.It.Hi),
19
+ Oe: this.j.St(s.It.Re),
20
+ host: this.j.St(s.It._e),
21
+ He: this.j.St(s.It.Fe),
22
+ expiration: this.j.St(s.It.Me),
23
23
  }
24
- : { Ki: null, host: null, Qi: null, expiration: null };
24
+ : { Oe: null, host: null, He: null, expiration: null };
25
25
  }
26
26
  write(t) {
27
27
  const i = this.j;
28
28
  i &&
29
- (i.Pt(s.It._i, t.Ki),
30
- i.Pt(s.It.Oi, t.host),
31
- t.Qi ? i.Pt(s.It.Gi, t.Qi) : i.Vt(s.It.Gi),
32
- t.expiration ? i.Pt(s.It.Hi, t.expiration) : i.Vt(s.It.Hi));
29
+ (i.Pt(s.It.Re, t.Oe),
30
+ i.Pt(s.It._e, t.host),
31
+ t.He ? i.Pt(s.It.Fe, t.He) : i.Vt(s.It.Fe),
32
+ t.expiration ? i.Pt(s.It.Me, t.expiration) : i.Vt(s.It.Me));
33
33
  }
34
34
  clear() {
35
35
  const t = this.j;
36
- t && (t.Vt(s.It._i), t.Vt(s.It.Oi), t.Vt(s.It.Gi), t.Vt(s.It.Hi));
36
+ t && (t.Vt(s.It.Re), t.Vt(s.It._e), t.Vt(s.It.Fe), t.Vt(s.It.Me));
37
37
  }
38
- Yi() {
38
+ Ve() {
39
39
  const t = this.j;
40
40
  if (!t) return V.de();
41
- const i = t.St(s.It.Zi),
41
+ const i = t.St(s.It.We),
42
42
  e = new Date().valueOf();
43
43
  if (i && "number" == typeof i.e && i.e > e) return null;
44
44
  const n = V.de();
45
- t.Pt(s.It.Zi, { t: n, e: e + 2e3 });
46
- const r = t.St(s.It.Zi);
45
+ t.Pt(s.It.We, { t: n, e: e + 2e3 });
46
+ const r = t.St(s.It.We);
47
47
  return r && r.t === n ? n : null;
48
48
  }
49
- we(t) {
49
+ Je(t) {
50
50
  const i = this.j;
51
51
  if (!i) return;
52
- const e = i.St(s.It.Zi);
53
- (e && e.t !== t) || i.Vt(s.It.Zi);
52
+ const e = i.St(s.It.We);
53
+ (e && e.t !== t) || i.Vt(s.It.We);
54
54
  }
55
- xe(t, i) {
56
- if (this.Vi || null !== this.Wi) return !1;
55
+ Qe(t, i) {
56
+ if (this.Ue || null !== this.Ge) return !1;
57
57
  const e = this.read();
58
58
  if (isConfigUsable(e)) return t(e), !0;
59
59
  const s = new Date().valueOf() + 2e3,
60
60
  n = () => {
61
61
  const e = this.read();
62
- if (isConfigUsable(e)) return this.Le(), void t(e);
62
+ if (isConfigUsable(e)) return this.Xe(), void t(e);
63
63
  new Date().valueOf() >= s &&
64
- (this.Le(),
64
+ (this.Xe(),
65
65
  b.info(
66
66
  "Timed out waiting for another tab to refresh real-time messaging configuration",
67
67
  ),
68
68
  i());
69
69
  };
70
70
  return (
71
- (this.Vi = (t) => {
71
+ (this.Ue = (t) => {
72
72
  if (t.key)
73
- for (let i = 0; i < ht.length; i++)
74
- if (0 === t.key.indexOf(ht[i])) return void n();
73
+ for (let i = 0; i < wt.length; i++)
74
+ if (0 === t.key.indexOf(wt[i])) return void n();
75
75
  }),
76
- window.addEventListener("storage", this.Vi),
77
- (this.Wi = window.setInterval(n, 100)),
76
+ window.addEventListener("storage", this.Ue),
77
+ (this.Ge = window.setInterval(n, 100)),
78
78
  !0
79
79
  );
80
80
  }
81
- Le() {
82
- this.Vi &&
83
- (window.removeEventListener("storage", this.Vi), (this.Vi = null)),
84
- null !== this.Wi && (window.clearInterval(this.Wi), (this.Wi = null));
81
+ Xe() {
82
+ this.Ue &&
83
+ (window.removeEventListener("storage", this.Ue), (this.Ue = null)),
84
+ null !== this.Ge && (window.clearInterval(this.Ge), (this.Ge = null));
85
85
  }
86
86
  destroy() {
87
- this.Le();
87
+ this.Xe();
88
88
  }
89
89
  }
@@ -1,7 +1,7 @@
1
1
  import { STORAGE_KEYS as s } from "../managers/storage-manager.js";
2
2
  export const MESSAGE_CLAIM_WINDOW_MS = 500;
3
- const ct = ["ccr", "ffr", "tgr"];
4
- export default class at {
3
+ const Mt = ["ccr", "ffr", "tgr"];
4
+ export default class At {
5
5
  constructor(t) {
6
6
  (this.j = t), (this.j = t);
7
7
  }
@@ -10,7 +10,7 @@ export default class at {
10
10
  if (
11
11
  !r ||
12
12
  !(function (t) {
13
- for (const r of ct) if (r === t) return !0;
13
+ for (const r of Mt) if (r === t) return !0;
14
14
  return !1;
15
15
  })(t)
16
16
  )
@@ -1,22 +1,22 @@
1
1
  import r from "../managers/braze-instance.js";
2
- import sr from "./dust-provider.js";
3
- const dr = {
2
+ import dr from "./dust-provider.js";
3
+ const nt = {
4
4
  i: !1,
5
5
  provider: null,
6
6
  o: () => {
7
- if ((dr.t(), !dr.provider)) {
7
+ if ((nt.t(), !nt.provider)) {
8
8
  const t = r.er("dustHost");
9
- (dr.provider = new sr(r.m(), r.p(), r.l(), t)),
10
- r.v(dr.provider),
11
- dr.provider.Hr();
9
+ (nt.provider = new dr(r.m(), r.p(), r.l(), t)),
10
+ r.v(nt.provider),
11
+ nt.provider.Hr();
12
12
  }
13
- return dr.provider;
13
+ return nt.provider;
14
14
  },
15
15
  t: () => {
16
- dr.i || (r.g(dr), (dr.i = !0));
16
+ nt.i || (r.g(nt), (nt.i = !0));
17
17
  },
18
18
  destroy: () => {
19
- dr.provider && dr.provider.destroy(), (dr.provider = null), (dr.i = !1);
19
+ nt.provider && nt.provider.destroy(), (nt.provider = null), (nt.i = !1);
20
20
  },
21
21
  };
22
- export default dr;
22
+ export default nt;