@webiny/telemetry 5.15.0-beta.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/CHANGELOG.md +231 -0
- package/LICENSE +21 -0
- package/README.md +1 -0
- package/cli.js +36 -0
- package/package.json +15 -0
- package/react.js +31 -0
- package/sendEvent.js +59 -0
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,231 @@
|
|
|
1
|
+
# Change Log
|
|
2
|
+
|
|
3
|
+
All notable changes to this project will be documented in this file.
|
|
4
|
+
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
5
|
+
|
|
6
|
+
# [5.15.0-beta.0](https://github.com/webiny/webiny-js/compare/v5.14.0...v5.15.0-beta.0) (2021-09-16)
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
### Bug Fixes
|
|
10
|
+
|
|
11
|
+
* add comment ([61dafeb](https://github.com/webiny/webiny-js/commit/61dafeb08883b1c80033d3164581f56138fee675))
|
|
12
|
+
* correct args passing in `setProperties` function ([2ac0fed](https://github.com/webiny/webiny-js/commit/2ac0fedb8bf760b15686de44523138816e708c36))
|
|
13
|
+
* correct if statements ([1dcdd73](https://github.com/webiny/webiny-js/commit/1dcdd735d89f1918952481a6ae510a60cf113b7f))
|
|
14
|
+
* create utils ([6a24dcf](https://github.com/webiny/webiny-js/commit/6a24dcfb02130a672c1e90794910f8a0549f659d))
|
|
15
|
+
* remove old api folder ([5dce8e2](https://github.com/webiny/webiny-js/commit/5dce8e2c7871fd1e24326e73e3a9459208ce7f75))
|
|
16
|
+
* rename to `extraPayload` ([b5bcda8](https://github.com/webiny/webiny-js/commit/b5bcda88029c003d0c5704a37bff4771b9056d5e))
|
|
17
|
+
* update dependencies ([37f2691](https://github.com/webiny/webiny-js/commit/37f2691f3cb615615a089d977f58a22a8bb21f50))
|
|
18
|
+
* use base `sendEvent` function ([6f93072](https://github.com/webiny/webiny-js/commit/6f9307212e05b98f2a4866002258238b216e0b3b))
|
|
19
|
+
* use built-in isEnabled ([4051257](https://github.com/webiny/webiny-js/commit/4051257c58165dbcc9805283d183583ed0bf7d15))
|
|
20
|
+
* use global-config package ([a678b18](https://github.com/webiny/webiny-js/commit/a678b18d9d760a69eb6badaaf6451acd3c7fb953))
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
### Features
|
|
24
|
+
|
|
25
|
+
* add telemetry getter ([b1a5e8d](https://github.com/webiny/webiny-js/commit/b1a5e8df96b1591266fbd8df90d6689a526da0f3))
|
|
26
|
+
* add utils ([d9be82a](https://github.com/webiny/webiny-js/commit/d9be82a76f5210704c71cd8e191aca698cb0963c))
|
|
27
|
+
* create `sendEvent` function for CLI environment ([d0babff](https://github.com/webiny/webiny-js/commit/d0babffeb1cb3a7a796caa8a25f3f9a2ba9359d7))
|
|
28
|
+
* create base `sendEvent` function ([a764e85](https://github.com/webiny/webiny-js/commit/a764e854c5da0ebcb99038e9b9aaf3184202edc3))
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
# [5.14.0](https://github.com/webiny/webiny-js/compare/v5.14.0-beta.0...v5.14.0) (2021-08-30)
|
|
35
|
+
|
|
36
|
+
**Note:** Version bump only for package @webiny/telemetry
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
|
|
41
|
+
|
|
42
|
+
# [5.14.0-beta.0](https://github.com/webiny/webiny-js/compare/v5.13.0...v5.14.0-beta.0) (2021-08-26)
|
|
43
|
+
|
|
44
|
+
**Note:** Version bump only for package @webiny/telemetry
|
|
45
|
+
|
|
46
|
+
|
|
47
|
+
|
|
48
|
+
|
|
49
|
+
|
|
50
|
+
# [5.13.0](https://github.com/webiny/webiny-js/compare/v5.13.0-beta.4...v5.13.0) (2021-08-18)
|
|
51
|
+
|
|
52
|
+
**Note:** Version bump only for package @webiny/telemetry
|
|
53
|
+
|
|
54
|
+
|
|
55
|
+
|
|
56
|
+
|
|
57
|
+
|
|
58
|
+
# [5.13.0-beta.4](https://github.com/webiny/webiny-js/compare/v5.13.0-beta.3...v5.13.0-beta.4) (2021-08-18)
|
|
59
|
+
|
|
60
|
+
**Note:** Version bump only for package @webiny/telemetry
|
|
61
|
+
|
|
62
|
+
|
|
63
|
+
|
|
64
|
+
|
|
65
|
+
|
|
66
|
+
# [5.13.0-beta.3](https://github.com/webiny/webiny-js/compare/v5.13.0-beta.2...v5.13.0-beta.3) (2021-08-17)
|
|
67
|
+
|
|
68
|
+
**Note:** Version bump only for package @webiny/telemetry
|
|
69
|
+
|
|
70
|
+
|
|
71
|
+
|
|
72
|
+
|
|
73
|
+
|
|
74
|
+
# [5.13.0-beta.2](https://github.com/webiny/webiny-js/compare/v5.13.0-beta.1...v5.13.0-beta.2) (2021-08-17)
|
|
75
|
+
|
|
76
|
+
**Note:** Version bump only for package @webiny/telemetry
|
|
77
|
+
|
|
78
|
+
|
|
79
|
+
|
|
80
|
+
|
|
81
|
+
|
|
82
|
+
# [5.13.0-beta.1](https://github.com/webiny/webiny-js/compare/v5.13.0-beta.0...v5.13.0-beta.1) (2021-08-16)
|
|
83
|
+
|
|
84
|
+
**Note:** Version bump only for package @webiny/telemetry
|
|
85
|
+
|
|
86
|
+
|
|
87
|
+
|
|
88
|
+
|
|
89
|
+
|
|
90
|
+
# [5.13.0-beta.0](https://github.com/webiny/webiny-js/compare/v5.12.0...v5.13.0-beta.0) (2021-08-16)
|
|
91
|
+
|
|
92
|
+
**Note:** Version bump only for package @webiny/telemetry
|
|
93
|
+
|
|
94
|
+
|
|
95
|
+
|
|
96
|
+
|
|
97
|
+
|
|
98
|
+
# [5.12.0](https://github.com/webiny/webiny-js/compare/v5.12.0-beta.1...v5.12.0) (2021-08-05)
|
|
99
|
+
|
|
100
|
+
**Note:** Version bump only for package @webiny/telemetry
|
|
101
|
+
|
|
102
|
+
|
|
103
|
+
|
|
104
|
+
|
|
105
|
+
|
|
106
|
+
# [5.12.0-beta.1](https://github.com/webiny/webiny-js/compare/v5.12.0-beta.0...v5.12.0-beta.1) (2021-08-05)
|
|
107
|
+
|
|
108
|
+
**Note:** Version bump only for package @webiny/telemetry
|
|
109
|
+
|
|
110
|
+
|
|
111
|
+
|
|
112
|
+
|
|
113
|
+
|
|
114
|
+
# [5.12.0-beta.0](https://github.com/webiny/webiny-js/compare/v5.11.1...v5.12.0-beta.0) (2021-08-04)
|
|
115
|
+
|
|
116
|
+
**Note:** Version bump only for package @webiny/telemetry
|
|
117
|
+
|
|
118
|
+
|
|
119
|
+
|
|
120
|
+
|
|
121
|
+
|
|
122
|
+
## [5.11.1](https://github.com/webiny/webiny-js/compare/v5.11.1-beta.0...v5.11.1) (2021-07-31)
|
|
123
|
+
|
|
124
|
+
**Note:** Version bump only for package @webiny/telemetry
|
|
125
|
+
|
|
126
|
+
|
|
127
|
+
|
|
128
|
+
|
|
129
|
+
|
|
130
|
+
## [5.11.1-beta.0](https://github.com/webiny/webiny-js/compare/v5.11.0...v5.11.1-beta.0) (2021-07-31)
|
|
131
|
+
|
|
132
|
+
**Note:** Version bump only for package @webiny/telemetry
|
|
133
|
+
|
|
134
|
+
|
|
135
|
+
|
|
136
|
+
|
|
137
|
+
|
|
138
|
+
# [5.11.0](https://github.com/webiny/webiny-js/compare/v5.11.0-beta.2...v5.11.0) (2021-07-22)
|
|
139
|
+
|
|
140
|
+
**Note:** Version bump only for package @webiny/telemetry
|
|
141
|
+
|
|
142
|
+
|
|
143
|
+
|
|
144
|
+
|
|
145
|
+
|
|
146
|
+
# [5.11.0-beta.2](https://github.com/webiny/webiny-js/compare/v5.11.0-beta.1...v5.11.0-beta.2) (2021-07-21)
|
|
147
|
+
|
|
148
|
+
**Note:** Version bump only for package @webiny/telemetry
|
|
149
|
+
|
|
150
|
+
|
|
151
|
+
|
|
152
|
+
|
|
153
|
+
|
|
154
|
+
# [5.11.0-beta.1](https://github.com/webiny/webiny-js/compare/v5.11.0-beta.0...v5.11.0-beta.1) (2021-07-21)
|
|
155
|
+
|
|
156
|
+
**Note:** Version bump only for package @webiny/telemetry
|
|
157
|
+
|
|
158
|
+
|
|
159
|
+
|
|
160
|
+
|
|
161
|
+
|
|
162
|
+
# [5.11.0-beta.0](https://github.com/webiny/webiny-js/compare/v5.10.0...v5.11.0-beta.0) (2021-07-21)
|
|
163
|
+
|
|
164
|
+
**Note:** Version bump only for package @webiny/telemetry
|
|
165
|
+
|
|
166
|
+
|
|
167
|
+
|
|
168
|
+
|
|
169
|
+
|
|
170
|
+
# [5.10.0](https://github.com/webiny/webiny-js/compare/v5.10.0-beta.2...v5.10.0) (2021-07-06)
|
|
171
|
+
|
|
172
|
+
**Note:** Version bump only for package @webiny/telemetry
|
|
173
|
+
|
|
174
|
+
|
|
175
|
+
|
|
176
|
+
|
|
177
|
+
|
|
178
|
+
# [5.10.0-beta.2](https://github.com/webiny/webiny-js/compare/v5.10.0-beta.1...v5.10.0-beta.2) (2021-07-06)
|
|
179
|
+
|
|
180
|
+
**Note:** Version bump only for package @webiny/telemetry
|
|
181
|
+
|
|
182
|
+
|
|
183
|
+
|
|
184
|
+
|
|
185
|
+
|
|
186
|
+
# [5.10.0-beta.1](https://github.com/webiny/webiny-js/compare/v5.10.0-beta.0...v5.10.0-beta.1) (2021-07-06)
|
|
187
|
+
|
|
188
|
+
**Note:** Version bump only for package @webiny/telemetry
|
|
189
|
+
|
|
190
|
+
|
|
191
|
+
|
|
192
|
+
|
|
193
|
+
|
|
194
|
+
# [5.10.0-beta.0](https://github.com/webiny/webiny-js/compare/v5.9.0...v5.10.0-beta.0) (2021-07-02)
|
|
195
|
+
|
|
196
|
+
**Note:** Version bump only for package @webiny/telemetry
|
|
197
|
+
|
|
198
|
+
|
|
199
|
+
|
|
200
|
+
|
|
201
|
+
|
|
202
|
+
# [5.9.0](https://github.com/webiny/webiny-js/compare/v5.9.0-beta.2...v5.9.0) (2021-06-21)
|
|
203
|
+
|
|
204
|
+
**Note:** Version bump only for package @webiny/telemetry
|
|
205
|
+
|
|
206
|
+
|
|
207
|
+
|
|
208
|
+
|
|
209
|
+
|
|
210
|
+
# [5.9.0-beta.2](https://github.com/webiny/webiny-js/compare/v5.9.0-beta.1...v5.9.0-beta.2) (2021-06-20)
|
|
211
|
+
|
|
212
|
+
**Note:** Version bump only for package @webiny/telemetry
|
|
213
|
+
|
|
214
|
+
|
|
215
|
+
|
|
216
|
+
|
|
217
|
+
|
|
218
|
+
# [5.9.0-beta.1](https://github.com/webiny/webiny-js/compare/v5.9.0-beta.0...v5.9.0-beta.1) (2021-06-20)
|
|
219
|
+
|
|
220
|
+
**Note:** Version bump only for package @webiny/telemetry
|
|
221
|
+
|
|
222
|
+
|
|
223
|
+
|
|
224
|
+
|
|
225
|
+
|
|
226
|
+
# [5.9.0-beta.0](https://github.com/webiny/webiny-js/compare/v5.8.0...v5.9.0-beta.0) (2021-06-18)
|
|
227
|
+
|
|
228
|
+
|
|
229
|
+
### Bug Fixes
|
|
230
|
+
|
|
231
|
+
* **telemetry:** rename package and upgrade configs and env vars loading ([4791937](https://github.com/webiny/webiny-js/commit/4791937de3ec1431c82fca1dc2e91da9c7ac49d3))
|
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) Webiny
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
# @webiny/telemetry
|
package/cli.js
ADDED
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
const baseSendEvent = require("./sendEvent");
|
|
2
|
+
const { globalConfig } = require("@webiny/global-config");
|
|
3
|
+
|
|
4
|
+
const sendEvent = ({ event, user, version, properties, extraPayload }) => {
|
|
5
|
+
if (!isEnabled()) {
|
|
6
|
+
return;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
return baseSendEvent({
|
|
10
|
+
event,
|
|
11
|
+
user: user || globalConfig.get("id"),
|
|
12
|
+
version: version || require("./package.json").version,
|
|
13
|
+
properties,
|
|
14
|
+
extraPayload
|
|
15
|
+
});
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
const enable = () => {
|
|
19
|
+
globalConfig.set("telemetry", true);
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
const disable = () => {
|
|
23
|
+
globalConfig.set("telemetry", false);
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
const isEnabled = () => {
|
|
27
|
+
const config = globalConfig.get();
|
|
28
|
+
|
|
29
|
+
if (config.telemetry === false) {
|
|
30
|
+
return false;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
return config.tracking !== false;
|
|
34
|
+
};
|
|
35
|
+
|
|
36
|
+
module.exports = { sendEvent, enable, disable, isEnabled };
|
package/package.json
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@webiny/telemetry",
|
|
3
|
+
"version": "5.15.0-beta.0",
|
|
4
|
+
"license": "MIT",
|
|
5
|
+
"dependencies": {
|
|
6
|
+
"@webiny/global-config": "5.15.0-beta.0",
|
|
7
|
+
"form-data": "3.0.0",
|
|
8
|
+
"node-fetch": "2.6.1"
|
|
9
|
+
},
|
|
10
|
+
"publishConfig": {
|
|
11
|
+
"access": "public",
|
|
12
|
+
"directory": "."
|
|
13
|
+
},
|
|
14
|
+
"gitHead": "baf2dbb8cae1b623b59d20fedc0cd0e11a310ca1"
|
|
15
|
+
}
|
package/react.js
ADDED
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
const baseSendEvent = require("./sendEvent");
|
|
2
|
+
|
|
3
|
+
const setProperties = data => {
|
|
4
|
+
return sendEvent("$identify", data);
|
|
5
|
+
};
|
|
6
|
+
|
|
7
|
+
const sendEvent = (event, data = {}) => {
|
|
8
|
+
if (process.env.REACT_APP_WEBINY_TELEMETRY === "false") {
|
|
9
|
+
return;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
let properties = {};
|
|
13
|
+
let extraPayload = {};
|
|
14
|
+
if (event !== "$identify") {
|
|
15
|
+
properties = data;
|
|
16
|
+
} else {
|
|
17
|
+
extraPayload = {
|
|
18
|
+
$set: data
|
|
19
|
+
};
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
return baseSendEvent({
|
|
23
|
+
event,
|
|
24
|
+
properties,
|
|
25
|
+
extraPayload,
|
|
26
|
+
user: process.env.REACT_APP_USER_ID,
|
|
27
|
+
version: process.env.REACT_APP_WEBINY_VERSION
|
|
28
|
+
});
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
module.exports = { setProperties, sendEvent };
|
package/sendEvent.js
ADDED
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
const FormData = require("form-data");
|
|
2
|
+
const fetch = require("node-fetch");
|
|
3
|
+
|
|
4
|
+
const API_KEY = "ZdDZgkeOt4Z_m-UWmqFsE1d6-kcCK3BH0ypYTUIFty4";
|
|
5
|
+
const API_URL = "https://t.webiny.com";
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* The main `sendEvent` function.
|
|
9
|
+
* Note: it's recommended the one from `cli.js` and `react.js` files is used instead.
|
|
10
|
+
* @param event
|
|
11
|
+
* @param user
|
|
12
|
+
* @param version
|
|
13
|
+
* @param properties
|
|
14
|
+
* @param extraPayload
|
|
15
|
+
* @returns {Promise<T>}
|
|
16
|
+
*/
|
|
17
|
+
module.exports = async ({ event, user, version, properties, extraPayload } = {}) => {
|
|
18
|
+
if (!event) {
|
|
19
|
+
throw new Error(`Cannot send event - missing "event" name.`);
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
if (!user) {
|
|
23
|
+
throw new Error(`Cannot send event - missing "user" property.`);
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
if (!version) {
|
|
27
|
+
throw new Error(`Cannot send event - missing "version" property.`);
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
if (!properties) {
|
|
31
|
+
properties = {};
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
if (!extraPayload) {
|
|
35
|
+
extraPayload = {};
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
const payload = {
|
|
39
|
+
...extraPayload,
|
|
40
|
+
event,
|
|
41
|
+
properties: {
|
|
42
|
+
...properties,
|
|
43
|
+
version
|
|
44
|
+
},
|
|
45
|
+
distinct_id: user,
|
|
46
|
+
api_key: API_KEY,
|
|
47
|
+
timestamp: new Date().toISOString()
|
|
48
|
+
};
|
|
49
|
+
|
|
50
|
+
const body = new FormData();
|
|
51
|
+
body.append("data", Buffer.from(JSON.stringify(payload)).toString("base64"));
|
|
52
|
+
|
|
53
|
+
return fetch(API_URL + "/capture/", {
|
|
54
|
+
body,
|
|
55
|
+
method: "POST"
|
|
56
|
+
}).catch(() => {
|
|
57
|
+
// Ignore errors
|
|
58
|
+
});
|
|
59
|
+
};
|