@samitouri / QOS-React-2 / commits / 4bcee56210

Rename "tracking" API to "tracing" (#13641)

* Replaced "tracking" with "tracing" in all directory and file names * Global rename of track/tracking/tracked to trace/tracing/traced

Brian Vaughn committed Sep 13, 2018 at 14:23 UTC 4bcee56210bd3ab3f6440ff7313a255148e22107
43 files changed +894 -915
fixtures/tracing/index.html renamed
+9 -9
@@ -2,7 +2,7 @@
2 <html style="width: 100%; height: 100%;">
3 <head>
4 <meta charset="utf-8">
5 - <title>Test tracking UMD</title>
5 + <title>Test tracing UMD</title>
6 <style>
7 body {
8 font-family: sans-serif;
@@ -36,9 +36,9 @@
36 </style>
37 </head>
38 <body>
39 - <h1>Test tracking UMD</h1>
39 + <h1>Test tracing UMD</h1>
40 <p>
41 - This fixture tests that the new tracking API is accessible via UMD build using the UMD shim.
41 + This fixture tests that the new tracing API is accessible via UMD build using the UMD shim.
42 It does not exhaustively test API functionality, only that the forwarded methods can be called.
43 </p>
44 <p>
@@ -52,19 +52,19 @@
52 <li id="checkSchedulerAPI" data-value="...">
53 <strong>Test scheduler API</strong>
54 </li>
55 - <li id="checkSchedulerTrackingAPI" data-value="...">
56 - <strong>Test tracking API</strong>
55 + <li id="checkSchedulerTracingAPI" data-value="...">
56 + <strong>Test tracing API</strong>
57 </li>
58 - <li id="checkSchedulerTrackingSubscriptionsAPI" data-value="...">
59 - <strong>Test tracking subscriptions API</strong>
58 + <li id="checkSchedulerTracingSubscriptionsAPI" data-value="...">
59 + <strong>Test tracing subscriptions API</strong>
60 </li>
61 <li id="checkEndToEndIntegration" data-value="...">
62 <strong>Test end-to-end integration</strong>
63 </li>
64 </ol>
65 - <!-- Load the tracking API before react to test that it's lazily evaluated -->
65 + <!-- Load the tracing API before react to test that it's lazily evaluated -->
66 <script src="../../build/node_modules/schedule/umd/schedule.development.js"></script>
67 - <script src="../../build/node_modules/schedule/umd/schedule-tracking.development.js"></script>
67 + <script src="../../build/node_modules/schedule/umd/schedule-tracing.development.js"></script>
68 <script src="../../build/node_modules/react/umd/react.development.js"></script>
69 <script src="../../build/node_modules/react-dom/umd/react-dom.development.js"></script>
70 <script src="./script.js"></script>
fixtures/tracing/script.js renamed
+42 -42
@@ -14,10 +14,10 @@ function runAllTests() {
14 checkSchedulerAPI();
15 } finally {
16 try {
17 - checkSchedulerTrackingAPI();
17 + checkSchedulerTracingAPI();
18 } finally {
19 try {
20 - checkSchedulerTrackingSubscriptionsAPI();
20 + checkSchedulerTracingSubscriptionsAPI();
21 } finally {
22 checkEndToEndIntegration();
23 }
@@ -44,23 +44,23 @@ function checkSchedulerAPI() {
44 });
45 }
46
47 -function checkSchedulerTrackingAPI() {
48 - runTest(document.getElementById('checkSchedulerTrackingAPI'), () => {
47 +function checkSchedulerTracingAPI() {
48 + runTest(document.getElementById('checkSchedulerTracingAPI'), () => {
49 if (
50 - typeof ScheduleTracking === 'undefined' ||
51 - typeof ScheduleTracking.unstable_clear !== 'function' ||
52 - typeof ScheduleTracking.unstable_getCurrent !== 'function' ||
53 - typeof ScheduleTracking.unstable_getThreadID !== 'function' ||
54 - typeof ScheduleTracking.unstable_track !== 'function' ||
55 - typeof ScheduleTracking.unstable_wrap !== 'function'
50 + typeof ScheduleTracing === 'undefined' ||
51 + typeof ScheduleTracing.unstable_clear !== 'function' ||
52 + typeof ScheduleTracing.unstable_getCurrent !== 'function' ||
53 + typeof ScheduleTracing.unstable_getThreadID !== 'function' ||
54 + typeof ScheduleTracing.unstable_trace !== 'function' ||
55 + typeof ScheduleTracing.unstable_wrap !== 'function'
56 ) {
57 throw 'API is not defined';
58 }
59
60 try {
61 let interactionsSet;
62 - ScheduleTracking.unstable_track('test', 123, () => {
63 - interactionsSet = ScheduleTracking.unstable_getCurrent();
62 + ScheduleTracing.unstable_trace('test', 123, () => {
63 + interactionsSet = ScheduleTracing.unstable_getCurrent();
64 });
65 if (interactionsSet.size !== 1) {
66 throw null;
@@ -73,32 +73,32 @@ function checkSchedulerTrackingAPI() {
73 throw 'API does not work';
74 }
75
76 - const ForwardedSchedulerTracking =
77 - React.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ScheduleTracking;
76 + const ForwardedSchedulerTracing =
77 + React.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ScheduleTracing;
78
79 if (
80 - ScheduleTracking.unstable_getThreadID() ===
81 - ForwardedSchedulerTracking.unstable_getThreadID()
80 + ScheduleTracing.unstable_getThreadID() ===
81 + ForwardedSchedulerTracing.unstable_getThreadID()
82 ) {
83 throw 'API forwarding is broken';
84 }
85 });
86 }
87
88 -function checkSchedulerTrackingSubscriptionsAPI() {
88 +function checkSchedulerTracingSubscriptionsAPI() {
89 runTest(
90 - document.getElementById('checkSchedulerTrackingSubscriptionsAPI'),
90 + document.getElementById('checkSchedulerTracingSubscriptionsAPI'),
91 () => {
92 if (
93 - typeof ScheduleTracking === 'undefined' ||
94 - typeof ScheduleTracking.unstable_subscribe !== 'function' ||
95 - typeof ScheduleTracking.unstable_unsubscribe !== 'function'
93 + typeof ScheduleTracing === 'undefined' ||
94 + typeof ScheduleTracing.unstable_subscribe !== 'function' ||
95 + typeof ScheduleTracing.unstable_unsubscribe !== 'function'
96 ) {
97 throw 'API is not defined';
98 }
99
100 const onInteractionScheduledWorkCompletedCalls = [];
101 - const onInteractionTrackedCalls = [];
101 + const onInteractionTracedCalls = [];
102 const onWorkCanceledCalls = [];
103 const onWorkScheduledCalls = [];
104 const onWorkStartedCalls = [];
@@ -106,7 +106,7 @@ function checkSchedulerTrackingSubscriptionsAPI() {
106 const subscriber = {
107 onInteractionScheduledWorkCompleted: (...args) =>
108 onInteractionScheduledWorkCompletedCalls.push(args),
109 - onInteractionTracked: (...args) => onInteractionTrackedCalls.push(args),
109 + onInteractionTraced: (...args) => onInteractionTracedCalls.push(args),
110 onWorkCanceled: (...args) => onWorkCanceledCalls.push(args),
111 onWorkScheduled: (...args) => onWorkScheduledCalls.push(args),
112 onWorkStarted: (...args) => onWorkStartedCalls.push(args),
@@ -114,38 +114,38 @@ function checkSchedulerTrackingSubscriptionsAPI() {
114 };
115
116 try {
117 - ScheduleTracking.unstable_subscribe(subscriber);
118 - ScheduleTracking.unstable_track('foo', 123, () => {});
119 - ScheduleTracking.unstable_unsubscribe(subscriber);
120 - if (onInteractionTrackedCalls.length !== 1) {
117 + ScheduleTracing.unstable_subscribe(subscriber);
118 + ScheduleTracing.unstable_trace('foo', 123, () => {});
119 + ScheduleTracing.unstable_unsubscribe(subscriber);
120 + if (onInteractionTracedCalls.length !== 1) {
121 throw null;
122 }
123 - const interaction = onInteractionTrackedCalls[0][0];
123 + const interaction = onInteractionTracedCalls[0][0];
124 if (interaction.name !== 'foo' || interaction.timestamp !== 123) {
125 throw null;
126 }
127 - ScheduleTracking.unstable_track('bar', 456, () => {});
128 - if (onInteractionTrackedCalls.length !== 1) {
127 + ScheduleTracing.unstable_trace('bar', 456, () => {});
128 + if (onInteractionTracedCalls.length !== 1) {
129 throw null;
130 }
131 } catch (error) {
132 throw 'API does not forward methods';
133 }
134
135 - const ForwardedSchedulerTracking =
135 + const ForwardedSchedulerTracing =
136 React.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED
137 - .ScheduleTracking;
137 + .ScheduleTracing;
138
139 try {
140 - ForwardedSchedulerTracking.unstable_subscribe(subscriber);
141 - ScheduleTracking.unstable_track('foo', 123, () => {});
142 - ForwardedSchedulerTracking.unstable_track('bar', 456, () => {});
143 - ScheduleTracking.unstable_unsubscribe(subscriber);
144 - if (onInteractionTrackedCalls.length !== 3) {
140 + ForwardedSchedulerTracing.unstable_subscribe(subscriber);
141 + ScheduleTracing.unstable_trace('foo', 123, () => {});
142 + ForwardedSchedulerTracing.unstable_trace('bar', 456, () => {});
143 + ScheduleTracing.unstable_unsubscribe(subscriber);
144 + if (onInteractionTracedCalls.length !== 3) {
145 throw null;
146 }
147 - const interactionFoo = onInteractionTrackedCalls[1][0];
148 - const interactionBar = onInteractionTrackedCalls[2][0];
147 + const interactionFoo = onInteractionTracedCalls[1][0];
148 + const interactionBar = onInteractionTracedCalls[2][0];
149 if (
150 interactionFoo.name !== 'foo' ||
151 interactionFoo.timestamp !== 123 ||
@@ -154,8 +154,8 @@ function checkSchedulerTrackingSubscriptionsAPI() {
154 ) {
155 throw null;
156 }
157 - ForwardedSchedulerTracking.unstable_track('baz', 789, () => {});
158 - if (onInteractionTrackedCalls.length !== 3) {
157 + ForwardedSchedulerTracing.unstable_trace('baz', 789, () => {});
158 + if (onInteractionTracedCalls.length !== 3) {
159 throw null;
160 }
161 } catch (error) {
@@ -172,7 +172,7 @@ function checkEndToEndIntegration() {
172 const onRender = (...args) => onRenderCalls.push(args);
173 const container = document.createElement('div');
174
175 - ScheduleTracking.unstable_track('render', 123, () => {
175 + ScheduleTracing.unstable_trace('render', 123, () => {
176 ReactDOM.render(
177 React.createElement(
178 React.unstable_Profiler,
fixtures/unstable-async/suspense/src/components/App.js
+5 -8
@@ -1,9 +1,6 @@
1 import React, {Placeholder, PureComponent} from 'react';
2 import {unstable_scheduleWork} from 'schedule';
3 -import {
4 - unstable_track as track,
5 - unstable_wrap as wrap,
6 -} from 'schedule/tracking';
3 +import {unstable_trace as trace, unstable_wrap as wrap} from 'schedule/tracing';
4 import {createResource} from 'simple-cache-provider';
5 import {cache} from '../cache';
6 import Spinner from './Spinner';
@@ -32,15 +29,15 @@ export default class App extends PureComponent {
29 }
30
31 handleUserClick = id => {
35 - track(`View ${id}`, performance.now(), () => {
36 - track(`View ${id} (high-pri)`, performance.now(), () =>
32 + trace(`View ${id}`, performance.now(), () => {
33 + trace(`View ${id} (high-pri)`, performance.now(), () =>
34 this.setState({
35 currentId: id,
36 })
37 );
38 unstable_scheduleWork(
39 wrap(() =>
43 - track(`View ${id} (low-pri)`, performance.now(), () =>
40 + trace(`View ${id} (low-pri)`, performance.now(), () =>
41 this.setState({
42 showDetail: true,
43 })
@@ -51,7 +48,7 @@ export default class App extends PureComponent {
48 };
49
50 handleBackClick = () =>
54 - track('View list', performance.now(), () =>
51 + trace('View list', performance.now(), () =>
52 this.setState({
53 currentId: null,
54 showDetail: false,
fixtures/unstable-async/suspense/src/index.js
+2 -2
@@ -1,6 +1,6 @@
1 import React, {Fragment, PureComponent} from 'react';
2 import {unstable_createRoot, render} from 'react-dom';
3 -import {unstable_track as track} from 'schedule/tracking';
3 +import {unstable_trace as trace} from 'schedule/tracing';
4 import {cache} from './cache';
5 import {
6 setFakeRequestTime,
@@ -65,7 +65,7 @@ class Debugger extends PureComponent {
65 }
66
67 handleReset = () => {
68 - track('Clear cache', () => {
68 + trace('Clear cache', () => {
69 cache.invalidate();
70 this.setState(state => ({
71 requests: {},
packages/react-reconciler/src/ReactFiberCommitWork.js
+2 -2
@@ -20,7 +20,7 @@ import type {ExpirationTime} from './ReactFiberExpirationTime';
20 import type {CapturedValue, CapturedError} from './ReactCapturedValue';
21
22 import {
23 - enableSchedulerTracking,
23 + enableSchedulerTracing,
24 enableProfilerTimer,
25 enableSuspense,
26 } from 'shared/ReactFeatureFlags';
@@ -329,7 +329,7 @@ function commitLifeCycles(
329 if (enableProfilerTimer) {
330 const onRender = finishedWork.memoizedProps.onRender;
331
332 - if (enableSchedulerTracking) {
332 + if (enableSchedulerTracing) {
333 onRender(
334 finishedWork.memoizedProps.id,
335 current === null ? 'mount' : 'update',
packages/react-reconciler/src/ReactFiberRoot.js
+10 -10
@@ -10,13 +10,13 @@
10 import type {Fiber} from './ReactFiber';
11 import type {ExpirationTime} from './ReactFiberExpirationTime';
12 import type {TimeoutHandle, NoTimeout} from './ReactFiberHostConfig';
13 -import type {Interaction} from 'schedule/src/Tracking';
13 +import type {Interaction} from 'schedule/src/Tracing';
14
15 import {noTimeout} from './ReactFiberHostConfig';
16 import {createHostRootFiber} from './ReactFiber';
17 import {NoWork} from './ReactFiberExpirationTime';
18 -import {enableSchedulerTracking} from 'shared/ReactFeatureFlags';
19 -import {unstable_getThreadID} from 'schedule/tracking';
18 +import {enableSchedulerTracing} from 'shared/ReactFeatureFlags';
19 +import {unstable_getThreadID} from 'schedule/tracing';
20
21 /* eslint-disable no-use-before-define */
22 // TODO: This should be lifted into the renderer.
@@ -80,10 +80,10 @@ type BaseFiberRootProperties = {|
80 nextScheduledRoot: FiberRoot | null,
81 |};
82
83 -// The following attributes are only used by interaction tracking builds.
83 +// The following attributes are only used by interaction tracing builds.
84 // They enable interactions to be associated with their async work,
85 // And expose interaction metadata to the React DevTools Profiler plugin.
86 -// Note that these attributes are only defined when the enableSchedulerTracking flag is enabled.
86 +// Note that these attributes are only defined when the enableSchedulerTracing flag is enabled.
87 type ProfilingOnlyFiberRootProperties = {|
88 interactionThreadID: number,
89 memoizedInteractions: Set<Interaction>,
@@ -92,9 +92,9 @@ type ProfilingOnlyFiberRootProperties = {|
92
93 // Exported FiberRoot type includes all properties,
94 // To avoid requiring potentially error-prone :any casts throughout the project.
95 -// Profiling properties are only safe to access in profiling builds (when enableSchedulerTracking is true).
95 +// Profiling properties are only safe to access in profiling builds (when enableSchedulerTracing is true).
96 // The types are defined separately within this file to ensure they stay in sync.
97 -// (We don't have to use an inline :any cast when enableSchedulerTracking is disabled.)
97 +// (We don't have to use an inline :any cast when enableSchedulerTracing is disabled.)
98 export type FiberRoot = {
99 ...BaseFiberRootProperties,
100 ...ProfilingOnlyFiberRootProperties,
@@ -111,7 +111,7 @@ export function createFiberRoot(
111 const uninitializedFiber = createHostRootFiber(isAsync);
112
113 let root;
114 - if (enableSchedulerTracking) {
114 + if (enableSchedulerTracing) {
115 root = ({
116 current: uninitializedFiber,
117 containerInfo: containerInfo,
@@ -170,8 +170,8 @@ export function createFiberRoot(
170 uninitializedFiber.stateNode = root;
171
172 // The reason for the way the Flow types are structured in this file,
173 - // Is to avoid needing :any casts everywhere interaction tracking fields are used.
174 - // Unfortunately that requires an :any cast for non-interaction tracking capable builds.
173 + // Is to avoid needing :any casts everywhere interaction tracing fields are used.
174 + // Unfortunately that requires an :any cast for non-interaction tracing capable builds.
175 // $FlowFixMe Remove this :any cast and replace it with something better.
176 return ((root: any): FiberRoot);
177 }
packages/react-reconciler/src/ReactFiberScheduler.js
+19 -19
@@ -10,9 +10,9 @@
10 import type {Fiber} from './ReactFiber';
11 import type {Batch, FiberRoot} from './ReactFiberRoot';
12 import type {ExpirationTime} from './ReactFiberExpirationTime';
13 -import type {Interaction} from 'schedule/src/Tracking';
13 +import type {Interaction} from 'schedule/src/Tracing';
14
15 -import {__interactionsRef, __subscriberRef} from 'schedule/tracking';
15 +import {__interactionsRef, __subscriberRef} from 'schedule/tracing';
16 import {
17 invokeGuardedCallback,
18 hasCaughtError,
@@ -44,7 +44,7 @@ import {
44 HostPortal,
45 } from 'shared/ReactWorkTags';
46 import {
47 - enableSchedulerTracking,
47 + enableSchedulerTracing,
48 enableProfilerTimer,
49 enableUserTimingAPI,
50 replayFailedUnitOfWorkWithInvokeGuardedCallback,
@@ -168,13 +168,13 @@ let didWarnSetStateChildContext;
168 let warnAboutUpdateOnUnmounted;
169 let warnAboutInvalidUpdates;
170
171 -if (enableSchedulerTracking) {
171 +if (enableSchedulerTracing) {
172 // Provide explicit error message when production+profiling bundle of e.g. react-dom
173 - // is used with production (non-profiling) bundle of schedule/tracking
173 + // is used with production (non-profiling) bundle of schedule/tracing
174 invariant(
175 __interactionsRef != null && __interactionsRef.current != null,
176 'It is not supported to run the profiling version of a renderer (for example, `react-dom/profiling`) ' +
177 - 'without also replacing the `schedule/tracking` module with `schedule/tracking-profiling`. ' +
177 + 'without also replacing the `schedule/tracing` module with `schedule/tracing-profiling`. ' +
178 'Your bundler might have a setting for aliasing both modules. ' +
179 'Learn more at http://fb.me/react-profiling',
180 );
@@ -566,10 +566,10 @@ function commitRoot(root: FiberRoot, finishedWork: Fiber): void {
566 markCommittedPriorityLevels(root, earliestRemainingTimeBeforeCommit);
567
568 let prevInteractions: Set<Interaction> = (null: any);
569 - let committedInteractions: Array<Interaction> = enableSchedulerTracking
569 + let committedInteractions: Array<Interaction> = enableSchedulerTracing
570 ? []
571 : (null: any);
572 - if (enableSchedulerTracking) {
572 + if (enableSchedulerTracing) {
573 // Restore any pending interactions at this point,
574 // So that cascading work triggered during the render phase will be accounted for.
575 prevInteractions = __interactionsRef.current;
@@ -767,7 +767,7 @@ function commitRoot(root: FiberRoot, finishedWork: Fiber): void {
767 }
768 onCommit(root, earliestRemainingTimeAfterCommit);
769
770 - if (enableSchedulerTracking) {
770 + if (enableSchedulerTracing) {
771 __interactionsRef.current = prevInteractions;
772
773 let subscriber;
@@ -1175,8 +1175,8 @@ function renderRoot(
1175 const expirationTime = root.nextExpirationTimeToWorkOn;
1176
1177 let prevInteractions: Set<Interaction> = (null: any);
1178 - if (enableSchedulerTracking) {
1179 - // We're about to start new tracked work.
1178 + if (enableSchedulerTracing) {
1179 + // We're about to start new traced work.
1180 // Restore pending interactions so cascading work triggered during the render phase will be accounted for.
1181 prevInteractions = __interactionsRef.current;
1182 __interactionsRef.current = root.memoizedInteractions;
@@ -1200,7 +1200,7 @@ function renderRoot(
1200 );
1201 root.pendingCommitExpirationTime = NoWork;
1202
1203 - if (enableSchedulerTracking) {
1203 + if (enableSchedulerTracing) {
1204 // Determine which interactions this batch of work currently includes,
1205 // So that we can accurately attribute time spent working on it,
1206 // And so that cascading work triggered during the render phase will be associated with it.
@@ -1231,7 +1231,7 @@ function renderRoot(
1231 try {
1232 subscriber.onWorkStarted(interactions, threadID);
1233 } catch (error) {
1234 - // Work thrown by an interaction tracking subscriber should be rethrown,
1234 + // Work thrown by an interaction tracing subscriber should be rethrown,
1235 // But only once it's safe (to avoid leaveing the scheduler in an invalid state).
1236 // Store the error for now and we'll re-throw in finishRendering().
1237 if (!hasUnhandledError) {
@@ -1305,8 +1305,8 @@ function renderRoot(
1305 break;
1306 } while (true);
1307
1308 - if (enableSchedulerTracking) {
1309 - // Tracked work is done for now; restore the previous interactions.
1308 + if (enableSchedulerTracing) {
1309 + // Traced work is done for now; restore the previous interactions.
1310 __interactionsRef.current = prevInteractions;
1311 }
1312
@@ -1614,7 +1614,7 @@ function retrySuspendedRoot(
1614 scheduleWorkToRoot(fiber, retryTime);
1615 const rootExpirationTime = root.expirationTime;
1616 if (rootExpirationTime !== NoWork) {
1617 - if (enableSchedulerTracking) {
1617 + if (enableSchedulerTracing) {
1618 // Restore previous interactions so that new work is associated with them.
1619 let prevInteractions = __interactionsRef.current;
1620 __interactionsRef.current = root.memoizedInteractions;
@@ -1685,7 +1685,7 @@ function storeInteractionsForExpirationTime(
1685 expirationTime: ExpirationTime,
1686 updateInteractionCounts: boolean,
1687 ): void {
1688 - if (!enableSchedulerTracking) {
1688 + if (!enableSchedulerTracing) {
1689 return;
1690 }
1691
@@ -1744,7 +1744,7 @@ function scheduleWork(fiber: Fiber, expirationTime: ExpirationTime) {
1744 return;
1745 }
1746
1747 - if (enableSchedulerTracking) {
1747 + if (enableSchedulerTracing) {
1748 storeInteractionsForExpirationTime(root, expirationTime, true);
1749 }
1750
@@ -1935,7 +1935,7 @@ function onTimeout(root, finishedWork, suspendedExpirationTime) {
1935 recomputeCurrentRendererTime();
1936 currentSchedulerTime = currentRendererTime;
1937
1938 - if (enableSchedulerTracking) {
1938 + if (enableSchedulerTracing) {
1939 // Don't update pending interaction counts for suspense timeouts,
1940 // Because we know we still need to do more work in this case.
1941 suspenseDidTimeout = true;
packages/react-reconciler/src/__tests__/ReactTracing-test.internal.js renamed
+5 -5
@@ -10,16 +10,16 @@
10
11 'use strict';
12
13 -describe('ReactTracking', () => {
14 - it('should error if profiling renderer and non-profiling schedule/tracking bundles are combined', () => {
13 +describe('ReactTracing', () => {
14 + it('should error if profiling renderer and non-profiling schedule/tracing bundles are combined', () => {
15 jest.resetModules();
16
17 const ReactFeatureFlags = require('shared/ReactFeatureFlags');
18 - ReactFeatureFlags.enableSchedulerTracking = false;
18 + ReactFeatureFlags.enableSchedulerTracing = false;
19
20 - require('schedule/tracking');
20 + require('schedule/tracing');
21
22 - ReactFeatureFlags.enableSchedulerTracking = true;
22 + ReactFeatureFlags.enableSchedulerTracing = true;
23
24 expect(() => require('react-dom')).toThrow(
25 'Learn more at http://fb.me/react-profiling',
packages/react/src/ReactSharedInternals.js
+4 -4
@@ -18,10 +18,10 @@ import {
18 unstable_getCurrent,
19 unstable_getThreadID,
20 unstable_subscribe,
21 - unstable_track,
21 + unstable_trace,
22 unstable_unsubscribe,
23 unstable_wrap,
24 -} from 'schedule/tracking';
24 +} from 'schedule/tracing';
25 import ReactCurrentOwner from './ReactCurrentOwner';
26 import ReactDebugCurrentFrame from './ReactDebugCurrentFrame';
27
@@ -43,14 +43,14 @@ if (__UMD__) {
43 unstable_now,
44 unstable_scheduleWork,
45 },
46 - ScheduleTracking: {
46 + ScheduleTracing: {
47 __interactionsRef,
48 __subscriberRef,
49 unstable_clear,
50 unstable_getCurrent,
51 unstable_getThreadID,
52 unstable_subscribe,
53 - unstable_track,
53 + unstable_trace,
54 unstable_unsubscribe,
55 unstable_wrap,
56 },
packages/react/src/__tests__/ReactProfiler-test.internal.js
+189 -201
@@ -15,14 +15,14 @@ let ReactFeatureFlags;
15 let ReactNoop;
16 let ReactTestRenderer;
17 let advanceTimeBy;
18 -let SchedulerTracking;
18 +let SchedulerTracing;
19 let mockNow;
20 let AdvanceTime;
21
22 function loadModules({
23 enableProfilerTimer = true,
24 enableSuspense = false,
25 - enableSchedulerTracking = true,
25 + enableSchedulerTracing = true,
26 replayFailedUnitOfWorkWithInvokeGuardedCallback = false,
27 useNoopRenderer = false,
28 } = {}) {
@@ -37,12 +37,12 @@ function loadModules({
37 ReactFeatureFlags.debugRenderPhaseSideEffectsForStrictMode = false;
38 ReactFeatureFlags.enableProfilerTimer = enableProfilerTimer;
39 ReactFeatureFlags.enableGetDerivedStateFromCatch = true;
40 - ReactFeatureFlags.enableSchedulerTracking = enableSchedulerTracking;
40 + ReactFeatureFlags.enableSchedulerTracing = enableSchedulerTracing;
41 ReactFeatureFlags.enableSuspense = enableSuspense;
42 ReactFeatureFlags.replayFailedUnitOfWorkWithInvokeGuardedCallback = replayFailedUnitOfWorkWithInvokeGuardedCallback;
43
44 React = require('react');
45 - SchedulerTracking = require('schedule/tracking');
45 + SchedulerTracing = require('schedule/tracing');
46
47 if (useNoopRenderer) {
48 ReactNoop = require('react-noop-renderer');
@@ -82,17 +82,17 @@ const mockDevToolsForTest = () => {
82
83 describe('Profiler', () => {
84 describe('works in profiling and non-profiling bundles', () => {
85 - [true, false].forEach(enableSchedulerTracking => {
85 + [true, false].forEach(enableSchedulerTracing => {
86 [true, false].forEach(enableProfilerTimer => {
87 - describe(`enableSchedulerTracking:${
88 - enableSchedulerTracking ? 'enabled' : 'disabled'
87 + describe(`enableSchedulerTracing:${
88 + enableSchedulerTracing ? 'enabled' : 'disabled'
89 } enableProfilerTimer:${
90 enableProfilerTimer ? 'enabled' : 'disabled'
91 }`, () => {
92 beforeEach(() => {
93 jest.resetModules();
94
95 - loadModules({enableSchedulerTracking, enableProfilerTimer});
95 + loadModules({enableSchedulerTracing, enableProfilerTimer});
96 });
97
98 // This will throw in production too,
@@ -165,12 +165,12 @@ describe('Profiler', () => {
165 });
166 });
167
168 - [true, false].forEach(enableSchedulerTracking => {
168 + [true, false].forEach(enableSchedulerTracing => {
169 describe('onRender callback', () => {
170 beforeEach(() => {
171 jest.resetModules();
172
173 - loadModules({enableSchedulerTracking});
173 + loadModules({enableSchedulerTracing});
174 });
175
176 it('should handle errors thrown', () => {
@@ -265,16 +265,14 @@ describe('Profiler', () => {
265
266 let [call] = callback.mock.calls;
267
268 - expect(call).toHaveLength(enableSchedulerTracking ? 7 : 6);
268 + expect(call).toHaveLength(enableSchedulerTracing ? 7 : 6);
269 expect(call[0]).toBe('test');
270 expect(call[1]).toBe('mount');
271 expect(call[2]).toBe(10); // actual time
272 expect(call[3]).toBe(10); // base time
273 expect(call[4]).toBe(5); // start time
274 expect(call[5]).toBe(15); // commit time
275 - expect(call[6]).toEqual(
276 - enableSchedulerTracking ? new Set() : undefined,
277 - ); // interaction events
275 + expect(call[6]).toEqual(enableSchedulerTracing ? new Set() : undefined); // interaction events
276
277 callback.mockReset();
278
@@ -290,16 +288,14 @@ describe('Profiler', () => {
288
289 [call] = callback.mock.calls;
290
293 - expect(call).toHaveLength(enableSchedulerTracking ? 7 : 6);
291 + expect(call).toHaveLength(enableSchedulerTracing ? 7 : 6);
292 expect(call[0]).toBe('test');
293 expect(call[1]).toBe('update');
294 expect(call[2]).toBe(10); // actual time
295 expect(call[3]).toBe(10); // base time
296 expect(call[4]).toBe(35); // start time
297 expect(call[5]).toBe(45); // commit time
300 - expect(call[6]).toEqual(
301 - enableSchedulerTracking ? new Set() : undefined,
302 - ); // interaction events
298 + expect(call[6]).toEqual(enableSchedulerTracing ? new Set() : undefined); // interaction events
299
300 callback.mockReset();
301
@@ -315,16 +311,14 @@ describe('Profiler', () => {
311
312 [call] = callback.mock.calls;
313
318 - expect(call).toHaveLength(enableSchedulerTracking ? 7 : 6);
314 + expect(call).toHaveLength(enableSchedulerTracing ? 7 : 6);
315 expect(call[0]).toBe('test');
316 expect(call[1]).toBe('update');
317 expect(call[2]).toBe(4); // actual time
318 expect(call[3]).toBe(4); // base time
319 expect(call[4]).toBe(65); // start time
320 expect(call[5]).toBe(69); // commit time
325 - expect(call[6]).toEqual(
326 - enableSchedulerTracking ? new Set() : undefined,
327 - ); // interaction events
321 + expect(call[6]).toEqual(enableSchedulerTracing ? new Set() : undefined); // interaction events
322 });
323
324 it('includes render times of nested Profilers in their parent times', () => {
@@ -362,7 +356,7 @@ describe('Profiler', () => {
356 expect(parentCall[5]).toBe(35); // commit time
357 });
358
365 - it('tracks sibling Profilers separately', () => {
359 + it('traces sibling Profilers separately', () => {
360 const callback = jest.fn();
361
362 advanceTimeBy(5); // 0 -> 5
@@ -1220,9 +1214,9 @@ describe('Profiler', () => {
1214 expect(ReactNoop.getRoot('two').current.actualDuration).toBe(14);
1215 });
1216
1223 - describe('interaction tracking', () => {
1217 + describe('interaction tracing', () => {
1218 let onInteractionScheduledWorkCompleted;
1225 - let onInteractionTracked;
1219 + let onInteractionTraced;
1220 let onWorkCanceled;
1221 let onWorkScheduled;
1222 let onWorkStarted;
@@ -1239,7 +1233,7 @@ describe('Profiler', () => {
1233 jest.resetModules();
1234
1235 loadModules({
1242 - enableSchedulerTracking: true,
1236 + enableSchedulerTracing: true,
1237 });
1238
1239 throwInOnInteractionScheduledWorkCompleted = false;
@@ -1252,7 +1246,7 @@ describe('Profiler', () => {
1246 throw Error('Expected error onInteractionScheduledWorkCompleted');
1247 }
1248 });
1255 - onInteractionTracked = jest.fn();
1249 + onInteractionTraced = jest.fn();
1250 onWorkCanceled = jest.fn();
1251 onWorkScheduled = jest.fn(() => {
1252 if (throwInOnWorkScheduled) {
@@ -1271,9 +1265,9 @@ describe('Profiler', () => {
1265 });
1266
1267 // Verify interaction subscriber methods are called as expected.
1274 - SchedulerTracking.unstable_subscribe({
1268 + SchedulerTracing.unstable_subscribe({
1269 onInteractionScheduledWorkCompleted,
1276 - onInteractionTracked,
1270 + onInteractionTraced,
1271 onWorkCanceled,
1272 onWorkScheduled,
1273 onWorkStarted,
@@ -1293,7 +1287,7 @@ describe('Profiler', () => {
1287 // Errors that happen inside of a subscriber should throw,
1288 throwInOnWorkScheduled = true;
1289 expect(() => {
1296 - SchedulerTracking.unstable_track('event', mockNow(), () => {
1290 + SchedulerTracing.unstable_trace('event', mockNow(), () => {
1291 renderer = ReactTestRenderer.create(<Component>fail</Component>, {
1292 unstable_isAsync: true,
1293 });
@@ -1319,7 +1313,7 @@ describe('Profiler', () => {
1313 }
1314
1315 let renderer;
1322 - SchedulerTracking.unstable_track('event', mockNow(), () => {
1316 + SchedulerTracing.unstable_trace('event', mockNow(), () => {
1317 renderer = ReactTestRenderer.create(<Component>text</Component>, {
1318 unstable_isAsync: true,
1319 });
@@ -1348,7 +1342,7 @@ describe('Profiler', () => {
1342 }
1343
1344 let renderer;
1351 - SchedulerTracking.unstable_track('event', mockNow(), () => {
1345 + SchedulerTracing.unstable_trace('event', mockNow(), () => {
1346 renderer = ReactTestRenderer.create(<Component>text</Component>, {
1347 unstable_isAsync: true,
1348 });
@@ -1390,8 +1384,8 @@ describe('Profiler', () => {
1384 };
1385
1386 let renderer;
1393 - SchedulerTracking.unstable_track(eventOne.name, mockNow(), () => {
1394 - SchedulerTracking.unstable_track(eventTwo.name, mockNow(), () => {
1387 + SchedulerTracing.unstable_trace(eventOne.name, mockNow(), () => {
1388 + SchedulerTracing.unstable_trace(eventTwo.name, mockNow(), () => {
1389 renderer = ReactTestRenderer.create(<Component>text</Component>, {
1390 unstable_isAsync: true,
1391 });
@@ -1410,7 +1404,7 @@ describe('Profiler', () => {
1404 });
1405 });
1406
1413 - it('should associate tracked events with their subsequent commits', () => {
1407 + it('should associate traced events with their subsequent commits', () => {
1408 let instance = null;
1409
1410 const Yield = ({duration = 10, value}) => {
@@ -1445,7 +1439,7 @@ describe('Profiler', () => {
1439
1440 const onRender = jest.fn();
1441 let renderer;
1448 - SchedulerTracking.unstable_track(
1442 + SchedulerTracing.unstable_trace(
1443 interactionCreation.name,
1444 mockNow(),
1445 () => {
@@ -1460,13 +1454,13 @@ describe('Profiler', () => {
1454 },
1455 );
1456
1463 - expect(onInteractionTracked).toHaveBeenCalledTimes(1);
1464 - expect(onInteractionTracked).toHaveBeenLastNotifiedOfInteraction(
1457 + expect(onInteractionTraced).toHaveBeenCalledTimes(1);
1458 + expect(onInteractionTraced).toHaveBeenLastNotifiedOfInteraction(
1459 interactionCreation,
1460 );
1461 expect(onInteractionScheduledWorkCompleted).not.toHaveBeenCalled();
1462
1469 - // The schedule/tracking package will notify of work started for the default thread,
1463 + // The schedule/tracing package will notify of work started for the default thread,
1464 // But React shouldn't notify until it's been flushed.
1465 expect(getWorkForReactThreads(onWorkStarted)).toHaveLength(0);
1466 expect(getWorkForReactThreads(onWorkStopped)).toHaveLength(0);
@@ -1486,11 +1480,11 @@ describe('Profiler', () => {
1480 let call = onRender.mock.calls[0];
1481 expect(call[0]).toEqual('test-profiler');
1482 expect(call[5]).toEqual(mockNow());
1489 - if (ReactFeatureFlags.enableSchedulerTracking) {
1483 + if (ReactFeatureFlags.enableSchedulerTracing) {
1484 expect(call[6]).toMatchInteractions([interactionCreation]);
1485 }
1486
1493 - expect(onInteractionTracked).toHaveBeenCalledTimes(1);
1487 + expect(onInteractionTraced).toHaveBeenCalledTimes(1);
1488 expect(onInteractionScheduledWorkCompleted).toHaveBeenCalledTimes(1);
1489 expect(
1490 onInteractionScheduledWorkCompleted,
@@ -1518,13 +1512,13 @@ describe('Profiler', () => {
1512 name: 'initial event',
1513 timestamp: mockNow(),
1514 };
1521 - SchedulerTracking.unstable_track(interactionOne.name, mockNow(), () => {
1515 + SchedulerTracing.unstable_trace(interactionOne.name, mockNow(), () => {
1516 instance.setState({count: 1});
1517
1524 - // Update state again to verify our tracked interaction isn't registered twice
1518 + // Update state again to verify our traced interaction isn't registered twice
1519 instance.setState({count: 2});
1520
1527 - // The schedule/tracking package will notify of work started for the default thread,
1521 + // The schedule/tracing package will notify of work started for the default thread,
1522 // But React shouldn't notify until it's been flushed.
1523 expect(getWorkForReactThreads(onWorkStarted)).toHaveLength(0);
1524 expect(getWorkForReactThreads(onWorkStopped)).toHaveLength(0);
@@ -1541,8 +1535,8 @@ describe('Profiler', () => {
1535 expect(renderer).toFlushThrough(['first']);
1536 expect(onRender).not.toHaveBeenCalled();
1537
1544 - expect(onInteractionTracked).toHaveBeenCalledTimes(2);
1545 - expect(onInteractionTracked).toHaveBeenLastNotifiedOfInteraction(
1538 + expect(onInteractionTraced).toHaveBeenCalledTimes(2);
1539 + expect(onInteractionTraced).toHaveBeenLastNotifiedOfInteraction(
1540 interactionOne,
1541 );
1542 expect(onInteractionScheduledWorkCompleted).toHaveBeenCalledTimes(1);
@@ -1558,7 +1552,7 @@ describe('Profiler', () => {
1552 call = onRender.mock.calls[0];
1553 expect(call[0]).toEqual('test-profiler');
1554 expect(call[5]).toEqual(mockNow());
1561 - if (ReactFeatureFlags.enableSchedulerTracking) {
1555 + if (ReactFeatureFlags.enableSchedulerTracing) {
1556 expect(call[6]).toMatchInteractions([interactionOne]);
1557 }
1558
@@ -1591,11 +1585,11 @@ describe('Profiler', () => {
1585 call = onRender.mock.calls[0];
1586 expect(call[0]).toEqual('test-profiler');
1587 expect(call[5]).toEqual(mockNow());
1594 - if (ReactFeatureFlags.enableSchedulerTracking) {
1588 + if (ReactFeatureFlags.enableSchedulerTracing) {
1589 expect(call[6]).toMatchInteractions([]);
1590 }
1591
1598 - expect(onInteractionTracked).toHaveBeenCalledTimes(2);
1592 + expect(onInteractionTraced).toHaveBeenCalledTimes(2);
1593 expect(onInteractionScheduledWorkCompleted).toHaveBeenCalledTimes(2);
1594 expect(
1595 onInteractionScheduledWorkCompleted,
@@ -1607,13 +1601,13 @@ describe('Profiler', () => {
1601
1602 advanceTimeBy(3);
1603
1610 - // Verify that root updates are also associated with tracked events.
1604 + // Verify that root updates are also associated with traced events.
1605 const interactionTwo = {
1606 id: 2,
1607 name: 'root update event',
1608 timestamp: mockNow(),
1609 };
1616 - SchedulerTracking.unstable_track(interactionTwo.name, mockNow(), () => {
1610 + SchedulerTracing.unstable_trace(interactionTwo.name, mockNow(), () => {
1611 renderer.update(
1612 <React.unstable_Profiler id="test-profiler" onRender={onRender}>
1613 <Example />
@@ -1621,13 +1615,13 @@ describe('Profiler', () => {
1615 );
1616 });
1617
1624 - expect(onInteractionTracked).toHaveBeenCalledTimes(3);
1625 - expect(onInteractionTracked).toHaveBeenLastNotifiedOfInteraction(
1618 + expect(onInteractionTraced).toHaveBeenCalledTimes(3);
1619 + expect(onInteractionTraced).toHaveBeenLastNotifiedOfInteraction(
1620 interactionTwo,
1621 );
1622 expect(onInteractionScheduledWorkCompleted).toHaveBeenCalledTimes(2);
1623
1630 - // The schedule/tracking package will notify of work started for the default thread,
1624 + // The schedule/tracing package will notify of work started for the default thread,
1625 // But React shouldn't notify until it's been flushed.
1626 expect(getWorkForReactThreads(onWorkStarted)).toHaveLength(0);
1627 expect(getWorkForReactThreads(onWorkStopped)).toHaveLength(0);
@@ -1647,11 +1641,11 @@ describe('Profiler', () => {
1641 call = onRender.mock.calls[0];
1642 expect(call[0]).toEqual('test-profiler');
1643 expect(call[5]).toEqual(mockNow());
1650 - if (ReactFeatureFlags.enableSchedulerTracking) {
1644 + if (ReactFeatureFlags.enableSchedulerTracing) {
1645 expect(call[6]).toMatchInteractions([interactionTwo]);
1646 }
1647
1654 - expect(onInteractionTracked).toHaveBeenCalledTimes(3);
1648 + expect(onInteractionTraced).toHaveBeenCalledTimes(3);
1649 expect(onInteractionScheduledWorkCompleted).toHaveBeenCalledTimes(3);
1650 expect(
1651 onInteractionScheduledWorkCompleted,
@@ -1701,7 +1695,7 @@ describe('Profiler', () => {
1695 // Initial mount.
1696 renderer.unstable_flushAll(['FirstComponent', 'SecondComponent']);
1697
1704 - expect(onInteractionTracked).not.toHaveBeenCalled();
1698 + expect(onInteractionTraced).not.toHaveBeenCalled();
1699 expect(onInteractionScheduledWorkCompleted).not.toHaveBeenCalled();
1700
1701 onRender.mockClear();
@@ -1714,121 +1708,115 @@ describe('Profiler', () => {
1708 timestamp: mockNow(),
1709 };
1710
1717 - SchedulerTracking.unstable_track(
1718 - interactionLowPri.name,
1719 - mockNow(),
1720 - () => {
1721 - // Render a partially update, but don't finish.
1722 - first.setState({count: 1});
1711 + SchedulerTracing.unstable_trace(interactionLowPri.name, mockNow(), () => {
1712 + // Render a partially update, but don't finish.
1713 + first.setState({count: 1});
1714
1724 - expect(onWorkScheduled).toHaveBeenCalled();
1725 - expect(onWorkScheduled.mock.calls[0][0]).toMatchInteractions([
1726 - interactionLowPri,
1727 - ]);
1715 + expect(onWorkScheduled).toHaveBeenCalled();
1716 + expect(onWorkScheduled.mock.calls[0][0]).toMatchInteractions([
1717 + interactionLowPri,
1718 + ]);
1719
1729 - expect(renderer).toFlushThrough(['FirstComponent']);
1730 - expect(onRender).not.toHaveBeenCalled();
1720 + expect(renderer).toFlushThrough(['FirstComponent']);
1721 + expect(onRender).not.toHaveBeenCalled();
1722
1732 - expect(onInteractionTracked).toHaveBeenCalledTimes(1);
1733 - expect(onInteractionTracked).toHaveBeenLastNotifiedOfInteraction(
1734 - interactionLowPri,
1735 - );
1736 - expect(onInteractionScheduledWorkCompleted).not.toHaveBeenCalled();
1737 - expect(getWorkForReactThreads(onWorkStarted)).toHaveLength(1);
1738 - expect(
1739 - getWorkForReactThreads(onWorkStarted)[0][0],
1740 - ).toMatchInteractions([interactionLowPri]);
1741 - expect(getWorkForReactThreads(onWorkStopped)).toHaveLength(0);
1742 -
1743 - advanceTimeBy(100);
1744 -
1745 - const interactionHighPri = {
1746 - id: 1,
1747 - name: 'highPri',
1748 - timestamp: mockNow(),
1749 - };
1723 + expect(onInteractionTraced).toHaveBeenCalledTimes(1);
1724 + expect(onInteractionTraced).toHaveBeenLastNotifiedOfInteraction(
1725 + interactionLowPri,
1726 + );
1727 + expect(onInteractionScheduledWorkCompleted).not.toHaveBeenCalled();
1728 + expect(getWorkForReactThreads(onWorkStarted)).toHaveLength(1);
1729 + expect(getWorkForReactThreads(onWorkStarted)[0][0]).toMatchInteractions(
1730 + [interactionLowPri],
1731 + );
1732 + expect(getWorkForReactThreads(onWorkStopped)).toHaveLength(0);
1733
1751 - // Interrupt with higher priority work.
1752 - // This simulates a total of 37ms of actual render time.
1753 - renderer.unstable_flushSync(() => {
1754 - SchedulerTracking.unstable_track(
1755 - interactionHighPri.name,
1756 - mockNow(),
1757 - () => {
1758 - second.setState({count: 1});
1759 -
1760 - expect(onInteractionTracked).toHaveBeenCalledTimes(2);
1761 - expect(
1762 - onInteractionTracked,
1763 - ).toHaveBeenLastNotifiedOfInteraction(interactionHighPri);
1764 - expect(
1765 - onInteractionScheduledWorkCompleted,
1766 - ).not.toHaveBeenCalled();
1767 -
1768 - expect(getWorkForReactThreads(onWorkStarted)).toHaveLength(1);
1769 - expect(getWorkForReactThreads(onWorkStopped)).toHaveLength(0);
1770 - },
1771 - );
1772 - });
1773 - expect(ReactTestRenderer).toClearYields(['SecondComponent']);
1774 -
1775 - expect(onInteractionTracked).toHaveBeenCalledTimes(2);
1776 - expect(onInteractionScheduledWorkCompleted).toHaveBeenCalledTimes(1);
1777 - expect(
1778 - onInteractionScheduledWorkCompleted,
1779 - ).toHaveBeenLastNotifiedOfInteraction(interactionHighPri);
1780 -
1781 - // Verify the high priority update was associated with the high priority event.
1782 - expect(onRender).toHaveBeenCalledTimes(1);
1783 - let call = onRender.mock.calls[0];
1784 - expect(call[0]).toEqual('test');
1785 - expect(call[5]).toEqual(mockNow());
1786 - expect(call[6]).toMatchInteractions(
1787 - ReactFeatureFlags.enableSchedulerTracking
1788 - ? [interactionLowPri, interactionHighPri]
1789 - : [],
1790 - );
1734 + advanceTimeBy(100);
1735
1792 - onRender.mockClear();
1736 + const interactionHighPri = {
1737 + id: 1,
1738 + name: 'highPri',
1739 + timestamp: mockNow(),
1740 + };
1741
1794 - advanceTimeBy(100);
1742 + // Interrupt with higher priority work.
1743 + // This simulates a total of 37ms of actual render time.
1744 + renderer.unstable_flushSync(() => {
1745 + SchedulerTracing.unstable_trace(
1746 + interactionHighPri.name,
1747 + mockNow(),
1748 + () => {
1749 + second.setState({count: 1});
1750 +
1751 + expect(onInteractionTraced).toHaveBeenCalledTimes(2);
1752 + expect(onInteractionTraced).toHaveBeenLastNotifiedOfInteraction(
1753 + interactionHighPri,
1754 + );
1755 + expect(
1756 + onInteractionScheduledWorkCompleted,
1757 + ).not.toHaveBeenCalled();
1758
1796 - // Resume the original low priority update, with rebased state.
1797 - // Verify the low priority update was retained.
1798 - renderer.unstable_flushAll(['FirstComponent']);
1799 - expect(onRender).toHaveBeenCalledTimes(1);
1800 - call = onRender.mock.calls[0];
1801 - expect(call[0]).toEqual('test');
1802 - expect(call[5]).toEqual(mockNow());
1803 - expect(call[6]).toMatchInteractions(
1804 - ReactFeatureFlags.enableSchedulerTracking
1805 - ? [interactionLowPri]
1806 - : [],
1759 + expect(getWorkForReactThreads(onWorkStarted)).toHaveLength(1);
1760 + expect(getWorkForReactThreads(onWorkStopped)).toHaveLength(0);
1761 + },
1762 );
1763 + });
1764 + expect(ReactTestRenderer).toClearYields(['SecondComponent']);
1765
1809 - expect(onInteractionTracked).toHaveBeenCalledTimes(2);
1810 - expect(onInteractionScheduledWorkCompleted).toHaveBeenCalledTimes(1);
1811 -
1812 - // Work might be started multiple times before being completed.
1813 - // This is okay; it's part of the schedule/tracking contract.
1814 - expect(getWorkForReactThreads(onWorkStarted)).toHaveLength(3);
1815 - expect(
1816 - getWorkForReactThreads(onWorkStarted)[1][0],
1817 - ).toMatchInteractions([interactionLowPri, interactionHighPri]);
1818 - expect(
1819 - getWorkForReactThreads(onWorkStarted)[2][0],
1820 - ).toMatchInteractions([interactionLowPri]);
1821 - expect(getWorkForReactThreads(onWorkStopped)).toHaveLength(2);
1822 - expect(
1823 - getWorkForReactThreads(onWorkStopped)[0][0],
1824 - ).toMatchInteractions([interactionLowPri, interactionHighPri]);
1825 - expect(
1826 - getWorkForReactThreads(onWorkStopped)[1][0],
1827 - ).toMatchInteractions([interactionLowPri]);
1828 - },
1829 - );
1766 + expect(onInteractionTraced).toHaveBeenCalledTimes(2);
1767 + expect(onInteractionScheduledWorkCompleted).toHaveBeenCalledTimes(1);
1768 + expect(
1769 + onInteractionScheduledWorkCompleted,
1770 + ).toHaveBeenLastNotifiedOfInteraction(interactionHighPri);
1771 +
1772 + // Verify the high priority update was associated with the high priority event.
1773 + expect(onRender).toHaveBeenCalledTimes(1);
1774 + let call = onRender.mock.calls[0];
1775 + expect(call[0]).toEqual('test');
1776 + expect(call[5]).toEqual(mockNow());
1777 + expect(call[6]).toMatchInteractions(
1778 + ReactFeatureFlags.enableSchedulerTracing
1779 + ? [interactionLowPri, interactionHighPri]
1780 + : [],
1781 + );
1782 +
1783 + onRender.mockClear();
1784 +
1785 + advanceTimeBy(100);
1786 +
1787 + // Resume the original low priority update, with rebased state.
1788 + // Verify the low priority update was retained.
1789 + renderer.unstable_flushAll(['FirstComponent']);
1790 + expect(onRender).toHaveBeenCalledTimes(1);
1791 + call = onRender.mock.calls[0];
1792 + expect(call[0]).toEqual('test');
1793 + expect(call[5]).toEqual(mockNow());
1794 + expect(call[6]).toMatchInteractions(
1795 + ReactFeatureFlags.enableSchedulerTracing ? [interactionLowPri] : [],
1796 + );
1797 +
1798 + expect(onInteractionTraced).toHaveBeenCalledTimes(2);
1799 + expect(onInteractionScheduledWorkCompleted).toHaveBeenCalledTimes(1);
1800 +
1801 + // Work might be started multiple times before being completed.
1802 + // This is okay; it's part of the schedule/tracing contract.
1803 + expect(getWorkForReactThreads(onWorkStarted)).toHaveLength(3);
1804 + expect(getWorkForReactThreads(onWorkStarted)[1][0]).toMatchInteractions(
1805 + [interactionLowPri, interactionHighPri],
1806 + );
1807 + expect(getWorkForReactThreads(onWorkStarted)[2][0]).toMatchInteractions(
1808 + [interactionLowPri],
1809 + );
1810 + expect(getWorkForReactThreads(onWorkStopped)).toHaveLength(2);
1811 + expect(getWorkForReactThreads(onWorkStopped)[0][0]).toMatchInteractions(
1812 + [interactionLowPri, interactionHighPri],
1813 + );
1814 + expect(getWorkForReactThreads(onWorkStopped)[1][0]).toMatchInteractions(
1815 + [interactionLowPri],
1816 + );
1817 + });
1818
1831 - expect(onInteractionTracked).toHaveBeenCalledTimes(2);
1819 + expect(onInteractionTraced).toHaveBeenCalledTimes(2);
1820 expect(onInteractionScheduledWorkCompleted).toHaveBeenCalledTimes(2);
1821 expect(
1822 onInteractionScheduledWorkCompleted,
@@ -1837,7 +1825,7 @@ describe('Profiler', () => {
1825 expect(getWorkForReactThreads(onWorkStopped)).toHaveLength(2);
1826 });
1827
1840 - it('should track work spawned by a commit phase lifecycle and setState callback', () => {
1828 + it('should trace work spawned by a commit phase lifecycle and setState callback', () => {
1829 let instance;
1830 class Example extends React.Component {
1831 state = {
@@ -1870,7 +1858,7 @@ describe('Profiler', () => {
1858 const onRender = jest.fn();
1859 let firstCommitTime = mockNow();
1860 let renderer;
1873 - SchedulerTracking.unstable_track(interactionOne.name, mockNow(), () => {
1861 + SchedulerTracing.unstable_trace(interactionOne.name, mockNow(), () => {
1862 renderer = ReactTestRenderer.create(
1863 <React.unstable_Profiler id="test" onRender={onRender}>
1864 <Example />
@@ -1879,8 +1867,8 @@ describe('Profiler', () => {
1867 );
1868 });
1869
1882 - expect(onInteractionTracked).toHaveBeenCalledTimes(1);
1883 - expect(onInteractionTracked).toHaveBeenLastNotifiedOfInteraction(
1870 + expect(onInteractionTraced).toHaveBeenCalledTimes(1);
1871 + expect(onInteractionTraced).toHaveBeenLastNotifiedOfInteraction(
1872 interactionOne,
1873 );
1874 expect(onInteractionScheduledWorkCompleted).not.toHaveBeenCalled();
@@ -1889,7 +1877,7 @@ describe('Profiler', () => {
1877
1878 renderer.unstable_flushAll(['Example:0', 'Example:1']);
1879
1892 - expect(onInteractionTracked).toHaveBeenCalledTimes(1);
1880 + expect(onInteractionTraced).toHaveBeenCalledTimes(1);
1881 expect(onInteractionScheduledWorkCompleted).toHaveBeenCalledTimes(1);
1882 expect(
1883 onInteractionScheduledWorkCompleted,
@@ -1914,13 +1902,13 @@ describe('Profiler', () => {
1902 expect(call[0]).toEqual('test');
1903 expect(call[5]).toEqual(firstCommitTime);
1904 expect(call[6]).toMatchInteractions(
1917 - ReactFeatureFlags.enableSchedulerTracking ? [interactionOne] : [],
1905 + ReactFeatureFlags.enableSchedulerTracing ? [interactionOne] : [],
1906 );
1907 call = onRender.mock.calls[1];
1908 expect(call[0]).toEqual('test');
1909 expect(call[5]).toEqual(mockNow());
1910 expect(call[6]).toMatchInteractions(
1923 - ReactFeatureFlags.enableSchedulerTracking ? [interactionOne] : [],
1911 + ReactFeatureFlags.enableSchedulerTracing ? [interactionOne] : [],
1912 );
1913
1914 onRender.mockClear();
@@ -1931,13 +1919,13 @@ describe('Profiler', () => {
1919 timestamp: mockNow(),
1920 };
1921
1934 - // Cause an tracked, async update
1935 - SchedulerTracking.unstable_track(interactionTwo.name, mockNow(), () => {
1922 + // Cause an traced, async update
1923 + SchedulerTracing.unstable_trace(interactionTwo.name, mockNow(), () => {
1924 instance.setState({count: 2});
1925 });
1926 expect(onRender).not.toHaveBeenCalled();
1939 - expect(onInteractionTracked).toHaveBeenCalledTimes(2);
1940 - expect(onInteractionTracked).toHaveBeenLastNotifiedOfInteraction(
1927 + expect(onInteractionTraced).toHaveBeenCalledTimes(2);
1928 + expect(onInteractionTraced).toHaveBeenLastNotifiedOfInteraction(
1929 interactionTwo,
1930 );
1931 expect(onInteractionScheduledWorkCompleted).toHaveBeenCalledTimes(1);
@@ -1946,12 +1934,12 @@ describe('Profiler', () => {
1934
1935 advanceTimeBy(5);
1936
1949 - // Flush async work (outside of tracked scope)
1937 + // Flush async work (outside of traced scope)
1938 // This will cause an intentional cascading update from did-update
1939 firstCommitTime = mockNow();
1940 renderer.unstable_flushAll(['Example:2', 'Example:3']);
1941
1954 - expect(onInteractionTracked).toHaveBeenCalledTimes(2);
1942 + expect(onInteractionTraced).toHaveBeenCalledTimes(2);
1943 expect(onInteractionScheduledWorkCompleted).toHaveBeenCalledTimes(2);
1944 expect(
1945 onInteractionScheduledWorkCompleted,
@@ -1977,13 +1965,13 @@ describe('Profiler', () => {
1965 expect(call[0]).toEqual('test');
1966 expect(call[5]).toEqual(firstCommitTime);
1967 expect(call[6]).toMatchInteractions(
1980 - ReactFeatureFlags.enableSchedulerTracking ? [interactionTwo] : [],
1968 + ReactFeatureFlags.enableSchedulerTracing ? [interactionTwo] : [],
1969 );
1970 call = onRender.mock.calls[1];
1971 expect(call[0]).toEqual('test');
1972 expect(call[5]).toEqual(mockNow());
1973 expect(call[6]).toMatchInteractions(
1986 - ReactFeatureFlags.enableSchedulerTracking ? [interactionTwo] : [],
1974 + ReactFeatureFlags.enableSchedulerTracing ? [interactionTwo] : [],
1975 );
1976
1977 onRender.mockClear();
@@ -1998,25 +1986,25 @@ describe('Profiler', () => {
1986 function callback() {
1987 instance.setState({count: 6});
1988 }
2001 - SchedulerTracking.unstable_track(interactionThree.name, mockNow(), () => {
1989 + SchedulerTracing.unstable_trace(interactionThree.name, mockNow(), () => {
1990 instance.setState({count: 5}, callback);
1991 });
1992 expect(onRender).not.toHaveBeenCalled();
1993
2006 - expect(onInteractionTracked).toHaveBeenCalledTimes(3);
2007 - expect(onInteractionTracked).toHaveBeenLastNotifiedOfInteraction(
1994 + expect(onInteractionTraced).toHaveBeenCalledTimes(3);
1995 + expect(onInteractionTraced).toHaveBeenLastNotifiedOfInteraction(
1996 interactionThree,
1997 );
1998 expect(onInteractionScheduledWorkCompleted).toHaveBeenCalledTimes(2);
1999 expect(getWorkForReactThreads(onWorkStarted)).toHaveLength(4);
2000 expect(getWorkForReactThreads(onWorkStopped)).toHaveLength(4);
2001
2014 - // Flush async work (outside of tracked scope)
2002 + // Flush async work (outside of traced scope)
2003 // This will cause an intentional cascading update from the setState callback
2004 firstCommitTime = mockNow();
2005 renderer.unstable_flushAll(['Example:5', 'Example:6']);
2006
2019 - expect(onInteractionTracked).toHaveBeenCalledTimes(3);
2007 + expect(onInteractionTraced).toHaveBeenCalledTimes(3);
2008 expect(onInteractionScheduledWorkCompleted).toHaveBeenCalledTimes(3);
2009 expect(
2010 onInteractionScheduledWorkCompleted,
@@ -2042,17 +2030,17 @@ describe('Profiler', () => {
2030 expect(call[0]).toEqual('test');
2031 expect(call[5]).toEqual(firstCommitTime);
2032 expect(call[6]).toMatchInteractions(
2045 - ReactFeatureFlags.enableSchedulerTracking ? [interactionThree] : [],
2033 + ReactFeatureFlags.enableSchedulerTracing ? [interactionThree] : [],
2034 );
2035 call = onRender.mock.calls[1];
2036 expect(call[0]).toEqual('test');
2037 expect(call[5]).toEqual(mockNow());
2038 expect(call[6]).toMatchInteractions(
2051 - ReactFeatureFlags.enableSchedulerTracking ? [interactionThree] : [],
2039 + ReactFeatureFlags.enableSchedulerTracing ? [interactionThree] : [],
2040 );
2041 });
2042
2055 - it('should track interactions associated with a parent component state update', () => {
2043 + it('should trace interactions associated with a parent component state update', () => {
2044 const onRender = jest.fn();
2045 let parentInstance = null;
2046
@@ -2091,12 +2079,12 @@ describe('Profiler', () => {
2079 timestamp: mockNow(),
2080 };
2081
2094 - SchedulerTracking.unstable_track(interaction.name, mockNow(), () => {
2082 + SchedulerTracing.unstable_trace(interaction.name, mockNow(), () => {
2083 parentInstance.setState({count: 1});
2084 });
2085
2098 - expect(onInteractionTracked).toHaveBeenCalledTimes(1);
2099 - expect(onInteractionTracked).toHaveBeenLastNotifiedOfInteraction(
2086 + expect(onInteractionTraced).toHaveBeenCalledTimes(1);
2087 + expect(onInteractionTraced).toHaveBeenLastNotifiedOfInteraction(
2088 interaction,
2089 );
2090 expect(onInteractionScheduledWorkCompleted).not.toHaveBeenCalled();
@@ -2109,10 +2097,10 @@ describe('Profiler', () => {
2097 let call = onRender.mock.calls[0];
2098 expect(call[0]).toEqual('test-profiler');
2099 expect(call[6]).toMatchInteractions(
2112 - ReactFeatureFlags.enableSchedulerTracking ? [interaction] : [],
2100 + ReactFeatureFlags.enableSchedulerTracing ? [interaction] : [],
2101 );
2102
2115 - expect(onInteractionTracked).toHaveBeenCalledTimes(1);
2103 + expect(onInteractionTraced).toHaveBeenCalledTimes(1);
2104 expect(onInteractionScheduledWorkCompleted).toHaveBeenCalledTimes(1);
2105 expect(
2106 onInteractionScheduledWorkCompleted,
@@ -2127,19 +2115,19 @@ describe('Profiler', () => {
2115 ]);
2116 });
2117
2130 - it('tracks both the temporary placeholder and the finished render for an interaction', async () => {
2118 + it('traces both the temporary placeholder and the finished render for an interaction', async () => {
2119 jest.resetModules();
2120
2121 loadModules({
2122 useNoopRenderer: true,
2123 enableSuspense: true,
2136 - enableSchedulerTracking: true,
2124 + enableSchedulerTracing: true,
2125 });
2126
2127 // Re-register since we've reloaded modules
2140 - SchedulerTracking.unstable_subscribe({
2128 + SchedulerTracing.unstable_subscribe({
2129 onInteractionScheduledWorkCompleted,
2142 - onInteractionTracked,
2130 + onInteractionTraced,
2131 onWorkCanceled,
2132 onWorkScheduled,
2133 onWorkStarted,
@@ -2204,7 +2192,7 @@ describe('Profiler', () => {
2192 };
2193
2194 const onRender = jest.fn();
2207 - SchedulerTracking.unstable_track(interaction.name, mockNow(), () => {
2195 + SchedulerTracing.unstable_trace(interaction.name, mockNow(), () => {
2196 ReactNoop.render(
2197 <React.unstable_Profiler id="test-profiler" onRender={onRender}>
2198 <React.Placeholder fallback={<Text text="Loading..." />}>
@@ -2215,8 +2203,8 @@ describe('Profiler', () => {
2203 );
2204 });
2205
2218 - expect(onInteractionTracked).toHaveBeenCalledTimes(1);
2219 - expect(onInteractionTracked).toHaveBeenLastNotifiedOfInteraction(
2206 + expect(onInteractionTraced).toHaveBeenCalledTimes(1);
2207 + expect(onInteractionTraced).toHaveBeenLastNotifiedOfInteraction(
2208 interaction,
2209 );
2210 expect(onInteractionScheduledWorkCompleted).not.toHaveBeenCalled();
@@ -2249,10 +2237,10 @@ describe('Profiler', () => {
2237 let call = onRender.mock.calls[0];
2238 expect(call[0]).toEqual('test-profiler');
2239 expect(call[6]).toMatchInteractions(
2252 - ReactFeatureFlags.enableSchedulerTracking ? [interaction] : [],
2240 + ReactFeatureFlags.enableSchedulerTracing ? [interaction] : [],
2241 );
2242
2255 - expect(onInteractionTracked).toHaveBeenCalledTimes(1);
2243 + expect(onInteractionTraced).toHaveBeenCalledTimes(1);
2244 expect(onInteractionScheduledWorkCompleted).not.toHaveBeenCalled();
2245
2246 // Once the promise resolves, we render the suspended view
@@ -2264,10 +2252,10 @@ describe('Profiler', () => {
2252 call = onRender.mock.calls[1];
2253 expect(call[0]).toEqual('test-profiler');
2254 expect(call[6]).toMatchInteractions(
2267 - ReactFeatureFlags.enableSchedulerTracking ? [interaction] : [],
2255 + ReactFeatureFlags.enableSchedulerTracing ? [interaction] : [],
2256 );
2257
2270 - expect(onInteractionTracked).toHaveBeenCalledTimes(1);
2258 + expect(onInteractionTraced).toHaveBeenCalledTimes(1);
2259 expect(onInteractionScheduledWorkCompleted).toHaveBeenCalledTimes(1);
2260 expect(
2261 onInteractionScheduledWorkCompleted,
packages/react/src/__tests__/ReactProfilerDevToolsIntegration-test.internal.js
+5 -5
@@ -14,7 +14,7 @@ describe('ReactProfiler DevTools integration', () => {
14 let React;
15 let ReactFeatureFlags;
16 let ReactTestRenderer;
17 - let SchedulerTracking;
17 + let SchedulerTracing;
18 let AdvanceTime;
19 let advanceTimeBy;
20 let hook;
@@ -38,8 +38,8 @@ describe('ReactProfiler DevTools integration', () => {
38
39 ReactFeatureFlags = require('shared/ReactFeatureFlags');
40 ReactFeatureFlags.enableProfilerTimer = true;
41 - ReactFeatureFlags.enableSchedulerTracking = true;
42 - SchedulerTracking = require('schedule/tracking');
41 + ReactFeatureFlags.enableSchedulerTracing = true;
42 + SchedulerTracing = require('schedule/tracing');
43 React = require('react');
44 ReactTestRenderer = require('react-test-renderer');
45
@@ -168,7 +168,7 @@ describe('ReactProfiler DevTools integration', () => {
168 ).toBe(7);
169 });
170
171 - it('should store tracked interactions on the HostNode so DevTools can access them', () => {
171 + it('should store traced interactions on the HostNode so DevTools can access them', () => {
172 // Render without an interaction
173 const rendered = ReactTestRenderer.create(<div />);
174
@@ -180,7 +180,7 @@ describe('ReactProfiler DevTools integration', () => {
180 const eventTime = mockNow();
181
182 // Render with an interaction
183 - SchedulerTracking.unstable_track('some event', eventTime, () => {
183 + SchedulerTracing.unstable_trace('some event', eventTime, () => {
184 rendered.update(<div />);
185 });
186
packages/react/src/__tests__/__snapshots__/ReactProfiler-test.internal.js.snap
+16 -16
@@ -1,6 +1,6 @@
1 // Jest Snapshot v1, https://goo.gl/fbAQLP
2
3 -exports[`Profiler works in profiling and non-profiling bundles enableSchedulerTracking:disabled enableProfilerTimer:disabled should render children 1`] = `
3 +exports[`Profiler works in profiling and non-profiling bundles enableSchedulerTracing:disabled enableProfilerTimer:disabled should render children 1`] = `
4 <div>
5 <span>
6 outside span
@@ -14,11 +14,11 @@ exports[`Profiler works in profiling and non-profiling bundles enableSchedulerTr
14 </div>
15 `;
16
17 -exports[`Profiler works in profiling and non-profiling bundles enableSchedulerTracking:disabled enableProfilerTimer:disabled should support an empty Profiler (with no children) 1`] = `null`;
17 +exports[`Profiler works in profiling and non-profiling bundles enableSchedulerTracing:disabled enableProfilerTimer:disabled should support an empty Profiler (with no children) 1`] = `null`;
18
19 -exports[`Profiler works in profiling and non-profiling bundles enableSchedulerTracking:disabled enableProfilerTimer:disabled should support an empty Profiler (with no children) 2`] = `<div />`;
19 +exports[`Profiler works in profiling and non-profiling bundles enableSchedulerTracing:disabled enableProfilerTimer:disabled should support an empty Profiler (with no children) 2`] = `<div />`;
20
21 -exports[`Profiler works in profiling and non-profiling bundles enableSchedulerTracking:disabled enableProfilerTimer:disabled should support nested Profilers 1`] = `
21 +exports[`Profiler works in profiling and non-profiling bundles enableSchedulerTracing:disabled enableProfilerTimer:disabled should support nested Profilers 1`] = `
22 Array [
23 <div>
24 outer functional component
@@ -32,7 +32,7 @@ Array [
32 ]
33 `;
34
35 -exports[`Profiler works in profiling and non-profiling bundles enableSchedulerTracking:disabled enableProfilerTimer:enabled should render children 1`] = `
35 +exports[`Profiler works in profiling and non-profiling bundles enableSchedulerTracing:disabled enableProfilerTimer:enabled should render children 1`] = `
36 <div>
37 <span>
38 outside span
@@ -46,11 +46,11 @@ exports[`Profiler works in profiling and non-profiling bundles enableSchedulerTr
46 </div>
47 `;
48
49 -exports[`Profiler works in profiling and non-profiling bundles enableSchedulerTracking:disabled enableProfilerTimer:enabled should support an empty Profiler (with no children) 1`] = `null`;
49 +exports[`Profiler works in profiling and non-profiling bundles enableSchedulerTracing:disabled enableProfilerTimer:enabled should support an empty Profiler (with no children) 1`] = `null`;
50
51 -exports[`Profiler works in profiling and non-profiling bundles enableSchedulerTracking:disabled enableProfilerTimer:enabled should support an empty Profiler (with no children) 2`] = `<div />`;
51 +exports[`Profiler works in profiling and non-profiling bundles enableSchedulerTracing:disabled enableProfilerTimer:enabled should support an empty Profiler (with no children) 2`] = `<div />`;
52
53 -exports[`Profiler works in profiling and non-profiling bundles enableSchedulerTracking:disabled enableProfilerTimer:enabled should support nested Profilers 1`] = `
53 +exports[`Profiler works in profiling and non-profiling bundles enableSchedulerTracing:disabled enableProfilerTimer:enabled should support nested Profilers 1`] = `
54 Array [
55 <div>
56 outer functional component
@@ -64,7 +64,7 @@ Array [
64 ]
65 `;
66
67 -exports[`Profiler works in profiling and non-profiling bundles enableSchedulerTracking:enabled enableProfilerTimer:disabled should render children 1`] = `
67 +exports[`Profiler works in profiling and non-profiling bundles enableSchedulerTracing:enabled enableProfilerTimer:disabled should render children 1`] = `
68 <div>
69 <span>
70 outside span
@@ -78,11 +78,11 @@ exports[`Profiler works in profiling and non-profiling bundles enableSchedulerTr
78 </div>
79 `;
80
81 -exports[`Profiler works in profiling and non-profiling bundles enableSchedulerTracking:enabled enableProfilerTimer:disabled should support an empty Profiler (with no children) 1`] = `null`;
81 +exports[`Profiler works in profiling and non-profiling bundles enableSchedulerTracing:enabled enableProfilerTimer:disabled should support an empty Profiler (with no children) 1`] = `null`;
82
83 -exports[`Profiler works in profiling and non-profiling bundles enableSchedulerTracking:enabled enableProfilerTimer:disabled should support an empty Profiler (with no children) 2`] = `<div />`;
83 +exports[`Profiler works in profiling and non-profiling bundles enableSchedulerTracing:enabled enableProfilerTimer:disabled should support an empty Profiler (with no children) 2`] = `<div />`;
84
85 -exports[`Profiler works in profiling and non-profiling bundles enableSchedulerTracking:enabled enableProfilerTimer:disabled should support nested Profilers 1`] = `
85 +exports[`Profiler works in profiling and non-profiling bundles enableSchedulerTracing:enabled enableProfilerTimer:disabled should support nested Profilers 1`] = `
86 Array [
87 <div>
88 outer functional component
@@ -96,7 +96,7 @@ Array [
96 ]
97 `;
98
99 -exports[`Profiler works in profiling and non-profiling bundles enableSchedulerTracking:enabled enableProfilerTimer:enabled should render children 1`] = `
99 +exports[`Profiler works in profiling and non-profiling bundles enableSchedulerTracing:enabled enableProfilerTimer:enabled should render children 1`] = `
100 <div>
101 <span>
102 outside span
@@ -110,11 +110,11 @@ exports[`Profiler works in profiling and non-profiling bundles enableSchedulerTr
110 </div>
111 `;
112
113 -exports[`Profiler works in profiling and non-profiling bundles enableSchedulerTracking:enabled enableProfilerTimer:enabled should support an empty Profiler (with no children) 1`] = `null`;
113 +exports[`Profiler works in profiling and non-profiling bundles enableSchedulerTracing:enabled enableProfilerTimer:enabled should support an empty Profiler (with no children) 1`] = `null`;
114
115 -exports[`Profiler works in profiling and non-profiling bundles enableSchedulerTracking:enabled enableProfilerTimer:enabled should support an empty Profiler (with no children) 2`] = `<div />`;
115 +exports[`Profiler works in profiling and non-profiling bundles enableSchedulerTracing:enabled enableProfilerTimer:enabled should support an empty Profiler (with no children) 2`] = `<div />`;
116
117 -exports[`Profiler works in profiling and non-profiling bundles enableSchedulerTracking:enabled enableProfilerTimer:enabled should support nested Profilers 1`] = `
117 +exports[`Profiler works in profiling and non-profiling bundles enableSchedulerTracing:enabled enableProfilerTimer:enabled should support nested Profilers 1`] = `
118 Array [
119 <div>
120 outer functional component
packages/schedule/npm/tracing-profiling.js new
+7
@@ -0,0 +1,7 @@
1 +'use strict';
2 +
3 +if (process.env.NODE_ENV === 'production') {
4 + module.exports = require('./cjs/schedule-tracing.profiling.min.js');
5 +} else {
6 + module.exports = require('./cjs/schedule-tracing.development.js');
7 +}
packages/schedule/npm/tracing.js new
+7
@@ -0,0 +1,7 @@
1 +'use strict';
2 +
3 +if (process.env.NODE_ENV === 'production') {
4 + module.exports = require('./cjs/schedule-tracing.production.min.js');
5 +} else {
6 + module.exports = require('./cjs/schedule-tracing.development.js');
7 +}
packages/schedule/npm/tracking-profiling.js deleted
-7
@@ -1,7 +0,0 @@
1 -'use strict';
2 -
3 -if (process.env.NODE_ENV === 'production') {
4 - module.exports = require('./cjs/schedule-tracking.profiling.min.js');
5 -} else {
6 - module.exports = require('./cjs/schedule-tracking.development.js');
7 -}
packages/schedule/npm/tracking.js deleted
-7
@@ -1,7 +0,0 @@
1 -'use strict';
2 -
3 -if (process.env.NODE_ENV === 'production') {
4 - module.exports = require('./cjs/schedule-tracking.production.min.js');
5 -} else {
6 - module.exports = require('./cjs/schedule-tracking.development.js');
7 -}
packages/schedule/npm/umd/schedule-tracing.development.js renamed
+10 -10
@@ -14,24 +14,24 @@
14 ? (module.exports = factory(require('react')))
15 : typeof define === 'function' && define.amd // eslint-disable-line no-undef
16 ? define(['react'], factory) // eslint-disable-line no-undef
17 - : (global.ScheduleTracking = factory(global));
17 + : (global.ScheduleTracing = factory(global));
18 })(this, function(global) {
19 function unstable_clear() {
20 - return global.React.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ScheduleTracking.unstable_clear.apply(
20 + return global.React.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ScheduleTracing.unstable_clear.apply(
21 this,
22 arguments
23 );
24 }
25
26 function unstable_getCurrent() {
27 - return global.React.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ScheduleTracking.unstable_getCurrent.apply(
27 + return global.React.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ScheduleTracing.unstable_getCurrent.apply(
28 this,
29 arguments
30 );
31 }
32
33 function unstable_getThreadID() {
34 - return global.React.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ScheduleTracking.unstable_getThreadID.apply(
34 + return global.React.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ScheduleTracing.unstable_getThreadID.apply(
35 this,
36 arguments
37 );
@@ -39,14 +39,14 @@
39
40 function unstable_subscribe() {
41 // eslint-disable-next-line max-len
42 - return global.React.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ScheduleTracking.unstable_subscribe.apply(
42 + return global.React.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ScheduleTracing.unstable_subscribe.apply(
43 this,
44 arguments
45 );
46 }
47
48 - function unstable_track() {
49 - return global.React.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ScheduleTracking.unstable_track.apply(
48 + function unstable_trace() {
49 + return global.React.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ScheduleTracing.unstable_trace.apply(
50 this,
51 arguments
52 );
@@ -54,14 +54,14 @@
54
55 function unstable_unsubscribe() {
56 // eslint-disable-next-line max-len
57 - return global.React.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ScheduleTracking.unstable_unsubscribe.apply(
57 + return global.React.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ScheduleTracing.unstable_unsubscribe.apply(
58 this,
59 arguments
60 );
61 }
62
63 function unstable_wrap() {
64 - return global.React.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ScheduleTracking.unstable_wrap.apply(
64 + return global.React.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ScheduleTracing.unstable_wrap.apply(
65 this,
66 arguments
67 );
@@ -72,7 +72,7 @@
72 unstable_getCurrent: unstable_getCurrent,
73 unstable_getThreadID: unstable_getThreadID,
74 unstable_subscribe: unstable_subscribe,
75 - unstable_track: unstable_track,
75 + unstable_trace: unstable_trace,
76 unstable_unsubscribe: unstable_unsubscribe,
77 unstable_wrap: unstable_wrap,
78 });
packages/schedule/npm/umd/schedule-tracing.production.min.js renamed
+10 -10
@@ -14,24 +14,24 @@
14 ? (module.exports = factory(require('react')))
15 : typeof define === 'function' && define.amd // eslint-disable-line no-undef
16 ? define(['react'], factory) // eslint-disable-line no-undef
17 - : (global.ScheduleTracking = factory(global));
17 + : (global.ScheduleTracing = factory(global));
18 })(this, function(global) {
19 function unstable_clear() {
20 - return global.React.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ScheduleTracking.unstable_clear.apply(
20 + return global.React.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ScheduleTracing.unstable_clear.apply(
21 this,
22 arguments
23 );
24 }
25
26 function unstable_getCurrent() {
27 - return global.React.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ScheduleTracking.unstable_getCurrent.apply(
27 + return global.React.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ScheduleTracing.unstable_getCurrent.apply(
28 this,
29 arguments
30 );
31 }
32
33 function unstable_getThreadID() {
34 - return global.React.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ScheduleTracking.unstable_getThreadID.apply(
34 + return global.React.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ScheduleTracing.unstable_getThreadID.apply(
35 this,
36 arguments
37 );
@@ -39,14 +39,14 @@
39
40 function unstable_subscribe() {
41 // eslint-disable-next-line max-len
42 - return global.React.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ScheduleTracking.unstable_subscribe.apply(
42 + return global.React.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ScheduleTracing.unstable_subscribe.apply(
43 this,
44 arguments
45 );
46 }
47
48 - function unstable_track() {
49 - return global.React.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ScheduleTracking.unstable_track.apply(
48 + function unstable_trace() {
49 + return global.React.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ScheduleTracing.unstable_trace.apply(
50 this,
51 arguments
52 );
@@ -54,14 +54,14 @@
54
55 function unstable_unsubscribe() {
56 // eslint-disable-next-line max-len
57 - return global.React.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ScheduleTracking.unstable_unsubscribe.apply(
57 + return global.React.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ScheduleTracing.unstable_unsubscribe.apply(
58 this,
59 arguments
60 );
61 }
62
63 function unstable_wrap() {
64 - return global.React.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ScheduleTracking.unstable_wrap.apply(
64 + return global.React.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ScheduleTracing.unstable_wrap.apply(
65 this,
66 arguments
67 );
@@ -72,7 +72,7 @@
72 unstable_getCurrent: unstable_getCurrent,
73 unstable_getThreadID: unstable_getThreadID,
74 unstable_subscribe: unstable_subscribe,
75 - unstable_track: unstable_track,
75 + unstable_trace: unstable_trace,
76 unstable_unsubscribe: unstable_unsubscribe,
77 unstable_wrap: unstable_wrap,
78 });
packages/schedule/package.json
+2 -2
@@ -19,8 +19,8 @@
19 "LICENSE",
20 "README.md",
21 "index.js",
22 - "tracking.js",
23 - "tracking-profiling.js",
22 + "tracing.js",
23 + "tracing-profiling.js",
24 "cjs/",
25 "umd/"
26 ]
packages/schedule/src/Tracing.js renamed
+13 -13
@@ -7,7 +7,7 @@
7 * @flow
8 */
9
10 -import {enableSchedulerTracking} from 'shared/ReactFeatureFlags';
10 +import {enableSchedulerTracing} from 'shared/ReactFeatureFlags';
11
12 export type Interaction = {|
13 __count: number,
@@ -17,8 +17,8 @@ export type Interaction = {|
17 |};
18
19 export type Subscriber = {
20 - // A new interaction has been created via the track() method.
21 - onInteractionTracked: (interaction: Interaction) => void,
20 + // A new interaction has been created via the trace() method.
21 + onInteractionTraced: (interaction: Interaction) => void,
22
23 // All scheduled async work for an interaction has finished.
24 onInteractionScheduledWorkCompleted: (interaction: Interaction) => void,
@@ -61,16 +61,16 @@ const DEFAULT_THREAD_ID = 0;
61 let interactionIDCounter: number = 0;
62 let threadIDCounter: number = 0;
63
64 -// Set of currently tracked interactions.
64 +// Set of currently traced interactions.
65 // Interactions "stack"–
66 -// Meaning that newly tracked interactions are appended to the previously active set.
66 +// Meaning that newly traced interactions are appended to the previously active set.
67 // When an interaction goes out of scope, the previous set (if any) is restored.
68 let interactionsRef: InteractionsRef = (null: any);
69
70 // Listener(s) to notify when interactions begin and end.
71 let subscriberRef: SubscriberRef = (null: any);
72
73 -if (enableSchedulerTracking) {
73 +if (enableSchedulerTracing) {
74 interactionsRef = {
75 current: new Set(),
76 };
@@ -82,7 +82,7 @@ if (enableSchedulerTracking) {
82 export {interactionsRef as __interactionsRef, subscriberRef as __subscriberRef};
83
84 export function unstable_clear(callback: Function): any {
85 - if (!enableSchedulerTracking) {
85 + if (!enableSchedulerTracing) {
86 return callback();
87 }
88
@@ -97,7 +97,7 @@ export function unstable_clear(callback: Function): any {
97 }
98
99 export function unstable_getCurrent(): Set<Interaction> | null {
100 - if (!enableSchedulerTracking) {
100 + if (!enableSchedulerTracing) {
101 return null;
102 } else {
103 return interactionsRef.current;
@@ -108,13 +108,13 @@ export function unstable_getThreadID(): number {
108 return ++threadIDCounter;
109 }
110
111 -export function unstable_track(
111 +export function unstable_trace(
112 name: string,
113 timestamp: number,
114 callback: Function,
115 threadID: number = DEFAULT_THREAD_ID,
116 ): any {
117 - if (!enableSchedulerTracking) {
117 + if (!enableSchedulerTracing) {
118 return callback();
119 }
120
@@ -127,7 +127,7 @@ export function unstable_track(
127
128 const prevInteractions = interactionsRef.current;
129
130 - // Tracked interactions should stack/accumulate.
130 + // Traced interactions should stack/accumulate.
131 // To do that, clone the current interactions.
132 // The previous set will be restored upon completion.
133 const interactions = new Set(prevInteractions);
@@ -139,7 +139,7 @@ export function unstable_track(
139
140 try {
141 if (subscriber !== null) {
142 - subscriber.onInteractionTracked(interaction);
142 + subscriber.onInteractionTraced(interaction);
143 }
144 } finally {
145 try {
@@ -176,7 +176,7 @@ export function unstable_wrap(
176 callback: Function,
177 threadID: number = DEFAULT_THREAD_ID,
178 ): Function {
179 - if (!enableSchedulerTracking) {
179 + if (!enableSchedulerTracing) {
180 return callback;
181 }
182
packages/schedule/src/TracingSubscriptions.js renamed
+9 -9
@@ -7,24 +7,24 @@
7 * @flow
8 */
9
10 -import type {Interaction, Subscriber} from './Tracking';
10 +import type {Interaction, Subscriber} from './Tracing';
11
12 -import {enableSchedulerTracking} from 'shared/ReactFeatureFlags';
13 -import {__subscriberRef} from 'schedule/tracking';
12 +import {enableSchedulerTracing} from 'shared/ReactFeatureFlags';
13 +import {__subscriberRef} from 'schedule/tracing';
14
15 let subscribers: Set<Subscriber> = (null: any);
16 -if (enableSchedulerTracking) {
16 +if (enableSchedulerTracing) {
17 subscribers = new Set();
18 }
19
20 export function unstable_subscribe(subscriber: Subscriber): void {
21 - if (enableSchedulerTracking) {
21 + if (enableSchedulerTracing) {
22 subscribers.add(subscriber);
23
24 if (subscribers.size === 1) {
25 __subscriberRef.current = {
26 onInteractionScheduledWorkCompleted,
27 - onInteractionTracked,
27 + onInteractionTraced,
28 onWorkCanceled,
29 onWorkScheduled,
30 onWorkStarted,
@@ -35,7 +35,7 @@ export function unstable_subscribe(subscriber: Subscriber): void {
35 }
36
37 export function unstable_unsubscribe(subscriber: Subscriber): void {
38 - if (enableSchedulerTracking) {
38 + if (enableSchedulerTracing) {
39 subscribers.delete(subscriber);
40
41 if (subscribers.size === 0) {
@@ -44,13 +44,13 @@ export function unstable_unsubscribe(subscriber: Subscriber): void {
44 }
45 }
46
47 -function onInteractionTracked(interaction: Interaction): void {
47 +function onInteractionTraced(interaction: Interaction): void {
48 let didCatchError = false;
49 let caughtError = null;
50
51 subscribers.forEach(subscriber => {
52 try {
53 - subscriber.onInteractionTracked(interaction);
53 + subscriber.onInteractionTraced(interaction);
54 } catch (error) {
55 if (!didCatchError) {
56 didCatchError = true;
packages/schedule/src/__tests__/ScheduleUMDBundle-test.internal.js
+5 -5
@@ -41,15 +41,15 @@ describe('Scheduling UMD bundle', () => {
41 validateForwardedAPIs(api, [umdAPIDev, umdAPIProd, secretAPI.Schedule]);
42 });
43
44 - it('should define the same tracking API', () => {
45 - const api = require('../../tracking');
46 - const umdAPIDev = require('../../npm/umd/schedule-tracking.development');
47 - const umdAPIProd = require('../../npm/umd/schedule-tracking.production.min');
44 + it('should define the same tracing API', () => {
45 + const api = require('../../tracing');
46 + const umdAPIDev = require('../../npm/umd/schedule-tracing.development');
47 + const umdAPIProd = require('../../npm/umd/schedule-tracing.production.min');
48 const secretAPI = require('react/src/ReactSharedInternals').default;
49 validateForwardedAPIs(api, [
50 umdAPIDev,
51 umdAPIProd,
52 - secretAPI.ScheduleTracking,
52 + secretAPI.ScheduleTracing,
53 ]);
54 });
55 });
packages/schedule/src/__tests__/Tracing-test.internal.js new
+375
@@ -0,0 +1,375 @@
1 +/**
2 + * Copyright (c) Facebook, Inc. and its affiliates.
3 + *
4 + * This source code is licensed under the MIT license found in the
5 + * LICENSE file in the root directory of this source tree.
6 + *
7 + * @jest-environment node
8 + */
9 +'use strict';
10 +
11 +describe('Tracing', () => {
12 + let SchedulerTracing;
13 + let ReactFeatureFlags;
14 +
15 + let advanceTimeBy;
16 + let currentTime;
17 +
18 + function loadModules({enableSchedulerTracing}) {
19 + jest.resetModules();
20 + jest.useFakeTimers();
21 +
22 + currentTime = 0;
23 + Date.now = jest.fn().mockImplementation(() => currentTime);
24 +
25 + advanceTimeBy = amount => {
26 + currentTime += amount;
27 + };
28 +
29 + ReactFeatureFlags = require('shared/ReactFeatureFlags');
30 + ReactFeatureFlags.enableSchedulerTracing = enableSchedulerTracing;
31 +
32 + SchedulerTracing = require('schedule/tracing');
33 + }
34 +
35 + describe('enableSchedulerTracing enabled', () => {
36 + beforeEach(() => loadModules({enableSchedulerTracing: true}));
37 +
38 + it('should return the value of a traced function', () => {
39 + expect(
40 + SchedulerTracing.unstable_trace('arbitrary', currentTime, () => 123),
41 + ).toBe(123);
42 + });
43 +
44 + it('should return the value of a clear function', () => {
45 + expect(SchedulerTracing.unstable_clear(() => 123)).toBe(123);
46 + });
47 +
48 + it('should return the value of a wrapped function', () => {
49 + let wrapped;
50 + SchedulerTracing.unstable_trace('arbitrary', currentTime, () => {
51 + wrapped = SchedulerTracing.unstable_wrap(() => 123);
52 + });
53 + expect(wrapped()).toBe(123);
54 + });
55 +
56 + it('should pass arguments through to a wrapped function', done => {
57 + let wrapped;
58 + SchedulerTracing.unstable_trace('arbitrary', currentTime, () => {
59 + wrapped = SchedulerTracing.unstable_wrap((param1, param2) => {
60 + expect(param1).toBe('foo');
61 + expect(param2).toBe('bar');
62 + done();
63 + });
64 + });
65 + wrapped('foo', 'bar');
66 + });
67 +
68 + it('should return an empty set when outside of a traced event', () => {
69 + expect(SchedulerTracing.unstable_getCurrent()).toContainNoInteractions();
70 + });
71 +
72 + it('should report the traced interaction from within the trace callback', done => {
73 + advanceTimeBy(100);
74 +
75 + SchedulerTracing.unstable_trace('some event', currentTime, () => {
76 + const interactions = SchedulerTracing.unstable_getCurrent();
77 + expect(interactions).toMatchInteractions([
78 + {name: 'some event', timestamp: 100},
79 + ]);
80 +
81 + done();
82 + });
83 + });
84 +
85 + it('should report the traced interaction from within wrapped callbacks', done => {
86 + let wrappedIndirection;
87 +
88 + function indirection() {
89 + const interactions = SchedulerTracing.unstable_getCurrent();
90 + expect(interactions).toMatchInteractions([
91 + {name: 'some event', timestamp: 100},
92 + ]);
93 +
94 + done();
95 + }
96 +
97 + advanceTimeBy(100);
98 +
99 + SchedulerTracing.unstable_trace('some event', currentTime, () => {
100 + wrappedIndirection = SchedulerTracing.unstable_wrap(indirection);
101 + });
102 +
103 + advanceTimeBy(50);
104 +
105 + wrappedIndirection();
106 + });
107 +
108 + it('should clear the interaction stack for traced callbacks', () => {
109 + let innerTestReached = false;
110 +
111 + SchedulerTracing.unstable_trace('outer event', currentTime, () => {
112 + expect(SchedulerTracing.unstable_getCurrent()).toMatchInteractions([
113 + {name: 'outer event'},
114 + ]);
115 +
116 + SchedulerTracing.unstable_clear(() => {
117 + expect(SchedulerTracing.unstable_getCurrent()).toMatchInteractions(
118 + [],
119 + );
120 +
121 + SchedulerTracing.unstable_trace('inner event', currentTime, () => {
122 + expect(SchedulerTracing.unstable_getCurrent()).toMatchInteractions([
123 + {name: 'inner event'},
124 + ]);
125 +
126 + innerTestReached = true;
127 + });
128 + });
129 +
130 + expect(SchedulerTracing.unstable_getCurrent()).toMatchInteractions([
131 + {name: 'outer event'},
132 + ]);
133 + });
134 +
135 + expect(innerTestReached).toBe(true);
136 + });
137 +
138 + it('should clear the interaction stack for wrapped callbacks', () => {
139 + let innerTestReached = false;
140 + let wrappedIndirection;
141 +
142 + const indirection = jest.fn(() => {
143 + expect(SchedulerTracing.unstable_getCurrent()).toMatchInteractions([
144 + {name: 'outer event'},
145 + ]);
146 +
147 + SchedulerTracing.unstable_clear(() => {
148 + expect(SchedulerTracing.unstable_getCurrent()).toMatchInteractions(
149 + [],
150 + );
151 +
152 + SchedulerTracing.unstable_trace('inner event', currentTime, () => {
153 + expect(SchedulerTracing.unstable_getCurrent()).toMatchInteractions([
154 + {name: 'inner event'},
155 + ]);
156 +
157 + innerTestReached = true;
158 + });
159 + });
160 +
161 + expect(SchedulerTracing.unstable_getCurrent()).toMatchInteractions([
162 + {name: 'outer event'},
163 + ]);
164 + });
165 +
166 + SchedulerTracing.unstable_trace('outer event', currentTime, () => {
167 + wrappedIndirection = SchedulerTracing.unstable_wrap(indirection);
168 + });
169 +
170 + wrappedIndirection();
171 +
172 + expect(innerTestReached).toBe(true);
173 + });
174 +
175 + it('should support nested traced events', done => {
176 + advanceTimeBy(100);
177 +
178 + let innerIndirectionTraced = false;
179 + let outerIndirectionTraced = false;
180 +
181 + function innerIndirection() {
182 + const interactions = SchedulerTracing.unstable_getCurrent();
183 + expect(interactions).toMatchInteractions([
184 + {name: 'outer event', timestamp: 100},
185 + {name: 'inner event', timestamp: 150},
186 + ]);
187 +
188 + innerIndirectionTraced = true;
189 + }
190 +
191 + function outerIndirection() {
192 + const interactions = SchedulerTracing.unstable_getCurrent();
193 + expect(interactions).toMatchInteractions([
194 + {name: 'outer event', timestamp: 100},
195 + ]);
196 +
197 + outerIndirectionTraced = true;
198 + }
199 +
200 + SchedulerTracing.unstable_trace('outer event', currentTime, () => {
201 + // Verify the current traced event
202 + let interactions = SchedulerTracing.unstable_getCurrent();
203 + expect(interactions).toMatchInteractions([
204 + {name: 'outer event', timestamp: 100},
205 + ]);
206 +
207 + advanceTimeBy(50);
208 +
209 + const wrapperOuterIndirection = SchedulerTracing.unstable_wrap(
210 + outerIndirection,
211 + );
212 +
213 + let wrapperInnerIndirection;
214 + let innerEventTraced = false;
215 +
216 + // Verify that a nested event is properly traced
217 + SchedulerTracing.unstable_trace('inner event', currentTime, () => {
218 + interactions = SchedulerTracing.unstable_getCurrent();
219 + expect(interactions).toMatchInteractions([
220 + {name: 'outer event', timestamp: 100},
221 + {name: 'inner event', timestamp: 150},
222 + ]);
223 +
224 + // Verify that a wrapped outer callback is properly traced
225 + wrapperOuterIndirection();
226 + expect(outerIndirectionTraced).toBe(true);
227 +
228 + wrapperInnerIndirection = SchedulerTracing.unstable_wrap(
229 + innerIndirection,
230 + );
231 +
232 + innerEventTraced = true;
233 + });
234 +
235 + expect(innerEventTraced).toBe(true);
236 +
237 + // Verify that the original event is restored
238 + interactions = SchedulerTracing.unstable_getCurrent();
239 + expect(interactions).toMatchInteractions([
240 + {name: 'outer event', timestamp: 100},
241 + ]);
242 +
243 + // Verify that a wrapped nested callback is properly traced
244 + wrapperInnerIndirection();
245 + expect(innerIndirectionTraced).toBe(true);
246 +
247 + done();
248 + });
249 + });
250 +
251 + describe('error handling', () => {
252 + it('should reset state appropriately when an error occurs in a trace callback', done => {
253 + advanceTimeBy(100);
254 +
255 + SchedulerTracing.unstable_trace('outer event', currentTime, () => {
256 + expect(() => {
257 + SchedulerTracing.unstable_trace('inner event', currentTime, () => {
258 + throw Error('intentional');
259 + });
260 + }).toThrow();
261 +
262 + expect(SchedulerTracing.unstable_getCurrent()).toMatchInteractions([
263 + {name: 'outer event', timestamp: 100},
264 + ]);
265 +
266 + done();
267 + });
268 + });
269 +
270 + it('should reset state appropriately when an error occurs in a wrapped callback', done => {
271 + advanceTimeBy(100);
272 +
273 + SchedulerTracing.unstable_trace('outer event', currentTime, () => {
274 + let wrappedCallback;
275 +
276 + SchedulerTracing.unstable_trace('inner event', currentTime, () => {
277 + wrappedCallback = SchedulerTracing.unstable_wrap(() => {
278 + throw Error('intentional');
279 + });
280 + });
281 +
282 + expect(wrappedCallback).toThrow();
283 +
284 + expect(SchedulerTracing.unstable_getCurrent()).toMatchInteractions([
285 + {name: 'outer event', timestamp: 100},
286 + ]);
287 +
288 + done();
289 + });
290 + });
291 + });
292 +
293 + describe('advanced integration', () => {
294 + it('should return a unique threadID per request', () => {
295 + expect(SchedulerTracing.unstable_getThreadID()).not.toBe(
296 + SchedulerTracing.unstable_getThreadID(),
297 + );
298 + });
299 +
300 + it('should expose the current set of interactions to be externally manipulated', () => {
301 + SchedulerTracing.unstable_trace('outer event', currentTime, () => {
302 + expect(SchedulerTracing.__interactionsRef.current).toBe(
303 + SchedulerTracing.unstable_getCurrent(),
304 + );
305 +
306 + SchedulerTracing.__interactionsRef.current = new Set([
307 + {name: 'override event'},
308 + ]);
309 +
310 + expect(SchedulerTracing.unstable_getCurrent()).toMatchInteractions([
311 + {name: 'override event'},
312 + ]);
313 + });
314 + });
315 +
316 + it('should expose a subscriber ref to be externally manipulated', () => {
317 + SchedulerTracing.unstable_trace('outer event', currentTime, () => {
318 + expect(SchedulerTracing.__subscriberRef).toEqual({
319 + current: null,
320 + });
321 + });
322 + });
323 + });
324 + });
325 +
326 + describe('enableSchedulerTracing disabled', () => {
327 + beforeEach(() => loadModules({enableSchedulerTracing: false}));
328 +
329 + it('should return the value of a traced function', () => {
330 + expect(
331 + SchedulerTracing.unstable_trace('arbitrary', currentTime, () => 123),
332 + ).toBe(123);
333 + });
334 +
335 + it('should return the value of a wrapped function', () => {
336 + let wrapped;
337 + SchedulerTracing.unstable_trace('arbitrary', currentTime, () => {
338 + wrapped = SchedulerTracing.unstable_wrap(() => 123);
339 + });
340 + expect(wrapped()).toBe(123);
341 + });
342 +
343 + it('should return null for traced interactions', () => {
344 + expect(SchedulerTracing.unstable_getCurrent()).toBe(null);
345 + });
346 +
347 + it('should execute traced callbacks', done => {
348 + SchedulerTracing.unstable_trace('some event', currentTime, () => {
349 + expect(SchedulerTracing.unstable_getCurrent()).toBe(null);
350 +
351 + done();
352 + });
353 + });
354 +
355 + it('should return the value of a clear function', () => {
356 + expect(SchedulerTracing.unstable_clear(() => 123)).toBe(123);
357 + });
358 +
359 + it('should execute wrapped callbacks', done => {
360 + const wrappedCallback = SchedulerTracing.unstable_wrap(() => {
361 + expect(SchedulerTracing.unstable_getCurrent()).toBe(null);
362 +
363 + done();
364 + });
365 +
366 + wrappedCallback();
367 + });
368 +
369 + describe('advanced integration', () => {
370 + it('should not create unnecessary objects', () => {
371 + expect(SchedulerTracing.__interactionsRef).toBe(null);
372 + });
373 + });
374 + });
375 +});
packages/schedule/src/__tests__/Tracing-test.js renamed
+11 -11
@@ -8,41 +8,41 @@
8 */
9 'use strict';
10
11 -describe('Tracking', () => {
12 - let SchedulerTracking;
11 +describe('Tracing', () => {
12 + let SchedulerTracing;
13
14 beforeEach(() => {
15 jest.resetModules();
16
17 - SchedulerTracking = require('schedule/tracking');
17 + SchedulerTracing = require('schedule/tracing');
18 });
19
20 - it('should return the value of a tracked function', () => {
21 - expect(SchedulerTracking.unstable_track('arbitrary', 0, () => 123)).toBe(
20 + it('should return the value of a traced function', () => {
21 + expect(SchedulerTracing.unstable_trace('arbitrary', 0, () => 123)).toBe(
22 123,
23 );
24 });
25
26 it('should return the value of a wrapped function', () => {
27 let wrapped;
28 - SchedulerTracking.unstable_track('arbitrary', 0, () => {
29 - wrapped = SchedulerTracking.unstable_wrap(() => 123);
28 + SchedulerTracing.unstable_trace('arbitrary', 0, () => {
29 + wrapped = SchedulerTracing.unstable_wrap(() => 123);
30 });
31 expect(wrapped()).toBe(123);
32 });
33
34 - it('should execute tracked callbacks', done => {
35 - SchedulerTracking.unstable_track('some event', 0, () => {
34 + it('should execute traced callbacks', done => {
35 + SchedulerTracing.unstable_trace('some event', 0, () => {
36 done();
37 });
38 });
39
40 it('should return the value of a clear function', () => {
41 - expect(SchedulerTracking.unstable_clear(() => 123)).toBe(123);
41 + expect(SchedulerTracing.unstable_clear(() => 123)).toBe(123);
42 });
43
44 it('should execute wrapped callbacks', done => {
45 - const wrappedCallback = SchedulerTracking.unstable_wrap(() => {
45 + const wrappedCallback = SchedulerTracing.unstable_wrap(() => {
46 done();
47 });
48
packages/schedule/src/__tests__/TracingSubscriptions-test.internal.js renamed
+113 -119
@@ -8,20 +8,20 @@
8 */
9 'use strict';
10
11 -describe('TrackingSubscriptions', () => {
12 - let SchedulerTracking;
11 +describe('TracingSubscriptions', () => {
12 + let SchedulerTracing;
13 let ReactFeatureFlags;
14
15 let currentTime;
16
17 let onInteractionScheduledWorkCompleted;
18 - let onInteractionTracked;
18 + let onInteractionTraced;
19 let onWorkCanceled;
20 let onWorkScheduled;
21 let onWorkStarted;
22 let onWorkStopped;
23 let throwInOnInteractionScheduledWorkCompleted;
24 - let throwInOnInteractionTracked;
24 + let throwInOnInteractionTraced;
25 let throwInOnWorkCanceled;
26 let throwInOnWorkScheduled;
27 let throwInOnWorkStarted;
@@ -33,19 +33,19 @@ describe('TrackingSubscriptions', () => {
33 const secondEvent = {id: 1, name: 'second', timestamp: 0};
34 const threadID = 123;
35
36 - function loadModules({enableSchedulerTracking, autoSubscribe = true}) {
36 + function loadModules({enableSchedulerTracing, autoSubscribe = true}) {
37 jest.resetModules();
38 jest.useFakeTimers();
39
40 currentTime = 0;
41
42 ReactFeatureFlags = require('shared/ReactFeatureFlags');
43 - ReactFeatureFlags.enableSchedulerTracking = enableSchedulerTracking;
43 + ReactFeatureFlags.enableSchedulerTracing = enableSchedulerTracing;
44
45 - SchedulerTracking = require('schedule/tracking');
45 + SchedulerTracing = require('schedule/tracing');
46
47 throwInOnInteractionScheduledWorkCompleted = false;
48 - throwInOnInteractionTracked = false;
48 + throwInOnInteractionTraced = false;
49 throwInOnWorkCanceled = false;
50 throwInOnWorkScheduled = false;
51 throwInOnWorkStarted = false;
@@ -56,9 +56,9 @@ describe('TrackingSubscriptions', () => {
56 throw Error('Expected error onInteractionScheduledWorkCompleted');
57 }
58 });
59 - onInteractionTracked = jest.fn(() => {
60 - if (throwInOnInteractionTracked) {
61 - throw Error('Expected error onInteractionTracked');
59 + onInteractionTraced = jest.fn(() => {
60 + if (throwInOnInteractionTraced) {
61 + throw Error('Expected error onInteractionTraced');
62 }
63 });
64 onWorkCanceled = jest.fn(() => {
@@ -84,7 +84,7 @@ describe('TrackingSubscriptions', () => {
84
85 firstSubscriber = {
86 onInteractionScheduledWorkCompleted,
87 - onInteractionTracked,
87 + onInteractionTraced,
88 onWorkCanceled,
89 onWorkScheduled,
90 onWorkStarted,
@@ -93,7 +93,7 @@ describe('TrackingSubscriptions', () => {
93
94 secondSubscriber = {
95 onInteractionScheduledWorkCompleted: jest.fn(),
96 - onInteractionTracked: jest.fn(),
96 + onInteractionTraced: jest.fn(),
97 onWorkCanceled: jest.fn(),
98 onWorkScheduled: jest.fn(),
99 onWorkStarted: jest.fn(),
@@ -101,49 +101,49 @@ describe('TrackingSubscriptions', () => {
101 };
102
103 if (autoSubscribe) {
104 - SchedulerTracking.unstable_subscribe(firstSubscriber);
105 - SchedulerTracking.unstable_subscribe(secondSubscriber);
104 + SchedulerTracing.unstable_subscribe(firstSubscriber);
105 + SchedulerTracing.unstable_subscribe(secondSubscriber);
106 }
107 }
108
109 describe('enabled', () => {
110 - beforeEach(() => loadModules({enableSchedulerTracking: true}));
111 -
112 - it('should lazily subscribe to tracking and unsubscribe again if there are no external subscribers', () => {
113 - loadModules({enableSchedulerTracking: true, autoSubscribe: false});
114 -
115 - expect(SchedulerTracking.__subscriberRef.current).toBe(null);
116 - SchedulerTracking.unstable_subscribe(firstSubscriber);
117 - expect(SchedulerTracking.__subscriberRef.current).toBeDefined();
118 - SchedulerTracking.unstable_subscribe(secondSubscriber);
119 - expect(SchedulerTracking.__subscriberRef.current).toBeDefined();
120 - SchedulerTracking.unstable_unsubscribe(secondSubscriber);
121 - expect(SchedulerTracking.__subscriberRef.current).toBeDefined();
122 - SchedulerTracking.unstable_unsubscribe(firstSubscriber);
123 - expect(SchedulerTracking.__subscriberRef.current).toBe(null);
110 + beforeEach(() => loadModules({enableSchedulerTracing: true}));
111 +
112 + it('should lazily subscribe to tracing and unsubscribe again if there are no external subscribers', () => {
113 + loadModules({enableSchedulerTracing: true, autoSubscribe: false});
114 +
115 + expect(SchedulerTracing.__subscriberRef.current).toBe(null);
116 + SchedulerTracing.unstable_subscribe(firstSubscriber);
117 + expect(SchedulerTracing.__subscriberRef.current).toBeDefined();
118 + SchedulerTracing.unstable_subscribe(secondSubscriber);
119 + expect(SchedulerTracing.__subscriberRef.current).toBeDefined();
120 + SchedulerTracing.unstable_unsubscribe(secondSubscriber);
121 + expect(SchedulerTracing.__subscriberRef.current).toBeDefined();
122 + SchedulerTracing.unstable_unsubscribe(firstSubscriber);
123 + expect(SchedulerTracing.__subscriberRef.current).toBe(null);
124 });
125
126 describe('error handling', () => {
127 - it('should cover onInteractionTracked/onWorkStarted within', done => {
128 - SchedulerTracking.unstable_track(firstEvent.name, currentTime, () => {
127 + it('should cover onInteractionTraced/onWorkStarted within', done => {
128 + SchedulerTracing.unstable_trace(firstEvent.name, currentTime, () => {
129 const mock = jest.fn();
130
131 // It should call the callback before re-throwing
132 - throwInOnInteractionTracked = true;
132 + throwInOnInteractionTraced = true;
133 expect(() =>
134 - SchedulerTracking.unstable_track(
134 + SchedulerTracing.unstable_trace(
135 secondEvent.name,
136 currentTime,
137 mock,
138 threadID,
139 ),
140 - ).toThrow('Expected error onInteractionTracked');
141 - throwInOnInteractionTracked = false;
140 + ).toThrow('Expected error onInteractionTraced');
141 + throwInOnInteractionTraced = false;
142 expect(mock).toHaveBeenCalledTimes(1);
143
144 throwInOnWorkStarted = true;
145 expect(() =>
146 - SchedulerTracking.unstable_track(
146 + SchedulerTracing.unstable_trace(
147 secondEvent.name,
148 currentTime,
149 mock,
@@ -153,32 +153,30 @@ describe('TrackingSubscriptions', () => {
153 expect(mock).toHaveBeenCalledTimes(2);
154
155 // It should restore the previous/outer interactions
156 - expect(SchedulerTracking.unstable_getCurrent()).toMatchInteractions([
156 + expect(SchedulerTracing.unstable_getCurrent()).toMatchInteractions([
157 firstEvent,
158 ]);
159
160 // It should call other subscribers despite the earlier error
161 - expect(secondSubscriber.onInteractionTracked).toHaveBeenCalledTimes(
162 - 3,
163 - );
161 + expect(secondSubscriber.onInteractionTraced).toHaveBeenCalledTimes(3);
162 expect(secondSubscriber.onWorkStarted).toHaveBeenCalledTimes(3);
163
164 done();
165 });
166 });
167
170 - it('should cover onWorkStopped within track', done => {
171 - SchedulerTracking.unstable_track(firstEvent.name, currentTime, () => {
168 + it('should cover onWorkStopped within trace', done => {
169 + SchedulerTracing.unstable_trace(firstEvent.name, currentTime, () => {
170 let innerInteraction;
171 const mock = jest.fn(() => {
172 innerInteraction = Array.from(
175 - SchedulerTracking.unstable_getCurrent(),
173 + SchedulerTracing.unstable_getCurrent(),
174 )[1];
175 });
176
177 throwInOnWorkStopped = true;
178 expect(() =>
181 - SchedulerTracking.unstable_track(
179 + SchedulerTracing.unstable_trace(
180 secondEvent.name,
181 currentTime,
182 mock,
@@ -187,7 +185,7 @@ describe('TrackingSubscriptions', () => {
185 throwInOnWorkStopped = false;
186
187 // It should restore the previous/outer interactions
190 - expect(SchedulerTracking.unstable_getCurrent()).toMatchInteractions([
188 + expect(SchedulerTracing.unstable_getCurrent()).toMatchInteractions([
189 firstEvent,
190 ]);
191
@@ -201,13 +199,13 @@ describe('TrackingSubscriptions', () => {
199 });
200 });
201
204 - it('should cover onInteractionScheduledWorkCompleted within track', done => {
205 - SchedulerTracking.unstable_track(firstEvent.name, currentTime, () => {
202 + it('should cover onInteractionScheduledWorkCompleted within trace', done => {
203 + SchedulerTracing.unstable_trace(firstEvent.name, currentTime, () => {
204 const mock = jest.fn();
205
206 throwInOnInteractionScheduledWorkCompleted = true;
207 expect(() =>
210 - SchedulerTracking.unstable_track(
208 + SchedulerTracing.unstable_trace(
209 secondEvent.name,
210 currentTime,
211 mock,
@@ -216,7 +214,7 @@ describe('TrackingSubscriptions', () => {
214 throwInOnInteractionScheduledWorkCompleted = false;
215
216 // It should restore the previous/outer interactions
219 - expect(SchedulerTracking.unstable_getCurrent()).toMatchInteractions([
217 + expect(SchedulerTracing.unstable_getCurrent()).toMatchInteractions([
218 firstEvent,
219 ]);
220
@@ -229,12 +227,12 @@ describe('TrackingSubscriptions', () => {
227 });
228 });
229
232 - it('should cover the callback within track', done => {
230 + it('should cover the callback within trace', done => {
231 expect(onWorkStarted).not.toHaveBeenCalled();
232 expect(onWorkStopped).not.toHaveBeenCalled();
233
234 expect(() => {
237 - SchedulerTracking.unstable_track(firstEvent.name, currentTime, () => {
235 + SchedulerTracing.unstable_trace(firstEvent.name, currentTime, () => {
236 throw Error('Expected error callback');
237 });
238 }).toThrow('Expected error callback');
@@ -246,14 +244,14 @@ describe('TrackingSubscriptions', () => {
244 });
245
246 it('should cover onWorkScheduled within wrap', done => {
249 - SchedulerTracking.unstable_track(firstEvent.name, currentTime, () => {
247 + SchedulerTracing.unstable_trace(firstEvent.name, currentTime, () => {
248 const interaction = Array.from(
251 - SchedulerTracking.unstable_getCurrent(),
249 + SchedulerTracing.unstable_getCurrent(),
250 )[0];
251 const beforeCount = interaction.__count;
252
253 throwInOnWorkScheduled = true;
256 - expect(() => SchedulerTracking.unstable_wrap(() => {})).toThrow(
254 + expect(() => SchedulerTracing.unstable_wrap(() => {})).toThrow(
255 'Expected error onWorkScheduled',
256 );
257
@@ -270,9 +268,9 @@ describe('TrackingSubscriptions', () => {
268 it('should cover onWorkStarted within wrap', () => {
269 const mock = jest.fn();
270 let interaction, wrapped;
273 - SchedulerTracking.unstable_track(firstEvent.name, currentTime, () => {
274 - interaction = Array.from(SchedulerTracking.unstable_getCurrent())[0];
275 - wrapped = SchedulerTracking.unstable_wrap(mock);
271 + SchedulerTracing.unstable_trace(firstEvent.name, currentTime, () => {
272 + interaction = Array.from(SchedulerTracing.unstable_getCurrent())[0];
273 + wrapped = SchedulerTracing.unstable_wrap(mock);
274 });
275 expect(interaction.__count).toBe(1);
276
@@ -290,30 +288,26 @@ describe('TrackingSubscriptions', () => {
288 });
289
290 it('should cover onWorkStopped within wrap', done => {
293 - SchedulerTracking.unstable_track(firstEvent.name, currentTime, () => {
291 + SchedulerTracing.unstable_trace(firstEvent.name, currentTime, () => {
292 const outerInteraction = Array.from(
295 - SchedulerTracking.unstable_getCurrent(),
293 + SchedulerTracing.unstable_getCurrent(),
294 )[0];
295 expect(outerInteraction.__count).toBe(1);
296
297 let wrapped;
298 let innerInteraction;
299
302 - SchedulerTracking.unstable_track(
303 - secondEvent.name,
304 - currentTime,
305 - () => {
306 - innerInteraction = Array.from(
307 - SchedulerTracking.unstable_getCurrent(),
308 - )[1];
309 - expect(outerInteraction.__count).toBe(1);
310 - expect(innerInteraction.__count).toBe(1);
311 -
312 - wrapped = SchedulerTracking.unstable_wrap(jest.fn());
313 - expect(outerInteraction.__count).toBe(2);
314 - expect(innerInteraction.__count).toBe(2);
315 - },
316 - );
300 + SchedulerTracing.unstable_trace(secondEvent.name, currentTime, () => {
301 + innerInteraction = Array.from(
302 + SchedulerTracing.unstable_getCurrent(),
303 + )[1];
304 + expect(outerInteraction.__count).toBe(1);
305 + expect(innerInteraction.__count).toBe(1);
306 +
307 + wrapped = SchedulerTracing.unstable_wrap(jest.fn());
308 + expect(outerInteraction.__count).toBe(2);
309 + expect(innerInteraction.__count).toBe(2);
310 + });
311
312 expect(outerInteraction.__count).toBe(2);
313 expect(innerInteraction.__count).toBe(1);
@@ -323,7 +317,7 @@ describe('TrackingSubscriptions', () => {
317 throwInOnWorkStopped = false;
318
319 // It should restore the previous interactions
326 - expect(SchedulerTracking.unstable_getCurrent()).toMatchInteractions([
320 + expect(SchedulerTracing.unstable_getCurrent()).toMatchInteractions([
321 outerInteraction,
322 ]);
323
@@ -343,9 +337,9 @@ describe('TrackingSubscriptions', () => {
337
338 let wrapped;
339 let interaction;
346 - SchedulerTracking.unstable_track(firstEvent.name, currentTime, () => {
347 - interaction = Array.from(SchedulerTracking.unstable_getCurrent())[0];
348 - wrapped = SchedulerTracking.unstable_wrap(() => {
340 + SchedulerTracing.unstable_trace(firstEvent.name, currentTime, () => {
341 + interaction = Array.from(SchedulerTracing.unstable_getCurrent())[0];
342 + wrapped = SchedulerTracing.unstable_wrap(() => {
343 throw Error('Expected error wrap');
344 });
345 });
@@ -364,9 +358,9 @@ describe('TrackingSubscriptions', () => {
358
359 it('should cover onWorkCanceled within wrap', () => {
360 let interaction, wrapped;
367 - SchedulerTracking.unstable_track(firstEvent.name, currentTime, () => {
368 - interaction = Array.from(SchedulerTracking.unstable_getCurrent())[0];
369 - wrapped = SchedulerTracking.unstable_wrap(jest.fn());
361 + SchedulerTracing.unstable_trace(firstEvent.name, currentTime, () => {
362 + interaction = Array.from(SchedulerTracing.unstable_getCurrent())[0];
363 + wrapped = SchedulerTracing.unstable_wrap(jest.fn());
364 });
365 expect(interaction.__count).toBe(1);
366
@@ -386,16 +380,16 @@ describe('TrackingSubscriptions', () => {
380 });
381 });
382
389 - it('calls lifecycle methods for track', () => {
390 - expect(onInteractionTracked).not.toHaveBeenCalled();
383 + it('calls lifecycle methods for trace', () => {
384 + expect(onInteractionTraced).not.toHaveBeenCalled();
385 expect(onInteractionScheduledWorkCompleted).not.toHaveBeenCalled();
386
393 - SchedulerTracking.unstable_track(
387 + SchedulerTracing.unstable_trace(
388 firstEvent.name,
389 currentTime,
390 () => {
397 - expect(onInteractionTracked).toHaveBeenCalledTimes(1);
398 - expect(onInteractionTracked).toHaveBeenLastNotifiedOfInteraction(
391 + expect(onInteractionTraced).toHaveBeenCalledTimes(1);
392 + expect(onInteractionTraced).toHaveBeenLastNotifiedOfInteraction(
393 firstEvent,
394 );
395 expect(onInteractionScheduledWorkCompleted).not.toHaveBeenCalled();
@@ -406,12 +400,12 @@ describe('TrackingSubscriptions', () => {
400 );
401 expect(onWorkStopped).not.toHaveBeenCalled();
402
409 - SchedulerTracking.unstable_track(
403 + SchedulerTracing.unstable_trace(
404 secondEvent.name,
405 currentTime,
406 () => {
413 - expect(onInteractionTracked).toHaveBeenCalledTimes(2);
414 - expect(onInteractionTracked).toHaveBeenLastNotifiedOfInteraction(
407 + expect(onInteractionTraced).toHaveBeenCalledTimes(2);
408 + expect(onInteractionTraced).toHaveBeenLastNotifiedOfInteraction(
409 secondEvent,
410 );
411 expect(
@@ -458,19 +452,19 @@ describe('TrackingSubscriptions', () => {
452 const unwrapped = jest.fn();
453 let wrapped;
454
461 - SchedulerTracking.unstable_track(firstEvent.name, currentTime, () => {
462 - expect(onInteractionTracked).toHaveBeenCalledTimes(1);
463 - expect(onInteractionTracked).toHaveBeenLastNotifiedOfInteraction(
455 + SchedulerTracing.unstable_trace(firstEvent.name, currentTime, () => {
456 + expect(onInteractionTraced).toHaveBeenCalledTimes(1);
457 + expect(onInteractionTraced).toHaveBeenLastNotifiedOfInteraction(
458 firstEvent,
459 );
460
467 - SchedulerTracking.unstable_track(secondEvent.name, currentTime, () => {
468 - expect(onInteractionTracked).toHaveBeenCalledTimes(2);
469 - expect(onInteractionTracked).toHaveBeenLastNotifiedOfInteraction(
461 + SchedulerTracing.unstable_trace(secondEvent.name, currentTime, () => {
462 + expect(onInteractionTraced).toHaveBeenCalledTimes(2);
463 + expect(onInteractionTraced).toHaveBeenLastNotifiedOfInteraction(
464 secondEvent,
465 );
466
473 - wrapped = SchedulerTracking.unstable_wrap(unwrapped, threadID);
467 + wrapped = SchedulerTracing.unstable_wrap(unwrapped, threadID);
468 expect(onWorkScheduled).toHaveBeenCalledTimes(1);
469 expect(onWorkScheduled).toHaveBeenLastNotifiedOfWork(
470 new Set([firstEvent, secondEvent]),
@@ -479,7 +473,7 @@ describe('TrackingSubscriptions', () => {
473 });
474 });
475
482 - expect(onInteractionTracked).toHaveBeenCalledTimes(2);
476 + expect(onInteractionTraced).toHaveBeenCalledTimes(2);
477 expect(onInteractionScheduledWorkCompleted).not.toHaveBeenCalled();
478
479 wrapped();
@@ -510,14 +504,14 @@ describe('TrackingSubscriptions', () => {
504 const fnOne = jest.fn();
505 const fnTwo = jest.fn();
506 let wrappedOne, wrappedTwo;
513 - SchedulerTracking.unstable_track(firstEvent.name, currentTime, () => {
514 - wrappedOne = SchedulerTracking.unstable_wrap(fnOne, threadID);
515 - SchedulerTracking.unstable_track(secondEvent.name, currentTime, () => {
516 - wrappedTwo = SchedulerTracking.unstable_wrap(fnTwo, threadID);
507 + SchedulerTracing.unstable_trace(firstEvent.name, currentTime, () => {
508 + wrappedOne = SchedulerTracing.unstable_wrap(fnOne, threadID);
509 + SchedulerTracing.unstable_trace(secondEvent.name, currentTime, () => {
510 + wrappedTwo = SchedulerTracing.unstable_wrap(fnTwo, threadID);
511 });
512 });
513
520 - expect(onInteractionTracked).toHaveBeenCalledTimes(2);
514 + expect(onInteractionTraced).toHaveBeenCalledTimes(2);
515 expect(onInteractionScheduledWorkCompleted).not.toHaveBeenCalled();
516 expect(onWorkCanceled).not.toHaveBeenCalled();
517 expect(onWorkStarted).toHaveBeenCalledTimes(2);
@@ -553,25 +547,25 @@ describe('TrackingSubscriptions', () => {
547
548 it('should not end an interaction twice if wrap is used to schedule follow up work within another wrap', () => {
549 const fnOne = jest.fn(() => {
556 - wrappedTwo = SchedulerTracking.unstable_wrap(fnTwo, threadID);
550 + wrappedTwo = SchedulerTracing.unstable_wrap(fnTwo, threadID);
551 });
552 const fnTwo = jest.fn();
553 let wrappedOne, wrappedTwo;
560 - SchedulerTracking.unstable_track(firstEvent.name, currentTime, () => {
561 - wrappedOne = SchedulerTracking.unstable_wrap(fnOne, threadID);
554 + SchedulerTracing.unstable_trace(firstEvent.name, currentTime, () => {
555 + wrappedOne = SchedulerTracing.unstable_wrap(fnOne, threadID);
556 });
557
564 - expect(onInteractionTracked).toHaveBeenCalledTimes(1);
558 + expect(onInteractionTraced).toHaveBeenCalledTimes(1);
559 expect(onInteractionScheduledWorkCompleted).not.toHaveBeenCalled();
560
561 wrappedOne();
562
569 - expect(onInteractionTracked).toHaveBeenCalledTimes(1);
563 + expect(onInteractionTraced).toHaveBeenCalledTimes(1);
564 expect(onInteractionScheduledWorkCompleted).not.toHaveBeenCalled();
565
566 wrappedTwo();
567
574 - expect(onInteractionTracked).toHaveBeenCalledTimes(1);
568 + expect(onInteractionTraced).toHaveBeenCalledTimes(1);
569 expect(onInteractionScheduledWorkCompleted).toHaveBeenCalledTimes(1);
570 expect(
571 onInteractionScheduledWorkCompleted,
@@ -582,29 +576,29 @@ describe('TrackingSubscriptions', () => {
576 const unwrappedOne = jest.fn();
577 const unwrappedTwo = jest.fn();
578 let wrappedOne, wrappedTwo;
585 - SchedulerTracking.unstable_track(firstEvent.name, currentTime, () => {
586 - wrappedOne = SchedulerTracking.unstable_wrap(unwrappedOne, threadID);
587 - wrappedTwo = SchedulerTracking.unstable_wrap(unwrappedTwo, threadID);
579 + SchedulerTracing.unstable_trace(firstEvent.name, currentTime, () => {
580 + wrappedOne = SchedulerTracing.unstable_wrap(unwrappedOne, threadID);
581 + wrappedTwo = SchedulerTracing.unstable_wrap(unwrappedTwo, threadID);
582 });
583
590 - expect(onInteractionTracked).toHaveBeenCalledTimes(1);
584 + expect(onInteractionTraced).toHaveBeenCalledTimes(1);
585 expect(onInteractionScheduledWorkCompleted).not.toHaveBeenCalled();
586
587 wrappedOne();
588
589 expect(unwrappedOne).toHaveBeenCalledTimes(1);
596 - expect(onInteractionTracked).toHaveBeenCalledTimes(1);
590 + expect(onInteractionTraced).toHaveBeenCalledTimes(1);
591 expect(onInteractionScheduledWorkCompleted).not.toHaveBeenCalled();
592
593 wrappedOne();
594
595 expect(unwrappedOne).toHaveBeenCalledTimes(2);
602 - expect(onInteractionTracked).toHaveBeenCalledTimes(1);
596 + expect(onInteractionTraced).toHaveBeenCalledTimes(1);
597 expect(onInteractionScheduledWorkCompleted).not.toHaveBeenCalled();
598
599 wrappedTwo();
600
607 - expect(onInteractionTracked).toHaveBeenCalledTimes(1);
601 + expect(onInteractionTraced).toHaveBeenCalledTimes(1);
602 expect(onInteractionScheduledWorkCompleted).toHaveBeenCalledTimes(1);
603 expect(
604 onInteractionScheduledWorkCompleted,
@@ -612,15 +606,15 @@ describe('TrackingSubscriptions', () => {
606 });
607
608 it('should unsubscribe', () => {
615 - SchedulerTracking.unstable_unsubscribe(firstSubscriber);
616 - SchedulerTracking.unstable_track(firstEvent.name, currentTime, () => {});
609 + SchedulerTracing.unstable_unsubscribe(firstSubscriber);
610 + SchedulerTracing.unstable_trace(firstEvent.name, currentTime, () => {});
611
618 - expect(onInteractionTracked).not.toHaveBeenCalled();
612 + expect(onInteractionTraced).not.toHaveBeenCalled();
613 });
614 });
615
616 describe('disabled', () => {
623 - beforeEach(() => loadModules({enableSchedulerTracking: false}));
617 + beforeEach(() => loadModules({enableSchedulerTracing: false}));
618
619 // TODO
620 });
packages/schedule/src/__tests__/Tracking-test.internal.js deleted
-375
@@ -1,375 +0,0 @@
1 -/**
2 - * Copyright (c) Facebook, Inc. and its affiliates.
3 - *
4 - * This source code is licensed under the MIT license found in the
5 - * LICENSE file in the root directory of this source tree.
6 - *
7 - * @jest-environment node
8 - */
9 -'use strict';
10 -
11 -describe('Tracking', () => {
12 - let SchedulerTracking;
13 - let ReactFeatureFlags;
14 -
15 - let advanceTimeBy;
16 - let currentTime;
17 -
18 - function loadModules({enableSchedulerTracking}) {
19 - jest.resetModules();
20 - jest.useFakeTimers();
21 -
22 - currentTime = 0;
23 - Date.now = jest.fn().mockImplementation(() => currentTime);
24 -
25 - advanceTimeBy = amount => {
26 - currentTime += amount;
27 - };
28 -
29 - ReactFeatureFlags = require('shared/ReactFeatureFlags');
30 - ReactFeatureFlags.enableSchedulerTracking = enableSchedulerTracking;
31 -
32 - SchedulerTracking = require('schedule/tracking');
33 - }
34 -
35 - describe('enableSchedulerTracking enabled', () => {
36 - beforeEach(() => loadModules({enableSchedulerTracking: true}));
37 -
38 - it('should return the value of a tracked function', () => {
39 - expect(
40 - SchedulerTracking.unstable_track('arbitrary', currentTime, () => 123),
41 - ).toBe(123);
42 - });
43 -
44 - it('should return the value of a clear function', () => {
45 - expect(SchedulerTracking.unstable_clear(() => 123)).toBe(123);
46 - });
47 -
48 - it('should return the value of a wrapped function', () => {
49 - let wrapped;
50 - SchedulerTracking.unstable_track('arbitrary', currentTime, () => {
51 - wrapped = SchedulerTracking.unstable_wrap(() => 123);
52 - });
53 - expect(wrapped()).toBe(123);
54 - });
55 -
56 - it('should pass arguments through to a wrapped function', done => {
57 - let wrapped;
58 - SchedulerTracking.unstable_track('arbitrary', currentTime, () => {
59 - wrapped = SchedulerTracking.unstable_wrap((param1, param2) => {
60 - expect(param1).toBe('foo');
61 - expect(param2).toBe('bar');
62 - done();
63 - });
64 - });
65 - wrapped('foo', 'bar');
66 - });
67 -
68 - it('should return an empty set when outside of a tracked event', () => {
69 - expect(SchedulerTracking.unstable_getCurrent()).toContainNoInteractions();
70 - });
71 -
72 - it('should report the tracked interaction from within the track callback', done => {
73 - advanceTimeBy(100);
74 -
75 - SchedulerTracking.unstable_track('some event', currentTime, () => {
76 - const interactions = SchedulerTracking.unstable_getCurrent();
77 - expect(interactions).toMatchInteractions([
78 - {name: 'some event', timestamp: 100},
79 - ]);
80 -
81 - done();
82 - });
83 - });
84 -
85 - it('should report the tracked interaction from within wrapped callbacks', done => {
86 - let wrappedIndirection;
87 -
88 - function indirection() {
89 - const interactions = SchedulerTracking.unstable_getCurrent();
90 - expect(interactions).toMatchInteractions([
91 - {name: 'some event', timestamp: 100},
92 - ]);
93 -
94 - done();
95 - }
96 -
97 - advanceTimeBy(100);
98 -
99 - SchedulerTracking.unstable_track('some event', currentTime, () => {
100 - wrappedIndirection = SchedulerTracking.unstable_wrap(indirection);
101 - });
102 -
103 - advanceTimeBy(50);
104 -
105 - wrappedIndirection();
106 - });
107 -
108 - it('should clear the interaction stack for tracked callbacks', () => {
109 - let innerTestReached = false;
110 -
111 - SchedulerTracking.unstable_track('outer event', currentTime, () => {
112 - expect(SchedulerTracking.unstable_getCurrent()).toMatchInteractions([
113 - {name: 'outer event'},
114 - ]);
115 -
116 - SchedulerTracking.unstable_clear(() => {
117 - expect(SchedulerTracking.unstable_getCurrent()).toMatchInteractions(
118 - [],
119 - );
120 -
121 - SchedulerTracking.unstable_track('inner event', currentTime, () => {
122 - expect(SchedulerTracking.unstable_getCurrent()).toMatchInteractions(
123 - [{name: 'inner event'}],
124 - );
125 -
126 - innerTestReached = true;
127 - });
128 - });
129 -
130 - expect(SchedulerTracking.unstable_getCurrent()).toMatchInteractions([
131 - {name: 'outer event'},
132 - ]);
133 - });
134 -
135 - expect(innerTestReached).toBe(true);
136 - });
137 -
138 - it('should clear the interaction stack for wrapped callbacks', () => {
139 - let innerTestReached = false;
140 - let wrappedIndirection;
141 -
142 - const indirection = jest.fn(() => {
143 - expect(SchedulerTracking.unstable_getCurrent()).toMatchInteractions([
144 - {name: 'outer event'},
145 - ]);
146 -
147 - SchedulerTracking.unstable_clear(() => {
148 - expect(SchedulerTracking.unstable_getCurrent()).toMatchInteractions(
149 - [],
150 - );
151 -
152 - SchedulerTracking.unstable_track('inner event', currentTime, () => {
153 - expect(SchedulerTracking.unstable_getCurrent()).toMatchInteractions(
154 - [{name: 'inner event'}],
155 - );
156 -
157 - innerTestReached = true;
158 - });
159 - });
160 -
161 - expect(SchedulerTracking.unstable_getCurrent()).toMatchInteractions([
162 - {name: 'outer event'},
163 - ]);
164 - });
165 -
166 - SchedulerTracking.unstable_track('outer event', currentTime, () => {
167 - wrappedIndirection = SchedulerTracking.unstable_wrap(indirection);
168 - });
169 -
170 - wrappedIndirection();
171 -
172 - expect(innerTestReached).toBe(true);
173 - });
174 -
175 - it('should support nested tracked events', done => {
176 - advanceTimeBy(100);
177 -
178 - let innerIndirectionTracked = false;
179 - let outerIndirectionTracked = false;
180 -
181 - function innerIndirection() {
182 - const interactions = SchedulerTracking.unstable_getCurrent();
183 - expect(interactions).toMatchInteractions([
184 - {name: 'outer event', timestamp: 100},
185 - {name: 'inner event', timestamp: 150},
186 - ]);
187 -
188 - innerIndirectionTracked = true;
189 - }
190 -
191 - function outerIndirection() {
192 - const interactions = SchedulerTracking.unstable_getCurrent();
193 - expect(interactions).toMatchInteractions([
194 - {name: 'outer event', timestamp: 100},
195 - ]);
196 -
197 - outerIndirectionTracked = true;
198 - }
199 -
200 - SchedulerTracking.unstable_track('outer event', currentTime, () => {
201 - // Verify the current tracked event
202 - let interactions = SchedulerTracking.unstable_getCurrent();
203 - expect(interactions).toMatchInteractions([
204 - {name: 'outer event', timestamp: 100},
205 - ]);
206 -
207 - advanceTimeBy(50);
208 -
209 - const wrapperOuterIndirection = SchedulerTracking.unstable_wrap(
210 - outerIndirection,
211 - );
212 -
213 - let wrapperInnerIndirection;
214 - let innerEventTracked = false;
215 -
216 - // Verify that a nested event is properly tracked
217 - SchedulerTracking.unstable_track('inner event', currentTime, () => {
218 - interactions = SchedulerTracking.unstable_getCurrent();
219 - expect(interactions).toMatchInteractions([
220 - {name: 'outer event', timestamp: 100},
221 - {name: 'inner event', timestamp: 150},
222 - ]);
223 -
224 - // Verify that a wrapped outer callback is properly tracked
225 - wrapperOuterIndirection();
226 - expect(outerIndirectionTracked).toBe(true);
227 -
228 - wrapperInnerIndirection = SchedulerTracking.unstable_wrap(
229 - innerIndirection,
230 - );
231 -
232 - innerEventTracked = true;
233 - });
234 -
235 - expect(innerEventTracked).toBe(true);
236 -
237 - // Verify that the original event is restored
238 - interactions = SchedulerTracking.unstable_getCurrent();
239 - expect(interactions).toMatchInteractions([
240 - {name: 'outer event', timestamp: 100},
241 - ]);
242 -
243 - // Verify that a wrapped nested callback is properly tracked
244 - wrapperInnerIndirection();
245 - expect(innerIndirectionTracked).toBe(true);
246 -
247 - done();
248 - });
249 - });
250 -
251 - describe('error handling', () => {
252 - it('should reset state appropriately when an error occurs in a track callback', done => {
253 - advanceTimeBy(100);
254 -
255 - SchedulerTracking.unstable_track('outer event', currentTime, () => {
256 - expect(() => {
257 - SchedulerTracking.unstable_track('inner event', currentTime, () => {
258 - throw Error('intentional');
259 - });
260 - }).toThrow();
261 -
262 - expect(SchedulerTracking.unstable_getCurrent()).toMatchInteractions([
263 - {name: 'outer event', timestamp: 100},
264 - ]);
265 -
266 - done();
267 - });
268 - });
269 -
270 - it('should reset state appropriately when an error occurs in a wrapped callback', done => {
271 - advanceTimeBy(100);
272 -
273 - SchedulerTracking.unstable_track('outer event', currentTime, () => {
274 - let wrappedCallback;
275 -
276 - SchedulerTracking.unstable_track('inner event', currentTime, () => {
277 - wrappedCallback = SchedulerTracking.unstable_wrap(() => {
278 - throw Error('intentional');
279 - });
280 - });
281 -
282 - expect(wrappedCallback).toThrow();
283 -
284 - expect(SchedulerTracking.unstable_getCurrent()).toMatchInteractions([
285 - {name: 'outer event', timestamp: 100},
286 - ]);
287 -
288 - done();
289 - });
290 - });
291 - });
292 -
293 - describe('advanced integration', () => {
294 - it('should return a unique threadID per request', () => {
295 - expect(SchedulerTracking.unstable_getThreadID()).not.toBe(
296 - SchedulerTracking.unstable_getThreadID(),
297 - );
298 - });
299 -
300 - it('should expose the current set of interactions to be externally manipulated', () => {
301 - SchedulerTracking.unstable_track('outer event', currentTime, () => {
302 - expect(SchedulerTracking.__interactionsRef.current).toBe(
303 - SchedulerTracking.unstable_getCurrent(),
304 - );
305 -
306 - SchedulerTracking.__interactionsRef.current = new Set([
307 - {name: 'override event'},
308 - ]);
309 -
310 - expect(SchedulerTracking.unstable_getCurrent()).toMatchInteractions([
311 - {name: 'override event'},
312 - ]);
313 - });
314 - });
315 -
316 - it('should expose a subscriber ref to be externally manipulated', () => {
317 - SchedulerTracking.unstable_track('outer event', currentTime, () => {
318 - expect(SchedulerTracking.__subscriberRef).toEqual({
319 - current: null,
320 - });
321 - });
322 - });
323 - });
324 - });
325 -
326 - describe('enableSchedulerTracking disabled', () => {
327 - beforeEach(() => loadModules({enableSchedulerTracking: false}));
328 -
329 - it('should return the value of a tracked function', () => {
330 - expect(
331 - SchedulerTracking.unstable_track('arbitrary', currentTime, () => 123),
332 - ).toBe(123);
333 - });
334 -
335 - it('should return the value of a wrapped function', () => {
336 - let wrapped;
337 - SchedulerTracking.unstable_track('arbitrary', currentTime, () => {
338 - wrapped = SchedulerTracking.unstable_wrap(() => 123);
339 - });
340 - expect(wrapped()).toBe(123);
341 - });
342 -
343 - it('should return null for tracked interactions', () => {
344 - expect(SchedulerTracking.unstable_getCurrent()).toBe(null);
345 - });
346 -
347 - it('should execute tracked callbacks', done => {
348 - SchedulerTracking.unstable_track('some event', currentTime, () => {
349 - expect(SchedulerTracking.unstable_getCurrent()).toBe(null);
350 -
351 - done();
352 - });
353 - });
354 -
355 - it('should return the value of a clear function', () => {
356 - expect(SchedulerTracking.unstable_clear(() => 123)).toBe(123);
357 - });
358 -
359 - it('should execute wrapped callbacks', done => {
360 - const wrappedCallback = SchedulerTracking.unstable_wrap(() => {
361 - expect(SchedulerTracking.unstable_getCurrent()).toBe(null);
362 -
363 - done();
364 - });
365 -
366 - wrappedCallback();
367 - });
368 -
369 - describe('advanced integration', () => {
370 - it('should not create unnecessary objects', () => {
371 - expect(SchedulerTracking.__interactionsRef).toBe(null);
372 - });
373 - });
374 - });
375 -});
packages/schedule/tracing.js renamed
+2 -2
@@ -9,5 +9,5 @@
9
10 'use strict';
11
12 -export * from './src/Tracking';
13 -export * from './src/TrackingSubscriptions';
12 +export * from './src/Tracing';
13 +export * from './src/TracingSubscriptions';
packages/shared/ReactFeatureFlags.js
+2 -2
@@ -37,8 +37,8 @@ export const warnAboutLegacyContextAPI = false;
37 // Gather advanced timing metrics for Profiler subtrees.
38 export const enableProfilerTimer = __PROFILE__;
39
40 -// Track which interactions trigger each commit.
41 -export const enableSchedulerTracking = __PROFILE__;
40 +// Trace which interactions trigger each commit.
41 +export const enableSchedulerTracing = __PROFILE__;
42
43 // Only used in www builds.
44 export const enableSuspenseServerRenderer = false;
packages/shared/forks/ReactFeatureFlags.native-fabric-fb.js
+1 -1
@@ -21,7 +21,7 @@ export const warnAboutDeprecatedLifecycles = false;
21 export const warnAboutLegacyContextAPI = __DEV__;
22 export const replayFailedUnitOfWorkWithInvokeGuardedCallback = __DEV__;
23 export const enableProfilerTimer = __PROFILE__;
24 -export const enableSchedulerTracking = __PROFILE__;
24 +export const enableSchedulerTracing = __PROFILE__;
25 export const enableSuspenseServerRenderer = false;
26 export const disableInputAttributeSyncing = false;
27
packages/shared/forks/ReactFeatureFlags.native-fabric-oss.js
+1 -1
@@ -21,7 +21,7 @@ export const warnAboutDeprecatedLifecycles = false;
21 export const warnAboutLegacyContextAPI = false;
22 export const replayFailedUnitOfWorkWithInvokeGuardedCallback = __DEV__;
23 export const enableProfilerTimer = __PROFILE__;
24 -export const enableSchedulerTracking = __PROFILE__;
24 +export const enableSchedulerTracing = __PROFILE__;
25 export const enableSuspenseServerRenderer = false;
26 export const disableInputAttributeSyncing = false;
27
packages/shared/forks/ReactFeatureFlags.native-fb.js
+1 -1
@@ -27,7 +27,7 @@ export const {
27 export const enableUserTimingAPI = __DEV__;
28 export const warnAboutLegacyContextAPI = __DEV__;
29 export const enableProfilerTimer = __PROFILE__;
30 -export const enableSchedulerTracking = __PROFILE__;
30 +export const enableSchedulerTracing = __PROFILE__;
31 export const enableSuspenseServerRenderer = false;
32
33 // Only used in www builds.
packages/shared/forks/ReactFeatureFlags.native-oss.js
+1 -1
@@ -21,7 +21,7 @@ export const replayFailedUnitOfWorkWithInvokeGuardedCallback = __DEV__;
21 export const warnAboutDeprecatedLifecycles = false;
22 export const warnAboutLegacyContextAPI = false;
23 export const enableProfilerTimer = __PROFILE__;
24 -export const enableSchedulerTracking = __PROFILE__;
24 +export const enableSchedulerTracing = __PROFILE__;
25 export const enableSuspenseServerRenderer = false;
26 export const disableInputAttributeSyncing = false;
27
packages/shared/forks/ReactFeatureFlags.persistent.js
+1 -1
@@ -21,7 +21,7 @@ export const warnAboutDeprecatedLifecycles = false;
21 export const warnAboutLegacyContextAPI = false;
22 export const replayFailedUnitOfWorkWithInvokeGuardedCallback = __DEV__;
23 export const enableProfilerTimer = __PROFILE__;
24 -export const enableSchedulerTracking = __PROFILE__;
24 +export const enableSchedulerTracing = __PROFILE__;
25 export const enableSuspenseServerRenderer = false;
26 export const disableInputAttributeSyncing = false;
27
packages/shared/forks/ReactFeatureFlags.test-renderer.js
+1 -1
@@ -21,7 +21,7 @@ export const warnAboutDeprecatedLifecycles = false;
21 export const warnAboutLegacyContextAPI = false;
22 export const replayFailedUnitOfWorkWithInvokeGuardedCallback = false;
23 export const enableProfilerTimer = false;
24 -export const enableSchedulerTracking = false;
24 +export const enableSchedulerTracing = false;
25 export const enableSuspenseServerRenderer = false;
26 export const disableInputAttributeSyncing = false;
27
packages/shared/forks/ReactFeatureFlags.test-renderer.www.js
+1 -1
@@ -21,7 +21,7 @@ export const warnAboutDeprecatedLifecycles = false;
21 export const warnAboutLegacyContextAPI = false;
22 export const replayFailedUnitOfWorkWithInvokeGuardedCallback = false;
23 export const enableProfilerTimer = false;
24 -export const enableSchedulerTracking = false;
24 +export const enableSchedulerTracing = false;
25 export const enableSuspenseServerRenderer = false;
26
27 // Only used in www builds.
packages/shared/forks/ReactFeatureFlags.www.js
+1 -1
@@ -34,7 +34,7 @@ export const warnAboutLegacyContextAPI = __DEV__;
34 export let enableUserTimingAPI = __DEV__;
35
36 export const enableProfilerTimer = __PROFILE__;
37 -export const enableSchedulerTracking = __PROFILE__;
37 +export const enableSchedulerTracing = __PROFILE__;
38
39 let refCount = 0;
40 export function addUserTimingListener() {
packages/shared/forks/ScheduleTracing.umd.js renamed
+3 -3
@@ -18,10 +18,10 @@ const {
18 unstable_getCurrent,
19 unstable_getThreadID,
20 unstable_subscribe,
21 - unstable_track,
21 + unstable_trace,
22 unstable_unsubscribe,
23 unstable_wrap,
24 -} = ReactInternals.ScheduleTracking;
24 +} = ReactInternals.ScheduleTracing;
25
26 export {
27 __interactionsRef,
@@ -30,7 +30,7 @@ export {
30 unstable_getCurrent,
31 unstable_getThreadID,
32 unstable_subscribe,
33 - unstable_track,
33 + unstable_trace,
34 unstable_unsubscribe,
35 unstable_wrap,
36 };
scripts/jest/matchers/interactionTracing.js renamed
scripts/jest/setupTests.js
+1 -1
@@ -44,7 +44,7 @@ if (process.env.REACT_CLASS_EQUIVALENCE_TEST) {
44 }
45
46 expect.extend({
47 - ...require('./matchers/interactionTracking'),
47 + ...require('./matchers/interactionTracing'),
48 ...require('./matchers/toWarnDev'),
49 ...require('./matchers/testRenderer'),
50 });
scripts/jest/spec-equivalence-reporter/setupTests.js
+1 -1
@@ -46,7 +46,7 @@ global.spyOnProd = function(...args) {
46 };
47
48 expect.extend({
49 - ...require('../matchers/interactionTracking'),
49 + ...require('../matchers/interactionTracing'),
50 ...require('../matchers/toWarnDev'),
51 ...require('../matchers/testRenderer'),
52 });
scripts/rollup/bundles.js
+3 -3
@@ -391,7 +391,7 @@ const bundles = [
391 },
392
393 {
394 - label: 'schedule-tracking',
394 + label: 'schedule-tracing',
395 bundleTypes: [
396 FB_WWW_DEV,
397 FB_WWW_PROD,
@@ -401,8 +401,8 @@ const bundles = [
401 NODE_PROFILING,
402 ],
403 moduleType: ISOMORPHIC,
404 - entry: 'schedule/tracking',
405 - global: 'ScheduleTracking',
404 + entry: 'schedule/tracing',
405 + global: 'ScheduleTracing',
406 externals: [],
407 },
408 ];
scripts/rollup/forks.js
+2 -2
@@ -132,7 +132,7 @@ const forks = Object.freeze({
132 }
133 },
134
135 - 'schedule/tracking': (bundleType, entry, dependencies) => {
135 + 'schedule/tracing': (bundleType, entry, dependencies) => {
136 switch (bundleType) {
137 case UMD_DEV:
138 case UMD_PROD:
@@ -143,7 +143,7 @@ const forks = Object.freeze({
143 }
144 // Optimization: for UMDs, use the API that is already a part of the React
145 // package instead of requiring it to be loaded via a separate <script> tag
146 - return 'shared/forks/ScheduleTracking.umd.js';
146 + return 'shared/forks/ScheduleTracing.umd.js';
147 default:
148 // For other bundles, use the shared NPM package.
149 return null;
scripts/rollup/modules.js
+2 -2
@@ -15,7 +15,7 @@ const importSideEffects = Object.freeze({
15 'prop-types/checkPropTypes': HAS_NO_SIDE_EFFECTS_ON_IMPORT,
16 deepFreezeAndThrowOnMutationInDev: HAS_NO_SIDE_EFFECTS_ON_IMPORT,
17 schedule: HAS_NO_SIDE_EFFECTS_ON_IMPORT,
18 - 'schedule/tracking': HAS_NO_SIDE_EFFECTS_ON_IMPORT,
18 + 'schedule/tracing': HAS_NO_SIDE_EFFECTS_ON_IMPORT,
19 });
20
21 // Bundles exporting globals that other modules rely on.
@@ -23,7 +23,7 @@ const knownGlobals = Object.freeze({
23 react: 'React',
24 'react-dom': 'ReactDOM',
25 schedule: 'Schedule',
26 - 'schedule/tracking': 'ScheduleTracking',
26 + 'schedule/tracing': 'ScheduleTracing',
27 });
28
29 // Given ['react'] in bundle externals, returns { 'react': 'React' }.