@financial-times/n-tracking
Advanced tools
Comparing version 4.2.0 to 4.2.1
@@ -330,3 +330,5 @@ import oTracking from '@financial-times/o-tracking'; | ||
'firstInputDelay', | ||
'cumulativeLayoutShift' | ||
'cumulativeLayoutShift', | ||
'firstContentfulPaint', | ||
'totalBlockingTime' | ||
]; | ||
@@ -354,4 +356,4 @@ | ||
// When testing, you will need to open a new browser window and paste the URL in i.e. simply reloading the page will not work. | ||
const navigation = performance.getEntriesByType('navigation')[0]; | ||
if (navigation.type !== 'navigate') return; | ||
const navigation = performance.getEntriesByType('navigation') && performance.getEntriesByType('navigation')[0]; | ||
if (!navigation || navigation.type !== 'navigate') return; | ||
@@ -382,4 +384,3 @@ const context = {}; | ||
} else if (metricName === 'lcp') { | ||
//This fires at two points - when FID is fired and when the page's lifecycle is changed to 'hidden' | ||
//this records the first, TODO: determine if that is the 'best' point or not. | ||
//This fires twice, we are collecting the 'first firing' - see PR notes for more context https://github.com/Financial-Times/n-tracking/pull/86 | ||
context.largestContentfulPaint = Math.round(data); | ||
@@ -390,7 +391,8 @@ } else if (metricName === 'ttfb') { | ||
context.firstPaint = Math.round(data); | ||
} else if (metricName === 'fcp'){ | ||
context.firstContentfulPaint = Math.round(data); | ||
} else if (metricName === 'cls') { | ||
//This fires at two points - when FID is fired and when the page's lifecycle is changed to 'hidden' | ||
//this records the first, TODO: determine if that is the 'best' point or not. | ||
//CLS is below 1 (ideally below 0.1) so am not rounding this data point | ||
context.cumulativeLayoutShift = data; | ||
} else if (metricName === 'tbt') { | ||
context.totalBlockingTime = Math.round(data); | ||
} | ||
@@ -413,4 +415,3 @@ | ||
analyticsTracker, | ||
logging: false, | ||
largestContentfulPaint: true | ||
logging: false | ||
}); | ||
@@ -417,0 +418,0 @@ }; |
@@ -6,3 +6,3 @@ { | ||
"browser": "dist/browser.js", | ||
"version": "4.2.0", | ||
"version": "4.2.1", | ||
"license": "MIT", | ||
@@ -9,0 +9,0 @@ "repository": "Financial-Times/n-tracking.git", |
@@ -15,3 +15,5 @@ import Perfume from 'perfume.js'; | ||
'firstInputDelay', | ||
'cumulativeLayoutShift' | ||
'cumulativeLayoutShift', | ||
'firstContentfulPaint', | ||
'totalBlockingTime' | ||
]; | ||
@@ -39,4 +41,4 @@ | ||
// When testing, you will need to open a new browser window and paste the URL in i.e. simply reloading the page will not work. | ||
const navigation = performance.getEntriesByType('navigation')[0]; | ||
if (navigation.type !== 'navigate') return; | ||
const navigation = performance.getEntriesByType('navigation') && performance.getEntriesByType('navigation')[0]; | ||
if (!navigation || navigation.type !== 'navigate') return; | ||
@@ -67,4 +69,3 @@ const context = {}; | ||
} else if (metricName === 'lcp') { | ||
//This fires at two points - when FID is fired and when the page's lifecycle is changed to 'hidden' | ||
//this records the first, TODO: determine if that is the 'best' point or not. | ||
//This fires twice, we are collecting the 'first firing' - see PR notes for more context https://github.com/Financial-Times/n-tracking/pull/86 | ||
context.largestContentfulPaint = Math.round(data); | ||
@@ -75,7 +76,8 @@ } else if (metricName === 'ttfb') { | ||
context.firstPaint = Math.round(data); | ||
} else if (metricName === 'fcp'){ | ||
context.firstContentfulPaint = Math.round(data); | ||
} else if (metricName === 'cls') { | ||
//This fires at two points - when FID is fired and when the page's lifecycle is changed to 'hidden' | ||
//this records the first, TODO: determine if that is the 'best' point or not. | ||
//CLS is below 1 (ideally below 0.1) so am not rounding this data point | ||
context.cumulativeLayoutShift = data; | ||
} else if (metricName === 'tbt') { | ||
context.totalBlockingTime = Math.round(data); | ||
} | ||
@@ -98,5 +100,4 @@ | ||
analyticsTracker, | ||
logging: false, | ||
largestContentfulPaint: true | ||
logging: false | ||
}); | ||
}; |
@@ -1,3 +0,3 @@ | ||
import { getCookie } from "./getCookie"; | ||
import { getCookie } from './getCookie'; | ||
export const getLibrarySession = () => getCookie('FTSession_PubLib'); |
@@ -1,3 +0,3 @@ | ||
import { getCookie } from "./getCookie"; | ||
import { getCookie } from './getCookie'; | ||
export const getSpoorId = () => getCookie('spoor-id'); |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
28538
1098397