@egintegrations/telemetry 0.2.2 → 0.3.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.
Files changed (3) hide show
  1. package/README.md +72 -32
  2. package/dist/cli.js +122 -8
  3. package/package.json +9 -4
package/README.md CHANGED
@@ -26,12 +26,37 @@ npx @egintegrations/telemetry init
26
26
  ```
27
27
 
28
28
  The CLI will:
29
- 1. Detect your framework (Next.js, Express, Fastify, or generic)
30
- 2. Prompt for engine name, SKU version, and Control Center URL
31
- 3. Generate configuration file (`.egi/telemetry.json`)
32
- 4. Create integration code (`lib/telemetry.ts` for Next.js, `src/telemetry.ts` for Express)
33
- 5. Add environment variables (`.env.local` or `.env`)
34
- 6. Optionally generate status endpoint boilerplate
29
+ 1. Show the EGI ASCII logo and welcome message
30
+ 2. Detect your framework (Next.js, Express, Fastify, or generic)
31
+ 3. Prompt for engine configuration:
32
+ - Engine name
33
+ - Version (semantic version like 1.0.0)
34
+ - System type (16 options: API, BOT, WA, RAG, ETL, INT, CMS, MA, DA, AI, DB, OP, FX, SDK, CLI, QA)
35
+ - Platform (25 options: VE, EKS, GKE, NPM, PYPI, etc.)
36
+ 4. Generate full SKU automatically (e.g., `1.0.0.API.VE.20260113`)
37
+ 5. Create configuration file (`.egi/telemetry.json`)
38
+ 6. Create integration code (`lib/telemetry.ts` for Next.js, `telemetry.ts` for Express/Fastify)
39
+
40
+ ### How It Works
41
+
42
+ 1. **Install and configure** (30 seconds)
43
+ 2. **Deploy your project** (Vercel, Heroku, K8s, anywhere)
44
+ 3. **Engine automatically registers** on first startup
45
+ 4. **View in dashboard**: https://control-center.egintegrations.com/ui
46
+
47
+ No manual configuration. No YAML files. Just install, configure, and deploy!
48
+
49
+ ### SKU Format
50
+
51
+ SKUs follow the format: `VERSION.TYPE.PLATFORM.DATE`
52
+
53
+ **Example:** `1.0.0.API.VE.20260113`
54
+ - **VERSION**: Semantic version (1.0.0, 2.1.3, etc.)
55
+ - **TYPE**: System type - API, BOT, WA, RAG, ETL, INT, CMS, MA, DA, AI, DB, OP, FX, SDK, CLI, QA
56
+ - **PLATFORM**: Deployment platform - VE (Vercel), EKS, GKE, NPM, PYPI, etc.
57
+ - **DATE**: Auto-generated timestamp (YYYYMMDD)
58
+
59
+ The CLI will guide you through selecting the appropriate type and platform for your project.
35
60
 
36
61
  ### Non-Interactive Setup
37
62
 
@@ -40,9 +65,10 @@ For CI/CD or automated setups:
40
65
  ```bash
41
66
  npx @egintegrations/telemetry init \
42
67
  --engine my-engine \
43
- --sku 1.0.0 \
44
- --url https://control-center.egintegrations.com \
45
- --token your-auth-token
68
+ --version 1.0.0 \
69
+ --type API \
70
+ --platform VE \
71
+ --url https://control-center.egintegrations.com
46
72
  ```
47
73
 
48
74
  ### CLI Options
@@ -50,15 +76,16 @@ npx @egintegrations/telemetry init \
50
76
  | Option | Description | Default |
51
77
  |--------|-------------|---------|
52
78
  | `--engine <name>` | Engine name (required) | - |
53
- | `--sku <version>` | SKU version (required) | - |
54
- | `--url <url>` | Control Center URL (required) | - |
79
+ | `--version <version>` | Semantic version (required) | - |
80
+ | `--type <type>` | System type (API, BOT, WA, etc.) | - |
81
+ | `--platform <platform>` | Platform (VE, EKS, NPM, etc.) | - |
82
+ | `--url <url>` | Control Center URL | `https://control-center.egintegrations.com` |
55
83
  | `--token <token>` | Auth token (optional) | - |
56
84
  | `--modules <modules>` | Comma-separated module list | - |
57
85
  | `--output <path>` | Config file location | `.egi/telemetry.json` |
58
86
  | `--framework <type>` | Force framework type (nextjs, express, fastify, generic) | Auto-detected |
59
87
  | `--no-interactive` | Skip prompts, fail on missing args | Interactive mode |
60
88
  | `--no-codegen` | Only generate config file | Code generation enabled |
61
- | `--status-endpoint` | Generate status endpoint boilerplate | false |
62
89
 
63
90
  ### Framework-Specific Examples
64
91
 
@@ -66,18 +93,26 @@ npx @egintegrations/telemetry init \
66
93
 
67
94
  ```bash
68
95
  cd my-nextjs-app
96
+ npm install @egintegrations/telemetry
69
97
  npx @egintegrations/telemetry init
98
+ # Select: 1.0.0, API type, VE platform
99
+
100
+ # Deploy to Vercel
101
+ vercel deploy --prod
102
+
103
+ # Check dashboard - engine appears automatically!
104
+ # https://control-center.egintegrations.com/ui
70
105
  ```
71
106
 
72
107
  **Generated Files:**
73
- - `.egi/telemetry.json` - Configuration
74
- - `lib/telemetry.ts` - Telemetry client singleton
75
- - `.env.local` - Environment variables
76
- - `app/api/engine-status/route.ts` - Status endpoint (if requested)
108
+ - `.egi/telemetry.json` - Configuration with full SKU
109
+ - `lib/telemetry.ts` - Telemetry client singleton (auto-registers on import)
77
110
 
78
111
  **Usage in Next.js:**
79
112
  ```typescript
80
- // app/api/data/route.ts
113
+ // The telemetry client is already registered automatically
114
+ // Just import and use when you need custom metrics:
115
+
81
116
  import telemetry from '@/lib/telemetry';
82
117
 
83
118
  export async function GET() {
@@ -93,35 +128,38 @@ export async function GET() {
93
128
 
94
129
  ```bash
95
130
  cd my-express-app
131
+ npm install @egintegrations/telemetry
96
132
  npx @egintegrations/telemetry init
133
+ # Select: 1.0.0, API type, EKS platform
134
+
135
+ # Deploy however you normally deploy
136
+ npm start
97
137
  ```
98
138
 
99
139
  **Generated Files:**
100
- - `.egi/telemetry.json` - Configuration
101
- - `src/telemetry.ts` - Telemetry client
102
- - `.env` - Environment variables
103
- - `src/routes/status.ts` - Status endpoint (if requested)
140
+ - `.egi/telemetry.json` - Configuration with full SKU
141
+ - `telemetry.ts` - Telemetry client with health endpoint
104
142
 
105
143
  **Usage in Express:**
106
144
  ```typescript
107
- // src/index.ts
145
+ // telemetry.ts already sets up /.well-known/engine-status endpoint
146
+ // and registers on startup. Just import and use:
147
+
108
148
  import express from 'express';
109
149
  import telemetry from './telemetry';
110
150
 
111
151
  const app = express();
112
152
 
113
- // Auto-track requests
153
+ // Optional: Auto-track requests
114
154
  app.use(telemetry.middleware());
115
155
 
116
- // Use in routes
156
+ // Use in routes for custom metrics
117
157
  app.get('/data', async (req, res) => {
118
158
  await telemetry.sendMetrics({ metrics: { requests: 1 } });
119
159
  res.json({ ok: true });
120
160
  });
121
161
 
122
- app.listen(3000, async () => {
123
- await telemetry.register();
124
- });
162
+ app.listen(3000);
125
163
  ```
126
164
 
127
165
  ## Manual Setup (Advanced)
@@ -136,13 +174,13 @@ import { TelemetryClient } from '@egintegrations/telemetry';
136
174
  // Initialize the client
137
175
  const telemetry = new TelemetryClient({
138
176
  engineName: 'my-awesome-engine',
139
- skuVersion: '1.0.0',
177
+ skuVersion: '1.0.0.API.VE.20260113', // Full SKU format: VERSION.TYPE.PLATFORM.DATE
140
178
  controlCenterUrl: 'https://control-center.egintegrations.com',
141
179
  authToken: 'optional-auth-token', // Optional
142
180
  enabled: true, // Default: true
143
181
  });
144
182
 
145
- // Register your engine
183
+ // Register your engine (auto-creates engine in dashboard)
146
184
  await telemetry.register({
147
185
  environment: 'production',
148
186
  region: 'us-east-1',
@@ -179,14 +217,16 @@ import { TelemetryClient } from '@egintegrations/telemetry';
179
217
  const app = express();
180
218
  const telemetry = new TelemetryClient({
181
219
  engineName: 'api-server',
182
- skuVersion: '1.0.0',
220
+ skuVersion: '1.0.0.API.EKS.20260113', // Full SKU format
183
221
  controlCenterUrl: 'https://control-center.egintegrations.com',
184
222
  });
185
223
 
186
224
  // Automatic request metrics
187
225
  app.use(telemetry.middleware());
188
226
 
189
- app.listen(3000);
227
+ app.listen(3000, async () => {
228
+ await telemetry.register(); // Auto-registers in dashboard
229
+ });
190
230
  ```
191
231
 
192
232
  ### Automatic Health Checks
@@ -215,7 +255,7 @@ process.on('SIGTERM', async () => {
215
255
  #### Constructor Options
216
256
 
217
257
  - `engineName` (string, required) - Unique name for your engine
218
- - `skuVersion` (string, required) - Version of your engine (e.g., "1.0.0")
258
+ - `skuVersion` (string, required) - Full SKU (e.g., "1.0.0.API.VE.20260113")
219
259
  - `controlCenterUrl` (string, required) - URL of your control center
220
260
  - `authToken` (string, optional) - Authentication token if required
221
261
  - `enabled` (boolean, optional) - Enable/disable telemetry (default: true)
package/dist/cli.js CHANGED
@@ -131,6 +131,120 @@ function buildSku(version, systemType, platform, date) {
131
131
  return `${version}.${systemType}.${platform}.${skuDate}`;
132
132
  }
133
133
 
134
+ // src/cli/banner.ts
135
+ var import_chalk = __toESM(require("chalk"));
136
+ var import_boxen = __toESM(require("boxen"));
137
+ var import_gradient_string = __toESM(require("gradient-string"));
138
+ var ASCII_LOGO = `
139
+ ###########################*#*#**#+
140
+ ########################*******************
141
+ ######%@@%###########**************###%@@@*******
142
+ #%%%%@*+===--===-------::::::::::::::--------=%@*****
143
+ %%%%%+==-%#####################################:::-@****
144
+ %%%%*==+%%%%#######################################:-+@****
145
+ %%%%===%%%%%# ######--@*##*
146
+ %%%%==*%%## #####--%####
147
+ %%%%*==%%%# %+*#### *****+++++++======== ####--%###
148
+ %%%%++%%%% %%%++%### *******++++++++======= %###--%###*
149
+ -%%%%++%%%% %%%%++%### *#********+++++++====== ####-=####
150
+ =%%%%++%%%% %%%%=+%###. ###*******+++++++++==== ####--####
151
+ =%%%%+*%%%% %%%%=+%###: .. ... :. ::
152
+ =%%%%**%%%% %%%%=+%%%%:
153
+ =%%%%**%%%% %%%%=+%%%%%%%%#################*******************#
154
+ =%%%%*#%%%% %%%%++%%%%###%%%%%%#######################*#*******
155
+ =%%%%*#%%%% %%%%+*@%%%###@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
156
+ =%%%%*#%%%% %%%%+*@%%%****++ ===================----------
157
+ =%%%%*#%%%% @@%%+*%%%%###%%%%%%%%%%%%%#########################
158
+ =%%%%*#%%%% @@@@*#%%%%%%%%%%%%%%%%%%%%%%%%#####################
159
+ +@%%%*#%%%% @@@@*#%%%%
160
+ +@%@%*#%%%% @@@@##%%%%
161
+ +@%%%*#%%%% @@@@##%%%% ##########**********+++ %%%%+*%%%%
162
+ +@@@%*#%%%% @@@@#%%%%% #############********++ %%%%++%%%%
163
+ @@@@**@%%%= %@@@#%@%%% %%%%%##########******* +%%%%=#%%%%
164
+ @@@@##%%%%% @@#%@@%% %%%%%%##########***** %%%%==@%%%
165
+ %@@@@**@@%%% %%@@@@ %%%%%%###########* @%%%*=+%%%%
166
+ @@@@@**@@@@@@ %%%%%*==%%%%
167
+ @@@@@+**@@@@@@@%+-:::::::::.......... =%%%%%%%%%++#%%%%
168
+ %@@@@@*##@@@@@@@@@@@@@%%%%%%%%%%%%%%%%%%%%%%%%%%@#*++%%%%%
169
+ @@@@@@*####%@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@%#***+@%%%%
170
+ @@@@@@@%*###*##############***####********#%%%%%%%%
171
+ @@@@@@@@@@@@@@@@@@@@@@@@@@%%%%%%%@@@%@%%%%%%%%
172
+ @@@@@@@@@@@@@@@@@@%@@@@@%%%%%@@@%@%%@@%
173
+ `;
174
+ var TAGLINE = "EGI Engine Platform \xB7 Telemetry SDK";
175
+ var VERSION = "v0.3.0";
176
+ function showBanner() {
177
+ console.clear();
178
+ const coloredLogo = (0, import_gradient_string.default)("cyan", "#00ffff", "#0099ff").multiline(ASCII_LOGO);
179
+ console.log(coloredLogo);
180
+ console.log();
181
+ console.log(
182
+ (0, import_boxen.default)(
183
+ import_chalk.default.cyan.bold(TAGLINE) + "\n" + import_chalk.default.gray(VERSION),
184
+ {
185
+ padding: 1,
186
+ margin: 1,
187
+ borderStyle: "round",
188
+ borderColor: "cyan",
189
+ align: "center"
190
+ }
191
+ )
192
+ );
193
+ console.log();
194
+ }
195
+ function showDetectedInfo(framework, version, features) {
196
+ const info = [
197
+ import_chalk.default.cyan("\u{1F50D} Project Detection"),
198
+ "",
199
+ import_chalk.default.white("Framework: ") + import_chalk.default.green.bold(framework)
200
+ ];
201
+ if (version) {
202
+ info.push(import_chalk.default.white("Version: ") + import_chalk.default.yellow(version));
203
+ }
204
+ if (features && features.length > 0) {
205
+ info.push(import_chalk.default.white("Features: ") + import_chalk.default.magenta(features.join(", ")));
206
+ }
207
+ console.log(
208
+ (0, import_boxen.default)(info.join("\n"), {
209
+ padding: 1,
210
+ margin: { top: 0, bottom: 1, left: 2, right: 2 },
211
+ borderStyle: "single",
212
+ borderColor: "cyan"
213
+ })
214
+ );
215
+ }
216
+ function showSuccess(message) {
217
+ console.log();
218
+ console.log(
219
+ (0, import_boxen.default)(
220
+ import_chalk.default.green("\u2713 ") + import_chalk.default.white.bold(message),
221
+ {
222
+ padding: 1,
223
+ margin: 1,
224
+ borderStyle: "round",
225
+ borderColor: "green",
226
+ align: "center"
227
+ }
228
+ )
229
+ );
230
+ }
231
+ function showGeneratedSku(sku) {
232
+ console.log();
233
+ console.log(
234
+ (0, import_boxen.default)(
235
+ import_chalk.default.cyan("\u{1F4E6} Generated SKU\n\n") + import_chalk.default.yellow.bold(sku),
236
+ {
237
+ padding: 1,
238
+ margin: { top: 0, bottom: 1, left: 2, right: 2 },
239
+ borderStyle: "round",
240
+ borderColor: "yellow",
241
+ align: "center"
242
+ }
243
+ )
244
+ );
245
+ console.log();
246
+ }
247
+
134
248
  // src/cli/prompts.ts
135
249
  async function gatherOptions(cliArgs, detected) {
136
250
  const questions = [];
@@ -222,8 +336,7 @@ async function gatherOptions(cliArgs, detected) {
222
336
  let finalSku = cliArgs.sku;
223
337
  if (!finalSku && answers.skuVersion && answers.skuType && answers.skuPlatform) {
224
338
  finalSku = buildSku(answers.skuVersion, answers.skuType, answers.skuPlatform);
225
- console.log(`
226
- \u{1F4E6} Generated SKU: ${finalSku}`);
339
+ showGeneratedSku(finalSku);
227
340
  }
228
341
  return {
229
342
  engine: cliArgs.engine || answers.engine,
@@ -496,15 +609,15 @@ async function runGenerator(ctx) {
496
609
 
497
610
  // src/cli/commands.ts
498
611
  async function initCommand(options) {
499
- console.log("\u{1F680} EGI Telemetry SDK Initialization\n");
612
+ showBanner();
500
613
  try {
501
614
  const cwd = process.cwd();
502
- console.log("\u{1F50D} Detecting framework...");
503
615
  const detected = await detectFramework(cwd);
504
- console.log(` Found: ${detected.type}${detected.version ? ` v${detected.version}` : ""}`);
616
+ const features = [];
505
617
  if (detected.type === "nextjs" && detected.appDir) {
506
- console.log(" Next.js App Router detected");
618
+ features.push("App Router");
507
619
  }
620
+ showDetectedInfo(detected.type, detected.version, features);
508
621
  console.log("");
509
622
  const telemetryOptions = await gatherOptions(options, detected);
510
623
  console.log("");
@@ -517,7 +630,7 @@ async function initCommand(options) {
517
630
  for (const file of files) {
518
631
  await writeFile(file);
519
632
  }
520
- console.log("\n\u2705 Telemetry SDK initialized successfully!\n");
633
+ showSuccess("Telemetry SDK initialized successfully!");
521
634
  if (telemetryOptions.codegen && detected.type !== "generic") {
522
635
  console.log("\u{1F4DD} Next steps:");
523
636
  console.log(" 1. Review the generated files");
@@ -527,7 +640,8 @@ async function initCommand(options) {
527
640
  } else {
528
641
  console.log(" import telemetry from './telemetry';");
529
642
  }
530
- console.log(" 3. Start using telemetry.sendMetrics() in your app");
643
+ console.log(" 3. Deploy your project");
644
+ console.log(" 4. Engine will auto-register in dashboard");
531
645
  console.log("");
532
646
  }
533
647
  } catch (error) {
package/package.json CHANGED
@@ -1,18 +1,18 @@
1
1
  {
2
2
  "name": "@egintegrations/telemetry",
3
- "version": "0.2.2",
3
+ "version": "0.3.1",
4
4
  "description": "Telemetry SDK for EGIntegrations client engines",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.mjs",
7
7
  "types": "dist/index.d.ts",
8
8
  "bin": {
9
- "egi-telemetry": "./dist/cli.js"
9
+ "egi-telemetry": "dist/cli.js"
10
10
  },
11
11
  "exports": {
12
12
  ".": {
13
+ "types": "./dist/index.d.ts",
13
14
  "require": "./dist/index.js",
14
- "import": "./dist/index.mjs",
15
- "types": "./dist/index.d.ts"
15
+ "import": "./dist/index.mjs"
16
16
  }
17
17
  },
18
18
  "scripts": {
@@ -33,7 +33,12 @@
33
33
  "license": "PROPRIETARY",
34
34
  "dependencies": {
35
35
  "axios": "^1.6.0",
36
+ "boxen": "^5.1.2",
37
+ "chalk": "^4.1.2",
38
+ "cli-table3": "^0.6.5",
36
39
  "commander": "^12.0.0",
40
+ "gradient-string": "^2.0.2",
41
+ "ora": "^5.4.1",
37
42
  "prompts": "^2.4.2"
38
43
  },
39
44
  "devDependencies": {