@moengage/web-sdk 2.65.0 → 2.66.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.ts +56 -0
- package/dist/index.js +1 -1
- package/package.json +2 -2
package/dist/index.d.ts
CHANGED
|
@@ -5,6 +5,8 @@ declare interface InitData {
|
|
|
5
5
|
app_id: string;
|
|
6
6
|
cluster: string;
|
|
7
7
|
debug_logs?: number;
|
|
8
|
+
env?: SDK_ENVIRONMENT;
|
|
9
|
+
logLevel?: LOG_LEVEL;
|
|
8
10
|
project_id?: string;
|
|
9
11
|
disable_onsite?: boolean;
|
|
10
12
|
enableSPA?: boolean;
|
|
@@ -89,6 +91,23 @@ declare interface InitData {
|
|
|
89
91
|
bots_list?: string[];
|
|
90
92
|
}
|
|
91
93
|
|
|
94
|
+
/**
|
|
95
|
+
* SDK Environment enum
|
|
96
|
+
*/
|
|
97
|
+
declare enum SDK_ENVIRONMENT {
|
|
98
|
+
TEST = 'TEST',
|
|
99
|
+
LIVE = 'LIVE',
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
/**
|
|
103
|
+
* Log Level enum
|
|
104
|
+
*/
|
|
105
|
+
declare enum LOG_LEVEL {
|
|
106
|
+
NONE = 0,
|
|
107
|
+
LIMITED = 1,
|
|
108
|
+
ALL = 2,
|
|
109
|
+
}
|
|
110
|
+
|
|
92
111
|
/**
|
|
93
112
|
* The proxies for the SDK's network requests
|
|
94
113
|
*/
|
|
@@ -145,11 +164,24 @@ declare function track_event(eventName: string, eventAttrs: any): Promise<any>;
|
|
|
145
164
|
*/
|
|
146
165
|
declare function getSdkVersion(): string;
|
|
147
166
|
|
|
167
|
+
/**
|
|
168
|
+
* Sets the log level for console output (PRIMARY METHOD).
|
|
169
|
+
* @param level - Log level to set (0=none, 1=limited, 2=all)
|
|
170
|
+
* @returns A Promise that resolves when the log level is set.
|
|
171
|
+
*/
|
|
172
|
+
declare function setLogLevel(level: number): Promise<void>;
|
|
173
|
+
|
|
148
174
|
/**
|
|
149
175
|
* Explicitly set new debug level. To be used to see log messages in live environment too.
|
|
150
176
|
* @note This does not append '_DEBUG' to the workspace ID.
|
|
151
177
|
* @param level Debug level to set.
|
|
152
178
|
*/
|
|
179
|
+
/**
|
|
180
|
+
* @deprecated Use setLogLevel instead. This method is kept for backward compatibility.
|
|
181
|
+
* Sets the log level for console output.
|
|
182
|
+
* @param level - Log level to set (0=none, 1=limited, 2=all)
|
|
183
|
+
* @returns A Promise that resolves when the log level is set.
|
|
184
|
+
*/
|
|
153
185
|
declare function setDebugLevel(level: number): Promise<void>;
|
|
154
186
|
|
|
155
187
|
/**
|
|
@@ -203,6 +235,24 @@ declare function disableSdk(): Promise<boolean>;
|
|
|
203
235
|
*/
|
|
204
236
|
declare function isSdkEnabled(): boolean;
|
|
205
237
|
|
|
238
|
+
/**
|
|
239
|
+
* Enables data tracking.
|
|
240
|
+
* @returns A promise that resolves with `true` if `enableDataTracking` operation was successful.
|
|
241
|
+
*/
|
|
242
|
+
declare function enableDataTracking(): Promise<boolean>;
|
|
243
|
+
|
|
244
|
+
/**
|
|
245
|
+
* Disables data tracking.
|
|
246
|
+
* @returns A promise that resolves with `true` if `disableDataTracking` operation was successful.
|
|
247
|
+
*/
|
|
248
|
+
declare function disableDataTracking(): Promise<boolean>;
|
|
249
|
+
|
|
250
|
+
|
|
251
|
+
/**
|
|
252
|
+
* @returns `true` if data tracking is enabled; `false` otherwise.
|
|
253
|
+
*/
|
|
254
|
+
declare function isDataTrackingEnabled(): boolean;
|
|
255
|
+
|
|
206
256
|
/* Provides the unique user id if present.
|
|
207
257
|
* @return {*} {string} returns the unique user id if present else returns empty string
|
|
208
258
|
*/
|
|
@@ -385,6 +435,7 @@ export {
|
|
|
385
435
|
isMoeLoaded,
|
|
386
436
|
track_event,
|
|
387
437
|
getSdkVersion,
|
|
438
|
+
setLogLevel,
|
|
388
439
|
setDebugLevel,
|
|
389
440
|
add_unique_user_id,
|
|
390
441
|
update_unique_user_id,
|
|
@@ -393,6 +444,9 @@ export {
|
|
|
393
444
|
enableSdk,
|
|
394
445
|
disableSdk,
|
|
395
446
|
isSdkEnabled,
|
|
447
|
+
enableDataTracking,
|
|
448
|
+
disableDataTracking,
|
|
449
|
+
isDataTrackingEnabled,
|
|
396
450
|
getUserId,
|
|
397
451
|
getUserAttribute,
|
|
398
452
|
add_user_attribute,
|
|
@@ -412,4 +466,6 @@ export {
|
|
|
412
466
|
onsite,
|
|
413
467
|
InitData,
|
|
414
468
|
Attribute,
|
|
469
|
+
SDK_ENVIRONMENT as env,
|
|
470
|
+
LOG_LEVEL as logLevel,
|
|
415
471
|
};
|
package/dist/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
const Moe={initialize:e=>{var o=e.app_id,
|
|
1
|
+
const Moe={initialize:e=>{var o=e.app_id,n=e.debug_logs||0,d=e.env||null,a=e.logLevel||null,i=e.cluster||"DC_1",s=e.project_id||null,t=e.disable_onsite||!1,g=e.enableSPA||!1,r=e.cards||null,l=e.disable_web_push||!1,M=e.swPath||"/serviceworker.js",w=e.swScope||null,_=e.disableCookies||!1,u=e.useLatest||!1,c=e.sdkVersion||"2.66.00",L=e.disableSdk||!1,b=e.proxyDomains||null,m=e.bots_list||[];try{r&&(r=JSON.stringify(r))}catch(e){console.log("Failed to parse cards config",e)}try{m=JSON.stringify(m)}catch(e){console.log("Failed to parse bots list config",e)}try{b&&(b=JSON.stringify(b))}catch(e){console.log("Failed to parse proxy domains config",e)}if("undefined"!=typeof window&&document&&!window.Moengage){var f=i.toLowerCase(),p=document.createElement("script"),v=c&&!u?`https://cdn.moengage.com/release/${f}/versions/${c}/moe_webSdk.min.latest.js`:`https://cdn.moengage.com/release/${f}/moe_webSdk.min.latest.js`;p.type="text/javascript",p.text=`!function(e,n,i,t,a,r,o,d){if(!"${f}"||"{DC}"==="${f}")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","setLogLevel","setDebugLevel","handle_page_change","identifyUser","getUserIdentities"],m={onsite:["getData","registerCallback","getSelfHandledOSM"]};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","${v}","Moengage");\n Moengage = moe({\n app_id: "${o}",\n debug_logs: ${n},\n ${d?`env: "${d}",`:""}\n ${null!=a?`logLevel: ${"string"==typeof a?`"${a}"`:a},`:""}\n swPath: "${M}",\n swScope: ${w?`"${w}"`:null},\n cluster: "${i.toUpperCase()}",\n ${s?`project_id: "${s}",`:""}\n disableOnsite: ${t},\n disableCookies: ${_},\n disable_web_push: ${l},\n enableSPA: ${g},\n cards: ${r},\n disableSdk: ${L},\n proxyDomains: ${b},\n bots_list: ${m}\n });\n `,document.head.appendChild(p)}},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(),setLogLevel:e=>Moe.isMoeLoaded()&&window.Moengage.setLogLevel(e),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(),enableDataTracking:()=>Moe.isMoeLoaded()&&window.Moengage.enableDataTracking(),disableDataTracking:()=>Moe.isMoeLoaded()&&window.Moengage.disableDataTracking(),isDataTrackingEnabled:()=>Moe.isMoeLoaded()&&window.Moengage.isDataTrackingEnabled(),getUserId:()=>Moe.isMoeLoaded()&&window.Moengage.getUserId(),getUserAttribute:(e,o)=>Moe.isMoeLoaded()?o&&"string"==typeof o?window.Moengage.getUserAttribute(e,o):window.Moengage.getUserAttribute(e):null,add_user_attribute:(e,o,n)=>!!Moe.isMoeLoaded()&&(n&&"string"==typeof n?window.Moengage.add_user_attribute(e,o,n):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||{},onsite:{getData:()=>Moe.isMoeLoaded()&&window.Moengage.onsite.getData(),registerCallback:e=>Moe.isMoeLoaded()&&window.Moengage.onsite.registerCallback(e),getSelfHandledOSM:e=>Moe.isMoeLoaded()&&window.Moengage.onsite.getSelfHandledOSM(e),selfHandledShown:e=>Moe.isMoeLoaded()&&window.Moengage.onsite.selfHandledShown(e),selfHandledClicked:e=>Moe.isMoeLoaded()&&window.Moengage.onsite.selfHandledClicked(e),selfHandledDismissed:e=>Moe.isMoeLoaded()&&window.Moengage.onsite.selfHandledDismissed(e)},Attribute:{USER_ATTRIBUTE_LEVEL:{PROJECT:"PROJECT",PORTFOLIO:"PORTFOLIO"}},env:{TEST:"TEST",LIVE:"LIVE"},logLevel:{NONE:0,LIMITED:1,ALL:2}};module.exports=Moe;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@moengage/web-sdk",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.66.00",
|
|
4
4
|
"description": "Moengage Web SDK package",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"keywords": [
|
|
@@ -20,4 +20,4 @@
|
|
|
20
20
|
"type": "git",
|
|
21
21
|
"url": "git+https://github.com/moengage/webSDK.git"
|
|
22
22
|
}
|
|
23
|
-
}
|
|
23
|
+
}
|