@moengage/web-sdk 2.68.0 → 2.68.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 +109 -70
- package/dist/index.js +1 -1
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -10,76 +10,10 @@ declare interface InitData {
|
|
|
10
10
|
project_id?: string;
|
|
11
11
|
disable_onsite?: boolean;
|
|
12
12
|
enableSPA?: boolean;
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
overLayColor?: string;
|
|
18
|
-
fontFaces?: {
|
|
19
|
-
family?: string;
|
|
20
|
-
url?: string;
|
|
21
|
-
}[];
|
|
22
|
-
cardDismiss?: {
|
|
23
|
-
color?: string;
|
|
24
|
-
enable?: boolean;
|
|
25
|
-
};
|
|
26
|
-
optionButtonColor?: string;
|
|
27
|
-
dateTimeColor?: string;
|
|
28
|
-
unclickedCardIndicatorColor?: string;
|
|
29
|
-
pinIcon?: string;
|
|
30
|
-
refreshIcon?: string;
|
|
31
|
-
navigationBar?: {
|
|
32
|
-
backgroundColor?: string;
|
|
33
|
-
text?: string;
|
|
34
|
-
color?: string;
|
|
35
|
-
fontSize?: string;
|
|
36
|
-
fontFamily?: string;
|
|
37
|
-
};
|
|
38
|
-
closeButton?: {
|
|
39
|
-
webIcon?: string;
|
|
40
|
-
mWebIcon?: string;
|
|
41
|
-
};
|
|
42
|
-
tab?: {
|
|
43
|
-
active?: {
|
|
44
|
-
color?: string;
|
|
45
|
-
underlineColor?: string;
|
|
46
|
-
backgroundColor?: string;
|
|
47
|
-
};
|
|
48
|
-
inactiveTabFontColor?: string;
|
|
49
|
-
fontSize?: string;
|
|
50
|
-
fontFamily?: string;
|
|
51
|
-
backgroundColor?: string;
|
|
52
|
-
};
|
|
53
|
-
webFloating?: {
|
|
54
|
-
enable?: boolean;
|
|
55
|
-
icon?: string;
|
|
56
|
-
postion?: string;
|
|
57
|
-
countBackgroundColor?: string;
|
|
58
|
-
countColor?: string;
|
|
59
|
-
iconBackgroundColor?: string;
|
|
60
|
-
fontFamily?: string;
|
|
61
|
-
};
|
|
62
|
-
mWebFloating?: {
|
|
63
|
-
enable?: boolean;
|
|
64
|
-
icon?: string;
|
|
65
|
-
postion?: string;
|
|
66
|
-
countBackgroundColor?: string;
|
|
67
|
-
countColor?: string;
|
|
68
|
-
iconBackgroundColor?: string;
|
|
69
|
-
fontFamily?: string;
|
|
70
|
-
};
|
|
71
|
-
card?: {
|
|
72
|
-
headerFontSize?: string;
|
|
73
|
-
descriptionFontSize?: string;
|
|
74
|
-
ctaFontSize?: string;
|
|
75
|
-
fontFamily?: string;
|
|
76
|
-
horizontalRowColor?: string;
|
|
77
|
-
};
|
|
78
|
-
noDataContent?: {
|
|
79
|
-
img?: string;
|
|
80
|
-
text?: string;
|
|
81
|
-
};
|
|
82
|
-
};
|
|
13
|
+
/**
|
|
14
|
+
* Cards configuration for Web SDK Cards module
|
|
15
|
+
*/
|
|
16
|
+
cards?: CardsConfig;
|
|
83
17
|
disable_web_push?: boolean;
|
|
84
18
|
swPath?: string;
|
|
85
19
|
swScope?: string;
|
|
@@ -108,6 +42,111 @@ declare enum LOG_LEVEL {
|
|
|
108
42
|
ALL = 2,
|
|
109
43
|
}
|
|
110
44
|
|
|
45
|
+
/**
|
|
46
|
+
* Cards configuration interface
|
|
47
|
+
* Matches CardsConfigModel structure from the SDK
|
|
48
|
+
*/
|
|
49
|
+
declare interface CardsConfig {
|
|
50
|
+
/** Enable Cards module */
|
|
51
|
+
enable: boolean;
|
|
52
|
+
/** CSS selector for the placeholder element that opens the inbox */
|
|
53
|
+
placeholder?: string;
|
|
54
|
+
/** Background color (any valid CSS color format) */
|
|
55
|
+
backgroundColor?: string;
|
|
56
|
+
/** Overlay color (any valid CSS color format) */
|
|
57
|
+
overLayColor?: string;
|
|
58
|
+
/** Font faces array for custom fonts */
|
|
59
|
+
fontFaces?: {
|
|
60
|
+
family?: string;
|
|
61
|
+
url?: string;
|
|
62
|
+
}[];
|
|
63
|
+
/** Card dismiss configuration */
|
|
64
|
+
cardDismiss?: {
|
|
65
|
+
enable?: boolean;
|
|
66
|
+
color?: string;
|
|
67
|
+
};
|
|
68
|
+
/** Option button color */
|
|
69
|
+
optionButtonColor?: string;
|
|
70
|
+
/** Date/time text color */
|
|
71
|
+
dateTimeColor?: string;
|
|
72
|
+
/** Unclicked card indicator color */
|
|
73
|
+
unclickedCardIndicatorColor?: string;
|
|
74
|
+
/** Pin icon URL */
|
|
75
|
+
pinIcon?: string;
|
|
76
|
+
/** Refresh icon URL */
|
|
77
|
+
refreshIcon?: string;
|
|
78
|
+
/** Navigation bar configuration */
|
|
79
|
+
navigationBar?: {
|
|
80
|
+
backgroundColor?: string;
|
|
81
|
+
text?: string;
|
|
82
|
+
color?: string;
|
|
83
|
+
fontSize?: string;
|
|
84
|
+
fontFamily?: string;
|
|
85
|
+
};
|
|
86
|
+
/** Close button configuration */
|
|
87
|
+
closeButton?: {
|
|
88
|
+
webIcon?: string;
|
|
89
|
+
mWebIcon?: string;
|
|
90
|
+
callBack?: () => void;
|
|
91
|
+
};
|
|
92
|
+
/** Tab configuration */
|
|
93
|
+
tab?: {
|
|
94
|
+
active?: {
|
|
95
|
+
color?: string;
|
|
96
|
+
underlineColor?: string;
|
|
97
|
+
backgroundColor?: string;
|
|
98
|
+
};
|
|
99
|
+
inactiveTabFontColor?: string;
|
|
100
|
+
fontSize?: string;
|
|
101
|
+
fontFamily?: string;
|
|
102
|
+
backgroundColor?: string;
|
|
103
|
+
};
|
|
104
|
+
/** Web floating icon configuration */
|
|
105
|
+
webFloating?: {
|
|
106
|
+
enable?: boolean;
|
|
107
|
+
icon?: string;
|
|
108
|
+
postion?: string;
|
|
109
|
+
countBackgroundColor?: string;
|
|
110
|
+
countColor?: string;
|
|
111
|
+
iconBackgroundColor?: string;
|
|
112
|
+
fontFamily?: string;
|
|
113
|
+
zIndex?: string;
|
|
114
|
+
};
|
|
115
|
+
/** Mobile web floating icon configuration */
|
|
116
|
+
mWebFloating?: {
|
|
117
|
+
enable?: boolean;
|
|
118
|
+
icon?: string;
|
|
119
|
+
postion?: string;
|
|
120
|
+
countBackgroundColor?: string;
|
|
121
|
+
countColor?: string;
|
|
122
|
+
iconBackgroundColor?: string;
|
|
123
|
+
fontFamily?: string;
|
|
124
|
+
zIndex?: string;
|
|
125
|
+
};
|
|
126
|
+
/** Card styling configuration */
|
|
127
|
+
card?: {
|
|
128
|
+
headerFontSize?: string;
|
|
129
|
+
descriptionFontSize?: string;
|
|
130
|
+
ctaFontSize?: string;
|
|
131
|
+
fontFamily?: string;
|
|
132
|
+
horizontalRowColor?: string;
|
|
133
|
+
};
|
|
134
|
+
/** Error page configuration */
|
|
135
|
+
errorContent?: {
|
|
136
|
+
img?: string;
|
|
137
|
+
text?: string;
|
|
138
|
+
};
|
|
139
|
+
/** No data content configuration */
|
|
140
|
+
noDataContent?: {
|
|
141
|
+
img?: string;
|
|
142
|
+
text?: string;
|
|
143
|
+
};
|
|
144
|
+
/** Callback function to open inbox */
|
|
145
|
+
openInbox?: () => void;
|
|
146
|
+
/** Z-index for the cards container */
|
|
147
|
+
zIndex?: string;
|
|
148
|
+
}
|
|
149
|
+
|
|
111
150
|
declare interface Identity {
|
|
112
151
|
[identity: string]: string;
|
|
113
152
|
}
|
package/dist/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
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",t=e.project_id||null,s=e.disable_onsite||!1,
|
|
1
|
+
const Moe={initialize:e=>{if(e&&e.app_id){var o=e.app_id,n=e.debug_logs||0,d=e.env||null,a=e.logLevel||null,i=e.cluster||"DC_1",t=e.project_id||null,s=e.disable_onsite||!1,r=e.enableSPA||!1,g=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.68.02",L=e.disableSdk||!1,b=e.customProxyDomain||null,m=e.bots_list||[],f=null;try{g&&(f=JSON.stringify(g))}catch(e){console.log("Failed to parse cards config",e)}var p=null;try{m&&m.length>0&&(p=JSON.stringify(m))}catch(e){console.log("Failed to parse bots list config",e)}if("undefined"!=typeof window&&document&&!window.Moengage){var v=i.toLowerCase(),k=document.createElement("script"),S="string"==typeof b&&b.length?`https://cdn.${b}`:"https://cdn.moengage.com",h=c&&!u?`${S}/release/${v}/versions/${c}/moe_webSdk.min.latest.js`:`${S}/release/${v}/moe_webSdk.min.latest.js`;k.type="text/javascript",k.text=`!function(e,n,i,t,a,r,o,d){if(!"${v}"||"{DC}"==="${v}")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","${h}","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 ${w?`swScope: "${w}",`:""}\n cluster: "${i.toUpperCase()}",\n ${t?`project_id: "${t}",`:""}\n disable_onsite: ${s},\n disableCookies: ${_},\n disable_web_push: ${l},\n enableSPA: ${r},\n ${f?`cards: ${f},`:""}\n disableSdk: ${L},\n customProxyDomain: ${"string"==typeof b&&b.length?`"${b}"`:null},\n ${p?`bots_list: ${p},`:""}\n });\n `,document.head.appendChild(k)}}else console.error("MoEngage: app_id is required for initialization")},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;
|