Skip to content

Commit bd00f33

Browse files
committed
remove polyfill code
1 parent 5fcd791 commit bd00f33

File tree

4 files changed

+4
-60
lines changed

4 files changed

+4
-60
lines changed

packages/tracing-internal/src/browser/web-vitals/getFID.ts

Lines changed: 1 addition & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -14,21 +14,14 @@
1414
* limitations under the License.
1515
*/
1616

17-
import { WINDOW } from '../types';
1817
import { bindReporter } from './lib/bindReporter';
1918
import { getVisibilityWatcher } from './lib/getVisibilityWatcher';
2019
import { initMetric } from './lib/initMetric';
2120
import { observe } from './lib/observe';
2221
import { onHidden } from './lib/onHidden';
2322
import { runOnce } from './lib/runOnce';
2423
import { whenActivated } from './lib/whenActivated';
25-
import type {
26-
FIDMetric,
27-
FIDReportCallback,
28-
FirstInputPolyfillCallback,
29-
MetricRatingThresholds,
30-
ReportOpts,
31-
} from './types';
24+
import type { FIDMetric, FIDReportCallback, MetricRatingThresholds, ReportOpts } from './types';
3225

3326
/** Thresholds for FID. See https://web.dev/articles/fid#what_is_a_good_fid_score */
3427
export const FIDThresholds: MetricRatingThresholds = [100, 300];
@@ -73,15 +66,5 @@ export const onFID = (onReport: FIDReportCallback, opts: ReportOpts = {}): void
7366
}),
7467
);
7568
}
76-
77-
if (WINDOW.__WEB_VITALS_POLYFILL__) {
78-
// eslint-disable-next-line no-console
79-
console.warn('The web-vitals "base+polyfill" build is deprecated. See: https://bit.ly/3aqzsGm');
80-
81-
// Prefer the native implementation if available,
82-
if (!po) {
83-
WINDOW.webVitals.firstInputPolyfill(handleEntry as FirstInputPolyfillCallback);
84-
}
85-
}
8669
});
8770
};

packages/tracing-internal/src/browser/web-vitals/lib/getNavigationEntry.ts

Lines changed: 1 addition & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -17,35 +17,6 @@
1717
import { WINDOW } from '../../types';
1818
import type { NavigationTimingPolyfillEntry } from '../types';
1919

20-
const getNavigationEntryFromPerformanceTiming = (): NavigationTimingPolyfillEntry => {
21-
// eslint-disable-next-line deprecation/deprecation
22-
const timing = performance.timing;
23-
// eslint-disable-next-line deprecation/deprecation
24-
const type = performance.navigation.type;
25-
26-
const navigationEntry: { [key: string]: number | string } = {
27-
entryType: 'navigation',
28-
startTime: 0,
29-
type: type == 2 ? 'back_forward' : type === 1 ? 'reload' : 'navigate',
30-
};
31-
32-
for (const key in timing) {
33-
if (key !== 'navigationStart' && key !== 'toJSON') {
34-
// eslint-disable-next-line deprecation/deprecation
35-
navigationEntry[key] = Math.max((timing[key as keyof PerformanceTiming] as number) - timing.navigationStart, 0);
36-
}
37-
}
38-
return navigationEntry as unknown as NavigationTimingPolyfillEntry;
39-
};
40-
4120
export const getNavigationEntry = (): PerformanceNavigationTiming | NavigationTimingPolyfillEntry | undefined => {
42-
if (WINDOW.__WEB_VITALS_POLYFILL__) {
43-
return (
44-
WINDOW.performance &&
45-
((performance.getEntriesByType && performance.getEntriesByType('navigation')[0]) ||
46-
getNavigationEntryFromPerformanceTiming())
47-
);
48-
} else {
49-
return WINDOW.performance && performance.getEntriesByType && performance.getEntriesByType('navigation')[0];
50-
}
21+
return WINDOW.performance && performance.getEntriesByType && performance.getEntriesByType('navigation')[0];
5122
};

packages/tracing-internal/src/browser/web-vitals/lib/getVisibilityWatcher.ts

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -65,15 +65,8 @@ export const getVisibilityWatcher = () => {
6565
// since navigation start. This isn't a perfect heuristic, but it's the
6666
// best we can do until an API is available to support querying past
6767
// visibilityState.
68-
if (WINDOW.__WEB_VITALS_POLYFILL__) {
69-
firstHiddenTime = WINDOW.webVitals.firstHiddenTime;
70-
if (firstHiddenTime === Infinity) {
71-
addChangeListeners();
72-
}
73-
} else {
74-
firstHiddenTime = initHiddenTime();
75-
addChangeListeners();
76-
}
68+
firstHiddenTime = initHiddenTime();
69+
addChangeListeners();
7770
}
7871
return {
7972
get firstHiddenTime() {

packages/tracing-internal/src/browser/web-vitals/types.ts

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,9 +39,6 @@ export interface WebVitalsGlobal {
3939
declare global {
4040
interface Window {
4141
webVitals: WebVitalsGlobal;
42-
43-
// Build flags:
44-
__WEB_VITALS_POLYFILL__: boolean;
4542
}
4643
}
4744

0 commit comments

Comments
 (0)