@shopify/performance
Advanced tools
Comparing version 4.0.0 to 4.1.0
@@ -38,2 +38,3 @@ 'use strict'; | ||
utilities.withTiming(({ | ||
responseEnd, | ||
domContentLoadedEventStart, | ||
@@ -49,2 +50,7 @@ loadEventStart | ||
this.lifecycleEvent({ | ||
type: types.EventType.TimeToLastByte, | ||
start: responseEnd - this.timeOrigin, | ||
duration: 0 | ||
}); | ||
this.lifecycleEvent({ | ||
type: types.EventType.DomContentLoaded, | ||
@@ -62,2 +68,10 @@ start: domContentLoadedEventStart - this.timeOrigin, | ||
utilities.withEntriesOfType('navigation', entry => { | ||
if (entry.responseEnd > 0) { | ||
this.lifecycleEvent({ | ||
type: types.EventType.TimeToLastByte, | ||
start: entry.responseEnd, | ||
duration: 0 | ||
}); | ||
} | ||
if (entry.domContentLoadedEventStart > 0) { | ||
@@ -64,0 +78,0 @@ this.lifecycleEvent({ |
@@ -9,2 +9,3 @@ 'use strict'; | ||
EventType["TimeToFirstByte"] = "ttfb"; | ||
EventType["TimeToLastByte"] = "ttlb"; | ||
EventType["TimeToFirstPaint"] = "ttfp"; | ||
@@ -11,0 +12,0 @@ EventType["TimeToFirstContentfulPaint"] = "ttfcp"; |
export declare enum EventType { | ||
TimeToFirstByte = "ttfb", | ||
TimeToLastByte = "ttlb", | ||
TimeToFirstPaint = "ttfp", | ||
@@ -29,2 +30,8 @@ TimeToFirstContentfulPaint = "ttfcp", | ||
} | ||
export interface TimeToLastByteEvent extends BasicEvent { | ||
type: EventType.TimeToLastByte; | ||
metadata?: { | ||
[key: string]: any; | ||
}; | ||
} | ||
export interface TimeToFirstPaintEvent extends BasicEvent { | ||
@@ -88,6 +95,7 @@ type: EventType.TimeToFirstPaint; | ||
} | ||
export type LifecycleEvent = TimeToFirstByteEvent | TimeToFirstPaintEvent | TimeToFirstContentfulPaintEvent | TimeToLargestContentfulPaintEvent | DomContentLoadedEvent | FirstInputDelayEvent | LoadEvent; | ||
export type LifecycleEvent = TimeToFirstByteEvent | TimeToLastByteEvent | TimeToFirstPaintEvent | TimeToFirstContentfulPaintEvent | TimeToLargestContentfulPaintEvent | DomContentLoadedEvent | FirstInputDelayEvent | LoadEvent; | ||
export type Event = LifecycleEvent | LongTaskEvent | ScriptDownloadEvent | StyleDownloadEvent | GraphQLEvent | UsableEvent | CustomEvent; | ||
export interface EventMap { | ||
[EventType.TimeToFirstByte]: TimeToFirstByteEvent; | ||
[EventType.TimeToLastByte]: TimeToLastByteEvent; | ||
[EventType.TimeToFirstPaint]: TimeToFirstPaintEvent; | ||
@@ -94,0 +102,0 @@ [EventType.TimeToFirstContentfulPaint]: TimeToFirstContentfulPaintEvent; |
{ | ||
"name": "@shopify/performance", | ||
"version": "4.0.0", | ||
"version": "4.1.0", | ||
"license": "MIT", | ||
@@ -5,0 +5,0 @@ "description": "Primitives for collecting browser performance metrics", |
@@ -123,3 +123,3 @@ # `@shopify/performance` | ||
##### Largest Contentful Paint (`EventType.TimeToFirstContentfulPaint`) | ||
##### Largest Contentful Paint (`EventType.TimeToLargestContentfulPaint`) | ||
@@ -126,0 +126,0 @@ The render time of the largest image or text block visible within the viewport, relative to when the page first started loading. |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
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
89581
1497