@octaviaflow/telemetry 1.0.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 +260 -0
- package/dist/collect.js +44 -0
- package/package.json +99 -0
package/README.md
ADDED
|
@@ -0,0 +1,260 @@
|
|
|
1
|
+
# Octaviaflow Telemetry Collector
|
|
2
|
+
|
|
3
|
+
> JavaScript telemetry collection tooling for octaviaflow projects
|
|
4
|
+
|
|
5
|
+
[](https://opensource.org/licenses/MIT)
|
|
6
|
+
[](https://npmjs.org/package/@octaviaflow/telemetry-collector)
|
|
7
|
+
|
|
8
|
+
## Overview
|
|
9
|
+
|
|
10
|
+
Octaviaflow Telemetry Collector is a powerful analytics tool that captures anonymized usage data from JavaScript/TypeScript projects. It supports multiple data collection scopes including NPM dependencies, JSX components, JavaScript functions, and Web Components.
|
|
11
|
+
|
|
12
|
+
### Key Features
|
|
13
|
+
|
|
14
|
+
- **File-based Storage**: Store telemetry data in JSON files ready for MongoDB Atlas import
|
|
15
|
+
- **Multiple Collection Scopes**: NPM, JSX, JavaScript, and Web Components
|
|
16
|
+
- **Privacy-First**: Anonymized data collection with configurable allowlists
|
|
17
|
+
- **MongoDB Ready**: Generated files are formatted for direct MongoDB import
|
|
18
|
+
- **CLI Tool**: Easy-to-use command-line interface
|
|
19
|
+
|
|
20
|
+
## Installation
|
|
21
|
+
|
|
22
|
+
```bash
|
|
23
|
+
npm install @octaviaflow/telemetry-collector
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
## Quick Start
|
|
27
|
+
|
|
28
|
+
### 1. Create Configuration File
|
|
29
|
+
|
|
30
|
+
Create a `telemetry.yml` file in your project root:
|
|
31
|
+
|
|
32
|
+
```yaml
|
|
33
|
+
# yaml-language-server: $schema=https://unpkg.com/@octaviaflow/telemetry-config-schema@1/dist/config.schema.json
|
|
34
|
+
version: 1
|
|
35
|
+
projectId: 'my-awesome-project'
|
|
36
|
+
name: 'my-awesome-project'
|
|
37
|
+
storage:
|
|
38
|
+
type: 'file'
|
|
39
|
+
file:
|
|
40
|
+
directory: './telemetry-logs'
|
|
41
|
+
fileNamePattern: 'octaviaflow-telemetry-{timestamp}.json'
|
|
42
|
+
maxFileSizeMB: 10
|
|
43
|
+
collect:
|
|
44
|
+
npm:
|
|
45
|
+
dependencies:
|
|
46
|
+
jsx:
|
|
47
|
+
elements:
|
|
48
|
+
allowedAttributeNames: ['size', 'variant']
|
|
49
|
+
allowedAttributeStringValues: ['small', 'medium', 'large']
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
### 2. Run Collection
|
|
53
|
+
|
|
54
|
+
```bash
|
|
55
|
+
# Basic usage
|
|
56
|
+
npx octaviaflow-telemetry --config ./telemetry.yml
|
|
57
|
+
|
|
58
|
+
# With verbose output
|
|
59
|
+
npx octaviaflow-telemetry --config ./telemetry.yml --verbose
|
|
60
|
+
|
|
61
|
+
# Dry run (no data stored)
|
|
62
|
+
npx octaviaflow-telemetry --config ./telemetry.yml --dry-run
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
### 3. Import to MongoDB Atlas
|
|
66
|
+
|
|
67
|
+
After collection, import the generated JSON files to MongoDB Atlas:
|
|
68
|
+
|
|
69
|
+
```bash
|
|
70
|
+
mongoimport --uri "mongodb+srv://user:pass@cluster.mongodb.net/database" \
|
|
71
|
+
--collection telemetry \
|
|
72
|
+
--file ./telemetry-logs/octaviaflow-telemetry-2025-01-01T10-00-00-000Z.json
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
## Configuration
|
|
76
|
+
|
|
77
|
+
### Storage Options
|
|
78
|
+
|
|
79
|
+
#### File Storage (Current)
|
|
80
|
+
|
|
81
|
+
```yaml
|
|
82
|
+
storage:
|
|
83
|
+
type: 'file'
|
|
84
|
+
file:
|
|
85
|
+
directory: './telemetry-logs' # Directory to store files
|
|
86
|
+
fileNamePattern: 'octaviaflow-telemetry-{timestamp}.json' # File naming pattern
|
|
87
|
+
maxFileSizeMB: 10 # Max file size before rotation
|
|
88
|
+
compress: false # Enable compression (future)
|
|
89
|
+
```
|
|
90
|
+
|
|
91
|
+
#### MongoDB Storage (Future)
|
|
92
|
+
|
|
93
|
+
```yaml
|
|
94
|
+
storage:
|
|
95
|
+
type: 'mongodb'
|
|
96
|
+
mongodb:
|
|
97
|
+
connectionString: 'mongodb+srv://user:pass@cluster.mongodb.net'
|
|
98
|
+
database: 'telemetry'
|
|
99
|
+
collection: 'metrics'
|
|
100
|
+
```
|
|
101
|
+
|
|
102
|
+
### Collection Scopes
|
|
103
|
+
|
|
104
|
+
#### NPM Dependencies
|
|
105
|
+
|
|
106
|
+
Captures package dependency information:
|
|
107
|
+
|
|
108
|
+
```yaml
|
|
109
|
+
collect:
|
|
110
|
+
npm:
|
|
111
|
+
dependencies: # Captures all dependencies and versions
|
|
112
|
+
```
|
|
113
|
+
|
|
114
|
+
#### JSX Components
|
|
115
|
+
|
|
116
|
+
Captures React component usage:
|
|
117
|
+
|
|
118
|
+
```yaml
|
|
119
|
+
collect:
|
|
120
|
+
jsx:
|
|
121
|
+
elements:
|
|
122
|
+
allowedAttributeNames:
|
|
123
|
+
- 'size'
|
|
124
|
+
- 'variant'
|
|
125
|
+
- 'color'
|
|
126
|
+
allowedAttributeStringValues:
|
|
127
|
+
- 'small'
|
|
128
|
+
- 'medium'
|
|
129
|
+
- 'large'
|
|
130
|
+
```
|
|
131
|
+
|
|
132
|
+
#### JavaScript Functions
|
|
133
|
+
|
|
134
|
+
Captures function calls and arguments:
|
|
135
|
+
|
|
136
|
+
```yaml
|
|
137
|
+
collect:
|
|
138
|
+
js:
|
|
139
|
+
tokens: # Captures imported tokens
|
|
140
|
+
functions:
|
|
141
|
+
allowedArgumentStringValues:
|
|
142
|
+
- 'debug'
|
|
143
|
+
- 'info'
|
|
144
|
+
- 'error'
|
|
145
|
+
```
|
|
146
|
+
|
|
147
|
+
#### Web Components
|
|
148
|
+
|
|
149
|
+
Captures Web Component usage:
|
|
150
|
+
|
|
151
|
+
```yaml
|
|
152
|
+
collect:
|
|
153
|
+
wc:
|
|
154
|
+
elements:
|
|
155
|
+
allowedAttributeNames:
|
|
156
|
+
- 'type'
|
|
157
|
+
- 'disabled'
|
|
158
|
+
allowedAttributeStringValues:
|
|
159
|
+
- 'button'
|
|
160
|
+
- 'submit'
|
|
161
|
+
```
|
|
162
|
+
|
|
163
|
+
## CLI Options
|
|
164
|
+
|
|
165
|
+
```bash
|
|
166
|
+
octaviaflow-telemetry [options]
|
|
167
|
+
|
|
168
|
+
Options:
|
|
169
|
+
-c, --config <path> Path to telemetry configuration file (default: "./telemetry.yml")
|
|
170
|
+
-v, --verbose Enable verbose logging
|
|
171
|
+
--dry-run Perform a dry run without storing data
|
|
172
|
+
-h, --help Display help for command
|
|
173
|
+
--version Display version number
|
|
174
|
+
```
|
|
175
|
+
|
|
176
|
+
## Data Format
|
|
177
|
+
|
|
178
|
+
Generated JSON files contain telemetry data in MongoDB-ready format:
|
|
179
|
+
|
|
180
|
+
```json
|
|
181
|
+
{
|
|
182
|
+
"_id": "507f1f77bcf86cd799439011",
|
|
183
|
+
"timestamp": "2025-01-01T10:00:00.000Z",
|
|
184
|
+
"projectId": "my-awesome-project",
|
|
185
|
+
"scope": "jsx",
|
|
186
|
+
"metric": "jsx.element",
|
|
187
|
+
"data": {
|
|
188
|
+
"elements": [
|
|
189
|
+
{
|
|
190
|
+
"name": "Button",
|
|
191
|
+
"attributes": { "size": "large", "variant": "primary" },
|
|
192
|
+
"moduleSpecifier": "@octaviaflow/ui"
|
|
193
|
+
}
|
|
194
|
+
]
|
|
195
|
+
},
|
|
196
|
+
"metadata": {
|
|
197
|
+
"collectionTimestamp": "2025-01-01T10:00:00.000Z",
|
|
198
|
+
"storageType": "file",
|
|
199
|
+
"collectionMethod": "jsx-analysis"
|
|
200
|
+
}
|
|
201
|
+
}
|
|
202
|
+
```
|
|
203
|
+
|
|
204
|
+
## Integration with Package
|
|
205
|
+
|
|
206
|
+
Add telemetry collection to your package's `postinstall` script:
|
|
207
|
+
|
|
208
|
+
```json
|
|
209
|
+
{
|
|
210
|
+
"scripts": {
|
|
211
|
+
"postinstall": "octaviaflow-telemetry --config ./telemetry.yml"
|
|
212
|
+
}
|
|
213
|
+
}
|
|
214
|
+
```
|
|
215
|
+
|
|
216
|
+
## Privacy and Data Collection
|
|
217
|
+
|
|
218
|
+
- **Anonymized by Default**: All sensitive data is anonymized unless specifically allowlisted
|
|
219
|
+
- **Configurable Collection**: Only collect data you explicitly configure
|
|
220
|
+
- **Local Storage**: Data is stored locally in files, giving you full control
|
|
221
|
+
- **No External Calls**: No data is sent to external servers automatically
|
|
222
|
+
|
|
223
|
+
## MongoDB Atlas Import
|
|
224
|
+
|
|
225
|
+
### Prepare Data for Import
|
|
226
|
+
|
|
227
|
+
The collector can prepare all collected data for MongoDB import:
|
|
228
|
+
|
|
229
|
+
```javascript
|
|
230
|
+
import { FileStorage } from '@octaviaflow/telemetry-collector';
|
|
231
|
+
|
|
232
|
+
const storage = new FileStorage({ directory: './telemetry-logs' });
|
|
233
|
+
const importFile = await storage.prepareForMongoImport('./mongodb-ready.json');
|
|
234
|
+
console.log('Ready for import:', importFile);
|
|
235
|
+
```
|
|
236
|
+
|
|
237
|
+
### Import Commands
|
|
238
|
+
|
|
239
|
+
```bash
|
|
240
|
+
# Import single file
|
|
241
|
+
mongoimport --uri "your-connection-string" \
|
|
242
|
+
--collection telemetry \
|
|
243
|
+
--file ./telemetry-logs/octaviaflow-telemetry-2025-01-01T10-00-00-000Z.json
|
|
244
|
+
|
|
245
|
+
# Import all files
|
|
246
|
+
for file in ./telemetry-logs/*.json; do
|
|
247
|
+
mongoimport --uri "your-connection-string" \
|
|
248
|
+
--collection telemetry \
|
|
249
|
+
--file "$file"
|
|
250
|
+
done
|
|
251
|
+
```
|
|
252
|
+
|
|
253
|
+
## Related Packages
|
|
254
|
+
|
|
255
|
+
- [`@octaviaflow/telemetry-config-schema`](../octaviaflow-telemetry-config-schema) - Configuration schema and validation
|
|
256
|
+
- [`@octaviaflow/telemetry-attributes`](../octaviaflow-telemetry-attributes) - Telemetry attribute definitions
|
|
257
|
+
|
|
258
|
+
## License
|
|
259
|
+
|
|
260
|
+
MIT © octaviaflow
|
package/dist/collect.js
ADDED
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
/*
|
|
3
|
+
* Copyright OctaviaFlow 2025
|
|
4
|
+
*
|
|
5
|
+
* This source code is licensed under the MIT license found in the
|
|
6
|
+
* LICENSE file in the root directory of this source tree.
|
|
7
|
+
*/
|
|
8
|
+
import { Command } from 'commander';
|
|
9
|
+
import { TelemetryCollector } from './core/telemetry-collector.js';
|
|
10
|
+
import { loadConfig } from './config/config-loader.js';
|
|
11
|
+
const program = new Command();
|
|
12
|
+
program
|
|
13
|
+
.name('octaviaflow-telemetry')
|
|
14
|
+
.description('OctaviaFlow Telemetry Collection Tool')
|
|
15
|
+
.version('1.0.0')
|
|
16
|
+
.option('-c, --config <path>', 'path to telemetry configuration file', './telemetry.yml')
|
|
17
|
+
.option('-v, --verbose', 'enable verbose logging')
|
|
18
|
+
.option('--dry-run', 'perform a dry run without storing data')
|
|
19
|
+
.parse();
|
|
20
|
+
const options = program.opts();
|
|
21
|
+
async function main() {
|
|
22
|
+
try {
|
|
23
|
+
console.log('🚀 Starting OctaviaFlow Telemetry Collection...');
|
|
24
|
+
// Load configuration
|
|
25
|
+
const config = await loadConfig(options.config);
|
|
26
|
+
if (options.verbose) {
|
|
27
|
+
console.log('📋 Configuration loaded:', JSON.stringify(config, null, 2));
|
|
28
|
+
}
|
|
29
|
+
// Create collector instance
|
|
30
|
+
const collector = new TelemetryCollector(config, {
|
|
31
|
+
verbose: options.verbose,
|
|
32
|
+
dryRun: options.dryRun
|
|
33
|
+
});
|
|
34
|
+
// Run collection
|
|
35
|
+
await collector.collect();
|
|
36
|
+
console.log('✅ Telemetry collection completed successfully');
|
|
37
|
+
}
|
|
38
|
+
catch (error) {
|
|
39
|
+
console.error('❌ Telemetry collection failed:', error);
|
|
40
|
+
process.exit(1);
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
main().catch(console.error);
|
|
44
|
+
//# sourceMappingURL=collect.js.map
|
package/package.json
ADDED
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@octaviaflow/telemetry",
|
|
3
|
+
"description": "JavaScript telemetry collection tooling for OctaviaFlow projects",
|
|
4
|
+
"version": "1.0.0",
|
|
5
|
+
"license": "Apache-2.0",
|
|
6
|
+
"author": "OctaviaFlow",
|
|
7
|
+
"keywords": [
|
|
8
|
+
"octaviaflow",
|
|
9
|
+
"telemetry",
|
|
10
|
+
"metrics",
|
|
11
|
+
"analytics",
|
|
12
|
+
"javascript",
|
|
13
|
+
"typescript"
|
|
14
|
+
],
|
|
15
|
+
"publishConfig": {
|
|
16
|
+
"access": "public"
|
|
17
|
+
},
|
|
18
|
+
"homepage": "https://github.com/OctaviaFlow/OctaviaFlow-Design-System#readme",
|
|
19
|
+
"repository": {
|
|
20
|
+
"type": "git",
|
|
21
|
+
"url": "git+https://github.com/OctaviaFlow/OctaviaFlow-Design-System.git"
|
|
22
|
+
},
|
|
23
|
+
"bugs": {
|
|
24
|
+
"url": "https://github.com/OctaviaFlow/OctaviaFlow-Design-System/issues"
|
|
25
|
+
},
|
|
26
|
+
"type": "module",
|
|
27
|
+
"bin": {
|
|
28
|
+
"octaviaflow-telemetry": "dist/collect.js"
|
|
29
|
+
},
|
|
30
|
+
"files": [
|
|
31
|
+
"dist/background-process.js",
|
|
32
|
+
"dist/collect.js",
|
|
33
|
+
"dist/spawn-background-process.js",
|
|
34
|
+
"dist/notify.js"
|
|
35
|
+
],
|
|
36
|
+
"scripts": {
|
|
37
|
+
"build": "npm run clean && npm run compile && npm run compile:collect && npm run bundle",
|
|
38
|
+
"bundle": "node esbuild.js",
|
|
39
|
+
"clean": "rimraf dist .test-coverage",
|
|
40
|
+
"compile": "tsc",
|
|
41
|
+
"compile:collect": "tsc --project ./tsconfig.collect.json",
|
|
42
|
+
"compile:watch": "tsc --watch",
|
|
43
|
+
"lint": "scripts/lint",
|
|
44
|
+
"lint:fix": "scripts/lint_and_fix",
|
|
45
|
+
"prepare": "husky",
|
|
46
|
+
"test": "vitest run --coverage",
|
|
47
|
+
"test:watch": "vitest --coverage"
|
|
48
|
+
},
|
|
49
|
+
"devDependencies": {
|
|
50
|
+
"@commitlint/cli": "^19.4.1",
|
|
51
|
+
"@commitlint/config-conventional": "^19.4.1",
|
|
52
|
+
"@eslint-community/eslint-plugin-eslint-comments": "^4.4.0",
|
|
53
|
+
"@octaviaflow/telemetry-attributes": "workspace:*",
|
|
54
|
+
"@octaviaflow/telemetry-config-schema": "workspace:*",
|
|
55
|
+
"@opentelemetry/api": "^1.9.0",
|
|
56
|
+
"@opentelemetry/exporter-metrics-otlp-http": "^0.53.0",
|
|
57
|
+
"@opentelemetry/otlp-exporter-base": "^0.53.0",
|
|
58
|
+
"@opentelemetry/resources": "^1.26.0",
|
|
59
|
+
"@opentelemetry/sdk-metrics": "^1.26.0",
|
|
60
|
+
"@opentelemetry/semantic-conventions": "^1.27.0",
|
|
61
|
+
"@types/js-yaml": "^4.0.9",
|
|
62
|
+
"@types/lodash": "^4.17.7",
|
|
63
|
+
"@types/mock-fs": "^4.13.4",
|
|
64
|
+
"@types/node": "^20.16.5",
|
|
65
|
+
"@types/semver": "^7.5.8",
|
|
66
|
+
"@vitest/coverage-v8": "^1.6.0",
|
|
67
|
+
"@vitest/eslint-plugin": "^1.0.1",
|
|
68
|
+
"ajv": "^8.17.1",
|
|
69
|
+
"ci-info": "^4.0.0",
|
|
70
|
+
"commander": "^12.1.0",
|
|
71
|
+
"domhandler": "^5.0.3",
|
|
72
|
+
"domutils": "^3.2.2",
|
|
73
|
+
"esbuild": "^0.25.0",
|
|
74
|
+
"eslint": "^8.57.0",
|
|
75
|
+
"eslint-plugin-import": "^2.30.0",
|
|
76
|
+
"eslint-plugin-jsdoc": "^48.11.0",
|
|
77
|
+
"eslint-plugin-n": "^16.6.2",
|
|
78
|
+
"eslint-plugin-notice": "^0.9.10",
|
|
79
|
+
"eslint-plugin-promise": "^6.6.0",
|
|
80
|
+
"eslint-plugin-simple-import-sort": "^12.1.1",
|
|
81
|
+
"globals": "^15.9.0",
|
|
82
|
+
"htmlparser2": "^10.0.0",
|
|
83
|
+
"husky": "^9.1.5",
|
|
84
|
+
"js-yaml": "^4.1.0",
|
|
85
|
+
"lint-staged": "^15.2.10",
|
|
86
|
+
"lodash": "^4.17.21",
|
|
87
|
+
"mock-fs": "^5.4.0",
|
|
88
|
+
"object-scan": "^19.0.5",
|
|
89
|
+
"prettier": "^3.3.3",
|
|
90
|
+
"reflect-metadata": "^0.2.1",
|
|
91
|
+
"rimraf": "^5.0.10",
|
|
92
|
+
"semver": "^7.6.3",
|
|
93
|
+
"ts-json-schema-generator": "^1.5.1",
|
|
94
|
+
"typescript": "^5.5.4",
|
|
95
|
+
"typescript-eslint": "^7.18.0",
|
|
96
|
+
"vite": "^5.4.3",
|
|
97
|
+
"vitest": "^1.6.0"
|
|
98
|
+
}
|
|
99
|
+
}
|