@moengage/web-sdk 2.53.5 → 2.54.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/dist/index.d.ts +27 -0
- package/dist/index.js +1 -1
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -82,6 +82,17 @@ declare interface InitData {
|
|
|
82
82
|
disableCookies?: boolean;
|
|
83
83
|
useLatest?: boolean;
|
|
84
84
|
sdkVersion?: string;
|
|
85
|
+
proxyDomains?: ProxyDomains;
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
/**
|
|
89
|
+
* The proxies for the SDK's network requests
|
|
90
|
+
*/
|
|
91
|
+
declare interface ProxyDomains {
|
|
92
|
+
api?: string;
|
|
93
|
+
cdnScript?: string;
|
|
94
|
+
cdnImage?: string;
|
|
95
|
+
cdnApp?: string;
|
|
85
96
|
}
|
|
86
97
|
|
|
87
98
|
declare interface Identity {
|
|
@@ -155,6 +166,20 @@ declare function identifyUser(identity: string): Promise<any>;
|
|
|
155
166
|
*/
|
|
156
167
|
declare function getUserIdentities(): Identity | null;
|
|
157
168
|
|
|
169
|
+
/**
|
|
170
|
+
* Provides the unique user id if present.
|
|
171
|
+
* @return {*} {string} returns the unique user id if present else returns empty string
|
|
172
|
+
*/
|
|
173
|
+
declare function getUserId(): string;
|
|
174
|
+
|
|
175
|
+
/**
|
|
176
|
+
* Provides the value of the attribute passed as parameter
|
|
177
|
+
* @param {string} attribute
|
|
178
|
+
* @return {*} returns the value of the attribute passed as parameter
|
|
179
|
+
* if the attribute is not present, it returns empty string
|
|
180
|
+
*/
|
|
181
|
+
declare function getUserAttribute(attribute: string): any;
|
|
182
|
+
|
|
158
183
|
/**
|
|
159
184
|
* Adds a user attribute with the given name and value.
|
|
160
185
|
* @param attrName - The name of the user attribute.
|
|
@@ -263,6 +288,8 @@ export {
|
|
|
263
288
|
update_unique_user_id,
|
|
264
289
|
identifyUser,
|
|
265
290
|
getUserIdentities,
|
|
291
|
+
getUserId,
|
|
292
|
+
getUserAttribute,
|
|
266
293
|
add_user_attribute,
|
|
267
294
|
add_first_name,
|
|
268
295
|
add_last_name,
|
package/dist/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
const Moe={initialize:e=>{var
|
|
1
|
+
const Moe={initialize:e=>{var o=e.app_id,a=e.debug_logs||0,n=e.cluster||"DC_1",d=e.disable_onsite||!1,i=e.enableSPA||!1,t=e.cards||null,s=e.disable_web_push||!1,r=e.swPath||"/serviceworker.js",g=e.disableCookies||!1,_=e.useLatest||!1,l=e.sdkVersion||"2.54.1",u=e.proxyDomains||null;try{t&&(t=JSON.stringify(t))}catch(e){console.log("Failed to parse cards config",e)}if("undefined"!=typeof window&&document&&!window.Moengage){var w=n.toLowerCase(),M=document.createElement("script"),c=l&&!_?`https://cdn.moengage.com/release/${w}/versions/${l}/moe_webSdk.min.latest.js`:`https://cdn.moengage.com/release/${w}/moe_webSdk.min.latest.js`;M.type="text/javascript",M.text=`!function(e,n,i,t,a,r,o,d){if(!"${w}"||"{DC}"==="${w}")return console.error("Data center has not been passed correctly. Please follow the SDK installation instruction carefully.");var s=e[a]=e[a]||[];if(s.invoked=0,s&&s.initialised>0||s.invoked>0)return console.error("MoEngage Web SDK initialised multiple times. Please integrate the Web SDK only once!"),!1;e.moengage_object=a;var l={},g=function n(i){return function(){for(var n=arguments.length,t=Array(n),a=0;a<n;a++)t[a]=arguments[a];(e.moengage_q=e.moengage_q||[]).push({f:i,a:t})}},u=["track_event","add_user_attribute","add_first_name","add_last_name","add_email","add_mobile","add_user_name","add_gender","add_birthday","destroy_session","add_unique_user_id","update_unique_user_id","moe_events","call_web_push","track","location_type_attribute","track_page_view","getSdkVersion","setDebugLevel","handle_page_change","identifyUser","getUserIdentities"],m={onsite:["getData","registerCallback"]};for(var c in u)l[u[c]]=g(u[c]);for(var v in m)for(var f in m[v])null==l[v]&&(l[v]={}),l[v][m[v][f]]=g(v+"."+m[v][f]);r=n.createElement(i),o=n.getElementsByTagName("head")[0],r.async=1,r.src=t,o.appendChild(r),e.moe=e.moe||function(){return(s.invoked=s.invoked+1,s.invoked>1)?(console.error("MoEngage Web SDK initialised multiple times. Please integrate the Web SDK only once!"),!1):(d=arguments.length<=0?void 0:arguments[0],l)},r.addEventListener("load",function(){if(d)return e[a]=e.moe(d),(e[a]&&(e[a].initialised=e[a].initialised+1||1)),!0}),r.addEventListener("error",function(){return console.error("Moengage Web SDK loading failed."),!1})}(window,document,"script","${c}","Moengage");\n Moengage = moe({\n app_id: "${o}",\n debug_logs: ${a},\n swPath: "${r}",\n cluster: "${n.toUpperCase()}",\n disableOnsite: ${d},\n disableCookies: ${g},\n disable_web_push: ${s},\n enableSPA: ${i},\n cards: ${t},\n proxyDomains: ${u}\n });\n `,document.head.appendChild(M)}},isMoeLoaded:()=>{try{if("undefined"!=typeof window&&document&&window.Moengage)return!0}catch(e){return!1}return!1},track_event:(e,o)=>Moe.isMoeLoaded()&&window.Moengage.track_event(e,o),getSdkVersion:()=>Moe.isMoeLoaded()&&window.Moengage.getSdkVersion(),setDebugLevel:e=>Moe.isMoeLoaded()&&window.Moengage.setDebugLevel(e),add_unique_user_id:e=>Moe.isMoeLoaded()&&window.Moengage.add_unique_user_id(e),update_unique_user_id:e=>Moe.isMoeLoaded()&&window.Moengage.update_unique_user_id(e),identifyUser:e=>Moe.isMoeLoaded()&&window.Moengage.identifyUser(e),getUserIdentities:()=>Moe.isMoeLoaded()&&window.Moengage.getUserIdentities(),getUserId:()=>Moe.isMoeLoaded()&&window.Moengage.getUserId(),getUserAttribute:e=>Moe.isMoeLoaded()&&window.Moengage.getUserAttribute(e),add_user_attribute:(e,o)=>Moe.isMoeLoaded()&&window.Moengage.add_user_attribute(e,o),add_first_name:e=>Moe.isMoeLoaded()&&window.Moengage.add_first_name(e),add_last_name:e=>Moe.isMoeLoaded()&&window.Moengage.add_last_name(e),add_email:e=>Moe.isMoeLoaded()&&window.Moengage.add_email(e),add_mobile:e=>Moe.isMoeLoaded()&&window.Moengage.add_mobile(e),add_user_name:e=>Moe.isMoeLoaded()&&window.Moengage.add_user_name(e),add_gender:e=>Moe.isMoeLoaded()&&window.Moengage.add_gender(e),add_birthday:e=>Moe.isMoeLoaded()&&window.Moengage.add_birthday(e),destroy_session:()=>Moe.isMoeLoaded()&&window.Moengage.destroy_session(),call_web_push:e=>Moe.isMoeLoaded()&&window.Moengage.call_web_push(e),track_page_view:()=>Moe.isMoeLoaded()&&window.Moengage.track_page_view(),handle_page_change:()=>Moe.isMoeLoaded()&&window.Moengage.handle_page_change(),on_cards_loaded:()=>new Promise(((e,o)=>{"undefined"!=typeof window?window.Moengage.cards?(Moe.cards=window.Moengage.cards,e()):window.addEventListener("MOE_LIFECYCLE",(o=>{"CARDS_INITIALIZED"===o.detail.name&&(Moe.cards=window.Moengage.cards,e())})):o()})),cards:"undefined"!=typeof window&&window.Moengage&&window.Moengage.cards||{}};module.exports=Moe;
|