@@ -250,6 +250,79 @@ describe('WebVitalsReporter', () => {
250250 } )
251251 } )
252252
253+ it ( 'should not include isBot tag when browser.isBot is not set' , async ( ) => {
254+ const logger = { distribution : sinon . spy ( ) }
255+ const reporter = {
256+ onTTFB : fn => {
257+ fn ( { name : 'TTFB' , value : 10 , entries : [ ] , attribution : { } } )
258+ }
259+ }
260+ render ( < WebVitalsReporter metrics = { [ METRICS . TTFB ] } allowed = { [ '/' ] } reporter = { reporter } /> , { logger} )
261+ await waitFor ( ( ) => [
262+ expect (
263+ logger . distribution . calledWith ( {
264+ name : 'cwv' ,
265+ amount : 10 ,
266+ tags : [
267+ { key : 'name' , value : 'ttfb' } ,
268+ { key : 'pathname' , value : '/' } ,
269+ { key : 'browserEngine' , value : 'Other' }
270+ ]
271+ } )
272+ ) . to . be . true
273+ ] )
274+ } )
275+
276+ it ( 'should include isBot: true tag when browser.isBot is true' , async ( ) => {
277+ const logger = { distribution : sinon . spy ( ) }
278+ const reporter = {
279+ onTTFB : fn => {
280+ fn ( { name : 'TTFB' , value : 10 , entries : [ ] , attribution : { } } )
281+ }
282+ }
283+ const browser = { isBot : true }
284+ render ( < WebVitalsReporter metrics = { [ METRICS . TTFB ] } allowed = { [ '/' ] } reporter = { reporter } /> , { logger, browser} )
285+ await waitFor ( ( ) => [
286+ expect (
287+ logger . distribution . calledWith ( {
288+ name : 'cwv' ,
289+ amount : 10 ,
290+ tags : [
291+ { key : 'name' , value : 'ttfb' } ,
292+ { key : 'pathname' , value : '/' } ,
293+ { key : 'is_bot' , value : true } ,
294+ { key : 'browserEngine' , value : 'Other' }
295+ ]
296+ } )
297+ ) . to . be . true
298+ ] )
299+ } )
300+
301+ it ( 'should include isBot: false tag when browser.isBot is false' , async ( ) => {
302+ const logger = { distribution : sinon . spy ( ) }
303+ const reporter = {
304+ onTTFB : fn => {
305+ fn ( { name : 'TTFB' , value : 10 , entries : [ ] , attribution : { } } )
306+ }
307+ }
308+ const browser = { isBot : false }
309+ render ( < WebVitalsReporter metrics = { [ METRICS . TTFB ] } allowed = { [ '/' ] } reporter = { reporter } /> , { logger, browser} )
310+ await waitFor ( ( ) => [
311+ expect (
312+ logger . distribution . calledWith ( {
313+ name : 'cwv' ,
314+ amount : 10 ,
315+ tags : [
316+ { key : 'name' , value : 'ttfb' } ,
317+ { key : 'pathname' , value : '/' } ,
318+ { key : 'is_bot' , value : false } ,
319+ { key : 'browserEngine' , value : 'Other' }
320+ ]
321+ } )
322+ ) . to . be . true
323+ ] )
324+ } )
325+
253326 it ( 'should track TTFB using logger distribution with browser in context' , async ( ) => {
254327 const logger = {
255328 distribution : sinon . spy ( )
0 commit comments