@@ -420,4 +420,91 @@ describe('Telemetry CLI', () => {
420420 event1 = / N E X T _ B U I L D _ O P T I M I Z E D [ \s \S ] + ?{ ( [ \s \S ] + ?) } / . exec ( build . stderr ) . pop ( )
421421 expect ( event1 ) . toMatch ( / h a s R e p o r t W e b V i t a l s .* ?f a l s e / )
422422 } )
423+
424+ it ( 'detects rewrites, headers, and redirects for next build' , async ( ) => {
425+ await fs . rename (
426+ path . join ( appDir , 'next.config.custom-routes' ) ,
427+ path . join ( appDir , 'next.config.js' )
428+ )
429+
430+ const { stderr } = await nextBuild ( appDir , [ ] , {
431+ stderr : true ,
432+ env : { NEXT_TELEMETRY_DEBUG : 1 } ,
433+ } )
434+
435+ await fs . rename (
436+ path . join ( appDir , 'next.config.js' ) ,
437+ path . join ( appDir , 'next.config.custom-routes' )
438+ )
439+
440+ const event1 = / N E X T _ B U I L D _ O P T I M I Z E D [ \s \S ] + ?{ ( [ \s \S ] + ?) } / . exec ( stderr ) . pop ( )
441+ expect ( event1 ) . toMatch ( / " h e a d e r s C o u n t " : 1 / )
442+ expect ( event1 ) . toMatch ( / " r e w r i t e s C o u n t " : 2 / )
443+ expect ( event1 ) . toMatch ( / " r e d i r e c t s C o u n t " : 1 / )
444+ } )
445+
446+ it ( 'detects i18n and image configs for session start' , async ( ) => {
447+ await fs . rename (
448+ path . join ( appDir , 'next.config.i18n-images' ) ,
449+ path . join ( appDir , 'next.config.js' )
450+ )
451+
452+ const { stderr } = await nextBuild ( appDir , [ ] , {
453+ stderr : true ,
454+ env : { NEXT_TELEMETRY_DEBUG : 1 } ,
455+ } )
456+
457+ await fs . rename (
458+ path . join ( appDir , 'next.config.js' ) ,
459+ path . join ( appDir , 'next.config.i18n-images' )
460+ )
461+
462+ const event1 = / N E X T _ C L I _ S E S S I O N _ S T A R T E D [ \s \S ] + ?{ ( [ \s \S ] + ?) } /
463+ . exec ( stderr )
464+ . pop ( )
465+
466+ expect ( event1 ) . toMatch ( / " i 1 8 n E n a b l e d " : t r u e / )
467+ expect ( event1 ) . toMatch ( / " l o c a l e s " : " e n , n l , f r " / )
468+ expect ( event1 ) . toMatch ( / " l o c a l e D o m a i n s C o u n t " : 2 / )
469+ expect ( event1 ) . toMatch ( / " l o c a l e D e t e c t i o n E n a b l e d " : t r u e / )
470+ expect ( event1 ) . toMatch ( / " i m a g e D o m a i n s C o u n t " : 1 / )
471+ expect ( event1 ) . toMatch ( / " i m a g e S i z e s " : " 6 4 , 1 2 8 , 2 5 6 , 5 1 2 , 1 0 2 4 " / )
472+ expect ( event1 ) . toMatch ( / " t r a i l i n g S l a s h E n a b l e d " : f a l s e / )
473+ expect ( event1 ) . toMatch ( / " r e a c t S t r i c t M o d e " : f a l s e / )
474+
475+ await fs . rename (
476+ path . join ( appDir , 'next.config.i18n-images' ) ,
477+ path . join ( appDir , 'next.config.js' )
478+ )
479+
480+ let stderr2 = ''
481+
482+ let app = await launchApp ( appDir , await findPort ( ) , {
483+ onStderr ( msg ) {
484+ stderr2 += msg || ''
485+ } ,
486+ env : {
487+ NEXT_TELEMETRY_DEBUG : 1 ,
488+ } ,
489+ } )
490+ await waitFor ( 1000 )
491+ await killApp ( app )
492+
493+ await fs . rename (
494+ path . join ( appDir , 'next.config.js' ) ,
495+ path . join ( appDir , 'next.config.i18n-images' )
496+ )
497+
498+ const event2 = / N E X T _ C L I _ S E S S I O N _ S T A R T E D [ \s \S ] + ?{ ( [ \s \S ] + ?) } /
499+ . exec ( stderr2 )
500+ . pop ( )
501+ expect ( event2 ) . toMatch ( / " i 1 8 n E n a b l e d " : t r u e / )
502+ expect ( event2 ) . toMatch ( / " l o c a l e s " : " e n , n l , f r " / )
503+ expect ( event2 ) . toMatch ( / " l o c a l e D o m a i n s C o u n t " : 2 / )
504+ expect ( event2 ) . toMatch ( / " l o c a l e D e t e c t i o n E n a b l e d " : t r u e / )
505+ expect ( event2 ) . toMatch ( / " i m a g e D o m a i n s C o u n t " : 1 / )
506+ expect ( event2 ) . toMatch ( / " i m a g e S i z e s " : " 6 4 , 1 2 8 , 2 5 6 , 5 1 2 , 1 0 2 4 " / )
507+ expect ( event2 ) . toMatch ( / " t r a i l i n g S l a s h E n a b l e d " : f a l s e / )
508+ expect ( event2 ) . toMatch ( / " r e a c t S t r i c t M o d e " : f a l s e / )
509+ } )
423510} )
0 commit comments