@webiny/telemetry 6.0.0-alpha.5 β†’ 6.0.0-rc.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/README.md CHANGED
@@ -1 +1,11 @@
1
1
  # @webiny/telemetry
2
+
3
+ > [!NOTE]
4
+ > This package is part of the [Webiny](https://www.webiny.com) monorepo.
5
+ > It’s **included in every Webiny project by default** and is not meant to be used as a standalone package.
6
+
7
+ πŸ“˜ **Documentation:** [https://www.webiny.com/docs](https://www.webiny.com/docs)
8
+
9
+ ---
10
+
11
+ _This README file is automatically generated during the publish process._
package/cli.d.ts ADDED
@@ -0,0 +1,12 @@
1
+ export declare interface SendEventParams {
2
+ event: string;
3
+ user?: string;
4
+ version?: string;
5
+ properties: Record<string, any>;
6
+ }
7
+
8
+ export declare function sendEvent(params: SendEventParams): Promise<void>;
9
+
10
+ export declare function isEnabled(): boolean;
11
+ export declare function enable(): boolean;
12
+ export declare function disable(): boolean;
package/cli.js CHANGED
@@ -1,9 +1,11 @@
1
- const { globalConfig } = require("@webiny/global-config");
2
- const { isCI } = require("ci-info");
3
- const { WTS } = require("wts-client/node");
4
- const baseSendEvent = require("./sendEvent");
1
+ import { globalConfig } from "@webiny/global-config";
2
+ import { isCI } from "ci-info";
3
+ import { WTS } from "wts-client/node.js";
4
+ import baseSendEvent from "./sendEvent.js";
5
+ import { loadJsonFileSync } from "load-json-file";
6
+ import path from "path";
5
7
 
6
- const sendEvent = async ({ event, user, version, properties }) => {
8
+ export const sendEvent = async ({ event, user, version, properties }) => {
7
9
  const shouldSend = isEnabled();
8
10
  if (!shouldSend) {
9
11
  return;
@@ -18,13 +20,16 @@ const sendEvent = async ({ event, user, version, properties }) => {
18
20
  wcpProperties.wcpProjectId = wcpProjectId;
19
21
  }
20
22
 
23
+ const packageJsonPath = path.join(import.meta.dirname, "package.json");
24
+ const packageJson = loadJsonFileSync(packageJsonPath);
25
+
21
26
  return baseSendEvent({
22
27
  event,
23
28
  user: user || globalConfig.get("id"),
24
29
  properties: {
25
30
  ...properties,
26
31
  ...wcpProperties,
27
- version: version || require("./package.json").version,
32
+ version: version || packageJson.version,
28
33
  ci: isCI,
29
34
  newUser: Boolean(globalConfig.get("newUser"))
30
35
  },
@@ -41,15 +46,15 @@ const getWcpOrgProjectId = () => {
41
46
  return [];
42
47
  };
43
48
 
44
- const enable = () => {
49
+ export const enable = () => {
45
50
  globalConfig.set("telemetry", true);
46
51
  };
47
52
 
48
- const disable = () => {
53
+ export const disable = () => {
49
54
  globalConfig.set("telemetry", false);
50
55
  };
51
56
 
52
- const isEnabled = () => {
57
+ export const isEnabled = () => {
53
58
  const config = globalConfig.get();
54
59
 
55
60
  if (config.telemetry === false) {
@@ -59,5 +64,3 @@ const isEnabled = () => {
59
64
  // `tracking` is left here for backwards compatibility with previous versions of Webiny.
60
65
  return config.tracking !== false;
61
66
  };
62
-
63
- module.exports = { sendEvent, enable, disable, isEnabled };
package/package.json CHANGED
@@ -1,17 +1,19 @@
1
1
  {
2
2
  "name": "@webiny/telemetry",
3
- "version": "6.0.0-alpha.5",
3
+ "version": "6.0.0-rc.0",
4
+ "type": "module",
4
5
  "license": "MIT",
5
6
  "dependencies": {
6
- "@webiny/global-config": "6.0.0-alpha.5",
7
- "ci-info": "4.2.0",
8
- "jsesc": "3.0.2",
7
+ "@webiny/global-config": "6.0.0-rc.0",
8
+ "ci-info": "4.4.0",
9
+ "jsesc": "3.1.0",
10
+ "load-json-file": "7.0.1",
9
11
  "strip-ansi": "6.0.1",
10
- "wts-client": "1.0.1"
12
+ "wts-client": "2.0.0"
11
13
  },
12
14
  "publishConfig": {
13
15
  "access": "public",
14
16
  "directory": "."
15
17
  },
16
- "gitHead": "b7e120541b093e91f214904a9f13e4c2c4640978"
18
+ "gitHead": "0f2aa699f4642e550ab62c96fcd050e8d02345c9"
17
19
  }
package/react.js CHANGED
@@ -1,7 +1,7 @@
1
- const baseSendEvent = require("./sendEvent");
2
- const { WTS } = require("wts-client/admin");
1
+ import baseSendEvent from "./sendEvent.js";
2
+ import { WTS } from "wts-client/admin.js";
3
3
 
4
- const sendEvent = async (event, properties = {}) => {
4
+ export const sendEvent = async (event, properties = {}) => {
5
5
  const shouldSend = process.env.REACT_APP_WEBINY_TELEMETRY !== "false";
6
6
  if (!shouldSend) {
7
7
  return;
@@ -38,5 +38,3 @@ const getWcpOrgProjectId = () => {
38
38
  }
39
39
  return [];
40
40
  };
41
-
42
- module.exports = { sendEvent };
package/sendEvent.js CHANGED
@@ -1,11 +1,12 @@
1
- const stripAnsi = require("strip-ansi");
2
- const jsesc = require("jsesc");
1
+ import stripAnsi from "strip-ansi";
2
+ import jsesc from "jsesc";
3
+
3
4
  /**
4
5
  * The main `sendEvent` function.
5
6
  * NOTE: don't use this in your app directly. Instead, use the one from `cli.js` or `react.js` files accordingly.
6
7
  */
7
- module.exports = ({ event, user, properties, wts } = {}) => {
8
- // 1. Check for existence of required base parameters.
8
+ export default ({ event, user, properties, wts } = {}) => {
9
+ // 1. Check for the existence of required base parameters.
9
10
  if (!event) {
10
11
  throw new Error(`Cannot send event - missing "event" name.`);
11
12
  }