dashcam 1.0.1-beta.12 → 1.0.1-beta.13
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/bin/dashcam.js +23 -59
- package/package.json +1 -1
package/bin/dashcam.js
CHANGED
|
@@ -310,75 +310,39 @@ program
|
|
|
310
310
|
program
|
|
311
311
|
.command('track')
|
|
312
312
|
.description('Add a logs config to Dashcam')
|
|
313
|
-
.option('--
|
|
314
|
-
.option('--
|
|
315
|
-
.option('--pattern <pattern>', 'Pattern to track (can be used multiple times)', (value, previous) => {
|
|
316
|
-
return previous ? previous.concat([value]) : [value];
|
|
317
|
-
})
|
|
318
|
-
.option('--web <pattern>', 'Web URL pattern to track (can use wildcards like *) - deprecated, use --type=web --pattern instead')
|
|
319
|
-
.option('--app <pattern>', 'Application file pattern to track (can use wildcards like *) - deprecated, use --type=application --pattern instead')
|
|
313
|
+
.option('--web <pattern>', 'Web URL pattern to track (can use wildcards like *)')
|
|
314
|
+
.option('--app <pattern>', 'Application file pattern to track (can use wildcards like *)')
|
|
320
315
|
.action(async (options) => {
|
|
321
316
|
try {
|
|
322
|
-
|
|
323
|
-
// New syntax: --name=social --type=web --pattern="*facebook.com*" --pattern="*twitter.com*"
|
|
324
|
-
// Old syntax: --web <pattern> --app <pattern>
|
|
325
|
-
|
|
326
|
-
if (options.type && options.pattern) {
|
|
327
|
-
// New syntax validation
|
|
328
|
-
if (!options.name) {
|
|
329
|
-
console.error('Error: --name is required when using --type and --pattern');
|
|
330
|
-
console.log('Example: dashcam track --name=social --type=web --pattern="*facebook.com*" --pattern="*twitter.com*"');
|
|
331
|
-
process.exit(1);
|
|
332
|
-
}
|
|
333
|
-
|
|
334
|
-
if (options.type !== 'web' && options.type !== 'application') {
|
|
335
|
-
console.error('Error: --type must be either "web" or "application"');
|
|
336
|
-
process.exit(1);
|
|
337
|
-
}
|
|
338
|
-
|
|
317
|
+
if (options.web) {
|
|
339
318
|
const config = {
|
|
340
|
-
name:
|
|
341
|
-
type:
|
|
342
|
-
patterns: options.
|
|
319
|
+
name: 'Web Pattern',
|
|
320
|
+
type: 'web',
|
|
321
|
+
patterns: [options.web],
|
|
343
322
|
enabled: true
|
|
344
323
|
};
|
|
345
324
|
|
|
346
325
|
await createPattern(config);
|
|
347
|
-
console.log(
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
} else if (options.web || options.app) {
|
|
351
|
-
// Old syntax for backward compatibility
|
|
352
|
-
if (options.web) {
|
|
353
|
-
const config = {
|
|
354
|
-
name: options.name || 'Web Pattern',
|
|
355
|
-
type: 'web',
|
|
356
|
-
patterns: [options.web],
|
|
357
|
-
enabled: true
|
|
358
|
-
};
|
|
359
|
-
|
|
360
|
-
await createPattern(config);
|
|
361
|
-
console.log('Web tracking pattern added successfully:', options.web);
|
|
362
|
-
}
|
|
326
|
+
console.log('Web tracking pattern added successfully:', options.web);
|
|
327
|
+
}
|
|
363
328
|
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
console.
|
|
378
|
-
console.log(' --web or --app (old syntax)');
|
|
329
|
+
if (options.app) {
|
|
330
|
+
const config = {
|
|
331
|
+
name: 'App Pattern',
|
|
332
|
+
type: 'application',
|
|
333
|
+
patterns: [options.app],
|
|
334
|
+
enabled: true
|
|
335
|
+
};
|
|
336
|
+
|
|
337
|
+
await createPattern(config);
|
|
338
|
+
console.log('Application tracking pattern added successfully:', options.app);
|
|
339
|
+
}
|
|
340
|
+
|
|
341
|
+
if (!options.web && !options.app) {
|
|
342
|
+
console.error('Error: Must provide either --web or --app');
|
|
379
343
|
console.log('\nExamples:');
|
|
380
|
-
console.log(' dashcam track --name=social --type=web --pattern="*facebook.com*" --pattern="*twitter.com*"');
|
|
381
344
|
console.log(' dashcam track --web "*facebook.com*"');
|
|
345
|
+
console.log(' dashcam track --app "/var/log/app.log"');
|
|
382
346
|
process.exit(1);
|
|
383
347
|
}
|
|
384
348
|
|