@moengage/web-sdk 2.54.0 → 2.54.2
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 +37 -0
- package/dist/index.js +1 -1
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -82,6 +82,7 @@ declare interface InitData {
|
|
|
82
82
|
disableCookies?: boolean;
|
|
83
83
|
useLatest?: boolean;
|
|
84
84
|
sdkVersion?: string;
|
|
85
|
+
disableSdk?: boolean;
|
|
85
86
|
proxyDomains?: ProxyDomains;
|
|
86
87
|
}
|
|
87
88
|
|
|
@@ -166,6 +167,37 @@ declare function identifyUser(identity: string): Promise<any>;
|
|
|
166
167
|
*/
|
|
167
168
|
declare function getUserIdentities(): Identity | null;
|
|
168
169
|
|
|
170
|
+
/**
|
|
171
|
+
* Enables the Web SDK.
|
|
172
|
+
* @returns A promise that resolves with `true` if `enableSdk` operation was successful.
|
|
173
|
+
*/
|
|
174
|
+
declare function enableSdk(): Promise<boolean>;
|
|
175
|
+
|
|
176
|
+
/**
|
|
177
|
+
* Disables the Web SDK.
|
|
178
|
+
* @returns A promise that resolves with `true` if `disableSdk` operation was successful.
|
|
179
|
+
*/
|
|
180
|
+
declare function disableSdk(): Promise<boolean>;
|
|
181
|
+
|
|
182
|
+
/**
|
|
183
|
+
* @returns `true` if Web SDK is enabled; `false` otherwise.
|
|
184
|
+
*/
|
|
185
|
+
declare function isSdkEnabled(): boolean;
|
|
186
|
+
|
|
187
|
+
/* Provides the unique user id if present.
|
|
188
|
+
* @return {*} {string} returns the unique user id if present else returns empty string
|
|
189
|
+
*/
|
|
190
|
+
|
|
191
|
+
declare function getUserId(): string;
|
|
192
|
+
|
|
193
|
+
/**
|
|
194
|
+
* Provides the value of the attribute passed as parameter
|
|
195
|
+
* @param {string} attribute
|
|
196
|
+
* @return {*} returns the value of the attribute passed as parameter
|
|
197
|
+
* if the attribute is not present, it returns empty string
|
|
198
|
+
*/
|
|
199
|
+
declare function getUserAttribute(attribute: string): any;
|
|
200
|
+
|
|
169
201
|
/**
|
|
170
202
|
* Adds a user attribute with the given name and value.
|
|
171
203
|
* @param attrName - The name of the user attribute.
|
|
@@ -274,6 +306,11 @@ export {
|
|
|
274
306
|
update_unique_user_id,
|
|
275
307
|
identifyUser,
|
|
276
308
|
getUserIdentities,
|
|
309
|
+
enableSdk,
|
|
310
|
+
disableSdk,
|
|
311
|
+
isSdkEnabled,
|
|
312
|
+
getUserId,
|
|
313
|
+
getUserAttribute,
|
|
277
314
|
add_user_attribute,
|
|
278
315
|
add_first_name,
|
|
279
316
|
add_last_name,
|
package/dist/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
const Moe={initialize:e=>{var
|
|
1
|
+
const Moe={initialize:e=>{var d=e.app_id,o=e.debug_logs||0,a=e.cluster||"DC_1",n=e.disable_onsite||!1,i=e.enableSPA||!1,s=e.cards||null,t=e.disable_web_push||!1,r=e.swPath||"/serviceworker.js",g=e.disableCookies||!1,l=e.useLatest||!1,_=e.sdkVersion||"2.54.2",w=e.disableSdk||!1,M=e.proxyDomains||null;try{s&&(s=JSON.stringify(s))}catch(e){console.log("Failed to parse cards config",e)}if("undefined"!=typeof window&&document&&!window.Moengage){var u=a.toLowerCase(),c=document.createElement("script"),m=_&&!l?`https://cdn.moengage.com/release/${u}/versions/${_}/moe_webSdk.min.latest.js`:`https://cdn.moengage.com/release/${u}/moe_webSdk.min.latest.js`;c.type="text/javascript",c.text=`!function(e,n,i,t,a,r,o,d){if(!"${u}"||"{DC}"==="${u}")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","${m}","Moengage");\n Moengage = moe({\n app_id: "${d}",\n debug_logs: ${o},\n swPath: "${r}",\n cluster: "${a.toUpperCase()}",\n disableOnsite: ${n},\n disableCookies: ${g},\n disable_web_push: ${t},\n enableSPA: ${i},\n cards: ${s},\n disableSdk: ${w},\n proxyDomains: ${M}\n });\n `,document.head.appendChild(c)}},isMoeLoaded:()=>{try{if("undefined"!=typeof window&&document&&window.Moengage)return!0}catch(e){return!1}return!1},track_event:(e,d)=>Moe.isMoeLoaded()&&window.Moengage.track_event(e,d),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(),enableSdk:()=>Moe.isMoeLoaded()&&window.Moengage.enableSdk(),disableSdk:()=>Moe.isMoeLoaded()&&window.Moengage.disableSdk(),isSdkEnabled:()=>Moe.isMoeLoaded()&&window.Moengage.isSdkEnabled(),getUserId:()=>Moe.isMoeLoaded()&&window.Moengage.getUserId(),getUserAttribute:e=>Moe.isMoeLoaded()&&window.Moengage.getUserAttribute(e),add_user_attribute:(e,d)=>Moe.isMoeLoaded()&&window.Moengage.add_user_attribute(e,d),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,d)=>{"undefined"!=typeof window?window.Moengage.cards?(Moe.cards=window.Moengage.cards,e()):window.addEventListener("MOE_LIFECYCLE",(d=>{"CARDS_INITIALIZED"===d.detail.name&&(Moe.cards=window.Moengage.cards,e())})):d()})),cards:"undefined"!=typeof window&&window.Moengage&&window.Moengage.cards||{}};module.exports=Moe;
|