@textback/notification-widget 2.0.1-84986 → 2.0.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/.eslintrc.js +291 -291
- package/.idea/inspectionProfiles/Project_Default.xml +6 -0
- package/.idea/misc.xml +6 -0
- package/.idea/modules.xml +8 -0
- package/.idea/notificationwidget.iml +9 -0
- package/.idea/vcs.xml +6 -0
- package/build/index.js +3 -3
- package/build/sdk.js +2 -2
- package/package.json +70 -70
- package/promote_tag.sh +1 -1
- package/readme.md +569 -569
- package/server.js +1 -1
- package/src/libraries/ai.1.0.11.js +4088 -4088
- package/src/libraries/localization/locales/index.js +8 -8
- package/src/libraries/localization/text.js +9 -9
- package/src/libraries/t.js +82 -82
- package/src/sdk/channels/channel.js +30 -30
- package/src/sdk/channels/facebook.js +13 -13
- package/src/sdk/channels/skype.js +12 -12
- package/src/sdk/channels/telegram.js +18 -18
- package/src/sdk/channels/viber.js +12 -12
- package/src/sdk/channels/vk-modal/vk-modal.html +17 -17
- package/src/sdk/channels/vk-modal/vk-modal.js +25 -25
- package/src/sdk/channels/vk-modal/vk-modal.scss +116 -116
- package/src/sdk/channels/vk.js +195 -195
- package/src/sdk/events/observer.js +46 -46
- package/src/sdk/index.js +5 -5
- package/src/sdk/sdk.js +67 -67
- package/src/sdk/utils/apiErrorHandler.js +11 -11
- package/src/sdk/utils/appInsights.js +88 -88
- package/src/sdk/utils/browserInfo.js +8 -8
- package/src/sdk/utils/constants.js +17 -17
- package/src/sdk/utils/cookies.js +67 -67
- package/src/sdk/utils/find.js +7 -7
- package/src/sdk/utils/loadConfig.js +20 -20
- package/src/sdk/utils/loadDeepLink.js +48 -48
- package/src/sdk/utils/loadScript.js +25 -25
- package/src/sdk/utils/loadSubscriptions.js +6 -6
- package/src/sdk/utils/parseQueryString.js +33 -33
- package/src/sdk/utils/windowHelper.js +25 -25
- package/src/sdk/widget/widget.js +192 -192
- package/src/widget/components/tb-notification-button/index.js +34 -34
- package/src/widget/components/tb-notification-button/styles.scss +657 -657
- package/src/widget/components/tb-notification-widget/normalize.scss +395 -395
- package/src/widget/components/tb-nw-wahunter/styles.scss +471 -471
- package/src/widget/config.js +5 -5
- package/src/widget/icons/icon_chat_window.svg +1 -1
- package/src/widget/icons/icon_close.svg +1 -1
- package/src/widget/icons/icon_facebook.svg +7 -7
- package/src/widget/icons/icon_facebook_circle.svg +7 -7
- package/src/widget/icons/icon_instagram_circle.svg +95 -95
- package/src/widget/icons/icon_skype.svg +44 -44
- package/src/widget/icons/icon_skype_circle.svg +46 -46
- package/src/widget/icons/icon_skype_new.svg +113 -113
- package/src/widget/icons/icon_tg.svg +25 -25
- package/src/widget/icons/icon_tg_circle.svg +17 -17
- package/src/widget/icons/icon_viber.svg +75 -75
- package/src/widget/icons/icon_viber_circle.svg +67 -67
- package/src/widget/icons/icon_viber_new.svg +102 -102
- package/src/widget/icons/icon_vk.svg +14 -14
- package/src/widget/icons/icon_vk_circle.svg +16 -16
- package/src/widget/icons/icon_whatsapp.svg +147 -147
- package/src/widget/icons/icon_whatsapp_circle.svg +3 -3
- package/src/widget/icons/icon_whatsapp_new.svg +127 -127
- package/src/widget/icons/icon_whatsappb.svg +147 -147
- package/src/widget/icons/icon_whatsappb_circle.svg +3 -3
- package/src/widget/icons/icon_whatsappb_new.svg +127 -127
- package/src/widget/icons/paper-plane-arrow.svg +3 -3
- package/src/widget/icons/tb-logo.svg +21 -21
- package/src/widget/index.js +28 -28
- package/src/widget/locales/cs.js +42 -42
- package/src/widget/locales/en.js +42 -42
- package/src/widget/locales/ro.js +41 -41
- package/src/widget/utils/cookiesEx.js +41 -41
- package/src/widget/utils/stringifyAttributes.js +19 -19
- package/src/widget/utils/widgetsStorage.js +28 -28
- package/src/widget/widget.entry.js +3 -3
- package/tests/gf.html +35 -35
- package/tests/gf.js +21 -21
- package/tests/index.js +61 -61
- package/views/examples.ejs +3 -3
- package/views/sdk.html +274 -274
- package/webpack.common.js +72 -72
- package/webpack.dev.js +15 -15
- package/webpack.prod.js +10 -10
package/src/sdk/widget/widget.js
CHANGED
@@ -1,192 +1,192 @@
|
|
1
|
-
import UUID from 'uuid-js';
|
2
|
-
import assign from 'lodash/assign';
|
3
|
-
|
4
|
-
import apiErrorHandler from '../utils/apiErrorHandler.js';
|
5
|
-
import loadConfig from '../utils/loadConfig.js';
|
6
|
-
import loadDeepLink from '../utils/loadDeepLink.js';
|
7
|
-
import loadSubscriptions from '../utils/loadSubscriptions.js';
|
8
|
-
import cookies from '../utils/cookies.js';
|
9
|
-
import constants from '../utils/constants.js';
|
10
|
-
import parseQueryString from '../utils/parseQueryString.js';
|
11
|
-
import find from '../utils/find.js';
|
12
|
-
import appInsights from '../utils/appInsights.js';
|
13
|
-
|
14
|
-
import channelsFactory from '../channels/factory.js';
|
15
|
-
|
16
|
-
const INITIAL_CONFIG_DEFAULTS = {
|
17
|
-
apiPath: 'https://api.textback.io/api',
|
18
|
-
};
|
19
|
-
|
20
|
-
export default class Widget {
|
21
|
-
constructor(config, sdk) {
|
22
|
-
this.initialConfig = assign({}, INITIAL_CONFIG_DEFAULTS, config);
|
23
|
-
this.sdk = sdk;
|
24
|
-
|
25
|
-
this.config = {};
|
26
|
-
this.channels = [];
|
27
|
-
this.initialized = false;
|
28
|
-
this.initPromise = null;
|
29
|
-
|
30
|
-
this.id = this.initialConfig.widgetId;
|
31
|
-
this.widgetUserId = Widget.getWidgetUserId();
|
32
|
-
this.insecureContext = Widget.createInsecureContext(this.initialConfig.insecureContext);
|
33
|
-
this.secureContextToken = this.initialConfig.secureContextToken;
|
34
|
-
}
|
35
|
-
|
36
|
-
getConfig() {
|
37
|
-
return this.config;
|
38
|
-
}
|
39
|
-
|
40
|
-
initialize() {
|
41
|
-
this.initPromise = Promise.all([
|
42
|
-
this.initializeConfig(),
|
43
|
-
loadSubscriptions(this.widgetUserId, this.initialConfig.widgetId, this.initialConfig.apiPath),
|
44
|
-
]).then(([config, subscriptions]) => {
|
45
|
-
this.config = config.$value;
|
46
|
-
this.subscriptions = subscriptions.$items;
|
47
|
-
|
48
|
-
this.useVKApi = this.config.type === constants.WIDGET_TYPE_API_CALL;
|
49
|
-
this.aiKey = Widget.getAiKey(config);
|
50
|
-
|
51
|
-
let customDeeplinkData = this.config.channels.filter(
|
52
|
-
c => c.hasOwnProperty('additionalProperties') && c.additionalProperties.hasOwnProperty('customDeeplinkValue')
|
53
|
-
).filter(
|
54
|
-
c => c.channel === 'whatsapp' || c.channel === 'whatsappb'
|
55
|
-
).filter(
|
56
|
-
c => c.enabled
|
57
|
-
).map(
|
58
|
-
({additionalProperties, channel, channelId}) => {
|
59
|
-
return {
|
60
|
-
channel: channel,
|
61
|
-
channelId: channelId,
|
62
|
-
customDeeplinkValue: additionalProperties.customDeeplinkValue
|
63
|
-
};
|
64
|
-
}
|
65
|
-
);
|
66
|
-
|
67
|
-
let deeplinkData = {
|
68
|
-
accountId: this.config.accountId,
|
69
|
-
insecureContext: this.insecureContext,
|
70
|
-
widgetId: this.config.id,
|
71
|
-
secureContextToken: this.secureContextToken,
|
72
|
-
user: {
|
73
|
-
id: this.widgetUserId
|
74
|
-
}
|
75
|
-
};
|
76
|
-
|
77
|
-
if(customDeeplinkData.length > 0) {
|
78
|
-
deeplinkData.customDeeplinkValue = customDeeplinkData;
|
79
|
-
}
|
80
|
-
|
81
|
-
return Promise.all([
|
82
|
-
loadDeepLink(
|
83
|
-
this.initialConfig.apiPath,
|
84
|
-
deeplinkData
|
85
|
-
),
|
86
|
-
appInsights.init(this.aiKey, this.widgetUserId, this.config.accountId)
|
87
|
-
]);
|
88
|
-
}).then(([deeplink, ai]) => {
|
89
|
-
this.deeplink = `subscribe_${deeplink.$value.id}`;
|
90
|
-
this.channels = this.config.channels.map(channel => channelsFactory.create(channel, this.deeplink, this))
|
91
|
-
.filter(channel => !!channel);
|
92
|
-
|
93
|
-
const channelInitPromises = this.channels.filter(
|
94
|
-
channel => !!channel.initPromise
|
95
|
-
).map(
|
96
|
-
channel => channel.initPromise
|
97
|
-
);
|
98
|
-
|
99
|
-
return Promise.all(channelInitPromises);
|
100
|
-
}).then(channelPromises => {
|
101
|
-
return this;
|
102
|
-
}, err => {
|
103
|
-
appInsights.trackWidgetEvent(this.config.id, 'Widget.initialize.error', err);
|
104
|
-
return Promise.reject(err);
|
105
|
-
});
|
106
|
-
|
107
|
-
return this.initPromise;
|
108
|
-
}
|
109
|
-
|
110
|
-
initializeConfig() {
|
111
|
-
let promise;
|
112
|
-
if (!this.initialConfig.overrideConfig) {
|
113
|
-
promise = loadConfig(this.initialConfig.widgetId, this.initialConfig.apiPath);
|
114
|
-
} else {
|
115
|
-
promise = Promise.resolve({ $value: this.initialConfig.overrideConfig });
|
116
|
-
}
|
117
|
-
|
118
|
-
return promise;
|
119
|
-
}
|
120
|
-
|
121
|
-
subscribe(channelCode) {
|
122
|
-
const channel = find(this.getEnabledChannels(), chan => chan.channel === channelCode);
|
123
|
-
if (channel) {
|
124
|
-
channel.subscribe();
|
125
|
-
}
|
126
|
-
}
|
127
|
-
|
128
|
-
getChannels() {
|
129
|
-
return this.channels;
|
130
|
-
}
|
131
|
-
|
132
|
-
getEnabledChannels() {
|
133
|
-
return this.channels.filter(channel => channel.enabled && !channel.hasError);
|
134
|
-
}
|
135
|
-
|
136
|
-
runWahunter(phoneNumber) {
|
137
|
-
return fetch(`${this.initialConfig.apiPath}/wahunter`, {
|
138
|
-
method: 'POST',
|
139
|
-
headers: {
|
140
|
-
'Content-Type': 'application/json;charset=utf-8'
|
141
|
-
},
|
142
|
-
body: JSON.stringify({
|
143
|
-
notificationWidgetId: this.initialConfig.widgetId,
|
144
|
-
phone: phoneNumber,
|
145
|
-
insecureContext: this.insecureContext,
|
146
|
-
deeplinkId: this.deeplink,
|
147
|
-
}),
|
148
|
-
}).then((resp) => {
|
149
|
-
if (resp.ok) {
|
150
|
-
cookies.setCookie(`${constants.COOKIE_NAME_PREFIX + this.id}_wahunter_was_run`, true, this.config.showWidgetSetting.showSessionLength * 60);
|
151
|
-
} else {
|
152
|
-
return Promise.reject(resp);
|
153
|
-
}
|
154
|
-
})
|
155
|
-
}
|
156
|
-
|
157
|
-
static getWidgetUserId() {
|
158
|
-
let widgetUserId = cookies.getCookie(constants.COOKIE_WIDGET_USER_ID);
|
159
|
-
if (widgetUserId === null) {
|
160
|
-
let uuid = UUID.create(4);
|
161
|
-
widgetUserId = uuid.hex;
|
162
|
-
cookies.setCookie(constants.COOKIE_WIDGET_USER_ID, widgetUserId, constants.WIDGET_USER_ID_COOKIE_TTL);
|
163
|
-
}
|
164
|
-
return widgetUserId;
|
165
|
-
}
|
166
|
-
|
167
|
-
static createInsecureContext(insecureContext = {}) {
|
168
|
-
const ctx = assign({}, insecureContext);//Object.assign({}, insecureContext);
|
169
|
-
ctx.pageTitle = window.document.title;
|
170
|
-
ctx.pageUrl = window.location.protocol + '//' + window.location.host + window.location.pathname;
|
171
|
-
ctx.params = parseQueryString(window.location.search.substring(1));
|
172
|
-
ctx.timezoneOffset = new Date().getTimezoneOffset();
|
173
|
-
ctx.cookies = cookies.getCookieObject();
|
174
|
-
|
175
|
-
const roistatVisitCookie = cookies.getCookie("roistat_visit");
|
176
|
-
|
177
|
-
if (roistatVisitCookie) {
|
178
|
-
ctx.roistatVisit = roistatVisitCookie;
|
179
|
-
}
|
180
|
-
|
181
|
-
return ctx;
|
182
|
-
}
|
183
|
-
|
184
|
-
static getAiKey(config) {
|
185
|
-
let aiKey = undefined;
|
186
|
-
try {
|
187
|
-
aiKey = config.headers.get('X-TB-AIKEY');
|
188
|
-
} catch (e) { }
|
189
|
-
|
190
|
-
return aiKey;
|
191
|
-
}
|
192
|
-
}
|
1
|
+
import UUID from 'uuid-js';
|
2
|
+
import assign from 'lodash/assign';
|
3
|
+
|
4
|
+
import apiErrorHandler from '../utils/apiErrorHandler.js';
|
5
|
+
import loadConfig from '../utils/loadConfig.js';
|
6
|
+
import loadDeepLink from '../utils/loadDeepLink.js';
|
7
|
+
import loadSubscriptions from '../utils/loadSubscriptions.js';
|
8
|
+
import cookies from '../utils/cookies.js';
|
9
|
+
import constants from '../utils/constants.js';
|
10
|
+
import parseQueryString from '../utils/parseQueryString.js';
|
11
|
+
import find from '../utils/find.js';
|
12
|
+
import appInsights from '../utils/appInsights.js';
|
13
|
+
|
14
|
+
import channelsFactory from '../channels/factory.js';
|
15
|
+
|
16
|
+
const INITIAL_CONFIG_DEFAULTS = {
|
17
|
+
apiPath: 'https://api.textback.io/api',
|
18
|
+
};
|
19
|
+
|
20
|
+
export default class Widget {
|
21
|
+
constructor(config, sdk) {
|
22
|
+
this.initialConfig = assign({}, INITIAL_CONFIG_DEFAULTS, config);
|
23
|
+
this.sdk = sdk;
|
24
|
+
|
25
|
+
this.config = {};
|
26
|
+
this.channels = [];
|
27
|
+
this.initialized = false;
|
28
|
+
this.initPromise = null;
|
29
|
+
|
30
|
+
this.id = this.initialConfig.widgetId;
|
31
|
+
this.widgetUserId = Widget.getWidgetUserId();
|
32
|
+
this.insecureContext = Widget.createInsecureContext(this.initialConfig.insecureContext);
|
33
|
+
this.secureContextToken = this.initialConfig.secureContextToken;
|
34
|
+
}
|
35
|
+
|
36
|
+
getConfig() {
|
37
|
+
return this.config;
|
38
|
+
}
|
39
|
+
|
40
|
+
initialize() {
|
41
|
+
this.initPromise = Promise.all([
|
42
|
+
this.initializeConfig(),
|
43
|
+
loadSubscriptions(this.widgetUserId, this.initialConfig.widgetId, this.initialConfig.apiPath),
|
44
|
+
]).then(([config, subscriptions]) => {
|
45
|
+
this.config = config.$value;
|
46
|
+
this.subscriptions = subscriptions.$items;
|
47
|
+
|
48
|
+
this.useVKApi = this.config.type === constants.WIDGET_TYPE_API_CALL;
|
49
|
+
this.aiKey = Widget.getAiKey(config);
|
50
|
+
|
51
|
+
let customDeeplinkData = this.config.channels.filter(
|
52
|
+
c => c.hasOwnProperty('additionalProperties') && c.additionalProperties.hasOwnProperty('customDeeplinkValue')
|
53
|
+
).filter(
|
54
|
+
c => c.channel === 'whatsapp' || c.channel === 'whatsappb'
|
55
|
+
).filter(
|
56
|
+
c => c.enabled
|
57
|
+
).map(
|
58
|
+
({additionalProperties, channel, channelId}) => {
|
59
|
+
return {
|
60
|
+
channel: channel,
|
61
|
+
channelId: channelId,
|
62
|
+
customDeeplinkValue: additionalProperties.customDeeplinkValue
|
63
|
+
};
|
64
|
+
}
|
65
|
+
);
|
66
|
+
|
67
|
+
let deeplinkData = {
|
68
|
+
accountId: this.config.accountId,
|
69
|
+
insecureContext: this.insecureContext,
|
70
|
+
widgetId: this.config.id,
|
71
|
+
secureContextToken: this.secureContextToken,
|
72
|
+
user: {
|
73
|
+
id: this.widgetUserId
|
74
|
+
}
|
75
|
+
};
|
76
|
+
|
77
|
+
if(customDeeplinkData.length > 0) {
|
78
|
+
deeplinkData.customDeeplinkValue = customDeeplinkData;
|
79
|
+
}
|
80
|
+
|
81
|
+
return Promise.all([
|
82
|
+
loadDeepLink(
|
83
|
+
this.initialConfig.apiPath,
|
84
|
+
deeplinkData
|
85
|
+
),
|
86
|
+
appInsights.init(this.aiKey, this.widgetUserId, this.config.accountId)
|
87
|
+
]);
|
88
|
+
}).then(([deeplink, ai]) => {
|
89
|
+
this.deeplink = `subscribe_${deeplink.$value.id}`;
|
90
|
+
this.channels = this.config.channels.map(channel => channelsFactory.create(channel, this.deeplink, this))
|
91
|
+
.filter(channel => !!channel);
|
92
|
+
|
93
|
+
const channelInitPromises = this.channels.filter(
|
94
|
+
channel => !!channel.initPromise
|
95
|
+
).map(
|
96
|
+
channel => channel.initPromise
|
97
|
+
);
|
98
|
+
|
99
|
+
return Promise.all(channelInitPromises);
|
100
|
+
}).then(channelPromises => {
|
101
|
+
return this;
|
102
|
+
}, err => {
|
103
|
+
appInsights.trackWidgetEvent(this.config.id, 'Widget.initialize.error', err);
|
104
|
+
return Promise.reject(err);
|
105
|
+
});
|
106
|
+
|
107
|
+
return this.initPromise;
|
108
|
+
}
|
109
|
+
|
110
|
+
initializeConfig() {
|
111
|
+
let promise;
|
112
|
+
if (!this.initialConfig.overrideConfig) {
|
113
|
+
promise = loadConfig(this.initialConfig.widgetId, this.initialConfig.apiPath);
|
114
|
+
} else {
|
115
|
+
promise = Promise.resolve({ $value: this.initialConfig.overrideConfig });
|
116
|
+
}
|
117
|
+
|
118
|
+
return promise;
|
119
|
+
}
|
120
|
+
|
121
|
+
subscribe(channelCode) {
|
122
|
+
const channel = find(this.getEnabledChannels(), chan => chan.channel === channelCode);
|
123
|
+
if (channel) {
|
124
|
+
channel.subscribe();
|
125
|
+
}
|
126
|
+
}
|
127
|
+
|
128
|
+
getChannels() {
|
129
|
+
return this.channels;
|
130
|
+
}
|
131
|
+
|
132
|
+
getEnabledChannels() {
|
133
|
+
return this.channels.filter(channel => channel.enabled && !channel.hasError);
|
134
|
+
}
|
135
|
+
|
136
|
+
runWahunter(phoneNumber) {
|
137
|
+
return fetch(`${this.initialConfig.apiPath}/wahunter`, {
|
138
|
+
method: 'POST',
|
139
|
+
headers: {
|
140
|
+
'Content-Type': 'application/json;charset=utf-8'
|
141
|
+
},
|
142
|
+
body: JSON.stringify({
|
143
|
+
notificationWidgetId: this.initialConfig.widgetId,
|
144
|
+
phone: phoneNumber,
|
145
|
+
insecureContext: this.insecureContext,
|
146
|
+
deeplinkId: this.deeplink,
|
147
|
+
}),
|
148
|
+
}).then((resp) => {
|
149
|
+
if (resp.ok) {
|
150
|
+
cookies.setCookie(`${constants.COOKIE_NAME_PREFIX + this.id}_wahunter_was_run`, true, this.config.showWidgetSetting.showSessionLength * 60);
|
151
|
+
} else {
|
152
|
+
return Promise.reject(resp);
|
153
|
+
}
|
154
|
+
})
|
155
|
+
}
|
156
|
+
|
157
|
+
static getWidgetUserId() {
|
158
|
+
let widgetUserId = cookies.getCookie(constants.COOKIE_WIDGET_USER_ID);
|
159
|
+
if (widgetUserId === null) {
|
160
|
+
let uuid = UUID.create(4);
|
161
|
+
widgetUserId = uuid.hex;
|
162
|
+
cookies.setCookie(constants.COOKIE_WIDGET_USER_ID, widgetUserId, constants.WIDGET_USER_ID_COOKIE_TTL);
|
163
|
+
}
|
164
|
+
return widgetUserId;
|
165
|
+
}
|
166
|
+
|
167
|
+
static createInsecureContext(insecureContext = {}) {
|
168
|
+
const ctx = assign({}, insecureContext);//Object.assign({}, insecureContext);
|
169
|
+
ctx.pageTitle = window.document.title;
|
170
|
+
ctx.pageUrl = window.location.protocol + '//' + window.location.host + window.location.pathname;
|
171
|
+
ctx.params = parseQueryString(window.location.search.substring(1));
|
172
|
+
ctx.timezoneOffset = new Date().getTimezoneOffset();
|
173
|
+
ctx.cookies = cookies.getCookieObject();
|
174
|
+
|
175
|
+
const roistatVisitCookie = cookies.getCookie("roistat_visit");
|
176
|
+
|
177
|
+
if (roistatVisitCookie) {
|
178
|
+
ctx.roistatVisit = roistatVisitCookie;
|
179
|
+
}
|
180
|
+
|
181
|
+
return ctx;
|
182
|
+
}
|
183
|
+
|
184
|
+
static getAiKey(config) {
|
185
|
+
let aiKey = undefined;
|
186
|
+
try {
|
187
|
+
aiKey = config.headers.get('X-TB-AIKEY');
|
188
|
+
} catch (e) { }
|
189
|
+
|
190
|
+
return aiKey;
|
191
|
+
}
|
192
|
+
}
|
@@ -1,35 +1,35 @@
|
|
1
|
-
import Component from '../index.js';
|
2
|
-
import appInsights from '../../../sdk/utils/appInsights.js';
|
3
|
-
import find from '../../../sdk/utils/find.js';
|
4
|
-
import './styles.scss';
|
5
|
-
|
6
|
-
export default class Button extends Component {
|
7
|
-
constructor() {
|
8
|
-
super(...arguments);
|
9
|
-
|
10
|
-
this.element.setAttribute('channel', this.channel);
|
11
|
-
|
12
|
-
this.channelAPI = find(this.widgetAPI.getEnabledChannels(), channel => {
|
13
|
-
return channel.id === this.config.id && channel.channel === this.config.channel && channel.channelId === this.config.channelId;
|
14
|
-
});
|
15
|
-
}
|
16
|
-
|
17
|
-
render() {
|
18
|
-
let self = this;
|
19
|
-
super.render();
|
20
|
-
this.element.addEventListener('click', () => {
|
21
|
-
appInsights.trackButtonClick(this.widgetId, 'notificationWidget.button.click', this.channel)
|
22
|
-
});
|
23
|
-
}
|
24
|
-
|
25
|
-
get defaults() {
|
26
|
-
return {
|
27
|
-
config: JSON.parse(this.element.getAttribute('config')) || {},
|
28
|
-
channel: this.element.getAttribute('channel')
|
29
|
-
}
|
30
|
-
}
|
31
|
-
|
32
|
-
static get tagName() {
|
33
|
-
return 'tb-notification-button';
|
34
|
-
}
|
1
|
+
import Component from '../index.js';
|
2
|
+
import appInsights from '../../../sdk/utils/appInsights.js';
|
3
|
+
import find from '../../../sdk/utils/find.js';
|
4
|
+
import './styles.scss';
|
5
|
+
|
6
|
+
export default class Button extends Component {
|
7
|
+
constructor() {
|
8
|
+
super(...arguments);
|
9
|
+
|
10
|
+
this.element.setAttribute('channel', this.channel);
|
11
|
+
|
12
|
+
this.channelAPI = find(this.widgetAPI.getEnabledChannels(), channel => {
|
13
|
+
return channel.id === this.config.id && channel.channel === this.config.channel && channel.channelId === this.config.channelId;
|
14
|
+
});
|
15
|
+
}
|
16
|
+
|
17
|
+
render() {
|
18
|
+
let self = this;
|
19
|
+
super.render();
|
20
|
+
this.element.addEventListener('click', () => {
|
21
|
+
appInsights.trackButtonClick(this.widgetId, 'notificationWidget.button.click', this.channel)
|
22
|
+
});
|
23
|
+
}
|
24
|
+
|
25
|
+
get defaults() {
|
26
|
+
return {
|
27
|
+
config: JSON.parse(this.element.getAttribute('config')) || {},
|
28
|
+
channel: this.element.getAttribute('channel')
|
29
|
+
}
|
30
|
+
}
|
31
|
+
|
32
|
+
static get tagName() {
|
33
|
+
return 'tb-notification-button';
|
34
|
+
}
|
35
35
|
};
|