@braze/web-sdk 4.10.1 → 5.0.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 (202) hide show
  1. package/index.d.ts +26 -111
  2. package/package.json +1 -1
  3. package/shared-lib/braze-shared-lib.js +8 -1
  4. package/shared-lib/encoding-utils.js +12 -1
  5. package/shared-lib/event-types.js +34 -1
  6. package/shared-lib/guid.js +10 -1
  7. package/shared-lib/indexed-db-adapter.js +352 -1
  8. package/shared-lib/logger.js +38 -1
  9. package/shared-lib/supported-options.js +26 -1
  10. package/shared-lib/types.js +1 -1
  11. package/src/Card/card-manager-factory.js +14 -1
  12. package/src/Card/card-manager.js +78 -1
  13. package/src/Card/display/card-display.js +138 -1
  14. package/src/Card/index.js +6 -1
  15. package/src/Card/log-card-click.js +11 -1
  16. package/src/Card/log-card-dismissal.js +11 -1
  17. package/src/Card/log-card-impressions.js +13 -1
  18. package/src/Card/log-content-card-click.js +4 -1
  19. package/src/Card/log-content-card-impressions.js +4 -1
  20. package/src/Card/models/captioned-image.js +33 -1
  21. package/src/Card/models/card.js +197 -1
  22. package/src/Card/models/classic-card.js +32 -1
  23. package/src/Card/models/control-card.js +23 -1
  24. package/src/Card/models/image-only.js +31 -1
  25. package/src/Card/models/index.js +5 -1
  26. package/src/Card/types.js +1 -1
  27. package/src/Card/util/card-factory.js +104 -1
  28. package/src/ContentCards/content-cards-provider-factory.js +20 -1
  29. package/src/ContentCards/content-cards-provider.js +391 -1
  30. package/src/ContentCards/content-cards.js +24 -1
  31. package/src/ContentCards/get-cached-content-cards.js +5 -1
  32. package/src/ContentCards/index.js +7 -1
  33. package/src/ContentCards/request-content-cards-refresh.js +5 -1
  34. package/src/ContentCards/subscribe-to-content-cards-updates.js +17 -1
  35. package/src/ContentCards/types.js +1 -1
  36. package/src/ContentCards/ui/hide-content-cards.js +8 -1
  37. package/src/ContentCards/ui/show-content-cards.js +77 -1
  38. package/src/ContentCards/ui/toggle-content-cards.js +8 -1
  39. package/src/Core/add-sdk-metadata.js +26 -1
  40. package/src/Core/braze-sdk-metadata.js +10 -1
  41. package/src/Core/change-user.js +17 -1
  42. package/src/Core/destroy.js +5 -1
  43. package/src/Core/device-properties.js +9 -1
  44. package/src/Core/disable-sdk.js +15 -1
  45. package/src/Core/enable-sdk.js +11 -1
  46. package/src/Core/get-device-id.js +13 -1
  47. package/src/Core/get-user.js +4 -1
  48. package/src/Core/handle-braze-action.js +87 -1
  49. package/src/Core/index.js +23 -1
  50. package/src/Core/initialize.js +4 -1
  51. package/src/Core/is-disabled.js +4 -1
  52. package/src/Core/log-custom-event.js +38 -1
  53. package/src/Core/log-purchase.js +245 -1
  54. package/src/Core/open-session.js +25 -1
  55. package/src/Core/remove-all-subscriptions.js +4 -1
  56. package/src/Core/remove-subscription.js +4 -1
  57. package/src/Core/request-immediate-data-flush.js +6 -1
  58. package/src/Core/set-logger.js +4 -1
  59. package/src/Core/set-sdk-authentication-signature.js +8 -1
  60. package/src/Core/subscribe-to-sdk-authentication-failures.js +6 -1
  61. package/src/Core/toggle-logging.js +4 -1
  62. package/src/Core/types.js +1 -1
  63. package/src/Core/wipe-data.js +16 -1
  64. package/src/FeatureFlags/feature-flag-factory.js +24 -1
  65. package/src/FeatureFlags/feature-flag.js +64 -1
  66. package/src/FeatureFlags/feature-flags-provider-factory.js +19 -1
  67. package/src/FeatureFlags/feature-flags-provider.js +145 -1
  68. package/src/FeatureFlags/get-all-feature-flags.js +12 -1
  69. package/src/FeatureFlags/get-feature-flag.js +10 -1
  70. package/src/FeatureFlags/index.js +6 -1
  71. package/src/FeatureFlags/log-feature-flag-impression.js +23 -1
  72. package/src/FeatureFlags/refresh-feature-flags.js +9 -1
  73. package/src/FeatureFlags/subscribe-to-feature-flags-updates.js +9 -1
  74. package/src/FeatureFlags/types.js +1 -1
  75. package/src/Feed/feed-provider-factory.js +18 -1
  76. package/src/Feed/feed-provider.js +90 -1
  77. package/src/Feed/feed.js +20 -1
  78. package/src/Feed/get-cached-feed.js +5 -1
  79. package/src/Feed/index.js +8 -1
  80. package/src/Feed/log-feed-displayed.js +7 -1
  81. package/src/Feed/request-feed-refresh.js +5 -1
  82. package/src/Feed/subscribe-to-feed-updates.js +5 -1
  83. package/src/Feed/types.js +1 -1
  84. package/src/Feed/ui/hide-feed.js +7 -1
  85. package/src/Feed/ui/show-feed.js +96 -1
  86. package/src/Feed/ui/toggle-feed.js +8 -1
  87. package/src/InAppMessage/defer-in-app-message.js +13 -1
  88. package/src/InAppMessage/display/get-animation-effect.js +19 -1
  89. package/src/InAppMessage/display/html-message-to-html.js +243 -1
  90. package/src/InAppMessage/display/in-app-message-to-html.js +188 -1
  91. package/src/InAppMessage/display/modal-utils.js +73 -1
  92. package/src/InAppMessage/get-deferred-in-app-message.js +5 -1
  93. package/src/InAppMessage/in-app-message-factory.js +166 -1
  94. package/src/InAppMessage/in-app-message-manager-factory.js +16 -1
  95. package/src/InAppMessage/in-app-message-manager.js +248 -1
  96. package/src/InAppMessage/index.js +16 -1
  97. package/src/InAppMessage/log-in-app-message-button-click.js +27 -1
  98. package/src/InAppMessage/log-in-app-message-click.js +19 -1
  99. package/src/InAppMessage/log-in-app-message-html-click.js +23 -1
  100. package/src/InAppMessage/log-in-app-message-impression.js +13 -1
  101. package/src/InAppMessage/models/control-message.js +11 -1
  102. package/src/InAppMessage/models/full-screen-message.js +105 -1
  103. package/src/InAppMessage/models/html-message.js +68 -1
  104. package/src/InAppMessage/models/in-app-message-button.js +47 -1
  105. package/src/InAppMessage/models/in-app-message.js +382 -1
  106. package/src/InAppMessage/models/modal-message.js +101 -1
  107. package/src/InAppMessage/models/slide-up-message.js +84 -1
  108. package/src/InAppMessage/models/templated-in-app-message.js +19 -1
  109. package/src/InAppMessage/subscribe-to-in-app-message.js +10 -1
  110. package/src/InAppMessage/types.js +1 -1
  111. package/src/InAppMessage/ui/automatically-show-in-app-messages.js +15 -1
  112. package/src/InAppMessage/ui/show-in-app-message.js +181 -1
  113. package/src/InAppMessage/utils/in-app-message-utils.js +1 -1
  114. package/src/Push/index.js +5 -1
  115. package/src/Push/is-push-blocked.js +5 -1
  116. package/src/Push/is-push-permission-granted.js +5 -1
  117. package/src/Push/is-push-supported.js +5 -1
  118. package/src/Push/push-manager-factory.js +30 -1
  119. package/src/Push/push-manager.js +387 -1
  120. package/src/Push/request-push-permission.js +9 -1
  121. package/src/Push/types.js +1 -1
  122. package/src/Push/unregister-push.js +5 -1
  123. package/src/Push/utils/push-utils.js +36 -1
  124. package/src/User/index.js +1 -1
  125. package/src/User/types.js +1 -1
  126. package/src/User/user-manager.js +73 -1
  127. package/src/User/user.js +302 -1
  128. package/src/common/base-feed.js +29 -1
  129. package/src/common/base-provider.js +6 -1
  130. package/src/common/constants.js +14 -1
  131. package/src/common/event-logger.js +31 -1
  132. package/src/common/feed-display.js +210 -1
  133. package/src/common/translations.js +148 -1
  134. package/src/common/types.js +1 -1
  135. package/src/index.js +9 -1
  136. package/src/l10n/l10n-manager-factory.js +22 -1
  137. package/src/l10n/l10n-manager.js +25 -1
  138. package/src/l10n/types.js +1 -1
  139. package/src/managers/auth-manager.js +51 -1
  140. package/src/managers/braze-instance.js +322 -1
  141. package/src/managers/device-manager.js +85 -1
  142. package/src/managers/network-manager.js +256 -1
  143. package/src/managers/server-config-manager.js +108 -1
  144. package/src/managers/session-manager.js +75 -1
  145. package/src/managers/storage-manager-factory.js +42 -1
  146. package/src/managers/storage-manager.js +426 -1
  147. package/src/managers/subscription-manager.js +28 -1
  148. package/src/managers/types.js +1 -1
  149. package/src/models/backend-errors.js +8 -1
  150. package/src/models/braze-event.js +47 -1
  151. package/src/models/braze-sdk-metadata.js +10 -1
  152. package/src/models/device.js +18 -1
  153. package/src/models/identifier.js +19 -1
  154. package/src/models/push-token.js +27 -1
  155. package/src/models/request-result.js +8 -1
  156. package/src/models/server-config.js +48 -1
  157. package/src/models/types.js +1 -1
  158. package/src/request-controller.js +311 -1
  159. package/src/triggers/models/custom-event-data.js +14 -1
  160. package/src/triggers/models/custom-event-property-data.js +21 -1
  161. package/src/triggers/models/filter-set.js +55 -1
  162. package/src/triggers/models/filter.js +102 -1
  163. package/src/triggers/models/in-app-message-click-data.js +25 -1
  164. package/src/triggers/models/purchase-data.js +14 -1
  165. package/src/triggers/models/purchase-property-data.js +21 -1
  166. package/src/triggers/models/push-click-data.js +15 -1
  167. package/src/triggers/models/trigger-condition.js +105 -1
  168. package/src/triggers/models/trigger-events.js +8 -1
  169. package/src/triggers/models/trigger.js +122 -1
  170. package/src/triggers/triggers-provider-factory.js +34 -1
  171. package/src/triggers/triggers-provider.js +326 -1
  172. package/src/triggers/types.js +1 -1
  173. package/src/types.js +1 -1
  174. package/src/ui/js/attach-css.js +13 -1
  175. package/src/ui/js/feed-css.js +12 -1
  176. package/src/ui/js/iam-css.js +12 -1
  177. package/src/ui/js/index.js +3 -1
  178. package/src/ui/js/load-font-awesome.js +13 -1
  179. package/src/util/base-device-parser.js +14 -1
  180. package/src/util/braze-actions.js +84 -1
  181. package/src/util/browser-detector.js +84 -1
  182. package/src/util/client-hints-parser.js +66 -1
  183. package/src/util/code-utils.js +100 -1
  184. package/src/util/color-utils.js +29 -1
  185. package/src/util/component-utils.js +26 -1
  186. package/src/util/date-utils.js +28 -1
  187. package/src/util/deprecation-utils.js +5 -1
  188. package/src/util/device-constants.js +13 -1
  189. package/src/util/dom-utils.js +91 -1
  190. package/src/util/error-utils.js +2 -1
  191. package/src/util/key-codes.js +1 -1
  192. package/src/util/math.js +5 -1
  193. package/src/util/net.js +71 -1
  194. package/src/util/request-header-utils.js +46 -1
  195. package/src/util/string-utils.js +22 -1
  196. package/src/util/types.js +1 -1
  197. package/src/util/url-utils.js +20 -1
  198. package/src/util/user-agent-parser.js +80 -1
  199. package/src/util/validation-utils.js +217 -1
  200. package/src/util/window-utils.js +34 -1
  201. package/src/Card/models/banner.js +0 -1
  202. package/src/ContentCards/log-content-cards-displayed.js +0 -1
@@ -1 +1,391 @@
1
- import C,{readResponseHeaders as b}from"../util/net.js";import y from"../common/base-provider.js";import e from"../managers/braze-instance.js";import ContentCards from"./content-cards.js";import{dateFromUnixTimestamp as l}from"../util/date-utils.js";import{isURIJavascriptOrData as N}from"../util/url-utils.js";import{newCardFromContentCardsJson as j,newCardFromSerializedValue as R}from"../Card/util/card-factory.js";import r from"../../shared-lib/braze-shared-lib.js";import{STORAGE_KEYS as i}from"../managers/storage-manager.js";import E from"../managers/subscription-manager.js";import s from"../common/event-logger.js";import T from"../util/request-header-utils.js";import{randomInclusive as D}from"../util/math.js";import{MAX_ERROR_RETRIES_CONTENT_CARDS as S}from"../common/constants.js";export default class v extends y{constructor(t,s,i,h,n){super(),this.ft=t,this.u=s,this.wt=i,this.vt=h,this.gt=n,this.ft=t,this.u=s,this.wt=i,this.vt=h,this.gt=n,this.yt=new E,e.jt(this.yt),this.kt=0,this.Ut=0,this.cards=[],this.Lt();const o=r.zt.Ft;new r.xt(o,r.j).Mt(o.Jt.qt,(t=>{this.Pt(t)})),this.$t=null,this._t=null,this.Bt=null,this.Gt=null,this.Ht=null,this.Kt=10,this.Ot=0}Qt(){return this.$t}Vt(t){this.$t=t}Wt(){return this._t}Xt(t){this._t=t}Lt(){if(!this.u)return;const t=this.u.v(i.k.Yt)||[],s=[];for(let i=0;i<t.length;i++){const e=R(t[i]);null!=e&&s.push(e)}this.cards=this.Zt(this.Cs(s,!1)),this.kt=this.u.v(i.k.ws)||this.kt,this.Ut=this.u.v(i.k.vs)||this.Ut}Ns(t,s=!1,e=0,h=0){let r;if(s){r=[];for(const t of this.cards)t.test&&r.push(t)}else r=this.cards.slice();for(let i=0;i<t.length;i++){const e=t[i];let h=null;for(let t=0;t<this.cards.length;t++)if(e.id===this.cards[t].id){h=this.cards[t];break}if(s){const t=j(e);null!=h&&h.viewed&&t&&(t.viewed=!0),null!=t&&r.push(t)}else if(null==h){const t=j(e);null!=t&&r.push(t)}else{if(!h.ot(e))for(let t=0;t<r.length;t++)if(e.id===r[t].id){r.splice(t,1);break}}}this.cards=this.Zt(this.Cs(r,s)),this.Rs(),this.kt=e,this.Ut=h,this.u&&(this.u.D(i.k.ws,this.kt),this.u.D(i.k.vs,this.Ut))}Ts(t){if(this.Ds()&&null!=t&&t.cards){this.u&&this.u.D(i.k.Ss,e.ks());const s=t.full_sync;s||this.Lt(),this.Ns(t.cards,s,t.last_full_sync_at,t.last_card_updated_at),this.yt.Et(this.Us(!0))}}As(t){this.u&&this.u.D(i.k.Ls,t)}Fs(t,e,h){const n=()=>{this.Ms(e,h,!0)},o=t?b(t):null;let l;if(this.Es(),!o||!o["retry-after"])return void this.As(0);const a=o["retry-after"];if(isNaN(a)&&!isNaN(Date.parse(a)))l=Date.parse(a)-(new Date).getTime(),l<0&&n();else{if(isNaN(parseFloat(a.toString()))){const t="Received unexpected value for retry-after header in /sync response";return s.N(r.q.qs,{e:t+": "+a}),void this.As(0)}l=1e3*parseFloat(a.toString())}this.Bt=window.setTimeout((()=>{n()}),l);let u=0;this.u&&(u=this.u.v(i.k.Ls)),(null==u||isNaN(parseInt(u.toString())))&&(u=0),this.As(parseInt(u.toString())+1)}Pt(t){if(!this.Ds())return;this.Lt();const s=this.cards.slice();let i=null;this.ft&&(i=this.ft.getUserId());for(let e=0;e<t.length;e++)if(i===t[e].userId||null==i&&null==t[e].userId){const i=t[e].card;let h=null;for(let t=0;t<this.cards.length;t++)if(i.id===this.cards[t].id){h=this.cards[t];break}if(null==h){const t=j(i);null!=t&&s.push(t)}else{if(!h.ot(i))for(let t=0;t<s.length;t++)if(i.id===s[t].id){s.splice(t,1);break}}}this.cards=this.Zt(this.Cs(s,!1)),this.Rs(),this.yt.Et(this.Us(!0))}Cs(t,s){let e={},h={},r={};this.u&&(e=this.u.v(i.k.C)||{},h=this.u.v(i.k.K)||{},r=this.u.v(i.k.G)||{});const n={},o={},l={};for(let s=0;s<t.length;s++){const i=t[s].id;i&&(e[i]&&(t[s].clicked=!0,n[i]=!0),h[i]&&(t[s].viewed=!0,o[i]=!0),r[i]&&(t[s].dismissed=!0,l[i]=!0))}return s&&this.u&&(this.u.D(i.k.C,n),this.u.D(i.k.K,o),this.u.D(i.k.G,l)),t}Zt(t){const s=[],e=new Date;let h={};this.u&&(h=this.u.v(i.k.G)||{});let n=!1;for(let i=0;i<t.length;i++){const o=t[i].url;if(!this.vt&&o&&N(o)){r.j.error(`Card with url ${o} will not be displayed because Javascript URLs are disabled. Use the "allowUserSuppliedJavascript" option for braze.initialize to enable this card.`);continue}const l=t[i].expiresAt;let a=!0;if(null!=l&&(a=l>=e),a=a&&!t[i].dismissed,a)s.push(t[i]);else{const s=t[i].id;s&&(h[s]=!0),n=!0}}return n&&this.u&&this.u.D(i.k.G,h),s}Rs(){if(!this.u)return;const t=[];for(let s=0;s<this.cards.length;s++)t.push(this.cards[s].ss());this.u.D(i.k.Yt,t)}Es(){this.Bt&&(clearTimeout(this.Bt),this.Bt=null)}Is(){null!=this.Gt&&(clearTimeout(this.Gt),this.Gt=null)}Js(t=1e3*this.Kt,s,i){this.Is(),this.Gt=window.setTimeout((()=>{this.Ms(s,i,!0)}),t),this.Ht=t}Ms(t,s,h=!1,n=!0){var o;const l=this.gt,a=this.u;if(!l||!a)return void("function"==typeof s&&s());const u=!h;if(u&&(this.Es(),this.As(0)),!this.Ds())return void(this.wt&&this.wt.Ps((()=>{this.Ms(t,s)})));let c=!0;if(u&&(null===(o=this.wt)||void 0===o?void 0:o.$s())&&(c=this._s()),!c)return void r.j.info("Content card sync being throttled.");n&&this.Is();const f=l.Bs({},!0);a.v(i.k.Ss)!==e.ks()&&this.Gs(),f.last_full_sync_at=this.kt,f.last_card_updated_at=this.Ut;const d=l.Hs(f,T.Os.Ks,h);let m=!1;l.Qs(f,(()=>{if(this.u){const t=(new Date).valueOf();u&&this.u.D(i.k.Vs,t),T.Ws(this.u,T.Os.Ks,t)}C.Xs({url:l.Ys()+"/content_cards/sync",data:f,headers:d,O:(i,e)=>{if(!l.Zs(f,i,d))return m=!0,void("function"==typeof s&&s());l.ti(),this.Fs(e,t,s),this.Ts(i),m=!1,T.si(this.u,T.Os.Ks,1),"function"==typeof t&&t()},error:t=>{l.ii(t,"retrieving content cards"),m=!0,"function"==typeof s&&s()},ei:()=>{if(m&&n&&!this.Gt&&this.Ot+1<S){T.hi(this.u,T.Os.Ks);let i=this.Ht;(null==i||i<1e3*this.Kt)&&(i=1e3*this.Kt),this.Js(Math.min(3e5,D(1e3*this.Kt,3*i)),t,s),this.Ot=this.Ot+1}}})}))}Us(t){t||this.Lt();const s=this.Zt(this.cards);s.sort(((t,s)=>t.pinned&&!s.pinned?-1:s.pinned&&!t.pinned?1:t.updated&&s.updated&&t.updated>s.updated?-1:t.updated&&s.updated&&s.updated>t.updated?1:0));let e=Math.max(this.Ut||0,this.kt||0);return 0===e&&(e=void 0),this.u&&this.u.v(i.k.vs)===this.Ut&&void 0===e&&(e=this.Ut),new ContentCards(s,l(e))}ri(t){return this.yt.lt(t)}Gs(){this.kt=0,this.Ut=0,this.u&&(this.u.ni(i.k.ws),this.u.ni(i.k.vs))}changeUser(t){t||(this.cards=[],this.yt.Et(new ContentCards(this.cards.slice(),null)),this.u&&(this.u.ni(i.k.Yt),this.u.ni(i.k.C),this.u.ni(i.k.K),this.u.ni(i.k.G))),this.Gs()}clearData(t){this.kt=0,this.Ut=0,this.cards=[],this.yt.Et(new ContentCards(this.cards.slice(),null)),t&&this.u&&(this.u.ni(i.k.Yt),this.u.ni(i.k.C),this.u.ni(i.k.K),this.u.ni(i.k.G),this.u.ni(i.k.ws),this.u.ni(i.k.vs))}Ds(){return!(this.wt&&!this.wt.oi())||(0!==this.wt.li()&&this.ai(),!1)}ui(t){this.u&&this.u.D(i.k.ci,t)}fi(){return this.u?this.u.v(i.k.ci):null}_s(){const t=this.u,s=this.wt;if(!t||!s)return!0;const e=t.v(i.k.Vs);if(null==e||isNaN(e))return!0;const h=s.di(),r=s.mi();if(-1===h||-1===r)return!0;let n=this.fi();(null==n||isNaN(n))&&(n=h);const o=((new Date).valueOf()-e)/1e3;return n=Math.min(n+o/r,h),!(n<1)&&(n=Math.trunc(n)-1,this.ui(n),!0)}ai(){this.yt.Et(new ContentCards([],new Date)),this.u&&this.u.ni(i.k.Yt)}}
1
+ import C, { readResponseHeaders as b } from "../util/net.js";
2
+ import y from "../common/base-provider.js";
3
+ import e from "../managers/braze-instance.js";
4
+ import ContentCards from "./content-cards.js";
5
+ import { dateFromUnixTimestamp as l } from "../util/date-utils.js";
6
+ import { isURIJavascriptOrData as N } from "../util/url-utils.js";
7
+ import {
8
+ newCardFromContentCardsJson as j,
9
+ newCardFromSerializedValue as R,
10
+ } from "../Card/util/card-factory.js";
11
+ import r from "../../shared-lib/braze-shared-lib.js";
12
+ import { STORAGE_KEYS as i } from "../managers/storage-manager.js";
13
+ import E from "../managers/subscription-manager.js";
14
+ import s from "../common/event-logger.js";
15
+ import T from "../util/request-header-utils.js";
16
+ import { randomInclusive as D } from "../util/math.js";
17
+ import { MAX_ERROR_RETRIES_CONTENT_CARDS as S } from "../common/constants.js";
18
+ export default class v extends y {
19
+ constructor(t, s, i, h, n) {
20
+ super(),
21
+ (this.wt = t),
22
+ (this.u = s),
23
+ (this.yt = i),
24
+ (this.Jt = h),
25
+ (this.$t = n),
26
+ (this.wt = t),
27
+ (this.u = s),
28
+ (this.yt = i),
29
+ (this.Jt = h),
30
+ (this.$t = n),
31
+ (this.Bt = new E()),
32
+ e.Ht(this.Bt),
33
+ (this.Kt = 0),
34
+ (this.Qt = 0),
35
+ (this.cards = []),
36
+ this.Yt();
37
+ const o = r.ts.Zt;
38
+ new r.es(o, r.j).ss(o.rs.hs, (t) => {
39
+ this.ns(t);
40
+ }),
41
+ (this.os = null),
42
+ (this.ls = null),
43
+ (this.us = null),
44
+ (this.cs = null),
45
+ (this.fs = null),
46
+ (this.ds = 10),
47
+ (this.ps = 0);
48
+ }
49
+ Cs() {
50
+ return this.os;
51
+ }
52
+ ws(t) {
53
+ this.os = t;
54
+ }
55
+ bs() {
56
+ return this.ls;
57
+ }
58
+ vs(t) {
59
+ this.ls = t;
60
+ }
61
+ Yt() {
62
+ if (!this.u) return;
63
+ const t = this.u.v(i.k.gs) || [],
64
+ s = [];
65
+ for (let i = 0; i < t.length; i++) {
66
+ const e = R(t[i]);
67
+ null != e && s.push(e);
68
+ }
69
+ (this.cards = this.ys(this.Ns(s, !1))),
70
+ (this.Kt = this.u.v(i.k.js) || this.Kt),
71
+ (this.Qt = this.u.v(i.k.Rs) || this.Qt);
72
+ }
73
+ Ts(t, s = !1, e = 0, h = 0) {
74
+ let r;
75
+ if (s) {
76
+ r = [];
77
+ for (const t of this.cards) t.test && r.push(t);
78
+ } else r = this.cards.slice();
79
+ for (let i = 0; i < t.length; i++) {
80
+ const e = t[i];
81
+ let h = null;
82
+ for (let t = 0; t < this.cards.length; t++)
83
+ if (e.id === this.cards[t].id) {
84
+ h = this.cards[t];
85
+ break;
86
+ }
87
+ if (s) {
88
+ const t = j(e);
89
+ null != h && h.viewed && t && (t.viewed = !0), null != t && r.push(t);
90
+ } else if (null == h) {
91
+ const t = j(e);
92
+ null != t && r.push(t);
93
+ } else {
94
+ if (!h.Ct(e))
95
+ for (let t = 0; t < r.length; t++)
96
+ if (e.id === r[t].id) {
97
+ r.splice(t, 1);
98
+ break;
99
+ }
100
+ }
101
+ }
102
+ (this.cards = this.ys(this.Ns(r, s))),
103
+ this.Ds(),
104
+ (this.Kt = e),
105
+ (this.Qt = h),
106
+ this.u && (this.u.D(i.k.js, this.Kt), this.u.D(i.k.Rs, this.Qt));
107
+ }
108
+ Ss(t) {
109
+ if (this.ks() && null != t && t.cards) {
110
+ this.u && this.u.D(i.k.Us, e.As());
111
+ const s = t.full_sync;
112
+ s || this.Yt(),
113
+ this.Ts(t.cards, s, t.last_full_sync_at, t.last_card_updated_at),
114
+ this.Bt.Dt(this.Ls(!0));
115
+ }
116
+ }
117
+ Fs(t) {
118
+ this.u && this.u.D(i.k.zs, t);
119
+ }
120
+ Ms(t, e, h) {
121
+ const n = () => {
122
+ this.xs(e, h, !0);
123
+ },
124
+ o = t ? b(t) : null;
125
+ let l;
126
+ if ((this.Es(), !o || !o["retry-after"])) return void this.Fs(0);
127
+ const a = o["retry-after"];
128
+ if (isNaN(a) && !isNaN(Date.parse(a)))
129
+ (l = Date.parse(a) - new Date().getTime()), l < 0 && n();
130
+ else {
131
+ if (isNaN(parseFloat(a.toString()))) {
132
+ const t =
133
+ "Received unexpected value for retry-after header in /sync response";
134
+ return s.N(r.q.qs, { e: t + ": " + a }), void this.Fs(0);
135
+ }
136
+ l = 1e3 * parseFloat(a.toString());
137
+ }
138
+ this.us = window.setTimeout(() => {
139
+ n();
140
+ }, l);
141
+ let u = 0;
142
+ this.u && (u = this.u.v(i.k.zs)),
143
+ (null == u || isNaN(parseInt(u.toString()))) && (u = 0),
144
+ this.Fs(parseInt(u.toString()) + 1);
145
+ }
146
+ ns(t) {
147
+ if (!this.ks()) return;
148
+ this.Yt();
149
+ const s = this.cards.slice();
150
+ let i = null;
151
+ this.wt && (i = this.wt.getUserId());
152
+ for (let e = 0; e < t.length; e++)
153
+ if (i === t[e].userId || (null == i && null == t[e].userId)) {
154
+ const i = t[e].card;
155
+ let h = null;
156
+ for (let t = 0; t < this.cards.length; t++)
157
+ if (i.id === this.cards[t].id) {
158
+ h = this.cards[t];
159
+ break;
160
+ }
161
+ if (null == h) {
162
+ const t = j(i);
163
+ null != t && s.push(t);
164
+ } else {
165
+ if (!h.Ct(i))
166
+ for (let t = 0; t < s.length; t++)
167
+ if (i.id === s[t].id) {
168
+ s.splice(t, 1);
169
+ break;
170
+ }
171
+ }
172
+ }
173
+ (this.cards = this.ys(this.Ns(s, !1))), this.Ds(), this.Bt.Dt(this.Ls(!0));
174
+ }
175
+ Ns(t, s) {
176
+ let e = {},
177
+ h = {},
178
+ r = {};
179
+ this.u &&
180
+ ((e = this.u.v(i.k.C) || {}),
181
+ (h = this.u.v(i.k.K) || {}),
182
+ (r = this.u.v(i.k.G) || {}));
183
+ const n = {},
184
+ o = {},
185
+ l = {};
186
+ for (let s = 0; s < t.length; s++) {
187
+ const i = t[s].id;
188
+ i &&
189
+ (e[i] && ((t[s].clicked = !0), (n[i] = !0)),
190
+ h[i] && ((t[s].viewed = !0), (o[i] = !0)),
191
+ r[i] && ((t[s].dismissed = !0), (l[i] = !0)));
192
+ }
193
+ return (
194
+ s &&
195
+ this.u &&
196
+ (this.u.D(i.k.C, n), this.u.D(i.k.K, o), this.u.D(i.k.G, l)),
197
+ t
198
+ );
199
+ }
200
+ ys(t) {
201
+ const s = [],
202
+ e = new Date();
203
+ let h = {};
204
+ this.u && (h = this.u.v(i.k.G) || {});
205
+ let n = !1;
206
+ for (let i = 0; i < t.length; i++) {
207
+ const o = t[i].url;
208
+ if (!this.Jt && o && N(o)) {
209
+ r.j.error(
210
+ `Card with url ${o} will not be displayed because Javascript URLs are disabled. Use the "allowUserSuppliedJavascript" option for braze.initialize to enable this card.`,
211
+ );
212
+ continue;
213
+ }
214
+ const l = t[i].expiresAt;
215
+ let a = !0;
216
+ if ((null != l && (a = l >= e), (a = a && !t[i].dismissed), a))
217
+ s.push(t[i]);
218
+ else {
219
+ const s = t[i].id;
220
+ s && (h[s] = !0), (n = !0);
221
+ }
222
+ }
223
+ return n && this.u && this.u.D(i.k.G, h), s;
224
+ }
225
+ Ds() {
226
+ if (!this.u) return;
227
+ const t = [];
228
+ for (let s = 0; s < this.cards.length; s++) t.push(this.cards[s].tt());
229
+ this.u.D(i.k.gs, t);
230
+ }
231
+ Es() {
232
+ this.us && (clearTimeout(this.us), (this.us = null));
233
+ }
234
+ Is() {
235
+ null != this.cs && (clearTimeout(this.cs), (this.cs = null));
236
+ }
237
+ Js(t = 1e3 * this.ds, s, i) {
238
+ this.Is(),
239
+ (this.cs = window.setTimeout(() => {
240
+ this.xs(s, i, !0);
241
+ }, t)),
242
+ (this.fs = t);
243
+ }
244
+ xs(t, s, h = !1, n = !0) {
245
+ var o;
246
+ const l = this.$t,
247
+ a = this.u;
248
+ if (!l || !a) return void ("function" == typeof s && s());
249
+ const u = !h;
250
+ if ((u && (this.Es(), this.Fs(0)), !this.ks()))
251
+ return void (
252
+ this.yt &&
253
+ this.yt.Ps(() => {
254
+ this.xs(t, s);
255
+ })
256
+ );
257
+ let c = !0;
258
+ if (
259
+ (u &&
260
+ (null === (o = this.yt) || void 0 === o ? void 0 : o.$s()) &&
261
+ (c = this._s()),
262
+ !c)
263
+ )
264
+ return void r.j.info("Content card sync being throttled.");
265
+ n && this.Is();
266
+ const f = l.Bs({}, !0);
267
+ a.v(i.k.Us) !== e.As() && this.Gs(),
268
+ (f.last_full_sync_at = this.Kt),
269
+ (f.last_card_updated_at = this.Qt);
270
+ const d = l.Hs(f, T.Os.Ks, h);
271
+ let m = !1;
272
+ l.Qs(f, () => {
273
+ if (this.u) {
274
+ const t = new Date().valueOf();
275
+ u && this.u.D(i.k.Vs, t), T.Ws(this.u, T.Os.Ks, t);
276
+ }
277
+ C.Xs({
278
+ url: l.Ys() + "/content_cards/sync",
279
+ data: f,
280
+ headers: d,
281
+ O: (i, e) => {
282
+ if (!l.Zs(f, i, d))
283
+ return (m = !0), void ("function" == typeof s && s());
284
+ l.ti(),
285
+ this.Ms(e, t, s),
286
+ this.Ss(i),
287
+ (m = !1),
288
+ T.si(this.u, T.Os.Ks, 1),
289
+ "function" == typeof t && t();
290
+ },
291
+ error: (t) => {
292
+ l.ii(t, "retrieving content cards"),
293
+ (m = !0),
294
+ "function" == typeof s && s();
295
+ },
296
+ ei: () => {
297
+ if (m && n && !this.cs && this.ps + 1 < S) {
298
+ T.hi(this.u, T.Os.Ks);
299
+ let i = this.fs;
300
+ (null == i || i < 1e3 * this.ds) && (i = 1e3 * this.ds),
301
+ this.Js(Math.min(3e5, D(1e3 * this.ds, 3 * i)), t, s),
302
+ (this.ps = this.ps + 1);
303
+ }
304
+ },
305
+ });
306
+ });
307
+ }
308
+ Ls(t) {
309
+ t || this.Yt();
310
+ const s = this.ys(this.cards);
311
+ s.sort((t, s) =>
312
+ t.pinned && !s.pinned
313
+ ? -1
314
+ : s.pinned && !t.pinned
315
+ ? 1
316
+ : t.updated && s.updated && t.updated > s.updated
317
+ ? -1
318
+ : t.updated && s.updated && s.updated > t.updated
319
+ ? 1
320
+ : 0,
321
+ );
322
+ let e = Math.max(this.Qt || 0, this.Kt || 0);
323
+ return (
324
+ 0 === e && (e = void 0),
325
+ this.u && this.u.v(i.k.Rs) === this.Qt && void 0 === e && (e = this.Qt),
326
+ new ContentCards(s, l(e))
327
+ );
328
+ }
329
+ ri(t) {
330
+ return this.Bt.It(t);
331
+ }
332
+ Gs() {
333
+ (this.Kt = 0),
334
+ (this.Qt = 0),
335
+ this.u && (this.u.ni(i.k.js), this.u.ni(i.k.Rs));
336
+ }
337
+ changeUser(t) {
338
+ t ||
339
+ ((this.cards = []),
340
+ this.Bt.Dt(new ContentCards(this.cards.slice(), null)),
341
+ this.u &&
342
+ (this.u.ni(i.k.gs),
343
+ this.u.ni(i.k.C),
344
+ this.u.ni(i.k.K),
345
+ this.u.ni(i.k.G))),
346
+ this.Gs();
347
+ }
348
+ clearData(t) {
349
+ (this.Kt = 0),
350
+ (this.Qt = 0),
351
+ (this.cards = []),
352
+ this.Bt.Dt(new ContentCards(this.cards.slice(), null)),
353
+ t &&
354
+ this.u &&
355
+ (this.u.ni(i.k.gs),
356
+ this.u.ni(i.k.C),
357
+ this.u.ni(i.k.K),
358
+ this.u.ni(i.k.G),
359
+ this.u.ni(i.k.js),
360
+ this.u.ni(i.k.Rs));
361
+ }
362
+ ks() {
363
+ return !(this.yt && !this.yt.oi()) || (0 !== this.yt.li() && this.ai(), !1);
364
+ }
365
+ ui(t) {
366
+ this.u && this.u.D(i.k.ci, t);
367
+ }
368
+ fi() {
369
+ return this.u ? this.u.v(i.k.ci) : null;
370
+ }
371
+ _s() {
372
+ const t = this.u,
373
+ s = this.yt;
374
+ if (!t || !s) return !0;
375
+ const e = t.v(i.k.Vs);
376
+ if (null == e || isNaN(e)) return !0;
377
+ const h = s.di(),
378
+ r = s.mi();
379
+ if (-1 === h || -1 === r) return !0;
380
+ let n = this.fi();
381
+ (null == n || isNaN(n)) && (n = h);
382
+ const o = (new Date().valueOf() - e) / 1e3;
383
+ return (
384
+ (n = Math.min(n + o / r, h)),
385
+ !(n < 1) && ((n = Math.trunc(n) - 1), this.ui(n), !0)
386
+ );
387
+ }
388
+ ai() {
389
+ this.Bt.Dt(new ContentCards([], new Date())), this.u && this.u.ni(i.k.gs);
390
+ }
391
+ }
@@ -1 +1,24 @@
1
- import x from"../common/base-feed.js";import{logCardClick,logCardImpressions}from"../Card/index.js";import{requestContentCardsRefresh}from"./request-content-cards-refresh.js";export default class ContentCards extends x{constructor(r,e){super(r,e)}getUnviewedCardCount(){return super.getUnreadCardCount()}logCardImpressions(r){logCardImpressions(r,!0)}logCardClick(r){return logCardClick(r,!0)}sr(){requestContentCardsRefresh()}ur(){return!0}}ContentCards.mr=6e4;
1
+ import x from "../common/base-feed.js";
2
+ import { logCardClick, logCardImpressions } from "../Card/index.js";
3
+ import { requestContentCardsRefresh } from "./request-content-cards-refresh.js";
4
+ export default class ContentCards extends x {
5
+ constructor(r, e) {
6
+ super(r, e);
7
+ }
8
+ getUnviewedCardCount() {
9
+ return super.getUnreadCardCount();
10
+ }
11
+ logCardImpressions(r) {
12
+ logCardImpressions(r, !0);
13
+ }
14
+ logCardClick(r) {
15
+ return logCardClick(r, !0);
16
+ }
17
+ sr() {
18
+ requestContentCardsRefresh();
19
+ }
20
+ ur() {
21
+ return !0;
22
+ }
23
+ }
24
+ ContentCards.mr = 6e4;
@@ -1 +1,5 @@
1
- import g from"./content-cards-provider-factory.js";import e from"../managers/braze-instance.js";export function getCachedContentCards(){if(e.rr())return g.er().Us(!1)}
1
+ import g from "./content-cards-provider-factory.js";
2
+ import e from "../managers/braze-instance.js";
3
+ export function getCachedContentCards() {
4
+ if (e.rr()) return g.er().Ls(!1);
5
+ }
@@ -1 +1,7 @@
1
- export{default as ContentCards}from"./content-cards.js";export{getCachedContentCards}from"./get-cached-content-cards.js";export{hideContentCards}from"./ui/hide-content-cards.js";export{logContentCardsDisplayed}from"./log-content-cards-displayed.js";export{requestContentCardsRefresh}from"./request-content-cards-refresh.js";export{showContentCards}from"./ui/show-content-cards.js";export{subscribeToContentCardsUpdates}from"./subscribe-to-content-cards-updates.js";export{toggleContentCards}from"./ui/toggle-content-cards.js";
1
+ export { default as ContentCards } from "./content-cards.js";
2
+ export { getCachedContentCards } from "./get-cached-content-cards.js";
3
+ export { hideContentCards } from "./ui/hide-content-cards.js";
4
+ export { requestContentCardsRefresh } from "./request-content-cards-refresh.js";
5
+ export { showContentCards } from "./ui/show-content-cards.js";
6
+ export { subscribeToContentCardsUpdates } from "./subscribe-to-content-cards-updates.js";
7
+ export { toggleContentCards } from "./ui/toggle-content-cards.js";
@@ -1 +1,5 @@
1
- import e from"../managers/braze-instance.js";import g from"./content-cards-provider-factory.js";export function requestContentCardsRefresh(r,t){if(e.rr())return g.er().Ms(r,t)}
1
+ import e from "../managers/braze-instance.js";
2
+ import g from "./content-cards-provider-factory.js";
3
+ export function requestContentCardsRefresh(r, t) {
4
+ if (e.rr()) return g.er().xs(r, t);
5
+ }
@@ -1 +1,17 @@
1
- import e from"../managers/braze-instance.js";import g from"./content-cards-provider-factory.js";export function subscribeToContentCardsUpdates(r){if(!e.rr())return;const t=g.er(),n=t.ri(r);if(!t.Wt()){const r=e.cr();if(r){const n=r.pr((()=>{t.Ms()}));n&&t.Xt(n)}}return n}
1
+ import e from "../managers/braze-instance.js";
2
+ import g from "./content-cards-provider-factory.js";
3
+ export function subscribeToContentCardsUpdates(r) {
4
+ if (!e.rr()) return;
5
+ const t = g.er(),
6
+ n = t.ri(r);
7
+ if (!t.bs()) {
8
+ const r = e.cr();
9
+ if (r) {
10
+ const n = r.pr(() => {
11
+ t.xs();
12
+ });
13
+ n && t.vs(n);
14
+ }
15
+ }
16
+ return n;
17
+ }
@@ -1 +1 @@
1
- export{};
1
+ export {};
@@ -1 +1,8 @@
1
- import e from"../../managers/braze-instance.js";import{destroyFeedHtml as k}from"../../common/feed-display.js";export function hideContentCards(n){if(!e.rr())return;const o=document.querySelectorAll(".ab-feed");for(let e=0;e<o.length;e++)(null==n||null!=n&&o[e].parentNode===n)&&k(o[e])}
1
+ import e from "../../managers/braze-instance.js";
2
+ import { destroyFeedHtml as z } from "../../common/feed-display.js";
3
+ export function hideContentCards(n) {
4
+ if (!e.rr()) return;
5
+ const o = document.querySelectorAll(".ab-feed");
6
+ for (let e = 0; e < o.length; e++)
7
+ (null == n || (null != n && o[e].parentNode === n)) && z(o[e]);
8
+ }
@@ -1 +1,77 @@
1
- import e,{OPTIONS as L}from"../../managers/braze-instance.js";import{ContentCards,subscribeToContentCardsUpdates}from"../index.js";import g from"../content-cards-provider-factory.js";import{destroyFeedHtml as k,detectFeedImpressions as q,feedToHtml as I,LAST_REQUESTED_REFRESH_DATA_ATTRIBUTE as M,refreshFeed as $,registerFeedSubscriptionId as A,updateFeedCards as B}from"../../common/feed-display.js";import{setCardHeight as F}from"../../Card/display/card-display.js";import{setupFeedUI as G}from"../../ui/js/index.js";import r from"../../../shared-lib/braze-shared-lib.js";export function showContentCards(n,t){if(!e.rr())return;G();let o=!1;null==n&&(n=document.body,o=!0);const a=e.nn(L.tn)||e.nn(L.en)||!1,i=g.er().Us(!1);"function"==typeof t&&B(i,t(i.cards.slice()),i.lastUpdated,null,a);const s=I(i,a,o),l=g.er(),f=l.Qt();(null==i.lastUpdated||(new Date).valueOf()-i.lastUpdated.valueOf()>ContentCards.mr)&&(null==f||(new Date).valueOf()-f>ContentCards.mr)&&(r.j.info(`Cached content cards were older than max TTL of ${ContentCards.mr} ms, requesting an update from the server.`),$(i,s),l.Vt((new Date).valueOf()));const c=(new Date).valueOf(),u=subscribeToContentCardsUpdates((function(n){const e=s.querySelectorAll(".ab-refresh-button")[0];if(null!=e){let n=500,t=n-=(new Date).valueOf()-c;const o=s.getAttribute(M);o&&(t=parseInt(o),isNaN(t)||(n-=(new Date).valueOf()-t)),setTimeout((function(){e.className=e.className.replace(/fa-spin/g,"")}),Math.max(n,0))}let o=n.cards;"function"==typeof t&&(o=t(o.slice())),B(i,o,n.lastUpdated,s,a)}));A(u,s);const d=function(n){const t=n.querySelectorAll(".ab-feed");let e=null;for(let o=0;o<t.length;o++)t[o].parentNode===n&&(e=t[o]);null!=e?(k(e),null!=e.parentNode&&e.parentNode.replaceChild(s,e)):n.appendChild(s),setTimeout((function(){s.className=s.className.replace("ab-hide","ab-show")}),0),o&&s.focus(),q(i,s),F(i.cards,n)};var m;null!=n?d(n):window.onload=(m=window.onload,function(){"function"==typeof m&&m(new Event("oldLoad")),d(document.body)})}
1
+ import e, { OPTIONS as L } from "../../managers/braze-instance.js";
2
+ import { ContentCards, subscribeToContentCardsUpdates } from "../index.js";
3
+ import g from "../content-cards-provider-factory.js";
4
+ import {
5
+ destroyFeedHtml as z,
6
+ detectFeedImpressions as q,
7
+ feedToHtml as I,
8
+ LAST_REQUESTED_REFRESH_DATA_ATTRIBUTE as M,
9
+ refreshFeed as $,
10
+ registerFeedSubscriptionId as k,
11
+ updateFeedCards as A,
12
+ } from "../../common/feed-display.js";
13
+ import { setCardHeight as B } from "../../Card/display/card-display.js";
14
+ import { setupFeedUI as F } from "../../ui/js/index.js";
15
+ import r from "../../../shared-lib/braze-shared-lib.js";
16
+ export function showContentCards(n, t) {
17
+ if (!e.rr()) return;
18
+ F();
19
+ let o = !1;
20
+ null == n && ((n = document.body), (o = !0));
21
+ const a = e.nn(L.tn) || e.nn(L.en) || !1,
22
+ i = g.er().Ls(!1);
23
+ "function" == typeof t && A(i, t(i.cards.slice()), i.lastUpdated, null, a);
24
+ const s = I(i, a, o),
25
+ l = g.er(),
26
+ f = l.Cs();
27
+ (null == i.lastUpdated ||
28
+ new Date().valueOf() - i.lastUpdated.valueOf() > ContentCards.mr) &&
29
+ (null == f || new Date().valueOf() - f > ContentCards.mr) &&
30
+ (r.j.info(
31
+ `Cached content cards were older than max TTL of ${ContentCards.mr} ms, requesting an update from the server.`,
32
+ ),
33
+ $(i, s),
34
+ l.ws(new Date().valueOf()));
35
+ const c = new Date().valueOf(),
36
+ u = subscribeToContentCardsUpdates(function (n) {
37
+ const e = s.querySelectorAll(".ab-refresh-button")[0];
38
+ if (null != e) {
39
+ let n = 500,
40
+ t = (n -= new Date().valueOf() - c);
41
+ const o = s.getAttribute(M);
42
+ o && ((t = parseInt(o)), isNaN(t) || (n -= new Date().valueOf() - t)),
43
+ setTimeout(
44
+ function () {
45
+ e.className = e.className.replace(/fa-spin/g, "");
46
+ },
47
+ Math.max(n, 0),
48
+ );
49
+ }
50
+ let o = n.cards;
51
+ "function" == typeof t && (o = t(o.slice())),
52
+ A(i, o, n.lastUpdated, s, a);
53
+ });
54
+ k(u, s);
55
+ const d = function (n) {
56
+ const t = n.querySelectorAll(".ab-feed");
57
+ let e = null;
58
+ for (let o = 0; o < t.length; o++) t[o].parentNode === n && (e = t[o]);
59
+ null != e
60
+ ? (z(e), null != e.parentNode && e.parentNode.replaceChild(s, e))
61
+ : n.appendChild(s),
62
+ setTimeout(function () {
63
+ s.className = s.className.replace("ab-hide", "ab-show");
64
+ }, 0),
65
+ o && s.focus(),
66
+ q(i, s),
67
+ B(i.cards, n);
68
+ };
69
+ var m;
70
+ null != n
71
+ ? d(n)
72
+ : (window.onload =
73
+ ((m = window.onload),
74
+ function () {
75
+ "function" == typeof m && m(new Event("oldLoad")), d(document.body);
76
+ }));
77
+ }
@@ -1 +1,8 @@
1
- import e from"../../managers/braze-instance.js";import{hideContentCards,showContentCards}from"../index.js";export function toggleContentCards(n,o){e.rr()&&(document.querySelectorAll(".ab-feed").length>0?hideContentCards():showContentCards(n,o))}
1
+ import e from "../../managers/braze-instance.js";
2
+ import { hideContentCards, showContentCards } from "../index.js";
3
+ export function toggleContentCards(n, o) {
4
+ e.rr() &&
5
+ (document.querySelectorAll(".ab-feed").length > 0
6
+ ? hideContentCards()
7
+ : showContentCards(n, o));
8
+ }
@@ -1 +1,26 @@
1
- import K from"../managers/braze-instance.js";import BrazeSdkMetadata from"./braze-sdk-metadata.js";import{isArray as p,validateValueIsFromEnum as H}from"../util/code-utils.js";import r from"../../shared-lib/braze-shared-lib.js";export function addSdkMetadata(a){if(!K.rr())return;if(!p(a))return r.j.error("Cannot set SDK metadata because metadata is not an array."),!1;for(const t of a)if(!H(BrazeSdkMetadata,t,"sdkMetadata contained an invalid value.","BrazeSdkMetadata"))return!1;const t=K.ar();return t&&t.addSdkMetadata(a),!0}
1
+ import K from "../managers/braze-instance.js";
2
+ import BrazeSdkMetadata from "./braze-sdk-metadata.js";
3
+ import {
4
+ isArray as p,
5
+ validateValueIsFromEnum as G,
6
+ } from "../util/code-utils.js";
7
+ import r from "../../shared-lib/braze-shared-lib.js";
8
+ export function addSdkMetadata(a) {
9
+ if (!K.rr()) return;
10
+ if (!p(a))
11
+ return (
12
+ r.j.error("Cannot set SDK metadata because metadata is not an array."), !1
13
+ );
14
+ for (const t of a)
15
+ if (
16
+ !G(
17
+ BrazeSdkMetadata,
18
+ t,
19
+ "sdkMetadata contained an invalid value.",
20
+ "BrazeSdkMetadata",
21
+ )
22
+ )
23
+ return !1;
24
+ const t = K.ar();
25
+ return t && t.addSdkMetadata(a), !0;
26
+ }
@@ -1 +1,10 @@
1
- export default{GOOGLE_TAG_MANAGER:"gg",MPARTICLE:"mp",SEGMENT:"sg",TEALIUM:"tl",MANUAL:"manu",NPM:"npm",CDN:"wcd",SHOPIFY:"shp"};
1
+ export default {
2
+ GOOGLE_TAG_MANAGER: "gg",
3
+ MPARTICLE: "mp",
4
+ SEGMENT: "sg",
5
+ TEALIUM: "tl",
6
+ MANUAL: "manu",
7
+ NPM: "npm",
8
+ CDN: "wcd",
9
+ SHOPIFY: "shp",
10
+ };
@@ -1 +1,17 @@
1
- import e from"../managers/braze-instance.js";import{getByteLength as U}from"../util/string-utils.js";import r from"../../shared-lib/braze-shared-lib.js";import{User}from"../User/index.js";import{validateStandardString as J}from"../util/validation-utils.js";export function changeUser(i,t){if(!e.rr())return;if(null==i||0===i.length||i!=i)return void r.j.error("changeUser requires a non-empty userId.");if(U(i)>User.lr)return void r.j.error(`Rejected user id "${i}" because it is longer than ${User.lr} bytes.`);if(null!=t&&!J(t,"set signature for new user","signature"))return;const s=e.cr();s&&s.changeUser(i.toString(),e.gr(),t)}
1
+ import e from "../managers/braze-instance.js";
2
+ import { getByteLength as U } from "../util/string-utils.js";
3
+ import r from "../../shared-lib/braze-shared-lib.js";
4
+ import { User } from "../User/index.js";
5
+ import { validateStandardString as H } from "../util/validation-utils.js";
6
+ export function changeUser(i, t) {
7
+ if (!e.rr()) return;
8
+ if (null == i || 0 === i.length || i != i)
9
+ return void r.j.error("changeUser requires a non-empty userId.");
10
+ if (U(i) > User.lr)
11
+ return void r.j.error(
12
+ `Rejected user id "${i}" because it is longer than ${User.lr} bytes.`,
13
+ );
14
+ if (null != t && !H(t, "set signature for new user", "signature")) return;
15
+ const s = e.cr();
16
+ s && s.changeUser(i.toString(), e.gr(), t);
17
+ }
@@ -1 +1,5 @@
1
- import e from"../managers/braze-instance.js";import r from"../../shared-lib/braze-shared-lib.js";export function destroy(){r.j.info("Destroying Braze instance"),e.destroy(!0)}
1
+ import e from "../managers/braze-instance.js";
2
+ import r from "../../shared-lib/braze-shared-lib.js";
3
+ export function destroy() {
4
+ r.j.info("Destroying Braze instance"), e.destroy(!0);
5
+ }
@@ -1 +1,9 @@
1
- export default{BROWSER:"browser",BROWSER_VERSION:"browserVersion",OS:"os",RESOLUTION:"resolution",LANGUAGE:"language",TIME_ZONE:"timeZone",USER_AGENT:"userAgent"};
1
+ export default {
2
+ BROWSER: "browser",
3
+ BROWSER_VERSION: "browserVersion",
4
+ OS: "os",
5
+ RESOLUTION: "resolution",
6
+ LANGUAGE: "language",
7
+ TIME_ZONE: "timeZone",
8
+ USER_AGENT: "userAgent",
9
+ };