wineater-bot 1.4.3 → 1.4.4
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/package.json +1 -1
- package/src/js/analytics.js +9 -2
package/package.json
CHANGED
package/src/js/analytics.js
CHANGED
|
@@ -15,6 +15,13 @@ function setCookie(name, value, days) {
|
|
|
15
15
|
const parts = value.split(`; ${name}=`);
|
|
16
16
|
if (parts.length === 2) return parts.pop().split(';').shift();
|
|
17
17
|
}
|
|
18
|
+
|
|
19
|
+
// Function to URL encode the data
|
|
20
|
+
function urlEncodeData(data) {
|
|
21
|
+
return Object.keys(data)
|
|
22
|
+
.map(key => encodeURIComponent(key) + '=' + encodeURIComponent(data[key]))
|
|
23
|
+
.join('&');
|
|
24
|
+
}
|
|
18
25
|
|
|
19
26
|
// Функция для отправки событий в Mixpanel
|
|
20
27
|
function trackEvent(event, properties) {
|
|
@@ -28,10 +35,10 @@ function setCookie(name, value, days) {
|
|
|
28
35
|
fetch(endpoint, {
|
|
29
36
|
method: 'POST',
|
|
30
37
|
headers: {
|
|
31
|
-
'Content-Type': 'application/
|
|
38
|
+
'Content-Type': 'application/x-www-form-urlencoded',
|
|
32
39
|
'Authentication': token
|
|
33
40
|
},
|
|
34
|
-
body:
|
|
41
|
+
body: urlEncodeData(data)
|
|
35
42
|
}).then(response => {
|
|
36
43
|
if (!response.ok) {
|
|
37
44
|
console.error('Mixpanel tracking failed', response);
|