@braze/web-sdk 4.2.0 → 4.2.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.
- package/index.d.ts +1 -1
- package/package.json +1 -1
- package/shared-lib/braze-shared-lib.js +1 -1
- package/shared-lib/encoding-utils.js +1 -1
- package/shared-lib/event-types.js +1 -1
- package/shared-lib/indexed-db-adapter.js +1 -1
- package/shared-lib/logger.js +1 -1
- package/shared-lib/supported-options.js +1 -1
- package/src/InAppMessage/in-app-message-manager.js +1 -1
- package/src/InAppMessage/models/in-app-message.js +1 -1
- package/src/InAppMessage/models/modal-message.js +1 -1
- package/src/InAppMessage/models/slide-up-message.js +1 -1
- package/src/InAppMessage/models/templated-in-app-message.js +1 -1
- package/src/InAppMessage/ui/show-in-app-message.js +1 -1
- package/src/Push/is-push-blocked.js +1 -1
- package/src/Push/is-push-permission-granted.js +1 -1
- package/src/Push/is-push-supported.js +1 -1
- package/src/Push/push-manager-factory.js +1 -1
- package/src/Push/push-manager.js +1 -1
- package/src/Push/request-push-permission.js +1 -1
- package/src/Push/unregister-push.js +1 -1
- package/src/Push/utils/push-utils.js +1 -0
- package/src/User/user-manager.js +1 -1
- package/src/User/user.js +1 -1
- package/src/common/feed-display.js +1 -1
- package/src/l10n/l10n-manager-factory.js +1 -1
- package/src/managers/auth-manager.js +1 -1
- package/src/managers/braze-instance.js +1 -1
- package/src/managers/device-manager.js +1 -1
- package/src/managers/network-manager.js +1 -1
- package/src/managers/server-config-manager.js +1 -1
- package/src/managers/session-manager.js +1 -1
- package/src/managers/storage-manager-factory.js +1 -1
- package/src/managers/storage-manager.js +1 -1
- package/src/models/backend-errors.js +1 -1
- package/src/models/braze-event.js +1 -1
- package/src/models/device.js +1 -1
- package/src/models/identifier.js +1 -1
- package/src/models/push-token.js +1 -1
- package/src/models/server-config.js +1 -1
- package/src/request-controller.js +1 -1
- package/src/triggers/models/filter-set.js +1 -1
- package/src/triggers/models/filter.js +1 -1
- package/src/triggers/models/in-app-message-click-data.js +1 -1
- package/src/triggers/models/purchase-data.js +1 -1
- package/src/triggers/models/purchase-property-data.js +1 -1
- package/src/triggers/models/push-click-data.js +1 -1
- package/src/triggers/models/trigger-condition.js +1 -1
- package/src/triggers/models/trigger.js +1 -1
- package/src/triggers/triggers-provider-factory.js +1 -1
- package/src/triggers/triggers-provider.js +1 -1
- package/src/ui/js/attach-css.js +1 -1
- package/src/ui/js/feed-css.js +1 -1
- package/src/ui/js/iam-css.js +1 -1
- package/src/ui/js/load-font-awesome.js +1 -1
- package/src/util/base-device-parser.js +1 -1
- package/src/util/braze-actions.js +1 -1
- package/src/util/browser-detector.js +1 -1
- package/src/util/client-hints-parser.js +1 -1
- package/src/util/net.js +1 -1
- package/src/util/user-agent-parser.js +1 -1
- package/src/util/window-utils.js +1 -1
package/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*
|
|
2
|
-
* Type definitions for @braze/web-sdk v4.2.
|
|
2
|
+
* Type definitions for @braze/web-sdk v4.2.1
|
|
3
3
|
* Project: https://github.com/braze-inc/braze-web-sdk
|
|
4
4
|
* (c) Braze, Inc. 2022 - http://braze.com
|
|
5
5
|
* License available at https://github.com/braze-inc/braze-web-sdk/blob/master/LICENSE
|
package/package.json
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import je from"./encoding-utils.js";import{EventTypes as ve,InternalEventTypes as De}from"./event-types.js";import Be from"./guid.js";import Ae from"./indexed-db-adapter.js";import Ge from"./logger.js";import Oe from"./supported-options.js";const r={
|
|
1
|
+
import je from"./encoding-utils.js";import{EventTypes as ve,InternalEventTypes as De}from"./event-types.js";import Be from"./guid.js";import Ae from"./indexed-db-adapter.js";import Ge from"./logger.js";import Oe from"./supported-options.js";const r={bn:je,A:ve,qr:De,it:Be,qt:Ae,xt:Ae.ep,D:Ge,zo:Oe};export default r;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
const je={
|
|
1
|
+
const je={pn:function(t){const r=(t+"=".repeat((4-t.length%4)%4)).replace(/\-/g,"+").replace(/_/g,"/"),n=atob(r),o=new Uint8Array(n.length);for(let t=0;t<n.length;++t)o[t]=n.charCodeAt(t);return o}};export default je;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
const ve={CustomEvent:"ce",Pr:"p",
|
|
1
|
+
const ve={CustomEvent:"ce",Pr:"p",Sl:"pc",oc:"ca",Ra:"i",qs:"ie",T:"cci",W:"ccic",_:"ccc",L:"ccd",Wh:"ss",bh:"se",Je:"si",Re:"sc",He:"sbc",Pe:"sfe",ro:"iec",vl:"lr",yl:"uae",U:"ci",F:"cc",Al:"lcaa",$l:"lcar",En:"inc",An:"add",Un:"rem",Sn:"set",Cl:"sgu"},De={Fr:"feed_displayed",ac:"content_cards_displayed"};export{ve as EventTypes,De as InternalEventTypes};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export default class Ae{constructor(t,e){this.td="undefined"==typeof window?self:window,this.ed=t,this.nd=e}od(){if("indexedDB"in this.td)return this.td.indexedDB}rd(){try{if(null==this.od())return!1;if(this.od().open("Braze IndexedDB Support Test"),"undefined"!=typeof window){const t=window.chrome||window.browser||window.msBrowser;if(t&&t.runtime&&t.runtime.id)return this.nd.info("Not using IndexedDB for storage because we are running inside an extension"),!1}return!0}catch(t){return this.nd.info("Not using IndexedDB for storage due to following error: "+t),!1}}dd(t,e){const n=this.od().open(this.ed.sd,this.ed.VERSION);if(null==n)return"function"==typeof e&&e(),!1;const o=this;return n.onupgradeneeded=t=>{o.nd.info("Upgrading indexedDB "+o.ed.sd+" to v"+o.ed.VERSION+"...");const e=t.target.result;for(const t in o.ed.$t)o.ed.$t.hasOwnProperty(t)&&!e.objectStoreNames.contains(o.ed.$t[t])&&e.createObjectStore(o.ed.$t[t])},n.onsuccess=n=>{const i=n.target.result;i.onversionchange=()=>{i.close(),"function"==typeof e&&e(),o.nd.error("Needed to close the database unexpectedly because of an upgrade in another tab")},t(i)},n.onerror=t=>(o.nd.info("Could not open indexedDB "+o.ed.sd+" v"+o.ed.VERSION+": "+t.target.errorCode),"function"==typeof e&&e(),!0),!0}setItem(t,e,n,o,i){if(!this.rd())return"function"==typeof i&&i(),!1;const r=this;return this.dd((d=>{if(!d.objectStoreNames.contains(t))return r.nd.error("Could not store object "+e+" in "+t+" on indexedDB "+r.ed.sd+" - "+t+" is not a valid objectStore"),void("function"==typeof i&&i());const s=d.transaction([t],"readwrite").objectStore(t).put(n,e);s.onerror=()=>{r.nd.error("Could not store object "+e+" in "+t+" on indexedDB "+r.ed.sd),"function"==typeof i&&i()},s.onsuccess=()=>{"function"==typeof o&&o()}}),i)}getItem(t,e,n){if(!this.rd())return!1;const o=this;return this.dd((i=>{if(!i.objectStoreNames.contains(t))return void o.nd.error("Could not retrieve object "+e+" in "+t+" on indexedDB "+o.ed.sd+" - "+t+" is not a valid objectStore");const r=i.transaction([t],"readonly").objectStore(t).get(e);r.onerror=()=>{o.nd.error("Could not retrieve object "+e+" in "+t+" on indexedDB "+o.ed.sd)},r.onsuccess=t=>{const e=t.target.result;null!=e&&n(e)}}))}hr(t,e,n){if(!this.rd())return"function"==typeof n&&n(),!1;const o=this;return this.dd((i=>{if(!i.objectStoreNames.contains(t))return o.nd.error("Could not retrieve last record from "+t+" on indexedDB "+o.ed.sd+" - "+t+" is not a valid objectStore"),void("function"==typeof n&&n());const r=i.transaction([t],"readonly").objectStore(t).openCursor(null,"prev");r.onerror=()=>{o.nd.error("Could not open cursor for "+t+" on indexedDB "+o.ed.sd),"function"==typeof n&&n()},r.onsuccess=t=>{const o=t.target.result;null!=o&&null!=o.value&&null!=o.key?e(o.key,o.value):"function"==typeof n&&n()}}),n)}br(t,e){if(!this.rd())return!1;const n=this;return this.dd((o=>{if(!o.objectStoreNames.contains(t))return void n.nd.error("Could not delete record "+e+" from "+t+" on indexedDB "+n.ed.sd+" - "+t+" is not a valid objectStore");o.transaction([t],"readwrite").objectStore(t).delete(e).onerror=()=>{n.nd.error("Could not delete record "+e+" from "+t+" on indexedDB "+n.ed.sd)}}))}Jt(t,e){if(!this.rd())return!1;const n=this;return this.dd((o=>{if(!o.objectStoreNames.contains(t))return void n.nd.error("Could not retrieve objects from "+t+" on indexedDB "+n.ed.sd+" - "+t+" is not a valid objectStore");const i=o.transaction([t],"readwrite").objectStore(t),r=i.openCursor(),d=[];r.onerror=()=>{d.length>0?(n.nd.info("Cursor closed midway through for "+t+" on indexedDB "+n.ed.sd),e(d)):n.nd.error("Could not open cursor for "+t+" on indexedDB "+n.ed.sd)},r.onsuccess=t=>{const n=t.target.result;if(null!=n){if(null!=n.value&&null!=n.key){i.delete(n.key).onsuccess=()=>{d.push(n.value)}}n.continue()}else d.length>0&&e(d)}}))}clearData(){if(!this.rd())return!1;const t=[];for(const e in this.ed.$t)this.ed.$t.hasOwnProperty(e)&&this.ed.$t[e]!==this.ed.$t.oe&&t.push(this.ed.$t[e]);const e=this;return this.dd((function(n){const o=n.transaction(t,"readwrite");for(let n=0;n<t.length;n++){const i=t[n];o.objectStore(i).clear().onerror=function(){e.nd.error("Could not clear "+this.source.name+" on indexedDB "+e.ed.sd)}}o.onerror=function(){e.nd.error("Could not clear object stores on indexedDB "+e.ed.sd)}}))}}Ae.ep={Ft:{sd:"AppboyServiceWorkerAsyncStorage",VERSION:6,$t:{
|
|
1
|
+
export default class Ae{constructor(t,e){this.td="undefined"==typeof window?self:window,this.ed=t,this.nd=e}od(){if("indexedDB"in this.td)return this.td.indexedDB}rd(){try{if(null==this.od())return!1;if(this.od().open("Braze IndexedDB Support Test"),"undefined"!=typeof window){const t=window.chrome||window.browser||window.msBrowser;if(t&&t.runtime&&t.runtime.id)return this.nd.info("Not using IndexedDB for storage because we are running inside an extension"),!1}return!0}catch(t){return this.nd.info("Not using IndexedDB for storage due to following error: "+t),!1}}dd(t,e){const n=this.od().open(this.ed.sd,this.ed.VERSION);if(null==n)return"function"==typeof e&&e(),!1;const o=this;return n.onupgradeneeded=t=>{o.nd.info("Upgrading indexedDB "+o.ed.sd+" to v"+o.ed.VERSION+"...");const e=t.target.result;for(const t in o.ed.$t)o.ed.$t.hasOwnProperty(t)&&!e.objectStoreNames.contains(o.ed.$t[t])&&e.createObjectStore(o.ed.$t[t])},n.onsuccess=n=>{const i=n.target.result;i.onversionchange=()=>{i.close(),"function"==typeof e&&e(),o.nd.error("Needed to close the database unexpectedly because of an upgrade in another tab")},t(i)},n.onerror=t=>(o.nd.info("Could not open indexedDB "+o.ed.sd+" v"+o.ed.VERSION+": "+t.target.errorCode),"function"==typeof e&&e(),!0),!0}setItem(t,e,n,o,i){if(!this.rd())return"function"==typeof i&&i(),!1;const r=this;return this.dd((d=>{if(!d.objectStoreNames.contains(t))return r.nd.error("Could not store object "+e+" in "+t+" on indexedDB "+r.ed.sd+" - "+t+" is not a valid objectStore"),void("function"==typeof i&&i());const s=d.transaction([t],"readwrite").objectStore(t).put(n,e);s.onerror=()=>{r.nd.error("Could not store object "+e+" in "+t+" on indexedDB "+r.ed.sd),"function"==typeof i&&i()},s.onsuccess=()=>{"function"==typeof o&&o()}}),i)}getItem(t,e,n){if(!this.rd())return!1;const o=this;return this.dd((i=>{if(!i.objectStoreNames.contains(t))return void o.nd.error("Could not retrieve object "+e+" in "+t+" on indexedDB "+o.ed.sd+" - "+t+" is not a valid objectStore");const r=i.transaction([t],"readonly").objectStore(t).get(e);r.onerror=()=>{o.nd.error("Could not retrieve object "+e+" in "+t+" on indexedDB "+o.ed.sd)},r.onsuccess=t=>{const e=t.target.result;null!=e&&n(e)}}))}hr(t,e,n){if(!this.rd())return"function"==typeof n&&n(),!1;const o=this;return this.dd((i=>{if(!i.objectStoreNames.contains(t))return o.nd.error("Could not retrieve last record from "+t+" on indexedDB "+o.ed.sd+" - "+t+" is not a valid objectStore"),void("function"==typeof n&&n());const r=i.transaction([t],"readonly").objectStore(t).openCursor(null,"prev");r.onerror=()=>{o.nd.error("Could not open cursor for "+t+" on indexedDB "+o.ed.sd),"function"==typeof n&&n()},r.onsuccess=t=>{const o=t.target.result;null!=o&&null!=o.value&&null!=o.key?e(o.key,o.value):"function"==typeof n&&n()}}),n)}br(t,e){if(!this.rd())return!1;const n=this;return this.dd((o=>{if(!o.objectStoreNames.contains(t))return void n.nd.error("Could not delete record "+e+" from "+t+" on indexedDB "+n.ed.sd+" - "+t+" is not a valid objectStore");o.transaction([t],"readwrite").objectStore(t).delete(e).onerror=()=>{n.nd.error("Could not delete record "+e+" from "+t+" on indexedDB "+n.ed.sd)}}))}Jt(t,e){if(!this.rd())return!1;const n=this;return this.dd((o=>{if(!o.objectStoreNames.contains(t))return void n.nd.error("Could not retrieve objects from "+t+" on indexedDB "+n.ed.sd+" - "+t+" is not a valid objectStore");const i=o.transaction([t],"readwrite").objectStore(t),r=i.openCursor(),d=[];r.onerror=()=>{d.length>0?(n.nd.info("Cursor closed midway through for "+t+" on indexedDB "+n.ed.sd),e(d)):n.nd.error("Could not open cursor for "+t+" on indexedDB "+n.ed.sd)},r.onsuccess=t=>{const n=t.target.result;if(null!=n){if(null!=n.value&&null!=n.key){i.delete(n.key).onsuccess=()=>{d.push(n.value)}}n.continue()}else d.length>0&&e(d)}}))}clearData(){if(!this.rd())return!1;const t=[];for(const e in this.ed.$t)this.ed.$t.hasOwnProperty(e)&&this.ed.$t[e]!==this.ed.$t.oe&&t.push(this.ed.$t[e]);const e=this;return this.dd((function(n){const o=n.transaction(t,"readwrite");for(let n=0;n<t.length;n++){const i=t[n];o.objectStore(i).clear().onerror=function(){e.nd.error("Could not clear "+this.source.name+" on indexedDB "+e.ed.sd)}}o.onerror=function(){e.nd.error("Could not clear object stores on indexedDB "+e.ed.sd)}}))}}Ae.ep={Ft:{sd:"AppboyServiceWorkerAsyncStorage",VERSION:6,$t:{jl:"data",jr:"pushClicks",pu:"pushSubscribed",ud:"fallbackDevice",Mt:"cardUpdates",oe:"optOut",$r:"pendingData",Kn:"sdkAuthenticationSignature"},se:1}};
|
package/shared-lib/logger.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
const Ge={init:function(n){void 0===n&&void 0!==Ge.zg||(Ge.zg=!!n),Ge.Dg||(Ge.Dg=!0)},destroy:function(){Ge.Dg=!1,Ge.zg=void 0,Ge.nd=void 0},setLogger:function(n){"function"==typeof n?(Ge.init(),Ge.nd=n):Ge.info("Ignoring setLogger call since logger is not a function")},toggleLogging:function(){Ge.init(),Ge.zg?(console.log("Disabling Braze logging"),Ge.zg=!1):(console.log("Enabled Braze logging"),Ge.zg=!0)},info:function(n){if(Ge.zg){const o="Braze: "+n;null!=Ge.nd?Ge.nd(o):console.log(o)}},warn:function(n){if(Ge.zg){const o="Braze SDK Warning: "+n+" (v4.2.
|
|
1
|
+
const Ge={init:function(n){void 0===n&&void 0!==Ge.zg||(Ge.zg=!!n),Ge.Dg||(Ge.Dg=!0)},destroy:function(){Ge.Dg=!1,Ge.zg=void 0,Ge.nd=void 0},setLogger:function(n){"function"==typeof n?(Ge.init(),Ge.nd=n):Ge.info("Ignoring setLogger call since logger is not a function")},toggleLogging:function(){Ge.init(),Ge.zg?(console.log("Disabling Braze logging"),Ge.zg=!1):(console.log("Enabled Braze logging"),Ge.zg=!0)},info:function(n){if(Ge.zg){const o="Braze: "+n;null!=Ge.nd?Ge.nd(o):console.log(o)}},warn:function(n){if(Ge.zg){const o="Braze SDK Warning: "+n+" (v4.2.1)";null!=Ge.nd?Ge.nd(o):console.warn(o)}},error:function(n){if(Ge.zg){const o="Braze SDK Error: "+n+" (v4.2.1)";null!=Ge.nd?Ge.nd(o):console.error(o)}}};export default Ge;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export default{
|
|
1
|
+
export default{Rn:"allowCrawlerActivity",Wn:"baseUrl",Vn:"noCookies",Yn:"devicePropertyAllowlist",ta:"disablePushTokenMaintenance",Xn:"enableLogging",Zn:"enableSdkAuthentication",ia:"manageServiceWorkerExternally",ho:"minimumIntervalBetweenTriggerActionsInSeconds",po:"sessionTimeoutInSeconds",Eo:"appVersion",na:"serviceWorkerLocation",ra:"safariWebsitePushId",jn:"localization",ao:"contentSecurityNonce",_o:"enableHtmlInAppMessages",Io:"allowUserSuppliedJavascript",no:"inAppMessageZIndex",lo:"openInAppMessagesInNewTab",en:"openNewsFeedCardsInNewTab",Ui:"requireExplicitInAppMessageDismissal",Ao:"doNotLoadFontAwesome",So:"sdkFlavor",tn:"openCardsInNewTab"};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import b from"../util/net.js";import e from"../managers/braze-instance.js";import ControlMessage from"./models/control-message.js";import HtmlMessage from"./models/html-message.js";import InAppMessage from"./models/in-app-message.js";import InAppMessageButton from"./models/in-app-message-button.js";import s from"../common/event-logger.js";import{newInAppMessageFromJson as it}from"./in-app-message-factory.js";import{randomInclusive as lt}from"../util/math.js";import t from"../models/request-result.js";import r from"../../shared-lib/braze-shared-lib.js";import u from"../managers/subscription-manager.js";import ut from"../triggers/models/trigger.js";import{validateValueIsFromEnum as F}from"../util/code-utils.js";import{BRAZE_ACTION_URI_REGEX as O}from"../util/validation-utils.js";import{containsPushPrimerBrazeAction as pt,containsUnknownBrazeAction as mt,getDecodedBrazeAction as J,ineligibleBrazeActionURLErrorMessage as
|
|
1
|
+
import b from"../util/net.js";import e from"../managers/braze-instance.js";import ControlMessage from"./models/control-message.js";import HtmlMessage from"./models/html-message.js";import InAppMessage from"./models/in-app-message.js";import InAppMessageButton from"./models/in-app-message-button.js";import s from"../common/event-logger.js";import{newInAppMessageFromJson as it}from"./in-app-message-factory.js";import{randomInclusive as lt}from"../util/math.js";import t from"../models/request-result.js";import r from"../../shared-lib/braze-shared-lib.js";import u from"../managers/subscription-manager.js";import ut from"../triggers/models/trigger.js";import{validateValueIsFromEnum as F}from"../util/code-utils.js";import{BRAZE_ACTION_URI_REGEX as O}from"../util/validation-utils.js";import{containsPushPrimerBrazeAction as pt,containsUnknownBrazeAction as mt,getDecodedBrazeAction as J,ineligibleBrazeActionURLErrorMessage as gt,INELIGIBLE_BRAZE_ACTION_URL_ERROR_TYPES as ct}from"../util/braze-actions.js";import ht from"../Push/utils/push-utils.js";export default class ge{constructor(t,s,i,r){this.vt=t,this.j=s,this.h=i,this.v=r,this.De=new u,e.jt(this.De),this._e=1e3,this.Se=6e4}Be(){return this.De}Ee(t){return this.De.ut(t)}Fe(){return this.Ge}Ne(t){this.Ge=t}qe(e,i){if(!F(InAppMessage.Oe,i,`${i} is not a valid in-app message display failure`,"InAppMessage.DisplayFailures"))return new t;const n={trigger_ids:[e],error_code:i};return s.G(r.A.Pe,n)}G(e,i,n,o){const a=new t;let l;if(e instanceof ControlMessage)l={trigger_ids:[e.triggerId]};else{if(i===r.A.Re||e instanceof HtmlMessage&&i===r.A.He){if(!e.k(o))return r.D.info("This in-app message has already received a click. Ignoring analytics event."),a}else if(i===r.A.Je){if(!e.R())return r.D.info("This in-app message has already received an impression. Ignoring analytics event."),a}l=this.Ke(e)}return null==l?a:(null!=n&&(l.bid=n),s.G(i,l))}Qe(e,i){const n=new t;if(!e.k())return r.D.info("This in-app message button has already received a click. Ignoring analytics event."),n;const o=this.Ke(i);return null==o?n:e.id===InAppMessageButton.Ue?(r.D.info("This in-app message button does not have a tracking id. Not logging event to Braze servers."),n):(null!=e.id&&(o.bid=e.id),s.G(r.A.He,o))}Ve(t){if(!(t instanceof InAppMessage))return;const s=t=>{const s=J(t);return mt(s)?gt(ct.We,"In-App Message"):pt(s)&&!ht.Xe()?gt(ct.Ye,"In-App Message"):void 0},e=t.buttons;let i;for(const t of e)if(t.clickAction===InAppMessage.ClickAction.URI&&O.test(t.uri)&&(i=s(t.uri),i))return i;return t.clickAction===InAppMessage.ClickAction.URI&&O.test(t.uri)?s(t.uri):void 0}Ze(t,s,e,i){let n=this.vt.ni(!1,!1);n=this.vt.Ps(n),n.template={trigger_id:t.triggerId,trigger_event_type:s},null!=e&&(n.template.data=e.li());const o=this.vt.Bs(n);this.vt.Gs(n,(()=>{b.Hs({url:`${this.vt.Ks()}/template/`,data:n,headers:o,S:async s=>{if(!this.vt.Os(n,s,o))return this.qe(t.triggerId,InAppMessage.Oe.ui),void("function"==typeof t.pi&&t.pi());if(this.vt.Qs(),null==s||null==s.templated_message)return void this.qe(t.triggerId,InAppMessage.Oe.ui);const e=s.templated_message;if(e.type!==ut.gi.mi)return void this.qe(t.triggerId,InAppMessage.Oe.ci);const i=it(e.data);if(null==i)return void this.qe(t.triggerId,InAppMessage.Oe.ci);let a=this.Ve(i);if(a)return r.D.error(a),void("function"==typeof t.pi&&t.pi());"function"==typeof t.fi?t.fi(i):this.qe(t.triggerId,InAppMessage.Oe.ui)},error:r=>{let n=`getting user personalization for message ${t.triggerId}`;if((new Date).valueOf()-t.di>t.vi)this.qe(t.triggerId,InAppMessage.Oe.ui);else{const r=Math.min(t.vi,this.Se),o=this._e;null==i&&(i=o);const a=Math.min(r,lt(o,3*i));n+=`. Retrying in ${a} ms`,setTimeout((()=>{this.Ze(t,s,e,a)}),a)}this.vt.Vs(r,n)}})}))}Ke(t){if(null==t.triggerId)return r.D.info("The in-app message has no analytics id. Not logging event to Braze servers."),null;const s={};return null!=t.triggerId&&(s.trigger_ids=[t.triggerId]),s}}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import e,{OPTIONS as T}from"../../managers/braze-instance.js";import et from"../../util/browser-detector.js";import{clickElement as
|
|
1
|
+
import e,{OPTIONS as T}from"../../managers/braze-instance.js";import et from"../../util/browser-detector.js";import{clickElement as Et,supportsPassive as Tt}from"../../util/dom-utils.js";import{KeyCodes as at}from"../../util/key-codes.js";import u from"../../managers/subscription-manager.js";export default class InAppMessage{constructor(t,s,i,e,h,n,r,o,l,E,T,a,m,c,I,A,N,_,L,d,O,S,D,M,R,b,P,C,U){this.message=t,this.messageAlignment=s||InAppMessage.TextAlignment.CENTER,this.duration=E||5e3,this.slideFrom=i||InAppMessage.SlideFrom.BOTTOM,this.extras=e||{},this.triggerId=h,this.clickAction=n||InAppMessage.ClickAction.NONE,this.uri=r,this.openTarget=o||InAppMessage.OpenTarget.NONE,this.dismissType=l||InAppMessage.DismissType.AUTO_DISMISS,this.icon=T,this.imageUrl=a,this.imageStyle=m||InAppMessage.ImageStyle.TOP,this.iconColor=c||InAppMessage.ji.ki,this.iconBackgroundColor=I||InAppMessage.ji.bi,this.backgroundColor=A||InAppMessage.ji.ki,this.textColor=N||InAppMessage.ji.Ei,this.closeButtonColor=_||InAppMessage.ji.Ti,this.animateIn=L,null==this.animateIn&&(this.animateIn=!0),this.animateOut=d,null==this.animateOut&&(this.animateOut=!0),this.header=O,this.headerAlignment=S||InAppMessage.TextAlignment.CENTER,this.headerTextColor=D||InAppMessage.ji.Ei,this.frameColor=M||InAppMessage.ji.Ii,this.buttons=R||[],this.cropType=b||InAppMessage.CropType.FIT_CENTER,this.orientation=P,this.htmlId=C,this.css=U,this.Ai=!1,this.nl=!1,this.Ni=!1,this.lt=new u,this._i=new u}subscribeToClickedEvent(t){return this.lt.ut(t)}subscribeToDismissedEvent(t){return this._i.ut(t)}removeSubscription(t){this.lt.removeSubscription(t),this._i.removeSubscription(t)}removeAllSubscriptions(){this.lt.removeAllSubscriptions(),this._i.removeAllSubscriptions()}closeMessage(){this.on(this.mn)}we(){return!0}ll(){return this.we()}an(){return null!=this.htmlId&&this.htmlId.length>4}sn(){return this.an()&&null!=this.css&&this.css.length>0}rn(){if(this.an()&&this.sn())return this.htmlId+"-css"}R(){return!this.Ai&&(this.Ai=!0,!0)}k(){return!this.nl&&(this.nl=!0,this.lt.St(),!0)}J(){return!this.Ni&&(this.Ni=!0,this._i.St(),!0)}Li(t){if(t&&t.parentNode){let s=t.closest(".ab-iam-root");if(null==s&&(s=t),this.we()&&null!=s.parentNode){const t=s.parentNode.classList;t&&t.contains(InAppMessage.Oi)&&t.remove(InAppMessage.Oi),document.body.removeEventListener("touchmove",InAppMessage.Si)}s.className=s.className.replace(InAppMessage.Di,InAppMessage._)}return this.animateOut}on(t,s){if(null==t)return;let i;this.mn=null,i=-1===t.className.indexOf("ab-in-app-message")?t.getElementsByClassName("ab-in-app-message")[0]:t;let e=!1;i&&(e=this.Li(i));const h=document.body;if(null!=h)var n=h.scrollTop;const r=()=>{if(t&&t.parentNode){let s=t.closest(".ab-iam-root");null==s&&(s=t),s.parentNode&&s.parentNode.removeChild(s)}if(null!=this.rn()){const t=document.getElementById(this.rn());t&&t.parentNode&&t.parentNode.removeChild(t)}null!=h&&"Safari"===et.browser&&(h.scrollTop=n),s?s():this.J()};e?setTimeout(r,InAppMessage.Mi):r(),this.he&&this.he.focus()}Me(){return document.createTextNode(this.message)}xe(t){let s="";this.message||this.header||!this.we()||(s="Modal Image"),t.setAttribute("alt",s)}static Si(t){t.targetTouches&&t.targetTouches.length>1||t.target.classList&&t.target.classList.contains("ab-message-text")&&t.target.scrollHeight>t.target.clientHeight||document.querySelector(`.${InAppMessage.Oi}`)&&t.preventDefault()}Ri(t){this.we()&&null!=t.parentNode&&this.orientation!==InAppMessage.Orientation.LANDSCAPE&&(null!=t.parentNode.classList&&t.parentNode.classList.add(InAppMessage.Oi),document.body.addEventListener("touchmove",InAppMessage.Si,!!Tt()&&{passive:!1})),t.className+=" "+InAppMessage.Di}static Pi(t){if(t.keyCode===at.Ci&&!e.nn(T.Ui)&&document.querySelectorAll(".ab-modal-interactions").length>0){const t=document.getElementsByClassName("ab-html-message");let s=!1;for(let i=0;i<t.length;i++){const e=t[i].contentWindow.document.getElementsByClassName("ab-programmatic-close-button")[0];null!=e&&(Et(e),s=!0)}if(!s){const t=document.querySelectorAll(".ab-modal-interactions > .ab-close-button")[0];null!=t&&Et(t)}}}Hi(){this.Fi||e.nn(T.Ui)||(document.addEventListener("keydown",InAppMessage.Pi,!1),e.Bi((()=>{document.removeEventListener("keydown",InAppMessage.Pi)})),this.Fi=!0)}}InAppMessage.ji={Ei:4281545523,ki:4294967295,bi:4278219733,Gi:4293914607,Wi:4283782485,Ii:3224580915,Ti:4288387995},InAppMessage.Oe={wi:"hd",yi:"ias",xi:"of",Ki:"do",ci:"umt",ui:"tf",Yi:"te"},InAppMessage.SlideFrom={TOP:"TOP",BOTTOM:"BOTTOM"},InAppMessage.ClickAction={NEWS_FEED:"NEWS_FEED",URI:"URI",NONE:"NONE"},InAppMessage.DismissType={AUTO_DISMISS:"AUTO_DISMISS",MANUAL:"SWIPE"},InAppMessage.OpenTarget={NONE:"NONE",BLANK:"BLANK"},InAppMessage.ImageStyle={TOP:"TOP",GRAPHIC:"GRAPHIC"},InAppMessage.Orientation={PORTRAIT:"PORTRAIT",LANDSCAPE:"LANDSCAPE"},InAppMessage.TextAlignment={START:"START",CENTER:"CENTER",END:"END"},InAppMessage.CropType={CENTER_CROP:"CENTER_CROP",FIT_CENTER:"FIT_CENTER"},InAppMessage.es={Xi:"SLIDEUP",zi:"MODAL",ye:"MODAL_STYLED",Tr:"FULL",el:"WEB_HTML",cn:"HTML"},InAppMessage.Mi=500,InAppMessage.Vi=200,InAppMessage.Di="ab-show",InAppMessage.$i="ab-hide",InAppMessage.Oi="ab-pause-scrolling";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import InAppMessage from"./in-app-message.js";export default class ModalMessage extends InAppMessage{constructor(e,t,r,s,n,l,o,u,a,p,d,i,m,c,f,g,x,j,v,A,T,b,h,k,q,w,y){super(e,t,null,r,s,n,l,o,u=u||InAppMessage.DismissType.MANUAL,a,p,d,i,m,c,f,g,x,j,v,A,T,b,h,k,q=q||InAppMessage.CropType.FIT_CENTER,void 0,w,y)}get ke(){return InAppMessage.TextAlignment.CENTER}}ModalMessage.es=InAppMessage.es.
|
|
1
|
+
import InAppMessage from"./in-app-message.js";export default class ModalMessage extends InAppMessage{constructor(e,t,r,s,n,l,o,u,a,p,d,i,m,c,f,g,x,j,v,A,T,b,h,k,q,w,y){super(e,t,null,r,s,n,l,o,u=u||InAppMessage.DismissType.MANUAL,a,p,d,i,m,c,f,g,x,j,v,A,T,b,h,k,q=q||InAppMessage.CropType.FIT_CENTER,void 0,w,y)}get ke(){return InAppMessage.TextAlignment.CENTER}}ModalMessage.es=InAppMessage.es.zi;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import InAppMessage from"./in-app-message.js";import{DOMUtils as dt}from"../../util/dom-utils.js";export default class SlideUpMessage extends InAppMessage{constructor(t,e,o,s,n,i,r,d,u,a,p,l,m,c,v,x,g,f,h,I,M){x=x||InAppMessage.ji.Wi,v=v||InAppMessage.ji.Gi,super(t,e=e||InAppMessage.TextAlignment.START,o,s,n,i,r,d,u,a,p,l,null,m,c,v,x,g,f,h,void 0,void 0,void 0,void 0,void 0,void 0,void 0,I,M)}we(){return!1}get ke(){return InAppMessage.TextAlignment.START}Me(){const t=document.createElement("span");return t.appendChild(document.createTextNode(this.message)),t}Ri(t){const e=t.getElementsByClassName("ab-in-app-message")[0];dt.eo(e,!0,!0)||(this.slideFrom===InAppMessage.SlideFrom.TOP?e.style.top="0px":e.style.bottom="0px"),super.Ri(t)}}SlideUpMessage.es=InAppMessage.es.
|
|
1
|
+
import InAppMessage from"./in-app-message.js";import{DOMUtils as dt}from"../../util/dom-utils.js";export default class SlideUpMessage extends InAppMessage{constructor(t,e,o,s,n,i,r,d,u,a,p,l,m,c,v,x,g,f,h,I,M){x=x||InAppMessage.ji.Wi,v=v||InAppMessage.ji.Gi,super(t,e=e||InAppMessage.TextAlignment.START,o,s,n,i,r,d,u,a,p,l,null,m,c,v,x,g,f,h,void 0,void 0,void 0,void 0,void 0,void 0,void 0,I,M)}we(){return!1}get ke(){return InAppMessage.TextAlignment.START}Me(){const t=document.createElement("span");return t.appendChild(document.createTextNode(this.message)),t}Ri(t){const e=t.getElementsByClassName("ab-in-app-message")[0];dt.eo(e,!0,!0)||(this.slideFrom===InAppMessage.SlideFrom.TOP?e.style.top="0px":e.style.bottom="0px"),super.Ri(t)}}SlideUpMessage.es=InAppMessage.es.Xi;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export default class ft{constructor(t,s,l,n,i){this.triggerId=t,this.
|
|
1
|
+
export default class ft{constructor(t,s,l,n,i){this.triggerId=t,this.fi=s,this.pi=l,this.di=n,this.vi=i}static fromJson(t,s,l,n,i){return null==t||null==t.trigger_id?null:new ft(t.trigger_id,s,l,n,i)}}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import e,{OPTIONS as T}from"../../managers/braze-instance.js";import ControlMessage from"../models/control-message.js";import HtmlMessage from"../models/html-message.js";import InAppMessage from"../models/in-app-message.js";import SlideUpMessage from"../models/slide-up-message.js";import pe from"../in-app-message-manager-factory.js";import se from"../display/get-animation-effect.js";import ce from"../display/in-app-message-to-html.js";import{logInAppMessageImpression}from"../log-in-app-message-impression.js";import{ORIENTATION as le,WindowUtils as H}from"../../util/window-utils.js";import{isURIJavascriptOrData as j}from"../../util/url-utils.js";import{KeyCodes as at}from"../../util/key-codes.js";import{setupInAppMessageUI as ss}from"../../ui/js/index.js";import r from"../../../shared-lib/braze-shared-lib.js";import{toRgba as ne}from"../../util/color-utils.js";export function showInAppMessage(t,s,o){if(!e.rr())return;if(ss(),null==t)return!1;if(t instanceof ControlMessage)return r.D.info("User received control for a multivariate test, logging to Braze servers."),logInAppMessageImpression(t),!0;if(!(t instanceof InAppMessage))return!1;const i=pe.m();t.Hi();const n=t instanceof HtmlMessage;if(n&&!t.trusted&&!e.tr())return r.D.error('HTML in-app messages are disabled. Use the "allowUserSuppliedJavascript" option for braze.initialize to enable these messages.'),i.qe(t.triggerId,InAppMessage.Oe.wi),!1;if(null==s&&(s=document.body),t.we()){if(s.querySelectorAll(".ab-modal-interactions").length>0)return r.D.info(`Cannot show in-app message ${t.message} because another message is being shown.`),i.qe(t.triggerId,InAppMessage.Oe.
|
|
1
|
+
import e,{OPTIONS as T}from"../../managers/braze-instance.js";import ControlMessage from"../models/control-message.js";import HtmlMessage from"../models/html-message.js";import InAppMessage from"../models/in-app-message.js";import SlideUpMessage from"../models/slide-up-message.js";import pe from"../in-app-message-manager-factory.js";import se from"../display/get-animation-effect.js";import ce from"../display/in-app-message-to-html.js";import{logInAppMessageImpression}from"../log-in-app-message-impression.js";import{ORIENTATION as le,WindowUtils as H}from"../../util/window-utils.js";import{isURIJavascriptOrData as j}from"../../util/url-utils.js";import{KeyCodes as at}from"../../util/key-codes.js";import{setupInAppMessageUI as ss}from"../../ui/js/index.js";import r from"../../../shared-lib/braze-shared-lib.js";import{toRgba as ne}from"../../util/color-utils.js";export function showInAppMessage(t,s,o){if(!e.rr())return;if(ss(),null==t)return!1;if(t instanceof ControlMessage)return r.D.info("User received control for a multivariate test, logging to Braze servers."),logInAppMessageImpression(t),!0;if(!(t instanceof InAppMessage))return!1;const i=pe.m();t.Hi();const n=t instanceof HtmlMessage;if(n&&!t.trusted&&!e.tr())return r.D.error('HTML in-app messages are disabled. Use the "allowUserSuppliedJavascript" option for braze.initialize to enable these messages.'),i.qe(t.triggerId,InAppMessage.Oe.wi),!1;if(null==s&&(s=document.body),t.we()){if(s.querySelectorAll(".ab-modal-interactions").length>0)return r.D.info(`Cannot show in-app message ${t.message} because another message is being shown.`),i.qe(t.triggerId,InAppMessage.Oe.yi),!1}if(H.so()){const e=H.io();if(e===le.PORTRAIT&&t.orientation===InAppMessage.Orientation.LANDSCAPE||e===le.LANDSCAPE&&t.orientation===InAppMessage.Orientation.PORTRAIT){const s=e===le.PORTRAIT?"portrait":"landscape",o=t.orientation===InAppMessage.Orientation.PORTRAIT?"portrait":"landscape";return r.D.info(`Not showing ${o} in-app message ${t.message} because the screen is currently ${s}`),i.qe(t.triggerId,InAppMessage.Oe.xi),!1}}if(!e.tr()){let e=!1;if(t.buttons&&t.buttons.length>0){const s=t.buttons;for(let t=0;t<s.length;t++)if(s[t].clickAction===InAppMessage.ClickAction.URI){const o=s[t].uri;e=j(o)}}else t.clickAction===InAppMessage.ClickAction.URI&&(e=j(t.uri));if(e)return r.D.error('Javascript click actions are disabled. Use the "allowUserSuppliedJavascript" option for braze.initialize to enable these actions.'),i.qe(t.triggerId,InAppMessage.Oe.wi),!1}const a=document.createElement("div");if(a.className="ab-iam-root v3",a.className+=se(t),a.setAttribute("role","complementary"),t.an()&&(a.id=t.htmlId),e.nn(T.no)&&(a.style.zIndex=e.nn(T.no)+1),s.appendChild(a),t.sn()){const s=document.createElement("style");s.innerHTML=t.css,s.id=t.rn(),null!=e.nn(T.ao)&&s.setAttribute("nonce",e.nn(T.ao)),document.getElementsByTagName("head")[0].appendChild(s)}const l=t instanceof SlideUpMessage,m=ce(t,(()=>{import("../../Feed/ui/show-feed.js").then((e=>e.showFeed()))}),(s=>{if(t.we()&&t.ll()){const o=document.createElement("div");if(o.className="ab-page-blocker",t.sn()||(o.style.backgroundColor=ne(t.frameColor)),e.nn(T.no)&&(o.style.zIndex=e.nn(T.no)),a.appendChild(o),!e.nn(T.Ui)){const e=(new Date).valueOf();o.onclick=o=>{(new Date).valueOf()-e>InAppMessage.Vi&&(t.on(s),o.stopPropagation())}}a.appendChild(s),s.focus(),t.Ri(a)}else if(l){const e=document.querySelectorAll(".ab-slideup");let o=null;for(let t=e.length-1;t>=0;t--)if(e[t]!==s){o=e[t];break}if(t.slideFrom===InAppMessage.SlideFrom.TOP){let e=0;null!=o&&(e=o.offsetTop+o.offsetHeight),s.style.top=Math.max(e,0)+"px"}else{let e=0;null!=o&&(e=(window.innerHeight||document.documentElement.clientHeight)-o.offsetTop),s.style.bottom=Math.max(e,0)+"px"}}else if(n&&!e.nn(T.Ui)){const e=t;s.contentWindow.addEventListener("keydown",(function(t){t.keyCode===at.Ci&&e.closeMessage()}))}logInAppMessageImpression(t),t.dismissType===InAppMessage.DismissType.AUTO_DISMISS&&setTimeout((()=>{a.contains(s)&&t.on(s)}),t.duration),"function"==typeof o&&o()}),e.nn(T.lo),e.nn(T.no),e.nn(T.ao));return(n||l)&&(a.appendChild(m),t.Ri(a)),!0}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import e from"../managers/braze-instance.js";import
|
|
1
|
+
import e from"../managers/braze-instance.js";import ht from"./utils/push-utils.js";export function isPushBlocked(){if(e.rr())return ht.isPushBlocked()}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import e from"../managers/braze-instance.js";import
|
|
1
|
+
import e from"../managers/braze-instance.js";import ht from"./utils/push-utils.js";export function isPushPermissionGranted(){if(e.rr())return ht.isPushPermissionGranted()}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import e from"../managers/braze-instance.js";import
|
|
1
|
+
import e from"../managers/braze-instance.js";import ht from"./utils/push-utils.js";export function isPushSupported(){if(e.rr())return ht.isPushSupported()}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import e,{OPTIONS as T}from"../managers/braze-instance.js";import aa from"./push-manager.js";const
|
|
1
|
+
import e,{OPTIONS as T}from"../managers/braze-instance.js";import aa from"./push-manager.js";const ea={t:!1,pushManager:null,aa:()=>(ea.o(),ea.pushManager||(ea.pushManager=new aa(e.gr(),e.ea(),e.ce(),e.Ks(),e.nn(T.na),e.nn(T.ra),e.ir(),e.nn(T.ta),e.nn(T.ia),e.l())),ea.pushManager),o:()=>{ea.t||(e.u(ea),ea.t=!0)},destroy:()=>{ea.pushManager=null,ea.t=!1}};export default ea;
|
package/src/Push/push-manager.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{isArray as p,isEqual as ii}from"../util/code-utils.js";import ei from"../models/push-token.js";import r from"../../shared-lib/braze-shared-lib.js";import{STORAGE_KEYS as o}from"../managers/storage-manager.js";import{User}from"../User/index.js";import{WindowUtils as H}from"../util/window-utils.js";export default class aa{constructor(i,e,t,s,n,
|
|
1
|
+
import{isArray as p,isEqual as ii}from"../util/code-utils.js";import ei from"../models/push-token.js";import r from"../../shared-lib/braze-shared-lib.js";import{STORAGE_KEYS as o}from"../managers/storage-manager.js";import{User}from"../User/index.js";import{WindowUtils as H}from"../util/window-utils.js";import ht from"./utils/push-utils.js";export default class aa{constructor(i,e,t,s,r,n,o,u,a,h){this.qi=i,this.Ji=e,this.Qi=t,this.Zi=s+"/safari/"+e,this.Sr=r||"/service-worker.js",this._r=n,this.gt=o,this.Ur=u||!1,this.Wr=a||!1,this.h=h,this.Nr=ht.Ir(),this.Vr=ht.Cr()}Er(){return this.Wr}Or(i,e,t,s,n){i.unsubscribe().then((i=>{i?this.Br(e,t,s,n):(r.D.error("Failed to unsubscribe device from push."),"function"==typeof n&&n(!1))})).catch((i=>{r.D.error("Push unsubscription error: "+i),"function"==typeof n&&n(!1)}))}Mr(i,e,t){const s=(i=>{if("string"==typeof i)return i;if(0!==i.endpoint.indexOf("https://android.googleapis.com/gcm/send"))return i.endpoint;let e=i.endpoint;return i.Yr&&-1===i.endpoint.indexOf(i.Yr)&&(e=i.endpoint+"/"+i.Yr),e})(i);let r=null,n=null;if(null!=i.getKey)try{r=btoa(String.fromCharCode.apply(null,new Uint8Array(i.getKey("p256dh")))),n=btoa(String.fromCharCode.apply(null,new Uint8Array(i.getKey("auth"))))}catch(i){if("invalid arguments"!==i.message)throw i}const o=(i=>{let e;return i.options&&(e=i.options.applicationServerKey)&&e.byteLength&&e.byteLength>0?btoa(String.fromCharCode.apply(null,new Uint8Array(e))).replace(/\+/g,"-").replace(/\//g,"_"):null})(i);this.qi.Gr(s,t,r,n,o),s&&"function"==typeof e&&e(s,r,n)}Hr(){this.qi.Jr(!0)}Kr(i,e){this.qi.Jr(!1),r.D.info(i),"function"==typeof e&&e(!1)}Lr(i,e,t,s){if("default"===e.permission)try{window.safari.pushNotification.requestPermission(this.Zi,i,{api_key:this.Ji,device_id:this.Qi.te().id},(e=>{"granted"===e.permission&&this.qi.setPushNotificationSubscriptionType(User.NotificationSubscriptionTypes.OPTED_IN),this.Lr(i,e,t,s)}))}catch(i){this.Kr("Could not request permission for push: "+i,s)}else"denied"===e.permission?this.Kr("The user has blocked notifications from this site, or Safari push is not configured in the Braze dashboard.",s):"granted"===e.permission&&(r.D.info("Device successfully subscribed to push."),this.Mr(e.deviceToken,t,new Date))}Qr(i,e,t){const s=s=>{switch(s){case"granted":return void("function"==typeof i&&i());case"default":return void("function"==typeof e&&e());case"denied":return void("function"==typeof t&&t());default:r.D.error("Received unexpected permission result "+s)}};let n=!1;const o=window.Notification.requestPermission((i=>{n&&s(i)}));o?o.then((i=>{s(i)})):n=!0}Br(i,e,t,s){const n={userVisibleOnly:!0};null!=e&&(n.applicationServerKey=e),i.pushManager.subscribe(n).then((i=>{r.D.info("Device successfully subscribed to push."),this.Mr(i,t,new Date)})).catch((i=>{ht.isPushBlocked()?(r.D.info("Permission for push notifications was denied."),"function"==typeof s&&s(!1)):r.D.error("Push subscription failed: "+i)}))}Xr(){return this.Ur?navigator.serviceWorker.getRegistration():navigator.serviceWorker.register(this.Sr).then((()=>navigator.serviceWorker.ready.then((i=>(i&&"function"==typeof i.update&&i.update().catch((i=>{r.D.info("ServiceWorker update failed: "+i)})),i)))))}Zr(i){this.Ur||(i.unregister(),r.D.info("Service worker successfully unregistered."))}subscribe(i,e){if(ht.isPushSupported()){if(this.Nr){if(!this.Ur&&null!=window.location){let i=this.Sr;-1===i.indexOf(window.location.host)&&(i=window.location.host+i),-1===i.indexOf(window.location.protocol)&&(i=window.location.protocol+"//"+i);const e=i.substr(0,i.lastIndexOf("/")+1);if(0!==H.hn().indexOf(e))return void r.D.error("Cannot subscribe to push from a path higher than the service worker location (tried to subscribe from "+window.location.pathname+" but service worker is at "+i+")")}if(ht.isPushBlocked())return void this.Kr("Notifications from this site are blocked. This may be a temporary embargo or a permanent denial.",e);if(this.gt&&!this.gt.fn()&&0===this.gt.Zs())return r.D.info("Waiting for VAPID key from server config before subscribing to push."),void this.gt.dn((()=>{this.subscribe(i,e)}));const t=()=>{r.D.info("Permission for push notifications was denied."),"function"==typeof e&&e(!1)},s=()=>{let i="Permission for push notifications was ignored.";ht.isPushBlocked()&&(i+=" The browser has automatically blocked further permission requests for a period (probably 1 week)."),r.D.info(i),"function"==typeof e&&e(!0)},n=ht.isPushPermissionGranted(),u=()=>{n||this.qi.setPushNotificationSubscriptionType(User.NotificationSubscriptionTypes.OPTED_IN),this.Xr().then((t=>{if(null==t)return r.D.error("No service worker registration. Set the `manageServiceWorkerExternally` initialization option to false or ensure that your service worker is registered before calling registerPush."),void("function"==typeof e&&e());t.pushManager.getSubscription().then((s=>{let n=null;if(this.gt&&null!=this.gt.fn()&&(n=r.bn.pn(this.gt.fn())),s){let u=null,a=null;const h=this.h.I(o.q.gn);if(h&&!p(h)){let i;try{i=ei.yn(h).wn}catch(e){i=null}null==i||isNaN(i.getTime())||0===i.getTime()||(u=i,a=new Date(u),a.setMonth(u.getMonth()+6))}null!=n&&s.options&&s.options.applicationServerKey&&s.options.applicationServerKey.byteLength&&s.options.applicationServerKey.byteLength>0&&!ii(n,new Uint8Array(s.options.applicationServerKey))?(s.options.applicationServerKey.byteLength>12?r.D.info("Device was already subscribed to push using a different VAPID provider, creating new subscription."):r.D.info("Attempting to upgrade a gcm_sender_id-based push registration to VAPID - depending on the browser this may or may not result in the same gcm_sender_id-based subscription."),this.Or(s,t,n,i,e)):s.expirationTime&&new Date(s.expirationTime)<=(new Date).valueOf()?(r.D.info("Push subscription is expired, creating new subscription."),this.Or(s,t,n,i,e)):h&&p(h)?this.Or(s,t,n,i,e):null==a?(r.D.info("No push subscription creation date found, creating new subscription."),this.Or(s,t,n,i,e)):a<=(new Date).valueOf()?(r.D.info("Push subscription older than 6 months, creating new subscription."),this.Or(s,t,n,i,e)):(r.D.info("Device already subscribed to push, sending existing subscription to backend."),this.Mr(s,i,u))}else this.Br(t,n,i,e)})).catch((i=>{r.D.error("Error checking current push subscriptions: "+i)}))})).catch((i=>{r.D.error("ServiceWorker registration failed: "+i)}))};this.Qr(u,s,t)}else if(this.Vr){if(null==this._r||""===this._r)return void r.D.error("You must supply the safariWebsitePushId initialization option in order to use registerPush on Safari");const t=window.safari.pushNotification.permission(this._r);this.Lr(this._r,t,i,e)}}else r.D.info(this.vn)}unsubscribe(i,e){ht.isPushSupported()?this.Nr?navigator.serviceWorker.getRegistration().then((t=>{t?t.pushManager.getSubscription().then((s=>{s&&(this.Hr(),s.unsubscribe().then((s=>{s?(r.D.info("Device successfully unsubscribed from push."),"function"==typeof i&&i()):(r.D.error("Failed to unsubscribe device from push."),"function"==typeof e&&e()),this.Zr(t)})).catch((i=>{r.D.error("Push unsubscription error: "+i),"function"==typeof e&&e()})))})).catch((i=>{r.D.error("Error unsubscribing from push: "+i),"function"==typeof e&&e()})):(r.D.info("Device already unsubscribed from push."),"function"==typeof i&&i())})):this.Vr&&(this.Hr(),r.D.info("Device unsubscribed from push."),"function"==typeof i&&i()):r.D.info(this.vn)}}aa.vn="Push notifications are not supported in this browser.";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import e from"../managers/braze-instance.js";import
|
|
1
|
+
import e from"../managers/braze-instance.js";import ea from"./push-manager-factory.js";export function requestPushPermission(r,n){if(e.rr())return ea.aa().subscribe(((n,o,t)=>{e.mr().requestImmediateDataFlush(),"function"==typeof r&&r(n,o,t)}),n)}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import e from"../managers/braze-instance.js";import
|
|
1
|
+
import e from"../managers/braze-instance.js";import ea from"./push-manager-factory.js";export function unregisterPush(r,n){if(e.rr())return ea.aa().unsubscribe(r,n)}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
const ht={Ir:()=>"serviceWorker"in navigator&&"undefined"!=typeof ServiceWorkerRegistration&&"showNotification"in ServiceWorkerRegistration.prototype&&"PushManager"in window,Cr:()=>"safari"in window&&"pushNotification"in window.safari&&"function"==typeof window.safari.pushNotification.permission&&"function"==typeof window.safari.pushNotification.requestPermission,isPushSupported:()=>ht.Ir()||ht.Cr(),isPushBlocked:()=>{const i=ht.isPushSupported()&&"Notification"in window&&null!=window.Notification&&null!=window.Notification.permission&&"denied"===window.Notification.permission,n=ht.isPushSupported()&&(!("Notification"in window)||null==window.Notification);return i||n},isPushPermissionGranted:()=>ht.isPushSupported()&&"Notification"in window&&null!=window.Notification&&null!=window.Notification.permission&&"granted"===window.Notification.permission,Xe:()=>!ht.isPushBlocked()&&ht.isPushSupported()&&!ht.isPushPermissionGranted()};export default ht;
|
package/src/User/user-manager.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import _t from"../models/identifier.js";import{getByteLength as U}from"../util/string-utils.js";import ei from"../models/push-token.js";import r from"../../shared-lib/braze-shared-lib.js";import{STORAGE_KEYS as o}from"../managers/storage-manager.js";import{User}from"../User/index.js";export default class bt{constructor(t,s){this.gt=t,this.h=s}getUserId(){const t=this.h.
|
|
1
|
+
import _t from"../models/identifier.js";import{getByteLength as U}from"../util/string-utils.js";import ei from"../models/push-token.js";import r from"../../shared-lib/braze-shared-lib.js";import{STORAGE_KEYS as o}from"../managers/storage-manager.js";import{User}from"../User/index.js";export default class bt{constructor(t,s){this.gt=t,this.h=s}getUserId(){const t=this.h.tu(o.iu.su);if(null==t)return null;let s=t.eu,i=U(s);if(i>User.ee){for(;i>User.ee;)s=s.slice(0,s.length-1),i=U(s);t.eu=s,this.h.ru(o.iu.su,t)}return s}uu(t){const s=null==this.getUserId();this.h.ru(o.iu.su,new _t(t)),s&&this.h.ou(t)}setCustomUserAttribute(t,s){if(this.gt.hu(t))return r.D.info('Custom Attribute "'+t+'" is blocklisted, ignoring.'),!1;const i={};return i[t]=s,this.nu(User.lu,i,!0)}nu(t,s,i,e){const u=this.h.mu(this.getUserId(),t,s);return!e&&u&&r.D.info(`Logged${i?" custom":""} attribute ${t} with value ${s}`),u}Gr(t,s,i,e,u){this.nu("push_token",t,!1,!0),this.nu("custom_push_public_key",i,!1,!0),this.nu("custom_push_user_auth",e,!1,!0),this.nu("custom_push_vapid_public_key",u,!1,!0);const h=r.xt.Ft,n=new r.qt(h,r.D),l=new ei(t,s,i,e,u);this.h.B(o.q.gn,l.ss()),n.setItem(h.$t.pu,h.se,!0)}Jr(t){if(this.nu("push_token",null,!1,!0),this.nu("custom_push_public_key",null,!1,!0),this.nu("custom_push_user_auth",null,!1,!0),this.nu("custom_push_vapid_public_key",null,!1,!0),t){const t=r.xt.Ft,s=new r.qt(t,r.D);this.h.B(o.q.gn,!1),s.setItem(t.$t.pu,t.se,!1)}}}
|
package/src/User/user.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{isArray as p,isDate as yt,validateValueIsFromEnum as F}from"../util/code-utils.js";import r from"../../shared-lib/braze-shared-lib.js";import{toValidBackendTimeString as Nt}from"../util/date-utils.js";import{isValidEmail as vt,validateCustomString as Y,validateStandardString as R}from"../util/validation-utils.js";export default class User{constructor(t,e){this.v=t,this.si=e}getUserId(t){null==t&&r.D.error("getUserId must be supplied with a callback. e.g., braze.getUser().getUserId(function(userId) {console.log('the user id is ' + userId)})"),"function"==typeof t&&t(this.v.getUserId())}addAlias(t,e){return!R(t,"add alias","the alias",!1)||t.length<=0?(r.D.error("addAlias requires a non-empty alias"),!1):!R(e,"add alias","the label",!1)||e.length<=0?(r.D.error("addAlias requires a non-empty label"),!1):this.si.
|
|
1
|
+
import{isArray as p,isDate as yt,validateValueIsFromEnum as F}from"../util/code-utils.js";import r from"../../shared-lib/braze-shared-lib.js";import{toValidBackendTimeString as Nt}from"../util/date-utils.js";import{isValidEmail as vt,validateCustomString as Y,validateStandardString as R}from"../util/validation-utils.js";export default class User{constructor(t,e){this.v=t,this.si=e}getUserId(t){null==t&&r.D.error("getUserId must be supplied with a callback. e.g., braze.getUser().getUserId(function(userId) {console.log('the user id is ' + userId)})"),"function"==typeof t&&t(this.v.getUserId())}addAlias(t,e){return!R(t,"add alias","the alias",!1)||t.length<=0?(r.D.error("addAlias requires a non-empty alias"),!1):!R(e,"add alias","the label",!1)||e.length<=0?(r.D.error("addAlias requires a non-empty label"),!1):this.si.Nn(t,e).S}setFirstName(t){return!!R(t,"set first name","the firstName",!0)&&this.v.nu("first_name",t)}setLastName(t){return!!R(t,"set last name","the lastName",!0)&&this.v.nu("last_name",t)}setEmail(t){return null===t||vt(t)?this.v.nu("email",t):(r.D.error(`Cannot set email address - "${t}" did not pass RFC-5322 validation.`),!1)}setGender(t){return"string"==typeof t&&(t=t.toLowerCase()),!(null!==t&&!F(User.Genders,t,`Gender "${t}" is not a valid gender.`,"User.Genders"))&&this.v.nu("gender",t)}setDateOfBirth(t,e,s){return null===t&&null===e&&null===s?this.v.nu("dob",null):(t=parseInt(t),e=parseInt(e),s=parseInt(s),isNaN(t)||isNaN(e)||isNaN(s)||e>12||e<1||s>31||s<1?(r.D.error("Cannot set date of birth - parameters should comprise a valid date e.g. setDateOfBirth(1776, 7, 4);"),!1):this.v.nu("dob",`${t}-${e}-${s}`))}setCountry(t){return!!R(t,"set country","the country",!0)&&this.v.nu("country",t)}setHomeCity(t){return!!R(t,"set home city","the homeCity",!0)&&this.v.nu("home_city",t)}setLanguage(t){return!!R(t,"set language","the language",!0)&&this.v.nu("language",t)}setEmailNotificationSubscriptionType(t){return!!F(User.NotificationSubscriptionTypes,t,`Email notification setting "${t}" is not a valid subscription type.`,"User.NotificationSubscriptionTypes")&&this.v.nu("email_subscribe",t)}setPushNotificationSubscriptionType(t){return!!F(User.NotificationSubscriptionTypes,t,`Push notification setting "${t}" is not a valid subscription type.`,"User.NotificationSubscriptionTypes")&&this.v.nu("push_subscribe",t)}setPhoneNumber(t){return!!R(t,"set phone number","the phoneNumber",!0)&&(null===t||t.match(User.Cn)?this.v.nu("phone",t):(r.D.error(`Cannot set phone number - "${t}" did not pass validation.`),!1))}setLastKnownLocation(t,e,s,i,n){return null==t||null==e?(r.D.error("Cannot set last-known location - latitude and longitude are required."),!1):(t=parseFloat(t),e=parseFloat(e),null!=s&&(s=parseFloat(s)),null!=i&&(i=parseFloat(i)),null!=n&&(n=parseFloat(n)),isNaN(t)||isNaN(e)||null!=s&&isNaN(s)||null!=i&&isNaN(i)||null!=n&&isNaN(n)?(r.D.error("Cannot set last-known location - all supplied parameters must be numeric."),!1):t>90||t<-90||e>180||e<-180?(r.D.error("Cannot set last-known location - latitude and longitude are bounded by ±90 and ±180 respectively."),!1):null!=s&&s<0||null!=n&&n<0?(r.D.error("Cannot set last-known location - accuracy and altitudeAccuracy may not be negative."),!1):this.si.setLastKnownLocation(this.v.getUserId(),t,e,i,s,n).S)}setCustomUserAttribute(t,e){if(!Y(t,"set custom user attribute","the given key"))return!1;const s=typeof e,i=yt(e),n=p(e);if("number"!==s&&"boolean"!==s&&!i&&!n&&null!==e&&!Y(e,`set custom user attribute "${t}"`,"the given value"))return!1;if(i&&(e=Nt(e)),n){for(let s=0;s<e.length;s++){const r=e[s];if(!Y(r,`set custom user attribute "${t}"`,"the element in the given array"))return!1}return this.si.In(r.A.Sn,t,e).S}return this.v.setCustomUserAttribute(t,e)}addToCustomAttributeArray(t,e){return!!Y(t,"add to custom user attribute array","the given key")&&(!(null!=e&&!Y(e,"add to custom user attribute array","the given value"))&&this.si.In(r.A.An,t,e).S)}removeFromCustomAttributeArray(t,e){return!!Y(t,"remove from custom user attribute array","the given key")&&(!(null!=e&&!Y(e,"remove from custom user attribute array","the given value"))&&this.si.In(r.A.Un,t,e).S)}incrementCustomUserAttribute(t,e){if(!Y(t,"increment custom user attribute","the given key"))return!1;null==e&&(e=1);const s=parseInt(e);return isNaN(s)||s!==parseFloat(e)?(r.D.error(`Cannot increment custom user attribute because the given incrementValue "${e}" is not an integer.`),!1):this.si.In(r.A.En,t,s).S}setCustomLocationAttribute(t,e,s){return!!Y(t,"set custom location attribute","the given key")&&((null!==e||null!==s)&&(e=parseFloat(e),s=parseFloat(s),isNaN(e)||e>90||e<-90||isNaN(s)||s>180||s<-180)?(r.D.error("Received invalid values for latitude and/or longitude. Latitude and longitude are bounded by ±90 and ±180 respectively, or must both be null for removal."),!1):this.si.Fn(t,e,s).S)}addToSubscriptionGroup(t){return!R(t,"add user to subscription group","subscription group ID",!1)||t.length<=0?(r.D.error("addToSubscriptionGroup requires a non-empty subscription group ID"),!1):this.si.Tn(t,User.kn.SUBSCRIBED).S}removeFromSubscriptionGroup(t){return!R(t,"remove user from subscription group","subscription group ID",!1)||t.length<=0?(r.D.error("removeFromSubscriptionGroup requires a non-empty subscription group ID"),!1):this.si.Tn(t,User.kn.UNSUBSCRIBED).S}Gr(t,e,s,r,i){this.v.Gr(t,e,s,r,i),this.si.$n()}Jr(t){this.v.Jr(t)}}User.Cn=/^[0-9 .\\(\\)\\+\\-]+$/,User.Genders={MALE:"m",FEMALE:"f",OTHER:"o",UNKNOWN:"u",NOT_APPLICABLE:"n",PREFER_NOT_TO_SAY:"p"},User.NotificationSubscriptionTypes={OPTED_IN:"opted_in",SUBSCRIBED:"subscribed",UNSUBSCRIBED:"unsubscribed"},User.kn={SUBSCRIBED:"subscribed",UNSUBSCRIBED:"unsubscribed"},User._n="user_id",User.lu="custom",User.ee=997;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import x from"./base-feed.js";import{bottomHadImpression as de,getCardId as fe,impressOnBottom as be,impressOnTop as ye,markCardAsRead as Fe,topHadImpression as Te}from"../Card/display/card-display.js";import{bottomIsInView as he,topIsInView as _e}from"../util/dom-utils.js";import{Card,ControlCard}from"../Card/index.js";import{cardToHtml as xe}from"../Card/display/card-display.js";import{isArray as p}from"../util/code-utils.js";import{KeyCodes as at}from"../util/key-codes.js";import Ee from"../l10n/l10n-manager-factory.js";import{removeSubscription}from"../Core/remove-subscription.js";import r from"../../shared-lib/braze-shared-lib.js";import{BRAZE_ACTION_URI_REGEX as O}from"../util/validation-utils.js";import{INELIGIBLE_BRAZE_ACTION_URL_ERROR_TYPES as
|
|
1
|
+
import x from"./base-feed.js";import{bottomHadImpression as de,getCardId as fe,impressOnBottom as be,impressOnTop as ye,markCardAsRead as Fe,topHadImpression as Te}from"../Card/display/card-display.js";import{bottomIsInView as he,topIsInView as _e}from"../util/dom-utils.js";import{Card,ControlCard}from"../Card/index.js";import{cardToHtml as xe}from"../Card/display/card-display.js";import{isArray as p}from"../util/code-utils.js";import{KeyCodes as at}from"../util/key-codes.js";import Ee from"../l10n/l10n-manager-factory.js";import{removeSubscription}from"../Core/remove-subscription.js";import r from"../../shared-lib/braze-shared-lib.js";import{BRAZE_ACTION_URI_REGEX as O}from"../util/validation-utils.js";import{INELIGIBLE_BRAZE_ACTION_URL_ERROR_TYPES as ct,ineligibleBrazeActionURLErrorMessage as gt,getDecodedBrazeAction as J,containsUnknownBrazeAction as mt}from"../util/braze-actions.js";export const LAST_REQUESTED_REFRESH_DATA_ATTRIBUTE="data-last-requested-refresh";export const _SUBSCRIPTION_ID_DATA_ATTRIBUTE="data-update-subscription-id";export function destroyFeedHtml(e){e&&(e.className=e.className.replace("ab-show","ab-hide"),setTimeout((()=>{e&&e.parentNode&&e.parentNode.removeChild(e)}),x.Mi));const t=e.getAttribute("data-update-subscription-id");null!=t&&removeSubscription(t)}export function _generateFeedBody(e,t){const o=document.createElement("div");if(o.className="ab-feed-body",o.setAttribute("aria-label","Feed"),o.setAttribute("role","feed"),null==e.lastUpdated){const e=document.createElement("div");e.className="ab-no-cards-message";const t=document.createElement("i");t.className="fa fa-spinner fa-spin fa-4x ab-initial-spinner",e.appendChild(t),o.appendChild(e)}else{let s=!1;const logCardClick=t=>{e.logCardClick(t)};for(const n of e.cards){const a=n instanceof ControlCard;!a||e.dr()?(o.appendChild(xe(n,logCardClick,t)),s=s||!a):r.D.error("Received a control card for a legacy news feed. Control cards are only supported with content cards.")}if(!s){const e=document.createElement("div");e.className="ab-no-cards-message",e.innerHTML=Ee.m().get("NO_CARDS_MESSAGE"),e.setAttribute("role","article"),o.appendChild(e)}}return o}export function detectFeedImpressions(e,t){if(null!=t){const o=[],r=t.querySelectorAll(".ab-card");e.do||(e.do={});for(let t=0;t<r.length;t++){const s=fe(r[t]);if(e.do[s])continue;let n=Te(r[t]),a=de(r[t]);const i=n,d=a,f=_e(r[t]),c=he(r[t]);if(!n&&f&&(n=!0,ye(r[t])),!a&&c&&(a=!0,be(r[t])),n&&a){if(f||c||Fe(r[t]),i&&d)continue;for(const t of e.cards)if(t.id===s){e.do[t.id]=!0,o.push(t);break}}}o.length>0&&e.logCardImpressions(o)}}export function refreshFeed(e,t){t.setAttribute("aria-busy","true");const o=t.querySelectorAll(".ab-refresh-button")[0];null!=o&&(o.className+=" fa-spin");const r=(new Date).valueOf().toString();t.setAttribute("data-last-requested-refresh",r),setTimeout((()=>{if(t.getAttribute("data-last-requested-refresh")===r){const e=t.querySelectorAll(".fa-spin");for(let t=0;t<e.length;t++)e[t].className=e[t].className.replace(/fa-spin/g,"");const o=t.querySelectorAll(".ab-initial-spinner")[0];if(null!=o){const e=document.createElement("span");e.innerHTML=Ee.m().get("FEED_TIMEOUT_MESSAGE"),o.parentNode.appendChild(e),o.parentNode.removeChild(o)}"true"===t.getAttribute("aria-busy")&&t.setAttribute("aria-busy","false")}}),x.uo),e.sr()}export function feedToHtml(e,t){const o=document.createElement("div");o.className="ab-feed ab-hide ab-effect-slide",o.setAttribute("role","dialog"),o.setAttribute("aria-label","Feed"),o.setAttribute("tabindex","-1");const r=document.createElement("div");r.className="ab-feed-buttons-wrapper",r.setAttribute("role","group"),o.appendChild(r);const s=document.createElement("i");s.className="fa fa-times ab-close-button",s.setAttribute("aria-label","Close Feed"),s.setAttribute("tabindex","0"),s.setAttribute("role","button");const n=e=>{destroyFeedHtml(o),e.stopPropagation()};s.addEventListener("keydown",(e=>{e.keyCode!==at.fo&&e.keyCode!==at.co||n(e)})),s.onclick=n;const a=document.createElement("i");a.className="fa fa-refresh ab-refresh-button",null==e.lastUpdated&&(a.className+=" fa-spin"),a.setAttribute("aria-label","Refresh Feed"),a.setAttribute("tabindex","0"),a.setAttribute("role","button");const i=t=>{refreshFeed(e,o),t.stopPropagation()};return a.addEventListener("keydown",(e=>{e.keyCode!==at.fo&&e.keyCode!==at.co||i(e)})),a.onclick=i,r.appendChild(a),r.appendChild(s),o.appendChild(_generateFeedBody(e,t)),o.onscroll=()=>{detectFeedImpressions(e,o)},o}export function updateFeedCards(e,t,o,s,n){if(!p(t))return;const a=[];for(const e of t)if(e instanceof Card){if(e.url&&O.test(e.url)){let t=J(e.url);if(mt(t)){r.D.error(gt(ct.We,"Content Card"));continue}}a.push(e)}if(e.cards=a,e.lastUpdated=o,null!=s)if(s.setAttribute("aria-busy","false"),null==e.lastUpdated)destroyFeedHtml(s);else{const t=s.querySelectorAll(".ab-feed-body")[0];if(null!=t){const o=_generateFeedBody(e,n);t.parentNode.replaceChild(o,t),detectFeedImpressions(e,o.parentNode)}}}export function registerFeedSubscriptionId(e,t){t.setAttribute("data-update-subscription-id",e)}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import e,{OPTIONS as T}from"../managers/braze-instance.js";import et from"../util/browser-detector.js";import er from"./l10n-manager.js";const Ee={t:!1,i:null,m:()=>{if(Ee.o(),!Ee.i){let r=et.language,t=!1;e.nn(T.
|
|
1
|
+
import e,{OPTIONS as T}from"../managers/braze-instance.js";import et from"../util/browser-detector.js";import er from"./l10n-manager.js";const Ee={t:!1,i:null,m:()=>{if(Ee.o(),!Ee.i){let r=et.language,t=!1;e.nn(T.jn)&&(r=e.nn(T.jn),t=!0),Ee.i=new er(r,t)}return Ee.i},o:()=>{Ee.t||(e.u(Ee),Ee.t=!0)},destroy:()=>{Ee.i=null,Ee.t=!1}};export default Ee;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{STORAGE_KEYS as o}from"./storage-manager.js";import u from"./subscription-manager.js";import r from"../../shared-lib/braze-shared-lib.js";export default class St{constructor(t,i,s){this.h=t,this.
|
|
1
|
+
import{STORAGE_KEYS as o}from"./storage-manager.js";import u from"./subscription-manager.js";import r from"../../shared-lib/braze-shared-lib.js";export default class St{constructor(t,i,s){this.h=t,this.xn=i||!1,this.zn=s,this.qn=new u,this.Bn=0,this.Dn=1}Gn(){return this.xn}Hn(){return this.h.I(o.q.Jn)}setSdkAuthenticationSignature(t){const i=this.Hn();this.h.B(o.q.Jn,t);const s=r.xt.Ft;new r.qt(s,r.D).setItem(s.$t.Kn,this.Dn,t),i!==t&&this.Qs()}Ln(){this.h.Xs(o.q.Jn);const t=r.xt.Ft;new r.qt(t,r.D).br(t.$t.Kn,this.Dn)}subscribeToSdkAuthenticationFailures(t){return this.zn.ut(t)}Mn(t){this.zn.St(t)}On(){this.qn.removeAllSubscriptions()}Pn(){this.Bn+=1}Qn(){return this.Bn}Qs(){this.Bn=0}}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import St from"./auth-manager.js";import y from"../common/base-provider.js";import et from"../util/browser-detector.js";import It from"./device-manager.js";import DeviceProperties from"../Core/device-properties.js";import{isArray as p,keys as rr,validateValueIsFromEnum as F,values as At}from"../util/code-utils.js";import{logDeprecationWarning as D}from"../util/deprecation-utils.js";import wt from"./network-manager.js";import
|
|
1
|
+
import St from"./auth-manager.js";import y from"../common/base-provider.js";import et from"../util/browser-detector.js";import It from"./device-manager.js";import DeviceProperties from"../Core/device-properties.js";import{isArray as p,keys as rr,validateValueIsFromEnum as F,values as At}from"../util/code-utils.js";import{logDeprecationWarning as D}from"../util/deprecation-utils.js";import wt from"./network-manager.js";import Ot from"../request-controller.js";import Ct from"./server-config-manager.js";import Lt from"./session-manager.js";import r from"../../shared-lib/braze-shared-lib.js";import G,{STORAGE_KEYS as o}from"./storage-manager.js";import Pt from"./storage-manager-factory.js";import u from"./subscription-manager.js";import{TriggersProviderFactory as W}from"../triggers/triggers-provider-factory.js";import bt from"../User/user-manager.js";import{User}from"../User/index.js";import{parseQueryStringKeyValues as st}from"../util/url-utils.js";import{WindowUtils as H}from"../util/window-utils.js";const T={Rn:"allowCrawlerActivity",Wn:"baseUrl",Vn:"noCookies",Yn:"devicePropertyAllowlist",ta:"disablePushTokenMaintenance",Xn:"enableLogging",Zn:"enableSdkAuthentication",ia:"manageServiceWorkerExternally",ho:"minimumIntervalBetweenTriggerActionsInSeconds",po:"sessionTimeoutInSeconds",Eo:"appVersion",na:"serviceWorkerLocation",ra:"safariWebsitePushId",jn:"localization",ao:"contentSecurityNonce",_o:"enableHtmlInAppMessages",Io:"allowUserSuppliedJavascript",no:"inAppMessageZIndex",lo:"openInAppMessagesInNewTab",tn:"openCardsInNewTab",en:"openNewsFeedCardsInNewTab",Ui:"requireExplicitInAppMessageDismissal",Ao:"doNotLoadFontAwesome",So:"sdkFlavor"};class Rt{constructor(){this.No=!1,this.wo=!1,this.To=new u,this.Oo=new u,this.vo={},this.Co=[],this.Lo=[],this.De=[],this.Po="4.2.1"}Ro(t){this.To.ut(t)}Bi(t){this.Oo.ut(t)}initialize(t,i){if(this.Mo())return r.D.info("Braze has already been initialized with an API key."),!0;this.vo=i||{};let s=this.nn(T.Xn);const e=st(H.hn());if(e&&"true"===e.brazeLogging&&(s=!0),r.D.init(s),r.D.info(`Initialization Options: ${JSON.stringify(this.vo,null,2)}`),null==t||""===t||"string"!=typeof t)return r.D.error("Braze requires a valid API key to be initialized."),!1;this.Ji=t;let n=this.nn(T.Wn);if(null==n||""===n||"string"!=typeof n)return r.D.error("Braze requires a valid baseUrl to be initialized."),!1;if(n=n.replace(/(\.[a-z]+)[^\.]*$/i,"$1/api/v3"),0!==n.indexOf("http")&&(n="https://"+n),this.yo=n,et.Do&&!this.nn(T.Rn))return r.D.info("Ignoring activity from crawler bot "+navigator.userAgent),this.wo=!0,!1;const a=this.nn(Rt.Vn)||!1;if(this.h=Pt.jo(t,a),new G.ne(null,!0).lr(o.ae))return r.D.info("Ignoring all activity due to previous opt out"),this.wo=!0,!1;for(const t of rr(this.vo))-1===At(r.zo).indexOf(t)&&r.D.warn(`Ignoring unknown initialization option '${t}'.`);const h=["mparticle","wordpress","tealium"];if(null!=this.nn(T.So)){const t=this.nn(T.So);-1!==h.indexOf(t)?this.Uo=t:r.D.error("Invalid sdk flavor passed: "+t)}let l=this.nn(r.zo.Yn);if(null!=l)if(p(l)){const t=[];for(let i=0;i<l.length;i++)F(DeviceProperties,l[i],"devicePropertyAllowlist contained an invalid value.","DeviceProperties")&&t.push(l[i]);l=t}else r.D.error("devicePropertyAllowlist must be an array. Defaulting to all properties."),l=null;this.Qi=new It(this.h,l),this.gt=new Ct(this.h),this.v=new bt(this.gt,this.h),this.j=new Lt(this.h,this.v,this.gt,this.nn(T.po));const c=new u;return this.Bo=new St(this.h,this.nn(T.Zn),c),this.jt(c),this.vt=new wt(this.Qi,this.h,this.Bo,this.v,this.j,this.gt,this.Ji,this.yo,this.Po,this.Uo,this.nn(T.Eo)),this.si=new Ot(this.Ji,this.yo,this.j,this.Qi,this.v,this.gt,this.h,(t=>{if(this.Mo())for(const i of this.re())i.Rs(t)}),this.Bo,this.vt),this.si.initialize(),r.D.info(`Initialized for the Braze backend at "${this.nn(T.Wn)}" with API key "${this.Ji}".`),null!=this.nn(T._o)&&D("enableHtmlInAppMessages","initialization option","allowUserSuppliedJavascript"),W.init(),this.To.St(this.vo),this.No=!0,!0}destroy(t){if(r.D.destroy(),this.Mo()){this.Oo.St(),this.Oo.removeAllSubscriptions();for(const t of this.Co)t.destroy();this.Co=[];for(const t of this.Lo)t.clearData(!1);this.Lo=[],this.removeAllSubscriptions(),this.De=[],this.si.destroy(),this.si=null,this.Bo=null,this.Qi=null,this.vt=null,this.gt=null,this.j=null,this.v=null,this.vo={},this.Uo=void 0,this.No=!1,this.wo=!1,t&&(this.h=null)}}rr(){if(this.Wo())return!1;if(!this.Mo())throw new Error("Braze must be initialized before calling methods.");return!0}ea(){return this.Ji}ii(){return this.Bo}Ks(){return this.yo}ce(){return this.Qi}nr(){return this.vt}nn(t){return this.vo[t]}re(){return this.Lo}mr(){return this.si}ir(){return this.gt}g(){return this.j}l(){return this.h}gr(){if(this.v&&this.si)return new User(this.v,this.si)}p(){return this.v}tr(){return!0===this.nn(T.Io)||!0===this.nn(T._o)}u(t){let i=!1;for(const s of this.Co)s===t&&(i=!0);i||this.Co.push(t)}ar(t){let i=!1;for(const s of this.Lo)s.constructor===t.constructor&&(i=!0);t instanceof y&&!i&&this.Lo.push(t)}jt(t){t instanceof u&&this.De.push(t)}removeAllSubscriptions(){if(this.rr())for(const t of this.De)t.removeAllSubscriptions()}removeSubscription(t){if(this.rr())for(const i of this.De)i.removeSubscription(t)}le(t){this.wo=t}Mo(){return this.No}Wo(){return this.wo}Ds(){return this.Po}}const e=new Rt;export{e as default,Rt as BrazeSdkInstance,T as OPTIONS};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import et from"../util/browser-detector.js";import Ie from"../models/device.js";import DeviceProperties from"../Core/device-properties.js";import _t from"../models/identifier.js";import r from"../../shared-lib/braze-shared-lib.js";import{STORAGE_KEYS as o}from"../managers/storage-manager.js";import{values as At}from"../util/code-utils.js";export default class It{constructor(e,t){this.h=e,null==t&&(t=At(DeviceProperties)),this.xo=t}te(){let e=this.h.
|
|
1
|
+
import et from"../util/browser-detector.js";import Ie from"../models/device.js";import DeviceProperties from"../Core/device-properties.js";import _t from"../models/identifier.js";import r from"../../shared-lib/braze-shared-lib.js";import{STORAGE_KEYS as o}from"../managers/storage-manager.js";import{values as At}from"../util/code-utils.js";export default class It{constructor(e,t){this.h=e,null==t&&(t=At(DeviceProperties)),this.xo=t}te(){let e=this.h.tu(o.iu.Go);null==e&&(e=new _t(r.it.nt()),this.h.ru(o.iu.Go,e));const t=new Ie(e.eu);for(let e=0;e<this.xo.length;e++){const r=this.xo[e];switch(r){case DeviceProperties.BROWSER:t[r]=et.browser;break;case DeviceProperties.BROWSER_VERSION:t[r]=et.version;break;case DeviceProperties.OS:t[r]=this.Fo();break;case DeviceProperties.RESOLUTION:t[r]=screen.width+"x"+screen.height;break;case DeviceProperties.LANGUAGE:t[r]=et.language;break;case DeviceProperties.TIME_ZONE:t[r]=this.Jo(new Date);break;case DeviceProperties.USER_AGENT:t[r]=et.userAgent}}return t}Fo(){if(et.qo())return et.qo();const e=this.h.I(o.q.Ho);return e&&e.os_version?e.os_version:et.Ko()}Jo(e){if("undefined"!=typeof Intl&&"function"==typeof Intl.DateTimeFormat)try{if("function"==typeof Intl.DateTimeFormat().resolvedOptions){const e=Intl.DateTimeFormat().resolvedOptions().timeZone;if(null!=e&&""!==e)return e}}catch(e){r.D.info("Intl.DateTimeFormat threw an error, probably https://bugs.chromium.org/p/chromium/issues/detail?id=811403, falling back to GTM offset: "+e.message)}const t=e.getTimezoneOffset();return this.Qo(t)}Qo(e){const t=parseInt(e/60),r=parseInt(e%60);let s="GMT";return 0!==e&&(s+=e<0?"+":"-",s+=("00"+Math.abs(t)).slice(-2)+":"+("00"+Math.abs(r)).slice(-2)),s}}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import
|
|
1
|
+
import qt from"../models/backend-errors.js";import ue from"../models/braze-event.js";import{convertMsToSeconds as l,convertSecondsToMs as Dt}from"../util/date-utils.js";import s from"../common/event-logger.js";import{isArray as p,isEqual as ii}from"../util/code-utils.js";import r from"../../shared-lib/braze-shared-lib.js";import{STORAGE_KEYS as o}from"./storage-manager.js";export default class wt{constructor(t,e,s,i,r,o,n,a,h,u,c){this.Qi=t,this.h=e,this.Bo=s,this.v=i,this.j=r,this.gt=o,this.Ji=n,this.yo=a,this.Po=h,this.Uo=u,this.Xo=c,this.$o=["npm"]}Ps(t,e){const s=this.Qi.te(),i=s.li(),r=this.h.I(o.q.Ho);ii(r,i)||(t.device=i),t.api_key=this.Ji,t.time=l((new Date).valueOf(),!0);const n=this.h.I(o.q.Yo)||[],a=this.h.I(o.q.Zo)||"";if(this.$o.length>0&&(!ii(n,this.$o)||a!==this.j.Vo())&&(t.sdk_metadata=this.$o),t.sdk_version=this.Po,this.Uo&&(t.sdk_flavor=this.Uo),t.app_version=this.Xo,t.device_id=s.id,e){const e=this.v.getUserId();null!=e&&(t.user_id=e)}return t}Os(t,e,i){const o=e.auth_error,n=e.error;if(!o&&!n)return!0;if(o){let e;this.Bo.Pn();const s={errorCode:o.error_code};for(const t of i)p(t)&&"X-Braze-Auth-Signature"===t[0]&&(s.signature=t[1]);t.respond_with&&t.respond_with.user_id?s.userId=t.respond_with.user_id:t.user_id&&(s.userId=t.user_id);const n=o.reason;return n?(s.reason=n,e=`due to ${n}`):e=`with error code ${o.error_code}.`,this.Bo.Gn()||(e+=' Please use the "enableSdkAuthentication" initialization option to enable authentication.'),r.D.error(`SDK Authentication failed ${e}`),this.sa(t.events,t.attributes),this.Bo.Mn(s),!1}if(n){let i=n;switch(i){case qt.oa:const o="Received successful response with empty body.";return s.G(r.A.qs,{e:o}),r.D.info(o),!1;case qt.ha:const n="Received successful response with invalid JSON";return s.G(r.A.qs,{e:n+": "+e.response}),r.D.info(n),!1;case qt.ua:i=`The API key "${t.api_key}" is invalid for the baseUrl ${this.yo}`;break;case qt.ca:i="Sorry, we are not currently accepting your requests. If you think this is in error, please contact us.";break;case qt.la:i="No device identifier. Please contact support@braze.com"}r.D.error("Backend error: "+i)}return!1}fa(t,e,s,i){return!!(t&&0!==t.length||e&&0!==e.length||s||i)}ma(t,e,s,i){const r=[],o=t=>t||"",n=o(this.v.getUserId());let a,h,u,c,l=this.ni(t,e);if(s.length>0){const t=[];for(const e of s){if(a=e.li(),this.Bo.Gn()){if(n&&!a.user_id){c||(c={},c.events=[]),c.events.push(a);continue}if(o(a.user_id)!==n){h||(h=[]),h.push(a);continue}}t.push(a)}t.length>0&&(l.events=t)}if(i.length>0){const t=[];for(const e of i)this.Bo.Gn()&&o(e.user_id)!==n?(u||(u=[]),u.push(e)):t.push(e);t.length>0&&(l.attributes=t)}if(this.sa(h,u),l=this.Ps(l,!0),c){c=this.Ps(c,!1);const t={requestData:c,headers:this.Bs(c)};r.push(t)}if(l&&!this.fa(l.events,l.attributes,t,e))return c?r:null;const f={requestData:l,headers:this.Bs(l)};return r.push(f),r}sa(t,e){if(t){const e=[];for(const s of t){const t=ue.fromJson(s);t.time=Dt(t.time),e.push(t)}this.h.bo(e)}if(e)for(const t of e)this.h.pa(t)}Vs(t,e){let s="HTTP error ";null!=t&&(s+=t+" "),s+=e,r.D.error(s)}yr(t){return s.G(r.A.Ra,{n:t})}ni(t,e,s){const i={};t&&(i.feed=!0),e&&(i.triggers=!0);const r=null!=s?s:this.v.getUserId();return r&&(i.user_id=r),i.config={config_time:this.gt.Zs()},{respond_with:i}}Bs(t,e,s){const i=[["X-Braze-Api-Key",this.Ji]];let r=!1;if(null!=t.respond_with&&t.respond_with.triggers&&(i.push(["X-Braze-TriggersRequest","true"]),r=!0),null!=t.respond_with&&t.respond_with.feed&&(i.push(["X-Braze-FeedRequest","true"]),r=!0),e){i.push(["X-Braze-ContentCardsRequest","true"]);let t=this.h.I(o.q.As);t&&s||(t=0,this.h.B(o.q.As,t)),i.push(["BRAZE-SYNC-RETRY-COUNT",t.toString()]),r=!0}if(r&&i.push(["X-Braze-DataRequest","true"]),this.Bo.Gn()){const t=this.Bo.Hn();null!=t&&i.push(["X-Braze-Auth-Signature",t])}return i}Gs(t,e){const s=t.device;s&&s.os_version instanceof Promise?s.os_version.then((s=>{t.device.os_version=s,e()})):e()}Qs(){this.Bo.Qs()}Ks(){return this.yo}addSdkMetadata(t){for(const e of t)-1===this.$o.indexOf(e)&&this.$o.push(e)}}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{STORAGE_KEYS as o}from"./storage-manager.js";import u from"./subscription-manager.js";import jt from"../models/server-config.js";export default class
|
|
1
|
+
import{STORAGE_KEYS as o}from"./storage-manager.js";import u from"./subscription-manager.js";import jt from"../models/server-config.js";export default class Ct{constructor(t){this.h=t,this.sh=new u,this.eh=new u,this.ih=null}rh(){if(null==this.ih){const t=this.h.I(o.q.nh);this.ih=null!=t?jt.yn(t):new jt}return this.ih}Zs(){return this.rh().hh}lh(t){if(null!=t&&null!=t.config){const s=t.config;if(s.time>this.rh().hh){const t=new jt(s.time,s.events_blacklist,s.attributes_blacklist,s.purchases_blacklist,s.messaging_session_timeout,s.vapid_public_key,s.content_cards);let e=!1;null!=t.oh&&this.fn()!==t.oh&&(e=!0);let i=!1;null!=t.uh.enabled&&this.Ys()!==t.uh.enabled&&(i=!0),this.ih=t,this.h.B(o.q.nh,t.ss()),e&&this.sh.St(),i&&this.eh.St()}}}dn(t){let s=this.sh.ut(t);return this.ah&&this.sh.removeSubscription(this.ah),this.ah=s,s}Ms(t){return this.eh.ut(t)}ge(t){return-1!==this.rh().gh.indexOf(t)}hu(t){return-1!==this.rh().mh.indexOf(t)}Dr(t){return-1!==this.rh().fh.indexOf(t)}dh(){return this.rh().ph}fn(){return this.rh().oh}Ys(){return this.rh().uh.enabled||!1}}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{STORAGE_KEYS as o}from"../managers/storage-manager.js";import ue from"../models/braze-event.js";import _t from"../models/identifier.js";import{convertMsToSeconds as l}from"../util/date-utils.js";import r from"../../shared-lib/braze-shared-lib.js";export default class
|
|
1
|
+
import{STORAGE_KEYS as o}from"../managers/storage-manager.js";import ue from"../models/braze-event.js";import _t from"../models/identifier.js";import{convertMsToSeconds as l}from"../util/date-utils.js";import r from"../../shared-lib/braze-shared-lib.js";export default class Lt{constructor(s,t,e,i){this.h=s,this.v=t,this.gt=e,this.wh=1e3,i=parseFloat(i),isNaN(i)&&(i=1800),i<this.wh/1e3&&(r.D.info("Specified session timeout of "+i+"s is too small, using the minimum session timeout of "+this.wh/1e3+"s instead."),i=this.wh/1e3),this.Sh=i}jh(s,t){return new ue(this.v.getUserId(),r.A.bh,s,t.eu,{d:l(s-t.xh)})}Vo(){const s=this.h.tu(o.iu.Dh);return null==s?null:s.eu}Eh(){const s=(new Date).valueOf(),t=this.gt.dh(),e=this.h.I(o.q.Ch);if(null!=e&&null==t)return!1;const i=null==e||s-e>1e3*t;return i&&this.h.B(o.q.Ch,s),i}Gh(s,t){return null==t||!(s-t.xh<this.wh)&&t.Nh<s}mo(){const s=(new Date).valueOf(),t=s+1e3*this.Sh,e=this.h.tu(o.iu.Dh);if(this.Gh(s,e)){let i="Generating session start event with time "+s;if(null!=e){let s=e._h;s-e.xh<this.wh&&(s=e.xh+this.Fh),this.h.Hh(this.jh(s,e)),i+=" (old session ended "+s+")"}i+=". Will expire "+t.valueOf(),r.D.info(i);const n=new _t(r.it.nt(),t);this.h.Hh(new ue(this.v.getUserId(),r.A.Wh,s,n.eu)),this.h.ru(o.iu.Dh,n);return null==this.h.I(o.q.Ch)&&this.h.B(o.q.Ch,s),n.eu}return e._h=s,e.Nh=t,this.h.ru(o.iu.Dh,e),e.eu}kh(){const s=this.h.tu(o.iu.Dh);null!=s&&(this.h.qh(o.iu.Dh),this.h.Hh(this.jh((new Date).valueOf(),s)))}}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import G,{STORAGE_KEYS as o}from"./storage-manager.js";import r from"../../shared-lib/braze-shared-lib.js";const
|
|
1
|
+
import G,{STORAGE_KEYS as o}from"./storage-manager.js";import r from"../../shared-lib/braze-shared-lib.js";const Pt={jo:(e,t)=>{let a=!1;try{if(localStorage&&localStorage.getItem)try{localStorage.setItem(o.q.ga,!0),localStorage.getItem(o.q.ga)&&(localStorage.removeItem(o.q.ga),a=!0)}catch(e){if("QuotaExceededError"!==e.name&&"NS_ERROR_DOM_QUOTA_REACHED"!==e.name||!(localStorage.length>0))throw e;a=!0}}catch(e){r.D.info("Local Storage not supported!")}const l=Pt.Sa(),c=new G.Ea(e,l&&!t,a);let n=null;return n=a?new G.wa(e):new G._a,new G(c,n)},Sa:()=>navigator.cookieEnabled||"cookie"in document&&(document.cookie.length>0||(document.cookie="test").indexOf.call(document.cookie,"test")>-1)};export default Pt;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import et from"../util/browser-detector.js";import ue from"../models/braze-event.js";import _t from"../models/identifier.js";import{isArray as p,keys as rr,validateValueIsFromEnum as F,values as At}from"../util/code-utils.js";import r from"../../shared-lib/braze-shared-lib.js";import{User}from"../User/index.js";export const STORAGE_KEYS={
|
|
1
|
+
import et from"../util/browser-detector.js";import ue from"../models/braze-event.js";import _t from"../models/identifier.js";import{isArray as p,keys as rr,validateValueIsFromEnum as F,values as At}from"../util/code-utils.js";import r from"../../shared-lib/braze-shared-lib.js";import{User}from"../User/index.js";export const STORAGE_KEYS={iu:{su:"ab.storage.userId",Go:"ab.storage.deviceId",Dh:"ab.storage.sessionId"},q:{ga:"ab.test",Ta:"ab.storage.events",Aa:"ab.storage.attributes",Oa:"ab.storage.attributes.anonymous_user",Ho:"ab.storage.device",Yo:"ab.storage.sdk_metadata",Zo:"ab.storage.session_id_for_cached_metadata",gn:"ab.storage.pushToken",ei:"ab.storage.newsFeed",hi:"ab.storage.lastNewsFeedRefresh",P:"ab.storage.cardImpressions",nh:"ab.storage.serverConfig",ba:"ab.storage.triggers",Ia:"ab.storage.triggers.ts",Ch:"ab.storage.messagingSessionStart",Yt:"ab.storage.cc",vs:"ab.storage.ccLastFullSync",ys:"ab.storage.ccLastCardUpdated",$:"ab.storage.ccClicks",O:"ab.storage.ccImpressions",K:"ab.storage.ccDismissals",Ka:"ab.storage.lastDisplayedTriggerTimesById",Ya:"ab.storage.lastDisplayedTriggerTime",Da:"ab.storage.triggerFireInstancesById",Jn:"ab.storage.signature",As:"ab.storage.brazeSyncRetryCount",_s:"ab.storage.sdkVersion"},ae:"ab.optOut"};export default class G{constructor(t,e){this.Ga=t,this.Na=e}ru(t,e){let s=e;null!=e&&e instanceof _t&&(s=e.ss()),this.Ga.store(t,s)}va(t){const e=this.tu(t);null!=e&&(e._h=(new Date).valueOf(),this.ru(t,e))}tu(t){return _t.yn(this.Ga.lr(t))}qh(t){this.Ga.remove(t)}bo(t){if(null==t||0===t.length)return!1;p(t)||(t=[t]);let e=this.Na.lr(STORAGE_KEYS.q.Ta);null!=e&&p(e)||(e=[]);for(let s=0;s<t.length;s++)e.push(t[s].ss());return this.Na.store(STORAGE_KEYS.q.Ta,e)}Hh(t){return null!=t&&this.bo([t])}Ca(){let t=this.Na.lr(STORAGE_KEYS.q.Ta);this.Na.remove(STORAGE_KEYS.q.Ta),null==t&&(t=[]);const e=[];let s=!1,o=null;if(p(t))for(let s=0;s<t.length;s++)ue.Ma(t[s])?e.push(ue.yn(t[s])):o=s;else s=!0;if(s||null!=o){let n="Stored events could not be deserialized as Events";s&&(n+=", was "+Object.prototype.toString.call(t)+" not an array"),null!=o&&(n+=", value at index "+o+" does not look like an event"),n+=", serialized values were of type "+typeof t+": "+JSON.stringify(t),e.push(new ue(null,r.A.qs,(new Date).valueOf(),null,{e:n}))}return e}B(t,e){return!!F(STORAGE_KEYS.q,t,"StorageManager cannot store object.","STORAGE_KEYS.OBJECTS")&&this.Na.store(t,e)}I(t){return!!F(STORAGE_KEYS.q,t,"StorageManager cannot retrieve object.","STORAGE_KEYS.OBJECTS")&&this.Na.lr(t)}Xs(t){return!!F(STORAGE_KEYS.q,t,"StorageManager cannot remove object.","STORAGE_KEYS.OBJECTS")&&(this.Na.remove(t),!0)}clearData(){const t=rr(STORAGE_KEYS.iu),e=rr(STORAGE_KEYS.q);for(let e=0;e<t.length;e++){const s=t[e];this.Ga.remove(STORAGE_KEYS.iu[s])}for(let t=0;t<e.length;t++){const s=e[t];this.Na.remove(STORAGE_KEYS.q[s])}}ya(t){return t||STORAGE_KEYS.q.Oa}pa(t){let e=this.Na.lr(STORAGE_KEYS.q.Aa);null==e&&(e={});const s=this.ya(t[User._n]);for(let r in t)r===User._n||null!=e[s]&&null!=e[s][r]||this.mu(t[User._n],r,t[r])}mu(t,e,s){let r=this.Na.lr(STORAGE_KEYS.q.Aa);null==r&&(r={});const o=this.ya(t);let n=r[o];if(null==n&&(n={},null!=t&&(n[User._n]=t)),e===User.lu){null==n[e]&&(n[e]={});for(let t in s)n[e][t]=s[t]}else n[e]=s;return r[o]=n,this.Na.store(STORAGE_KEYS.q.Aa,r)}Ua(){const t=this.Na.lr(STORAGE_KEYS.q.Aa);this.Na.remove(STORAGE_KEYS.q.Aa);const e=[];for(let s in t)null!=t[s]&&e.push(t[s]);return e}ou(t){const e=this.Na.lr(STORAGE_KEYS.q.Aa);if(null!=e){const s=this.ya(null),r=e[s];null!=r&&(e[s]=void 0,this.Na.store(STORAGE_KEYS.q.Aa,e),r[User._n]=t,this.pa(r))}const s=this.tu(STORAGE_KEYS.iu.Dh);let r=null;null!=s&&(r=s.eu);const o=this.Ca();if(null!=o)for(let e=0;e<o.length;e++){const s=o[e];null==s.userId&&s.sessionId==r&&(s.userId=t),this.Hh(s)}}Ba(){return this.Na.Fa}}G.wa=class{constructor(t){this.Ji=t,this.Fa=et.La()?3:10}Pa(t){return t+"."+this.Ji}store(t,e){const s={v:e};try{return localStorage.setItem(this.Pa(t),JSON.stringify(s)),!0}catch(t){return r.D.info("Storage failure: "+t.message),!1}}lr(t){try{const e=JSON.parse(localStorage.getItem(this.Pa(t)));return null==e?null:e.v}catch(t){return r.D.info("Storage retrieval failure: "+t.message),null}}remove(t){try{localStorage.removeItem(this.Pa(t))}catch(t){return r.D.info("Storage removal failure: "+t.message),!1}}};G.ne=class{constructor(t,e){this.Ji=t,this.xa=this.Ja(),this.ka=576e3,this.Va=!!e}Pa(t){return null!=this.Ji?t+"."+this.Ji:t}Ja(){let t=0,e=document.location.hostname;const s=e.split("."),r="ab._gd";for(;t<s.length-1&&-1===document.cookie.indexOf(r+"="+r);)t++,e="."+s.slice(-1-t).join("."),document.cookie=r+"="+r+";domain="+e+";";return document.cookie=r+"=;expires="+new Date(0).toGMTString()+";domain="+e+";",e}ie(){const t=new Date;return t.setTime(t.getTime()+60*this.ka*1e3),t.getFullYear()}za(){const t=At(STORAGE_KEYS.iu),e=document.cookie.split(";");for(let s=0;s<e.length;s++){let r=e[s];for(;" "===r.charAt(0);)r=r.substring(1);let o=!1;for(let e=0;e<t.length;e++)if(0===r.indexOf(t[e])){o=!0;break}if(o){const t=r.split("=")[0];-1===t.indexOf("."+this.Ji)&&this.Qa(t)}}}store(t,e){this.za();const s=new Date;s.setTime(s.getTime()+60*this.ka*1e3);const o="expires="+s.toUTCString(),n="domain="+this.xa;let i;i=this.Va?e:encodeURIComponent(JSON.stringify(e));const a=this.Pa(t)+"="+i+";"+o+";"+n+";path=/";return a.length>=4093?(r.D.info("Storage failure: string is "+a.length+" chars which is too large to store as a cookie."),!1):(document.cookie=a,!0)}lr(t){const e=[],s=this.Pa(t)+"=",o=document.cookie.split(";");for(let n=0;n<o.length;n++){let i=o[n];for(;" "===i.charAt(0);)i=i.substring(1);if(0===i.indexOf(s))try{let t;t=this.Va?i.substring(s.length,i.length):JSON.parse(decodeURIComponent(i.substring(s.length,i.length))),e.push(t)}catch(e){return r.D.info("Storage retrieval failure: "+e.message),this.remove(t),null}}return e.length>0?e[e.length-1]:null}remove(t){this.Qa(this.Pa(t))}Qa(t){const e=t+"=;expires="+new Date(0).toGMTString();document.cookie=e,document.cookie=e+";path=/";const s=e+";domain="+this.xa;document.cookie=s,document.cookie=s+";path=/"}};G._a=class{constructor(){this.Ha={},this.Wa=5242880,this.Fa=3}store(t,e){const s={value:e},o=this.Xa(e);return o>this.Wa?(r.D.info("Storage failure: object is ≈"+o+" bytes which is greater than the max of "+this.Wa),!1):(this.Ha[t]=s,!0)}Xa(t){const e=[],s=[t];let r=0;for(;s.length;){const t=s.pop();if("boolean"==typeof t)r+=4;else if("string"==typeof t)r+=2*t.length;else if("number"==typeof t)r+=8;else if("object"==typeof t&&-1===e.indexOf(t)){e.push(t);for(let e in t)s.push(t[e])}}return r}lr(t){const e=this.Ha[t];return null==e?null:e.value}remove(t){this.Ha[t]=null}};G.Ea=class{constructor(t,e,s){this.Za=[],e&&this.Za.push(new G.ne(t)),s&&this.Za.push(new G.wa(t)),this.Za.push(new G._a(t))}store(t,e){let s=!0;for(let r=0;r<this.Za.length;r++)s=this.Za[r].store(t,e)&&s;return s}lr(t){for(let e=0;e<this.Za.length;e++){const s=this.Za[e].lr(t);if(null!=s)return s}return null}remove(t){for(let e=0;e<this.Za.length;e++)this.Za[e].remove(t)}};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export default{
|
|
1
|
+
export default{ua:"invalid_api_key",ca:"blacklisted",la:"no_device_identifier",ha:"invalid_json_response",oa:"empty_response",__:"sdk_auth_error"};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{isObject as Jt}from"../util/code-utils.js";import{convertMsToSeconds as l,timestampOrNow as Vt}from"../util/date-utils.js";export default class ue{constructor(t,i,s,r,e){this.userId=t,this.type=i,this.time=Vt(s),this.sessionId=r,this.data=e}
|
|
1
|
+
import{isObject as Jt}from"../util/code-utils.js";import{convertMsToSeconds as l,timestampOrNow as Vt}from"../util/date-utils.js";export default class ue{constructor(t,i,s,r,e){this.userId=t,this.type=i,this.time=Vt(s),this.sessionId=r,this.data=e}li(){const t={name:this.type,time:l(this.time),data:this.data||{},session_id:this.sessionId};return null!=this.userId&&(t.user_id=this.userId),t}ss(){return{u:this.userId,t:this.type,ts:this.time,s:this.sessionId,d:this.data}}static fromJson(t){return new ue(t.user_id,t.name,t.time,t.session_id,t.data)}static Ma(t){return null!=t&&Jt(t)&&null!=t.t&&""!==t.t}static yn(t){return new ue(t.u,t.t,t.ts,t.s,t.d)}}
|
package/src/models/device.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import DeviceProperties from"../Core/device-properties.js";export default class Ie{constructor(s){this.id=s}
|
|
1
|
+
import DeviceProperties from"../Core/device-properties.js";export default class Ie{constructor(s){this.id=s}li(){const s={};return null!=this[DeviceProperties.BROWSER]&&(s.browser=this[DeviceProperties.BROWSER]),null!=this[DeviceProperties.BROWSER_VERSION]&&(s.browser_version=this[DeviceProperties.BROWSER_VERSION]),null!=this[DeviceProperties.OS]&&(s.os_version=this[DeviceProperties.OS]),null!=this[DeviceProperties.RESOLUTION]&&(s.resolution=this[DeviceProperties.RESOLUTION]),null!=this[DeviceProperties.LANGUAGE]&&(s.locale=this[DeviceProperties.LANGUAGE]),null!=this[DeviceProperties.TIME_ZONE]&&(s.time_zone=this[DeviceProperties.TIME_ZONE]),null!=this[DeviceProperties.USER_AGENT]&&(s.user_agent=this[DeviceProperties.USER_AGENT]),s}}
|
package/src/models/identifier.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import r from"../../shared-lib/braze-shared-lib.js";export default class _t{constructor(t,e,s){null==t&&(t=r.it.nt()),s=parseInt(s),(isNaN(s)||0===s)&&(s=(new Date).valueOf()),this.
|
|
1
|
+
import r from"../../shared-lib/braze-shared-lib.js";export default class _t{constructor(t,e,s){null==t&&(t=r.it.nt()),s=parseInt(s),(isNaN(s)||0===s)&&(s=(new Date).valueOf()),this.eu=t,this.xh=s,this._h=(new Date).valueOf(),this.Nh=e}ss(){return{g:this.eu,e:this.Nh,c:this.xh,l:this._h}}static yn(t){if(null==t||null==t.g)return null;const e=new _t(t.g,t.e,t.c);return e._h=t.l,e}}
|
package/src/models/push-token.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{rehydrateDateAfterJsonization as w}from"../util/date-utils.js";export default class ei{constructor(t,i,l,s,u){this.endpoint=t||null,this.
|
|
1
|
+
import{rehydrateDateAfterJsonization as w}from"../util/date-utils.js";export default class ei{constructor(t,i,l,s,u){this.endpoint=t||null,this.wn=i||null,this.publicKey=l||null,this.tl=s||null,this.oh=u||null}ss(){return{e:this.endpoint,c:this.wn,p:this.publicKey,u:this.tl,v:this.oh}}static yn(t){return new ei(t.e,w(t.c),t.p,t.u,t.v)}}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export default class jt{constructor(t,s,i,h,l,e,r){this.hh=t||0,this.gh=s||[],this.mh=i||[],this.fh=h||[],this.ph=l,null!=l&&""!==l||(this.ph=null),this.oh=e||null,this.uh=r||{}}ss(){return{s:"4.2.
|
|
1
|
+
export default class jt{constructor(t,s,i,h,l,e,r){this.hh=t||0,this.gh=s||[],this.mh=i||[],this.fh=h||[],this.ph=l,null!=l&&""!==l||(this.ph=null),this.oh=e||null,this.uh=r||{}}ss(){return{s:"4.2.1",l:this.hh,e:this.gh,a:this.mh,p:this.fh,m:this.ph,v:this.oh,c:this.uh}}static yn(t){let s=t.l;return"4.2.1"!==t.s&&(s=0),new jt(s,t.e,t.a,t.p,t.m,t.v,t.c)}}
|