11/* eslint-disable security/detect-non-literal-fs-filename */
22import { exists , prereqs , runCLI } from '../src/test-utils/index.js' ;
3+ import { createTelemetryHelper } from '../src/test-utils/telemetry-helper.js' ;
34import { randomUUID } from 'node:crypto' ;
45import { mkdir , rm } from 'node:fs/promises' ;
56import { tmpdir } from 'node:os' ;
@@ -9,18 +10,21 @@ import { afterAll, beforeAll, describe, expect, it } from 'vitest';
910describe . skipIf ( ! prereqs . npm || ! prereqs . git ) ( 'integration: create edge cases' , ( ) => {
1011 let testDir : string ;
1112
13+ const telemetry = createTelemetryHelper ( ) ;
14+
1215 beforeAll ( async ( ) => {
1316 testDir = join ( tmpdir ( ) , `agentcore-integ-edge-${ randomUUID ( ) } ` ) ;
1417 await mkdir ( testDir , { recursive : true } ) ;
1518 } ) ;
1619
1720 afterAll ( async ( ) => {
21+ telemetry . destroy ( ) ;
1822 await rm ( testDir , { recursive : true , force : true } ) ;
1923 } ) ;
2024
2125 describe ( 'reserved names' , ( ) => {
2226 it ( 'rejects reserved name "Test"' , async ( ) => {
23- const result = await runCLI ( [ 'create' , '--name' , 'Test' , '--json' ] , testDir ) ;
27+ const result = await runCLI ( [ 'create' , '--name' , 'Test' , '--json' ] , testDir , { env : telemetry . env } ) ;
2428
2529 expect ( result . exitCode ) . toBe ( 1 ) ;
2630 const json = JSON . parse ( result . stdout ) ;
@@ -30,6 +34,11 @@ describe.skipIf(!prereqs.npm || !prereqs.git)('integration: create edge cases',
3034 json . error . toLowerCase ( ) . includes ( 'reserved' ) || json . error . toLowerCase ( ) . includes ( 'conflict' ) ,
3135 `Error should mention reserved/conflict: ${ json . error } `
3236 ) . toBeTruthy ( ) ;
37+
38+ telemetry . assertMetricEmitted ( {
39+ command : 'create' ,
40+ exit_reason : 'failure' ,
41+ } ) ;
3342 } ) ;
3443
3544 it ( 'rejects reserved name "bedrock"' , async ( ) => {
@@ -121,12 +130,21 @@ describe.skipIf(!prereqs.npm || !prereqs.git)('integration: create edge cases',
121130 describe ( 'flag interactions' , ( ) => {
122131 it ( '--defaults creates project with default settings' , async ( ) => {
123132 const name = `Def${ Date . now ( ) . toString ( ) . slice ( - 6 ) } ` ;
124- const result = await runCLI ( [ 'create' , '--name' , name , '--defaults' , '--json' ] , testDir ) ;
133+ const result = await runCLI ( [ 'create' , '--name' , name , '--defaults' , '--json' ] , testDir , { env : telemetry . env } ) ;
125134
126135 expect ( result . exitCode , `stderr: ${ result . stderr } ` ) . toBe ( 0 ) ;
127136 const json = JSON . parse ( result . stdout ) ;
128137 expect ( json . success ) . toBe ( true ) ;
129138 expect ( json . projectPath ) . toBeTruthy ( ) ;
139+
140+ telemetry . assertMetricEmitted ( {
141+ command : 'create' ,
142+ exit_reason : 'success' ,
143+ language : 'python' ,
144+ framework : 'strands' ,
145+ model_provider : 'bedrock' ,
146+ has_agent : 'true' ,
147+ } ) ;
130148 } ) ;
131149
132150 it ( '--dry-run shows what would be created without writing files' , async ( ) => {
0 commit comments