@textback/notification-widget 2.0.0 → 2.0.1-102913
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/build/index.js +12 -0
- package/build/sdk.js +9 -0
- package/package.json +70 -68
- package/promote_tag.sh +1 -1
- package/readme.md +569 -490
- package/server.js +8 -4
- package/src/libraries/ai.1.0.11.js +4088 -4088
- package/src/libraries/localization/locales/cs.js +14 -12
- package/src/libraries/localization/locales/en.js +14 -12
- package/src/libraries/localization/locales/index.js +8 -8
- package/src/libraries/localization/locales/pl.js +14 -12
- package/src/libraries/localization/locales/ro.js +14 -12
- package/src/libraries/localization/locales/ru.js +13 -12
- package/src/libraries/localization/locales/uk.js +14 -12
- 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/factory.js +3 -3
- 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 -184
- package/src/sdk/channels/whatsapp.js +16 -10
- package/src/sdk/channels/whatsappb.js +27 -0
- package/src/sdk/events/observer.js +46 -46
- package/src/sdk/index.js +5 -5
- package/src/sdk/sdk.js +67 -30
- 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 -50
- package/src/sdk/utils/find.js +7 -7
- package/src/sdk/utils/loadConfig.js +20 -20
- package/src/sdk/utils/loadDeepLink.js +48 -21
- 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 -140
- package/src/widget/components/index.js +6 -2
- package/src/widget/components/tb-notification-button/facebook.js +9 -2
- package/src/widget/components/tb-notification-button/index.js +34 -34
- package/src/widget/components/tb-notification-button/styles.scss +657 -433
- package/src/widget/components/tb-notification-button/telegram.js +9 -2
- package/src/widget/components/tb-notification-button/viber.js +9 -2
- package/src/widget/components/tb-notification-button/vk.js +59 -50
- package/src/widget/components/tb-notification-button/whatsapp.js +15 -8
- package/src/widget/components/tb-notification-button/whatsappb.js +58 -0
- package/src/widget/components/tb-notification-widget/index.js +589 -384
- package/src/widget/components/tb-notification-widget/normalize.scss +395 -394
- package/src/widget/components/tb-notification-widget/styles.scss +502 -139
- package/src/widget/components/tb-nw-wahunter/index.js +259 -0
- package/src/widget/components/tb-nw-wahunter/styles.scss +471 -0
- package/src/widget/config.js +5 -5
- package/src/widget/icons/icon_chat_window.svg +1 -0
- package/src/widget/icons/icon_close.svg +1 -0
- package/src/widget/icons/icon_facebook.svg +7 -7
- package/src/widget/icons/icon_facebook_circle.svg +7 -9
- 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 -27
- package/src/widget/icons/icon_viber.svg +75 -75
- package/src/widget/icons/icon_viber_circle.svg +67 -77
- 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_hollow.svg +128 -0
- package/src/widget/icons/icon_whatsapp_new.svg +127 -127
- package/src/widget/icons/icon_whatsappb.svg +147 -0
- package/src/widget/icons/icon_whatsappb_circle.svg +4 -0
- package/src/widget/icons/icon_whatsappb_new.svg +127 -0
- package/src/widget/icons/paper-plane-arrow.svg +3 -0
- package/src/widget/icons/tb-logo.svg +21 -0
- package/src/widget/index.js +28 -28
- package/src/widget/locales/cs.js +42 -0
- package/src/widget/locales/en.js +42 -20
- package/src/widget/locales/index.js +2 -2
- package/src/widget/locales/pl.js +41 -19
- package/src/widget/locales/ro.js +41 -20
- package/src/widget/locales/ru.js +40 -19
- package/src/widget/locales/uk.js +40 -19
- package/src/widget/utils/cookiesEx.js +41 -41
- package/src/widget/utils/getLocale.js +4 -2
- package/src/widget/utils/stringifyAttributes.js +19 -19
- package/src/widget/utils/text.js +2 -1
- package/src/widget/utils/widgetsStorage.js +28 -28
- package/src/widget/widget.entry.js +3 -4
- package/tests/gf.html +35 -35
- package/tests/gf.js +21 -21
- package/tests/index.js +61 -61
- package/views/examples.ejs +7 -3
- package/views/sdk.html +274 -256
- package/webpack.common.js +72 -72
- package/webpack.dev.js +15 -15
- package/webpack.prod.js +10 -10
- package/src/widget/components/tb-notification-button/skype.js +0 -47
- package/src/widget/icons/text-back-badge.png +0 -0
- package/src/widget/locales/cz.js +0 -20
@@ -1,25 +1,25 @@
|
|
1
|
-
'use strict';
|
2
|
-
|
3
|
-
export default class WindowHelper {
|
4
|
-
constructior() {}
|
5
|
-
|
6
|
-
static get center() {
|
7
|
-
return {
|
8
|
-
x: Math.floor(window.innerWidth * 0.5),
|
9
|
-
y: Math.floor(window.innerHeight * 0.5)
|
10
|
-
};
|
11
|
-
}
|
12
|
-
|
13
|
-
static getRatio(percent) {
|
14
|
-
let r = percent / 100;
|
15
|
-
return {
|
16
|
-
width: Math.floor(window.innerWidth * r),
|
17
|
-
height: Math.floor(window.innerHeight * r)
|
18
|
-
};
|
19
|
-
}
|
20
|
-
|
21
|
-
static getRatioPropString(percent) {
|
22
|
-
let ratioObj = this.getRatio(percent);
|
23
|
-
return `width=${ratioObj.width},height=${ratioObj.height}`;
|
24
|
-
}
|
25
|
-
}
|
1
|
+
'use strict';
|
2
|
+
|
3
|
+
export default class WindowHelper {
|
4
|
+
constructior() {}
|
5
|
+
|
6
|
+
static get center() {
|
7
|
+
return {
|
8
|
+
x: Math.floor(window.innerWidth * 0.5),
|
9
|
+
y: Math.floor(window.innerHeight * 0.5)
|
10
|
+
};
|
11
|
+
}
|
12
|
+
|
13
|
+
static getRatio(percent) {
|
14
|
+
let r = percent / 100;
|
15
|
+
return {
|
16
|
+
width: Math.floor(window.innerWidth * r),
|
17
|
+
height: Math.floor(window.innerHeight * r)
|
18
|
+
};
|
19
|
+
}
|
20
|
+
|
21
|
+
static getRatioPropString(percent) {
|
22
|
+
let ratioObj = this.getRatio(percent);
|
23
|
+
return `width=${ratioObj.width},height=${ratioObj.height}`;
|
24
|
+
}
|
25
|
+
}
|
package/src/sdk/widget/widget.js
CHANGED
@@ -1,140 +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
|
-
|
18
|
-
};
|
19
|
-
|
20
|
-
export default class Widget {
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
}
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
}
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
}
|
138
|
-
|
139
|
-
|
140
|
-
|
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
|
+
}
|
@@ -5,7 +5,9 @@ import getLocale from '../utils/getLocale.js';
|
|
5
5
|
|
6
6
|
export default class Component {
|
7
7
|
constructor(props = {}) {
|
8
|
-
|
8
|
+
|
9
|
+
if (Object.prototype.hasOwnProperty.call(props, 'parentElement')) this.element = props.parentElement;
|
10
|
+
if (!Object.prototype.hasOwnProperty.call(props, 'parentElement')) this.element = props.element || document.createElement(this.constructor.tagName);
|
9
11
|
|
10
12
|
const dataset = JSON.parse(JSON.stringify(this.element.dataset || {}));
|
11
13
|
const data = merge(JSON.parse(this.element.getAttribute('data')), dataset);
|
@@ -30,6 +32,8 @@ export default class Component {
|
|
30
32
|
}
|
31
33
|
|
32
34
|
set lang(value) {
|
35
|
+
if (!value) return;
|
36
|
+
|
33
37
|
this.element.setAttribute('lang', value);
|
34
38
|
}
|
35
39
|
|
@@ -45,4 +49,4 @@ export default class Component {
|
|
45
49
|
static get tagName() {
|
46
50
|
return 'div';
|
47
51
|
}
|
48
|
-
};
|
52
|
+
};
|
@@ -22,9 +22,16 @@ class FacebookButton extends Button {
|
|
22
22
|
<tb-notification-button__text>${this.text('facebook')}</tb-notification-button__text>
|
23
23
|
</a>
|
24
24
|
<p class="tb-notification-button__tip">
|
25
|
-
${this.text('
|
25
|
+
${this.text('facebookTip')}
|
26
26
|
</p>
|
27
27
|
`;
|
28
|
+
} else if(this.config.markUp.style === 'gradient') {
|
29
|
+
return `
|
30
|
+
<a target="_blank" href="https://m.me/${this.config.id}?ref=${this.deepLink}">
|
31
|
+
<tb-notification-button__icon>${icon}</tb-notification-button__icon>
|
32
|
+
<tb-notification-button__text>${this.text('facebook')}</tb-notification-button__text>
|
33
|
+
</a>
|
34
|
+
`;
|
28
35
|
} else if (this.config.markUp.style !== 'square') {
|
29
36
|
return `
|
30
37
|
<a target="_blank" href="https://m.me/${this.config.id}?ref=${this.deepLink}">
|
@@ -37,7 +44,7 @@ class FacebookButton extends Button {
|
|
37
44
|
<div class="tb-notification-button__inner">
|
38
45
|
<tb-notification-button__icon>${icon}</tb-notification-button__icon>
|
39
46
|
<a target="_blank" href="https://m.me/${this.config.id}?ref=${this.deepLink}">
|
40
|
-
<tb-notification-button__text>${this.text('
|
47
|
+
<tb-notification-button__text>${this.text('facebookExtended')}</tb-notification-button__text>
|
41
48
|
</a>
|
42
49
|
</div>
|
43
50
|
`;
|
@@ -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
|
};
|