@webiny/telemetry 0.0.0-mt-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/CHANGELOG.md ADDED
@@ -0,0 +1,466 @@
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.18.1](https://github.com/webiny/webiny-js/compare/v5.18.1-beta.0...v5.18.1) (2021-11-25)
7
+
8
+ **Note:** Version bump only for package @webiny/telemetry
9
+
10
+
11
+
12
+
13
+
14
+ ## [5.18.1-beta.0](https://github.com/webiny/webiny-js/compare/v5.18.0...v5.18.1-beta.0) (2021-11-25)
15
+
16
+ **Note:** Version bump only for package @webiny/telemetry
17
+
18
+
19
+
20
+
21
+
22
+ # [5.18.0](https://github.com/webiny/webiny-js/compare/v5.18.0-beta.4...v5.18.0) (2021-11-24)
23
+
24
+ **Note:** Version bump only for package @webiny/telemetry
25
+
26
+
27
+
28
+
29
+
30
+ # [5.18.0-beta.4](https://github.com/webiny/webiny-js/compare/v5.18.0-beta.3...v5.18.0-beta.4) (2021-11-23)
31
+
32
+ **Note:** Version bump only for package @webiny/telemetry
33
+
34
+
35
+
36
+
37
+
38
+ # [5.18.0-beta.3](https://github.com/webiny/webiny-js/compare/v5.18.0-beta.2...v5.18.0-beta.3) (2021-11-22)
39
+
40
+ **Note:** Version bump only for package @webiny/telemetry
41
+
42
+
43
+
44
+
45
+
46
+ # [5.18.0-beta.2](https://github.com/webiny/webiny-js/compare/v5.18.0-beta.1...v5.18.0-beta.2) (2021-11-21)
47
+
48
+ **Note:** Version bump only for package @webiny/telemetry
49
+
50
+
51
+
52
+
53
+
54
+ # [5.18.0-beta.1](https://github.com/webiny/webiny-js/compare/v5.18.0-beta.0...v5.18.0-beta.1) (2021-11-19)
55
+
56
+ **Note:** Version bump only for package @webiny/telemetry
57
+
58
+
59
+
60
+
61
+
62
+ # [5.18.0-beta.0](https://github.com/webiny/webiny-js/compare/v5.17.4...v5.18.0-beta.0) (2021-11-19)
63
+
64
+ **Note:** Version bump only for package @webiny/telemetry
65
+
66
+
67
+
68
+
69
+
70
+ ## [5.17.4](https://github.com/webiny/webiny-js/compare/v5.17.4-beta.1...v5.17.4) (2021-11-19)
71
+
72
+ **Note:** Version bump only for package @webiny/telemetry
73
+
74
+
75
+
76
+
77
+
78
+ ## [5.17.4-beta.1](https://github.com/webiny/webiny-js/compare/v5.17.4-beta.0...v5.17.4-beta.1) (2021-11-19)
79
+
80
+ **Note:** Version bump only for package @webiny/telemetry
81
+
82
+
83
+
84
+
85
+
86
+ ## [5.17.4-beta.0](https://github.com/webiny/webiny-js/compare/v5.17.3...v5.17.4-beta.0) (2021-11-19)
87
+
88
+ **Note:** Version bump only for package @webiny/telemetry
89
+
90
+
91
+
92
+
93
+
94
+ ## [5.17.3](https://github.com/webiny/webiny-js/compare/v5.17.3-beta.0...v5.17.3) (2021-11-15)
95
+
96
+ **Note:** Version bump only for package @webiny/telemetry
97
+
98
+
99
+
100
+
101
+
102
+ ## [5.17.3-beta.0](https://github.com/webiny/webiny-js/compare/v5.17.2...v5.17.3-beta.0) (2021-11-12)
103
+
104
+ **Note:** Version bump only for package @webiny/telemetry
105
+
106
+
107
+
108
+
109
+
110
+ ## [5.17.2](https://github.com/webiny/webiny-js/compare/v5.17.2-beta.0...v5.17.2) (2021-11-11)
111
+
112
+ **Note:** Version bump only for package @webiny/telemetry
113
+
114
+
115
+
116
+
117
+
118
+ ## [5.17.2-beta.0](https://github.com/webiny/webiny-js/compare/v5.17.1...v5.17.2-beta.0) (2021-11-11)
119
+
120
+
121
+ ### Bug Fixes
122
+
123
+ * force same version on all packages ([9cbae8b](https://github.com/webiny/webiny-js/commit/9cbae8b050900546eb17932c23a609593211c1c8))
124
+
125
+
126
+
127
+
128
+
129
+ # [5.17.0](https://github.com/webiny/webiny-js/compare/v5.17.0-beta.2...v5.17.0) (2021-11-08)
130
+
131
+ **Note:** Version bump only for package @webiny/telemetry
132
+
133
+
134
+
135
+
136
+
137
+ # [5.17.0-beta.2](https://github.com/webiny/webiny-js/compare/v5.17.0-beta.1...v5.17.0-beta.2) (2021-11-08)
138
+
139
+ **Note:** Version bump only for package @webiny/telemetry
140
+
141
+
142
+
143
+
144
+
145
+ # [5.17.0-beta.1](https://github.com/webiny/webiny-js/compare/v5.16.0...v5.17.0-beta.1) (2021-11-08)
146
+
147
+ **Note:** Version bump only for package @webiny/telemetry
148
+
149
+
150
+
151
+
152
+
153
+ # [5.16.0](https://github.com/webiny/webiny-js/compare/v5.16.0-beta.4...v5.16.0) (2021-10-21)
154
+
155
+ **Note:** Version bump only for package @webiny/telemetry
156
+
157
+
158
+
159
+
160
+
161
+ # [5.16.0-beta.4](https://github.com/webiny/webiny-js/compare/v5.16.0-beta.3...v5.16.0-beta.4) (2021-10-20)
162
+
163
+ **Note:** Version bump only for package @webiny/telemetry
164
+
165
+
166
+
167
+
168
+
169
+ # [5.16.0-beta.3](https://github.com/webiny/webiny-js/compare/v5.16.0-beta.2...v5.16.0-beta.3) (2021-10-20)
170
+
171
+ **Note:** Version bump only for package @webiny/telemetry
172
+
173
+
174
+
175
+
176
+
177
+ # [5.16.0-beta.2](https://github.com/webiny/webiny-js/compare/v5.16.0-beta.1...v5.16.0-beta.2) (2021-10-20)
178
+
179
+ **Note:** Version bump only for package @webiny/telemetry
180
+
181
+
182
+
183
+
184
+
185
+ # [5.16.0-beta.1](https://github.com/webiny/webiny-js/compare/v5.16.0-beta.0...v5.16.0-beta.1) (2021-10-19)
186
+
187
+ **Note:** Version bump only for package @webiny/telemetry
188
+
189
+
190
+
191
+
192
+
193
+ # [5.16.0-beta.0](https://github.com/webiny/webiny-js/compare/v5.17.0-beta.0...v5.16.0-beta.0) (2021-10-19)
194
+
195
+ **Note:** Version bump only for package @webiny/telemetry
196
+
197
+
198
+
199
+
200
+
201
+ # [5.17.0-beta.0](https://github.com/webiny/webiny-js/compare/v5.15.0...v5.17.0-beta.0) (2021-10-18)
202
+
203
+ **Note:** Version bump only for package @webiny/telemetry
204
+
205
+
206
+
207
+
208
+
209
+ # [5.15.0](https://github.com/webiny/webiny-js/compare/v5.15.0-beta.3...v5.15.0) (2021-09-30)
210
+
211
+ **Note:** Version bump only for package @webiny/telemetry
212
+
213
+
214
+
215
+
216
+
217
+ # [5.15.0-beta.3](https://github.com/webiny/webiny-js/compare/v5.15.0-beta.2...v5.15.0-beta.3) (2021-09-30)
218
+
219
+ **Note:** Version bump only for package @webiny/telemetry
220
+
221
+
222
+
223
+
224
+
225
+ # [5.15.0-beta.2](https://github.com/webiny/webiny-js/compare/v5.15.0-beta.1...v5.15.0-beta.2) (2021-09-29)
226
+
227
+ **Note:** Version bump only for package @webiny/telemetry
228
+
229
+
230
+
231
+
232
+
233
+ # [5.15.0-beta.1](https://github.com/webiny/webiny-js/compare/v5.15.0-beta.0...v5.15.0-beta.1) (2021-09-28)
234
+
235
+ **Note:** Version bump only for package @webiny/telemetry
236
+
237
+
238
+
239
+
240
+
241
+ # [5.15.0-beta.0](https://github.com/webiny/webiny-js/compare/v5.14.0...v5.15.0-beta.0) (2021-09-16)
242
+
243
+
244
+ ### Bug Fixes
245
+
246
+ * add comment ([61dafeb](https://github.com/webiny/webiny-js/commit/61dafeb08883b1c80033d3164581f56138fee675))
247
+ * correct args passing in `setProperties` function ([2ac0fed](https://github.com/webiny/webiny-js/commit/2ac0fedb8bf760b15686de44523138816e708c36))
248
+ * correct if statements ([1dcdd73](https://github.com/webiny/webiny-js/commit/1dcdd735d89f1918952481a6ae510a60cf113b7f))
249
+ * create utils ([6a24dcf](https://github.com/webiny/webiny-js/commit/6a24dcfb02130a672c1e90794910f8a0549f659d))
250
+ * remove old api folder ([5dce8e2](https://github.com/webiny/webiny-js/commit/5dce8e2c7871fd1e24326e73e3a9459208ce7f75))
251
+ * rename to `extraPayload` ([b5bcda8](https://github.com/webiny/webiny-js/commit/b5bcda88029c003d0c5704a37bff4771b9056d5e))
252
+ * update dependencies ([37f2691](https://github.com/webiny/webiny-js/commit/37f2691f3cb615615a089d977f58a22a8bb21f50))
253
+ * use base `sendEvent` function ([6f93072](https://github.com/webiny/webiny-js/commit/6f9307212e05b98f2a4866002258238b216e0b3b))
254
+ * use built-in isEnabled ([4051257](https://github.com/webiny/webiny-js/commit/4051257c58165dbcc9805283d183583ed0bf7d15))
255
+ * use global-config package ([a678b18](https://github.com/webiny/webiny-js/commit/a678b18d9d760a69eb6badaaf6451acd3c7fb953))
256
+
257
+
258
+ ### Features
259
+
260
+ * add telemetry getter ([b1a5e8d](https://github.com/webiny/webiny-js/commit/b1a5e8df96b1591266fbd8df90d6689a526da0f3))
261
+ * add utils ([d9be82a](https://github.com/webiny/webiny-js/commit/d9be82a76f5210704c71cd8e191aca698cb0963c))
262
+ * create `sendEvent` function for CLI environment ([d0babff](https://github.com/webiny/webiny-js/commit/d0babffeb1cb3a7a796caa8a25f3f9a2ba9359d7))
263
+ * create base `sendEvent` function ([a764e85](https://github.com/webiny/webiny-js/commit/a764e854c5da0ebcb99038e9b9aaf3184202edc3))
264
+
265
+
266
+
267
+
268
+
269
+ # [5.14.0](https://github.com/webiny/webiny-js/compare/v5.14.0-beta.0...v5.14.0) (2021-08-30)
270
+
271
+ **Note:** Version bump only for package @webiny/telemetry
272
+
273
+
274
+
275
+
276
+
277
+ # [5.14.0-beta.0](https://github.com/webiny/webiny-js/compare/v5.13.0...v5.14.0-beta.0) (2021-08-26)
278
+
279
+ **Note:** Version bump only for package @webiny/telemetry
280
+
281
+
282
+
283
+
284
+
285
+ # [5.13.0](https://github.com/webiny/webiny-js/compare/v5.13.0-beta.4...v5.13.0) (2021-08-18)
286
+
287
+ **Note:** Version bump only for package @webiny/telemetry
288
+
289
+
290
+
291
+
292
+
293
+ # [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)
294
+
295
+ **Note:** Version bump only for package @webiny/telemetry
296
+
297
+
298
+
299
+
300
+
301
+ # [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)
302
+
303
+ **Note:** Version bump only for package @webiny/telemetry
304
+
305
+
306
+
307
+
308
+
309
+ # [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)
310
+
311
+ **Note:** Version bump only for package @webiny/telemetry
312
+
313
+
314
+
315
+
316
+
317
+ # [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)
318
+
319
+ **Note:** Version bump only for package @webiny/telemetry
320
+
321
+
322
+
323
+
324
+
325
+ # [5.13.0-beta.0](https://github.com/webiny/webiny-js/compare/v5.12.0...v5.13.0-beta.0) (2021-08-16)
326
+
327
+ **Note:** Version bump only for package @webiny/telemetry
328
+
329
+
330
+
331
+
332
+
333
+ # [5.12.0](https://github.com/webiny/webiny-js/compare/v5.12.0-beta.1...v5.12.0) (2021-08-05)
334
+
335
+ **Note:** Version bump only for package @webiny/telemetry
336
+
337
+
338
+
339
+
340
+
341
+ # [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)
342
+
343
+ **Note:** Version bump only for package @webiny/telemetry
344
+
345
+
346
+
347
+
348
+
349
+ # [5.12.0-beta.0](https://github.com/webiny/webiny-js/compare/v5.11.1...v5.12.0-beta.0) (2021-08-04)
350
+
351
+ **Note:** Version bump only for package @webiny/telemetry
352
+
353
+
354
+
355
+
356
+
357
+ ## [5.11.1](https://github.com/webiny/webiny-js/compare/v5.11.1-beta.0...v5.11.1) (2021-07-31)
358
+
359
+ **Note:** Version bump only for package @webiny/telemetry
360
+
361
+
362
+
363
+
364
+
365
+ ## [5.11.1-beta.0](https://github.com/webiny/webiny-js/compare/v5.11.0...v5.11.1-beta.0) (2021-07-31)
366
+
367
+ **Note:** Version bump only for package @webiny/telemetry
368
+
369
+
370
+
371
+
372
+
373
+ # [5.11.0](https://github.com/webiny/webiny-js/compare/v5.11.0-beta.2...v5.11.0) (2021-07-22)
374
+
375
+ **Note:** Version bump only for package @webiny/telemetry
376
+
377
+
378
+
379
+
380
+
381
+ # [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)
382
+
383
+ **Note:** Version bump only for package @webiny/telemetry
384
+
385
+
386
+
387
+
388
+
389
+ # [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)
390
+
391
+ **Note:** Version bump only for package @webiny/telemetry
392
+
393
+
394
+
395
+
396
+
397
+ # [5.11.0-beta.0](https://github.com/webiny/webiny-js/compare/v5.10.0...v5.11.0-beta.0) (2021-07-21)
398
+
399
+ **Note:** Version bump only for package @webiny/telemetry
400
+
401
+
402
+
403
+
404
+
405
+ # [5.10.0](https://github.com/webiny/webiny-js/compare/v5.10.0-beta.2...v5.10.0) (2021-07-06)
406
+
407
+ **Note:** Version bump only for package @webiny/telemetry
408
+
409
+
410
+
411
+
412
+
413
+ # [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)
414
+
415
+ **Note:** Version bump only for package @webiny/telemetry
416
+
417
+
418
+
419
+
420
+
421
+ # [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)
422
+
423
+ **Note:** Version bump only for package @webiny/telemetry
424
+
425
+
426
+
427
+
428
+
429
+ # [5.10.0-beta.0](https://github.com/webiny/webiny-js/compare/v5.9.0...v5.10.0-beta.0) (2021-07-02)
430
+
431
+ **Note:** Version bump only for package @webiny/telemetry
432
+
433
+
434
+
435
+
436
+
437
+ # [5.9.0](https://github.com/webiny/webiny-js/compare/v5.9.0-beta.2...v5.9.0) (2021-06-21)
438
+
439
+ **Note:** Version bump only for package @webiny/telemetry
440
+
441
+
442
+
443
+
444
+
445
+ # [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)
446
+
447
+ **Note:** Version bump only for package @webiny/telemetry
448
+
449
+
450
+
451
+
452
+
453
+ # [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)
454
+
455
+ **Note:** Version bump only for package @webiny/telemetry
456
+
457
+
458
+
459
+
460
+
461
+ # [5.9.0-beta.0](https://github.com/webiny/webiny-js/compare/v5.8.0...v5.9.0-beta.0) (2021-06-18)
462
+
463
+
464
+ ### Bug Fixes
465
+
466
+ * **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": "0.0.0-mt-1",
4
+ "license": "MIT",
5
+ "dependencies": {
6
+ "@webiny/global-config": "0.0.0-mt-1",
7
+ "form-data": "3.0.0",
8
+ "node-fetch": "2.6.1"
9
+ },
10
+ "publishConfig": {
11
+ "access": "public",
12
+ "directory": "."
13
+ },
14
+ "gitHead": "37736d8456a6ecb342a6c3645060bd9a3f2d4bb0"
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
+ };