From 9721ecb9d756068d4953b1e4eacac4d90471f938 Mon Sep 17 00:00:00 2001 From: Brian Vaughn Date: Thu, 13 Sep 2018 11:12:38 -0700 Subject: [PATCH 1/4] Replaced "tracking" with "tracing" in all directory and file names --- fixtures/{tracking => tracing}/index.html | 0 fixtures/{tracking => tracing}/script.js | 0 ...actTracking-test.internal.js => ReactTracing-test.internal.js} | 0 .../schedule/npm/{tracking-profiling.js => tracing-profiling.js} | 0 packages/schedule/npm/{tracking.js => tracing.js} | 0 ...le-tracking.development.js => schedule-tracing.development.js} | 0 ...cking.production.min.js => schedule-tracing.production.min.js} | 0 packages/schedule/src/{Tracking.js => Tracing.js} | 0 .../src/{TrackingSubscriptions.js => TracingSubscriptions.js} | 0 .../{Tracking-test.internal.js => Tracing-test.internal.js} | 0 .../schedule/src/__tests__/{Tracking-test.js => Tracing-test.js} | 0 ...ons-test.internal.js => TracingSubscriptions-test.internal.js} | 0 packages/schedule/{tracking.js => tracing.js} | 0 .../forks/{ScheduleTracking.umd.js => ScheduleTracing.umd.js} | 0 .../matchers/{interactionTracking.js => interactionTracing.js} | 0 15 files changed, 0 insertions(+), 0 deletions(-) rename fixtures/{tracking => tracing}/index.html (100%) rename fixtures/{tracking => tracing}/script.js (100%) rename packages/react-reconciler/src/__tests__/{ReactTracking-test.internal.js => ReactTracing-test.internal.js} (100%) rename packages/schedule/npm/{tracking-profiling.js => tracing-profiling.js} (100%) rename packages/schedule/npm/{tracking.js => tracing.js} (100%) rename packages/schedule/npm/umd/{schedule-tracking.development.js => schedule-tracing.development.js} (100%) rename packages/schedule/npm/umd/{schedule-tracking.production.min.js => schedule-tracing.production.min.js} (100%) rename packages/schedule/src/{Tracking.js => Tracing.js} (100%) rename packages/schedule/src/{TrackingSubscriptions.js => TracingSubscriptions.js} (100%) rename packages/schedule/src/__tests__/{Tracking-test.internal.js => Tracing-test.internal.js} (100%) rename packages/schedule/src/__tests__/{Tracking-test.js => Tracing-test.js} (100%) rename packages/schedule/src/__tests__/{TrackingSubscriptions-test.internal.js => TracingSubscriptions-test.internal.js} (100%) rename packages/schedule/{tracking.js => tracing.js} (100%) rename packages/shared/forks/{ScheduleTracking.umd.js => ScheduleTracing.umd.js} (100%) rename scripts/jest/matchers/{interactionTracking.js => interactionTracing.js} (100%) diff --git a/fixtures/tracking/index.html b/fixtures/tracing/index.html similarity index 100% rename from fixtures/tracking/index.html rename to fixtures/tracing/index.html diff --git a/fixtures/tracking/script.js b/fixtures/tracing/script.js similarity index 100% rename from fixtures/tracking/script.js rename to fixtures/tracing/script.js diff --git a/packages/react-reconciler/src/__tests__/ReactTracking-test.internal.js b/packages/react-reconciler/src/__tests__/ReactTracing-test.internal.js similarity index 100% rename from packages/react-reconciler/src/__tests__/ReactTracking-test.internal.js rename to packages/react-reconciler/src/__tests__/ReactTracing-test.internal.js diff --git a/packages/schedule/npm/tracking-profiling.js b/packages/schedule/npm/tracing-profiling.js similarity index 100% rename from packages/schedule/npm/tracking-profiling.js rename to packages/schedule/npm/tracing-profiling.js diff --git a/packages/schedule/npm/tracking.js b/packages/schedule/npm/tracing.js similarity index 100% rename from packages/schedule/npm/tracking.js rename to packages/schedule/npm/tracing.js diff --git a/packages/schedule/npm/umd/schedule-tracking.development.js b/packages/schedule/npm/umd/schedule-tracing.development.js similarity index 100% rename from packages/schedule/npm/umd/schedule-tracking.development.js rename to packages/schedule/npm/umd/schedule-tracing.development.js diff --git a/packages/schedule/npm/umd/schedule-tracking.production.min.js b/packages/schedule/npm/umd/schedule-tracing.production.min.js similarity index 100% rename from packages/schedule/npm/umd/schedule-tracking.production.min.js rename to packages/schedule/npm/umd/schedule-tracing.production.min.js diff --git a/packages/schedule/src/Tracking.js b/packages/schedule/src/Tracing.js similarity index 100% rename from packages/schedule/src/Tracking.js rename to packages/schedule/src/Tracing.js diff --git a/packages/schedule/src/TrackingSubscriptions.js b/packages/schedule/src/TracingSubscriptions.js similarity index 100% rename from packages/schedule/src/TrackingSubscriptions.js rename to packages/schedule/src/TracingSubscriptions.js diff --git a/packages/schedule/src/__tests__/Tracking-test.internal.js b/packages/schedule/src/__tests__/Tracing-test.internal.js similarity index 100% rename from packages/schedule/src/__tests__/Tracking-test.internal.js rename to packages/schedule/src/__tests__/Tracing-test.internal.js diff --git a/packages/schedule/src/__tests__/Tracking-test.js b/packages/schedule/src/__tests__/Tracing-test.js similarity index 100% rename from packages/schedule/src/__tests__/Tracking-test.js rename to packages/schedule/src/__tests__/Tracing-test.js diff --git a/packages/schedule/src/__tests__/TrackingSubscriptions-test.internal.js b/packages/schedule/src/__tests__/TracingSubscriptions-test.internal.js similarity index 100% rename from packages/schedule/src/__tests__/TrackingSubscriptions-test.internal.js rename to packages/schedule/src/__tests__/TracingSubscriptions-test.internal.js diff --git a/packages/schedule/tracking.js b/packages/schedule/tracing.js similarity index 100% rename from packages/schedule/tracking.js rename to packages/schedule/tracing.js diff --git a/packages/shared/forks/ScheduleTracking.umd.js b/packages/shared/forks/ScheduleTracing.umd.js similarity index 100% rename from packages/shared/forks/ScheduleTracking.umd.js rename to packages/shared/forks/ScheduleTracing.umd.js diff --git a/scripts/jest/matchers/interactionTracking.js b/scripts/jest/matchers/interactionTracing.js similarity index 100% rename from scripts/jest/matchers/interactionTracking.js rename to scripts/jest/matchers/interactionTracing.js From 69659e6d33a69c2292e5bdc459f6826896e37c35 Mon Sep 17 00:00:00 2001 From: Brian Vaughn Date: Thu, 13 Sep 2018 13:28:11 -0700 Subject: [PATCH 2/4] Global rename of track/tracking/tracked to trace/tracing/traced --- fixtures/tracing/index.html | 18 +- fixtures/tracing/script.js | 84 ++-- .../suspense/src/components/App.js | 13 +- fixtures/unstable-async/suspense/src/index.js | 4 +- .../src/ReactFiberCommitWork.js | 4 +- .../react-reconciler/src/ReactFiberRoot.js | 20 +- .../src/ReactFiberScheduler.js | 38 +- .../__tests__/ReactTracing-test.internal.js | 10 +- packages/react/src/ReactSharedInternals.js | 8 +- .../__tests__/ReactProfiler-test.internal.js | 390 +++++++++--------- ...ofilerDevToolsIntegration-test.internal.js | 10 +- .../ReactProfiler-test.internal.js.snap | 32 +- packages/schedule/npm/tracing-profiling.js | 4 +- packages/schedule/npm/tracing.js | 4 +- .../npm/umd/schedule-tracing.development.js | 20 +- .../umd/schedule-tracing.production.min.js | 20 +- packages/schedule/package.json | 4 +- packages/schedule/src/Tracing.js | 26 +- packages/schedule/src/TracingSubscriptions.js | 18 +- .../ScheduleUMDBundle-test.internal.js | 10 +- .../src/__tests__/Tracing-test.internal.js | 196 ++++----- .../schedule/src/__tests__/Tracing-test.js | 22 +- .../TracingSubscriptions-test.internal.js | 232 +++++------ packages/schedule/tracing.js | 4 +- packages/shared/ReactFeatureFlags.js | 4 +- .../ReactFeatureFlags.native-fabric-fb.js | 2 +- .../ReactFeatureFlags.native-fabric-oss.js | 2 +- .../forks/ReactFeatureFlags.native-fb.js | 2 +- .../forks/ReactFeatureFlags.native-oss.js | 2 +- .../forks/ReactFeatureFlags.persistent.js | 2 +- .../forks/ReactFeatureFlags.test-renderer.js | 2 +- .../ReactFeatureFlags.test-renderer.www.js | 2 +- .../shared/forks/ReactFeatureFlags.www.js | 2 +- packages/shared/forks/ScheduleTracing.umd.js | 6 +- scripts/jest/setupTests.js | 2 +- .../spec-equivalence-reporter/setupTests.js | 2 +- scripts/rollup/bundles.js | 6 +- scripts/rollup/forks.js | 4 +- scripts/rollup/modules.js | 4 +- 39 files changed, 607 insertions(+), 628 deletions(-) diff --git a/fixtures/tracing/index.html b/fixtures/tracing/index.html index 79814c47eefee..f6b2a2d02cc91 100644 --- a/fixtures/tracing/index.html +++ b/fixtures/tracing/index.html @@ -2,7 +2,7 @@ - Test tracking UMD + Test tracing UMD -

Test tracking UMD

+

Test tracing UMD

- This fixture tests that the new tracking API is accessible via UMD build using the UMD shim. + This fixture tests that the new tracing API is accessible via UMD build using the UMD shim. It does not exhaustively test API functionality, only that the forwarded methods can be called.

@@ -52,19 +52,19 @@

  • Test scheduler API
  • -
  • - Test tracking API +
  • + Test tracing API
  • -
  • - Test tracking subscriptions API +
  • + Test tracing subscriptions API
  • Test end-to-end integration
  • - + - + diff --git a/fixtures/tracing/script.js b/fixtures/tracing/script.js index c1ba29b951959..06113d030173d 100644 --- a/fixtures/tracing/script.js +++ b/fixtures/tracing/script.js @@ -14,10 +14,10 @@ function runAllTests() { checkSchedulerAPI(); } finally { try { - checkSchedulerTrackingAPI(); + checkSchedulerTracingAPI(); } finally { try { - checkSchedulerTrackingSubscriptionsAPI(); + checkSchedulerTracingSubscriptionsAPI(); } finally { checkEndToEndIntegration(); } @@ -44,23 +44,23 @@ function checkSchedulerAPI() { }); } -function checkSchedulerTrackingAPI() { - runTest(document.getElementById('checkSchedulerTrackingAPI'), () => { +function checkSchedulerTracingAPI() { + runTest(document.getElementById('checkSchedulerTracingAPI'), () => { if ( - typeof ScheduleTracking === 'undefined' || - typeof ScheduleTracking.unstable_clear !== 'function' || - typeof ScheduleTracking.unstable_getCurrent !== 'function' || - typeof ScheduleTracking.unstable_getThreadID !== 'function' || - typeof ScheduleTracking.unstable_track !== 'function' || - typeof ScheduleTracking.unstable_wrap !== 'function' + typeof ScheduleTracing === 'undefined' || + typeof ScheduleTracing.unstable_clear !== 'function' || + typeof ScheduleTracing.unstable_getCurrent !== 'function' || + typeof ScheduleTracing.unstable_getThreadID !== 'function' || + typeof ScheduleTracing.unstable_trace !== 'function' || + typeof ScheduleTracing.unstable_wrap !== 'function' ) { throw 'API is not defined'; } try { let interactionsSet; - ScheduleTracking.unstable_track('test', 123, () => { - interactionsSet = ScheduleTracking.unstable_getCurrent(); + ScheduleTracing.unstable_trace('test', 123, () => { + interactionsSet = ScheduleTracing.unstable_getCurrent(); }); if (interactionsSet.size !== 1) { throw null; @@ -73,32 +73,32 @@ function checkSchedulerTrackingAPI() { throw 'API does not work'; } - const ForwardedSchedulerTracking = - React.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ScheduleTracking; + const ForwardedSchedulerTracing = + React.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ScheduleTracing; if ( - ScheduleTracking.unstable_getThreadID() === - ForwardedSchedulerTracking.unstable_getThreadID() + ScheduleTracing.unstable_getThreadID() === + ForwardedSchedulerTracing.unstable_getThreadID() ) { throw 'API forwarding is broken'; } }); } -function checkSchedulerTrackingSubscriptionsAPI() { +function checkSchedulerTracingSubscriptionsAPI() { runTest( - document.getElementById('checkSchedulerTrackingSubscriptionsAPI'), + document.getElementById('checkSchedulerTracingSubscriptionsAPI'), () => { if ( - typeof ScheduleTracking === 'undefined' || - typeof ScheduleTracking.unstable_subscribe !== 'function' || - typeof ScheduleTracking.unstable_unsubscribe !== 'function' + typeof ScheduleTracing === 'undefined' || + typeof ScheduleTracing.unstable_subscribe !== 'function' || + typeof ScheduleTracing.unstable_unsubscribe !== 'function' ) { throw 'API is not defined'; } const onInteractionScheduledWorkCompletedCalls = []; - const onInteractionTrackedCalls = []; + const onInteractionTracedCalls = []; const onWorkCanceledCalls = []; const onWorkScheduledCalls = []; const onWorkStartedCalls = []; @@ -106,7 +106,7 @@ function checkSchedulerTrackingSubscriptionsAPI() { const subscriber = { onInteractionScheduledWorkCompleted: (...args) => onInteractionScheduledWorkCompletedCalls.push(args), - onInteractionTracked: (...args) => onInteractionTrackedCalls.push(args), + onInteractionTraced: (...args) => onInteractionTracedCalls.push(args), onWorkCanceled: (...args) => onWorkCanceledCalls.push(args), onWorkScheduled: (...args) => onWorkScheduledCalls.push(args), onWorkStarted: (...args) => onWorkStartedCalls.push(args), @@ -114,38 +114,38 @@ function checkSchedulerTrackingSubscriptionsAPI() { }; try { - ScheduleTracking.unstable_subscribe(subscriber); - ScheduleTracking.unstable_track('foo', 123, () => {}); - ScheduleTracking.unstable_unsubscribe(subscriber); - if (onInteractionTrackedCalls.length !== 1) { + ScheduleTracing.unstable_subscribe(subscriber); + ScheduleTracing.unstable_trace('foo', 123, () => {}); + ScheduleTracing.unstable_unsubscribe(subscriber); + if (onInteractionTracedCalls.length !== 1) { throw null; } - const interaction = onInteractionTrackedCalls[0][0]; + const interaction = onInteractionTracedCalls[0][0]; if (interaction.name !== 'foo' || interaction.timestamp !== 123) { throw null; } - ScheduleTracking.unstable_track('bar', 456, () => {}); - if (onInteractionTrackedCalls.length !== 1) { + ScheduleTracing.unstable_trace('bar', 456, () => {}); + if (onInteractionTracedCalls.length !== 1) { throw null; } } catch (error) { throw 'API does not forward methods'; } - const ForwardedSchedulerTracking = + const ForwardedSchedulerTracing = React.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED - .ScheduleTracking; + .ScheduleTracing; try { - ForwardedSchedulerTracking.unstable_subscribe(subscriber); - ScheduleTracking.unstable_track('foo', 123, () => {}); - ForwardedSchedulerTracking.unstable_track('bar', 456, () => {}); - ScheduleTracking.unstable_unsubscribe(subscriber); - if (onInteractionTrackedCalls.length !== 3) { + ForwardedSchedulerTracing.unstable_subscribe(subscriber); + ScheduleTracing.unstable_trace('foo', 123, () => {}); + ForwardedSchedulerTracing.unstable_trace('bar', 456, () => {}); + ScheduleTracing.unstable_unsubscribe(subscriber); + if (onInteractionTracedCalls.length !== 3) { throw null; } - const interactionFoo = onInteractionTrackedCalls[1][0]; - const interactionBar = onInteractionTrackedCalls[2][0]; + const interactionFoo = onInteractionTracedCalls[1][0]; + const interactionBar = onInteractionTracedCalls[2][0]; if ( interactionFoo.name !== 'foo' || interactionFoo.timestamp !== 123 || @@ -154,8 +154,8 @@ function checkSchedulerTrackingSubscriptionsAPI() { ) { throw null; } - ForwardedSchedulerTracking.unstable_track('baz', 789, () => {}); - if (onInteractionTrackedCalls.length !== 3) { + ForwardedSchedulerTracing.unstable_trace('baz', 789, () => {}); + if (onInteractionTracedCalls.length !== 3) { throw null; } } catch (error) { @@ -172,7 +172,7 @@ function checkEndToEndIntegration() { const onRender = (...args) => onRenderCalls.push(args); const container = document.createElement('div'); - ScheduleTracking.unstable_track('render', 123, () => { + ScheduleTracing.unstable_trace('render', 123, () => { ReactDOM.render( React.createElement( React.unstable_Profiler, diff --git a/fixtures/unstable-async/suspense/src/components/App.js b/fixtures/unstable-async/suspense/src/components/App.js index fcff7a45f2610..b62d1646f12fd 100644 --- a/fixtures/unstable-async/suspense/src/components/App.js +++ b/fixtures/unstable-async/suspense/src/components/App.js @@ -1,9 +1,6 @@ import React, {Placeholder, PureComponent} from 'react'; import {unstable_scheduleWork} from 'schedule'; -import { - unstable_track as track, - unstable_wrap as wrap, -} from 'schedule/tracking'; +import {unstable_trace as trace, unstable_wrap as wrap} from 'schedule/tracing'; import {createResource} from 'simple-cache-provider'; import {cache} from '../cache'; import Spinner from './Spinner'; @@ -32,15 +29,15 @@ export default class App extends PureComponent { } handleUserClick = id => { - track(`View ${id}`, performance.now(), () => { - track(`View ${id} (high-pri)`, performance.now(), () => + trace(`View ${id}`, performance.now(), () => { + trace(`View ${id} (high-pri)`, performance.now(), () => this.setState({ currentId: id, }) ); unstable_scheduleWork( wrap(() => - track(`View ${id} (low-pri)`, performance.now(), () => + trace(`View ${id} (low-pri)`, performance.now(), () => this.setState({ showDetail: true, }) @@ -51,7 +48,7 @@ export default class App extends PureComponent { }; handleBackClick = () => - track('View list', performance.now(), () => + trace('View list', performance.now(), () => this.setState({ currentId: null, showDetail: false, diff --git a/fixtures/unstable-async/suspense/src/index.js b/fixtures/unstable-async/suspense/src/index.js index 0c2850506be99..622b5c92e3979 100644 --- a/fixtures/unstable-async/suspense/src/index.js +++ b/fixtures/unstable-async/suspense/src/index.js @@ -1,6 +1,6 @@ import React, {Fragment, PureComponent} from 'react'; import {unstable_createRoot, render} from 'react-dom'; -import {unstable_track as track} from 'schedule/tracking'; +import {unstable_trace as trace} from 'schedule/tracing'; import {cache} from './cache'; import { setFakeRequestTime, @@ -65,7 +65,7 @@ class Debugger extends PureComponent { } handleReset = () => { - track('Clear cache', () => { + trace('Clear cache', () => { cache.invalidate(); this.setState(state => ({ requests: {}, diff --git a/packages/react-reconciler/src/ReactFiberCommitWork.js b/packages/react-reconciler/src/ReactFiberCommitWork.js index e7cd027d7b6d9..53993f4136aec 100644 --- a/packages/react-reconciler/src/ReactFiberCommitWork.js +++ b/packages/react-reconciler/src/ReactFiberCommitWork.js @@ -20,7 +20,7 @@ import type {ExpirationTime} from './ReactFiberExpirationTime'; import type {CapturedValue, CapturedError} from './ReactCapturedValue'; import { - enableSchedulerTracking, + enableSchedulerTracing, enableProfilerTimer, enableSuspense, } from 'shared/ReactFeatureFlags'; @@ -329,7 +329,7 @@ function commitLifeCycles( if (enableProfilerTimer) { const onRender = finishedWork.memoizedProps.onRender; - if (enableSchedulerTracking) { + if (enableSchedulerTracing) { onRender( finishedWork.memoizedProps.id, current === null ? 'mount' : 'update', diff --git a/packages/react-reconciler/src/ReactFiberRoot.js b/packages/react-reconciler/src/ReactFiberRoot.js index 0065f841d0363..d9af7688f789b 100644 --- a/packages/react-reconciler/src/ReactFiberRoot.js +++ b/packages/react-reconciler/src/ReactFiberRoot.js @@ -10,13 +10,13 @@ import type {Fiber} from './ReactFiber'; import type {ExpirationTime} from './ReactFiberExpirationTime'; import type {TimeoutHandle, NoTimeout} from './ReactFiberHostConfig'; -import type {Interaction} from 'schedule/src/Tracking'; +import type {Interaction} from 'schedule/src/Tracing'; import {noTimeout} from './ReactFiberHostConfig'; import {createHostRootFiber} from './ReactFiber'; import {NoWork} from './ReactFiberExpirationTime'; -import {enableSchedulerTracking} from 'shared/ReactFeatureFlags'; -import {unstable_getThreadID} from 'schedule/tracking'; +import {enableSchedulerTracing} from 'shared/ReactFeatureFlags'; +import {unstable_getThreadID} from 'schedule/tracing'; /* eslint-disable no-use-before-define */ // TODO: This should be lifted into the renderer. @@ -80,10 +80,10 @@ type BaseFiberRootProperties = {| nextScheduledRoot: FiberRoot | null, |}; -// The following attributes are only used by interaction tracking builds. +// The following attributes are only used by interaction tracing builds. // They enable interactions to be associated with their async work, // And expose interaction metadata to the React DevTools Profiler plugin. -// Note that these attributes are only defined when the enableSchedulerTracking flag is enabled. +// Note that these attributes are only defined when the enableSchedulerTracing flag is enabled. type ProfilingOnlyFiberRootProperties = {| interactionThreadID: number, memoizedInteractions: Set, @@ -92,9 +92,9 @@ type ProfilingOnlyFiberRootProperties = {| // Exported FiberRoot type includes all properties, // To avoid requiring potentially error-prone :any casts throughout the project. -// Profiling properties are only safe to access in profiling builds (when enableSchedulerTracking is true). +// Profiling properties are only safe to access in profiling builds (when enableSchedulerTracing is true). // The types are defined separately within this file to ensure they stay in sync. -// (We don't have to use an inline :any cast when enableSchedulerTracking is disabled.) +// (We don't have to use an inline :any cast when enableSchedulerTracing is disabled.) export type FiberRoot = { ...BaseFiberRootProperties, ...ProfilingOnlyFiberRootProperties, @@ -111,7 +111,7 @@ export function createFiberRoot( const uninitializedFiber = createHostRootFiber(isAsync); let root; - if (enableSchedulerTracking) { + if (enableSchedulerTracing) { root = ({ current: uninitializedFiber, containerInfo: containerInfo, @@ -170,8 +170,8 @@ export function createFiberRoot( uninitializedFiber.stateNode = root; // The reason for the way the Flow types are structured in this file, - // Is to avoid needing :any casts everywhere interaction tracking fields are used. - // Unfortunately that requires an :any cast for non-interaction tracking capable builds. + // Is to avoid needing :any casts everywhere interaction tracing fields are used. + // Unfortunately that requires an :any cast for non-interaction tracing capable builds. // $FlowFixMe Remove this :any cast and replace it with something better. return ((root: any): FiberRoot); } diff --git a/packages/react-reconciler/src/ReactFiberScheduler.js b/packages/react-reconciler/src/ReactFiberScheduler.js index 1a407aab55619..089b1a38a37d1 100644 --- a/packages/react-reconciler/src/ReactFiberScheduler.js +++ b/packages/react-reconciler/src/ReactFiberScheduler.js @@ -10,9 +10,9 @@ import type {Fiber} from './ReactFiber'; import type {Batch, FiberRoot} from './ReactFiberRoot'; import type {ExpirationTime} from './ReactFiberExpirationTime'; -import type {Interaction} from 'schedule/src/Tracking'; +import type {Interaction} from 'schedule/src/Tracing'; -import {__interactionsRef, __subscriberRef} from 'schedule/tracking'; +import {__interactionsRef, __subscriberRef} from 'schedule/tracing'; import { invokeGuardedCallback, hasCaughtError, @@ -44,7 +44,7 @@ import { HostPortal, } from 'shared/ReactWorkTags'; import { - enableSchedulerTracking, + enableSchedulerTracing, enableProfilerTimer, enableUserTimingAPI, replayFailedUnitOfWorkWithInvokeGuardedCallback, @@ -168,13 +168,13 @@ let didWarnSetStateChildContext; let warnAboutUpdateOnUnmounted; let warnAboutInvalidUpdates; -if (enableSchedulerTracking) { +if (enableSchedulerTracing) { // Provide explicit error message when production+profiling bundle of e.g. react-dom - // is used with production (non-profiling) bundle of schedule/tracking + // is used with production (non-profiling) bundle of schedule/tracing invariant( __interactionsRef != null && __interactionsRef.current != null, 'It is not supported to run the profiling version of a renderer (for example, `react-dom/profiling`) ' + - 'without also replacing the `schedule/tracking` module with `schedule/tracking-profiling`. ' + + 'without also replacing the `schedule/tracing` module with `schedule/tracing-profiling`. ' + 'Your bundler might have a setting for aliasing both modules. ' + 'Learn more at http://fb.me/react-profiling', ); @@ -566,10 +566,10 @@ function commitRoot(root: FiberRoot, finishedWork: Fiber): void { markCommittedPriorityLevels(root, earliestRemainingTimeBeforeCommit); let prevInteractions: Set = (null: any); - let committedInteractions: Array = enableSchedulerTracking + let committedInteractions: Array = enableSchedulerTracing ? [] : (null: any); - if (enableSchedulerTracking) { + if (enableSchedulerTracing) { // Restore any pending interactions at this point, // So that cascading work triggered during the render phase will be accounted for. prevInteractions = __interactionsRef.current; @@ -767,7 +767,7 @@ function commitRoot(root: FiberRoot, finishedWork: Fiber): void { } onCommit(root, earliestRemainingTimeAfterCommit); - if (enableSchedulerTracking) { + if (enableSchedulerTracing) { __interactionsRef.current = prevInteractions; let subscriber; @@ -1175,8 +1175,8 @@ function renderRoot( const expirationTime = root.nextExpirationTimeToWorkOn; let prevInteractions: Set = (null: any); - if (enableSchedulerTracking) { - // We're about to start new tracked work. + if (enableSchedulerTracing) { + // We're about to start new traced work. // Restore pending interactions so cascading work triggered during the render phase will be accounted for. prevInteractions = __interactionsRef.current; __interactionsRef.current = root.memoizedInteractions; @@ -1200,7 +1200,7 @@ function renderRoot( ); root.pendingCommitExpirationTime = NoWork; - if (enableSchedulerTracking) { + if (enableSchedulerTracing) { // Determine which interactions this batch of work currently includes, // So that we can accurately attribute time spent working on it, // And so that cascading work triggered during the render phase will be associated with it. @@ -1231,7 +1231,7 @@ function renderRoot( try { subscriber.onWorkStarted(interactions, threadID); } catch (error) { - // Work thrown by an interaction tracking subscriber should be rethrown, + // Work thrown by an interaction tracing subscriber should be rethrown, // But only once it's safe (to avoid leaveing the scheduler in an invalid state). // Store the error for now and we'll re-throw in finishRendering(). if (!hasUnhandledError) { @@ -1305,8 +1305,8 @@ function renderRoot( break; } while (true); - if (enableSchedulerTracking) { - // Tracked work is done for now; restore the previous interactions. + if (enableSchedulerTracing) { + // Traced work is done for now; restore the previous interactions. __interactionsRef.current = prevInteractions; } @@ -1614,7 +1614,7 @@ function retrySuspendedRoot( scheduleWorkToRoot(fiber, retryTime); const rootExpirationTime = root.expirationTime; if (rootExpirationTime !== NoWork) { - if (enableSchedulerTracking) { + if (enableSchedulerTracing) { // Restore previous interactions so that new work is associated with them. let prevInteractions = __interactionsRef.current; __interactionsRef.current = root.memoizedInteractions; @@ -1685,7 +1685,7 @@ function storeInteractionsForExpirationTime( expirationTime: ExpirationTime, updateInteractionCounts: boolean, ): void { - if (!enableSchedulerTracking) { + if (!enableSchedulerTracing) { return; } @@ -1744,7 +1744,7 @@ function scheduleWork(fiber: Fiber, expirationTime: ExpirationTime) { return; } - if (enableSchedulerTracking) { + if (enableSchedulerTracing) { storeInteractionsForExpirationTime(root, expirationTime, true); } @@ -1935,7 +1935,7 @@ function onTimeout(root, finishedWork, suspendedExpirationTime) { recomputeCurrentRendererTime(); currentSchedulerTime = currentRendererTime; - if (enableSchedulerTracking) { + if (enableSchedulerTracing) { // Don't update pending interaction counts for suspense timeouts, // Because we know we still need to do more work in this case. suspenseDidTimeout = true; diff --git a/packages/react-reconciler/src/__tests__/ReactTracing-test.internal.js b/packages/react-reconciler/src/__tests__/ReactTracing-test.internal.js index 3168f6f778505..258facfbeb5da 100644 --- a/packages/react-reconciler/src/__tests__/ReactTracing-test.internal.js +++ b/packages/react-reconciler/src/__tests__/ReactTracing-test.internal.js @@ -10,16 +10,16 @@ 'use strict'; -describe('ReactTracking', () => { - it('should error if profiling renderer and non-profiling schedule/tracking bundles are combined', () => { +describe('ReactTracing', () => { + it('should error if profiling renderer and non-profiling schedule/tracing bundles are combined', () => { jest.resetModules(); const ReactFeatureFlags = require('shared/ReactFeatureFlags'); - ReactFeatureFlags.enableSchedulerTracking = false; + ReactFeatureFlags.enableSchedulerTracing = false; - require('schedule/tracking'); + require('schedule/tracing'); - ReactFeatureFlags.enableSchedulerTracking = true; + ReactFeatureFlags.enableSchedulerTracing = true; expect(() => require('react-dom')).toThrow( 'Learn more at http://fb.me/react-profiling', diff --git a/packages/react/src/ReactSharedInternals.js b/packages/react/src/ReactSharedInternals.js index 271e8aeb742af..d72669275634a 100644 --- a/packages/react/src/ReactSharedInternals.js +++ b/packages/react/src/ReactSharedInternals.js @@ -18,10 +18,10 @@ import { unstable_getCurrent, unstable_getThreadID, unstable_subscribe, - unstable_track, + unstable_trace, unstable_unsubscribe, unstable_wrap, -} from 'schedule/tracking'; +} from 'schedule/tracing'; import ReactCurrentOwner from './ReactCurrentOwner'; import ReactDebugCurrentFrame from './ReactDebugCurrentFrame'; @@ -43,14 +43,14 @@ if (__UMD__) { unstable_now, unstable_scheduleWork, }, - ScheduleTracking: { + ScheduleTracing: { __interactionsRef, __subscriberRef, unstable_clear, unstable_getCurrent, unstable_getThreadID, unstable_subscribe, - unstable_track, + unstable_trace, unstable_unsubscribe, unstable_wrap, }, diff --git a/packages/react/src/__tests__/ReactProfiler-test.internal.js b/packages/react/src/__tests__/ReactProfiler-test.internal.js index 1747e529919c6..eeede71999faa 100644 --- a/packages/react/src/__tests__/ReactProfiler-test.internal.js +++ b/packages/react/src/__tests__/ReactProfiler-test.internal.js @@ -15,14 +15,14 @@ let ReactFeatureFlags; let ReactNoop; let ReactTestRenderer; let advanceTimeBy; -let SchedulerTracking; +let SchedulerTracing; let mockNow; let AdvanceTime; function loadModules({ enableProfilerTimer = true, enableSuspense = false, - enableSchedulerTracking = true, + enableSchedulerTracing = true, replayFailedUnitOfWorkWithInvokeGuardedCallback = false, useNoopRenderer = false, } = {}) { @@ -37,12 +37,12 @@ function loadModules({ ReactFeatureFlags.debugRenderPhaseSideEffectsForStrictMode = false; ReactFeatureFlags.enableProfilerTimer = enableProfilerTimer; ReactFeatureFlags.enableGetDerivedStateFromCatch = true; - ReactFeatureFlags.enableSchedulerTracking = enableSchedulerTracking; + ReactFeatureFlags.enableSchedulerTracing = enableSchedulerTracing; ReactFeatureFlags.enableSuspense = enableSuspense; ReactFeatureFlags.replayFailedUnitOfWorkWithInvokeGuardedCallback = replayFailedUnitOfWorkWithInvokeGuardedCallback; React = require('react'); - SchedulerTracking = require('schedule/tracking'); + SchedulerTracing = require('schedule/tracing'); if (useNoopRenderer) { ReactNoop = require('react-noop-renderer'); @@ -82,17 +82,17 @@ const mockDevToolsForTest = () => { describe('Profiler', () => { describe('works in profiling and non-profiling bundles', () => { - [true, false].forEach(enableSchedulerTracking => { + [true, false].forEach(enableSchedulerTracing => { [true, false].forEach(enableProfilerTimer => { - describe(`enableSchedulerTracking:${ - enableSchedulerTracking ? 'enabled' : 'disabled' + describe(`enableSchedulerTracing:${ + enableSchedulerTracing ? 'enabled' : 'disabled' } enableProfilerTimer:${ enableProfilerTimer ? 'enabled' : 'disabled' }`, () => { beforeEach(() => { jest.resetModules(); - loadModules({enableSchedulerTracking, enableProfilerTimer}); + loadModules({enableSchedulerTracing, enableProfilerTimer}); }); // This will throw in production too, @@ -165,12 +165,12 @@ describe('Profiler', () => { }); }); - [true, false].forEach(enableSchedulerTracking => { + [true, false].forEach(enableSchedulerTracing => { describe('onRender callback', () => { beforeEach(() => { jest.resetModules(); - loadModules({enableSchedulerTracking}); + loadModules({enableSchedulerTracing}); }); it('should handle errors thrown', () => { @@ -265,16 +265,14 @@ describe('Profiler', () => { let [call] = callback.mock.calls; - expect(call).toHaveLength(enableSchedulerTracking ? 7 : 6); + expect(call).toHaveLength(enableSchedulerTracing ? 7 : 6); expect(call[0]).toBe('test'); expect(call[1]).toBe('mount'); expect(call[2]).toBe(10); // actual time expect(call[3]).toBe(10); // base time expect(call[4]).toBe(5); // start time expect(call[5]).toBe(15); // commit time - expect(call[6]).toEqual( - enableSchedulerTracking ? new Set() : undefined, - ); // interaction events + expect(call[6]).toEqual(enableSchedulerTracing ? new Set() : undefined); // interaction events callback.mockReset(); @@ -290,16 +288,14 @@ describe('Profiler', () => { [call] = callback.mock.calls; - expect(call).toHaveLength(enableSchedulerTracking ? 7 : 6); + expect(call).toHaveLength(enableSchedulerTracing ? 7 : 6); expect(call[0]).toBe('test'); expect(call[1]).toBe('update'); expect(call[2]).toBe(10); // actual time expect(call[3]).toBe(10); // base time expect(call[4]).toBe(35); // start time expect(call[5]).toBe(45); // commit time - expect(call[6]).toEqual( - enableSchedulerTracking ? new Set() : undefined, - ); // interaction events + expect(call[6]).toEqual(enableSchedulerTracing ? new Set() : undefined); // interaction events callback.mockReset(); @@ -315,16 +311,14 @@ describe('Profiler', () => { [call] = callback.mock.calls; - expect(call).toHaveLength(enableSchedulerTracking ? 7 : 6); + expect(call).toHaveLength(enableSchedulerTracing ? 7 : 6); expect(call[0]).toBe('test'); expect(call[1]).toBe('update'); expect(call[2]).toBe(4); // actual time expect(call[3]).toBe(4); // base time expect(call[4]).toBe(65); // start time expect(call[5]).toBe(69); // commit time - expect(call[6]).toEqual( - enableSchedulerTracking ? new Set() : undefined, - ); // interaction events + expect(call[6]).toEqual(enableSchedulerTracing ? new Set() : undefined); // interaction events }); it('includes render times of nested Profilers in their parent times', () => { @@ -362,7 +356,7 @@ describe('Profiler', () => { expect(parentCall[5]).toBe(35); // commit time }); - it('tracks sibling Profilers separately', () => { + it('traces sibling Profilers separately', () => { const callback = jest.fn(); advanceTimeBy(5); // 0 -> 5 @@ -1220,9 +1214,9 @@ describe('Profiler', () => { expect(ReactNoop.getRoot('two').current.actualDuration).toBe(14); }); - describe('interaction tracking', () => { + describe('interaction tracing', () => { let onInteractionScheduledWorkCompleted; - let onInteractionTracked; + let onInteractionTraced; let onWorkCanceled; let onWorkScheduled; let onWorkStarted; @@ -1239,7 +1233,7 @@ describe('Profiler', () => { jest.resetModules(); loadModules({ - enableSchedulerTracking: true, + enableSchedulerTracing: true, }); throwInOnInteractionScheduledWorkCompleted = false; @@ -1252,7 +1246,7 @@ describe('Profiler', () => { throw Error('Expected error onInteractionScheduledWorkCompleted'); } }); - onInteractionTracked = jest.fn(); + onInteractionTraced = jest.fn(); onWorkCanceled = jest.fn(); onWorkScheduled = jest.fn(() => { if (throwInOnWorkScheduled) { @@ -1271,9 +1265,9 @@ describe('Profiler', () => { }); // Verify interaction subscriber methods are called as expected. - SchedulerTracking.unstable_subscribe({ + SchedulerTracing.unstable_subscribe({ onInteractionScheduledWorkCompleted, - onInteractionTracked, + onInteractionTraced, onWorkCanceled, onWorkScheduled, onWorkStarted, @@ -1293,7 +1287,7 @@ describe('Profiler', () => { // Errors that happen inside of a subscriber should throw, throwInOnWorkScheduled = true; expect(() => { - SchedulerTracking.unstable_track('event', mockNow(), () => { + SchedulerTracing.unstable_trace('event', mockNow(), () => { renderer = ReactTestRenderer.create(fail, { unstable_isAsync: true, }); @@ -1319,7 +1313,7 @@ describe('Profiler', () => { } let renderer; - SchedulerTracking.unstable_track('event', mockNow(), () => { + SchedulerTracing.unstable_trace('event', mockNow(), () => { renderer = ReactTestRenderer.create(text, { unstable_isAsync: true, }); @@ -1348,7 +1342,7 @@ describe('Profiler', () => { } let renderer; - SchedulerTracking.unstable_track('event', mockNow(), () => { + SchedulerTracing.unstable_trace('event', mockNow(), () => { renderer = ReactTestRenderer.create(text, { unstable_isAsync: true, }); @@ -1390,8 +1384,8 @@ describe('Profiler', () => { }; let renderer; - SchedulerTracking.unstable_track(eventOne.name, mockNow(), () => { - SchedulerTracking.unstable_track(eventTwo.name, mockNow(), () => { + SchedulerTracing.unstable_trace(eventOne.name, mockNow(), () => { + SchedulerTracing.unstable_trace(eventTwo.name, mockNow(), () => { renderer = ReactTestRenderer.create(text, { unstable_isAsync: true, }); @@ -1410,7 +1404,7 @@ describe('Profiler', () => { }); }); - it('should associate tracked events with their subsequent commits', () => { + it('should associate traced events with their subsequent commits', () => { let instance = null; const Yield = ({duration = 10, value}) => { @@ -1445,7 +1439,7 @@ describe('Profiler', () => { const onRender = jest.fn(); let renderer; - SchedulerTracking.unstable_track( + SchedulerTracing.unstable_trace( interactionCreation.name, mockNow(), () => { @@ -1460,13 +1454,13 @@ describe('Profiler', () => { }, ); - expect(onInteractionTracked).toHaveBeenCalledTimes(1); - expect(onInteractionTracked).toHaveBeenLastNotifiedOfInteraction( + expect(onInteractionTraced).toHaveBeenCalledTimes(1); + expect(onInteractionTraced).toHaveBeenLastNotifiedOfInteraction( interactionCreation, ); expect(onInteractionScheduledWorkCompleted).not.toHaveBeenCalled(); - // The schedule/tracking package will notify of work started for the default thread, + // The schedule/tracing package will notify of work started for the default thread, // But React shouldn't notify until it's been flushed. expect(getWorkForReactThreads(onWorkStarted)).toHaveLength(0); expect(getWorkForReactThreads(onWorkStopped)).toHaveLength(0); @@ -1486,11 +1480,11 @@ describe('Profiler', () => { let call = onRender.mock.calls[0]; expect(call[0]).toEqual('test-profiler'); expect(call[5]).toEqual(mockNow()); - if (ReactFeatureFlags.enableSchedulerTracking) { + if (ReactFeatureFlags.enableSchedulerTracing) { expect(call[6]).toMatchInteractions([interactionCreation]); } - expect(onInteractionTracked).toHaveBeenCalledTimes(1); + expect(onInteractionTraced).toHaveBeenCalledTimes(1); expect(onInteractionScheduledWorkCompleted).toHaveBeenCalledTimes(1); expect( onInteractionScheduledWorkCompleted, @@ -1518,13 +1512,13 @@ describe('Profiler', () => { name: 'initial event', timestamp: mockNow(), }; - SchedulerTracking.unstable_track(interactionOne.name, mockNow(), () => { + SchedulerTracing.unstable_trace(interactionOne.name, mockNow(), () => { instance.setState({count: 1}); - // Update state again to verify our tracked interaction isn't registered twice + // Update state again to verify our traced interaction isn't registered twice instance.setState({count: 2}); - // The schedule/tracking package will notify of work started for the default thread, + // The schedule/tracing package will notify of work started for the default thread, // But React shouldn't notify until it's been flushed. expect(getWorkForReactThreads(onWorkStarted)).toHaveLength(0); expect(getWorkForReactThreads(onWorkStopped)).toHaveLength(0); @@ -1541,8 +1535,8 @@ describe('Profiler', () => { expect(renderer).toFlushThrough(['first']); expect(onRender).not.toHaveBeenCalled(); - expect(onInteractionTracked).toHaveBeenCalledTimes(2); - expect(onInteractionTracked).toHaveBeenLastNotifiedOfInteraction( + expect(onInteractionTraced).toHaveBeenCalledTimes(2); + expect(onInteractionTraced).toHaveBeenLastNotifiedOfInteraction( interactionOne, ); expect(onInteractionScheduledWorkCompleted).toHaveBeenCalledTimes(1); @@ -1558,7 +1552,7 @@ describe('Profiler', () => { call = onRender.mock.calls[0]; expect(call[0]).toEqual('test-profiler'); expect(call[5]).toEqual(mockNow()); - if (ReactFeatureFlags.enableSchedulerTracking) { + if (ReactFeatureFlags.enableSchedulerTracing) { expect(call[6]).toMatchInteractions([interactionOne]); } @@ -1591,11 +1585,11 @@ describe('Profiler', () => { call = onRender.mock.calls[0]; expect(call[0]).toEqual('test-profiler'); expect(call[5]).toEqual(mockNow()); - if (ReactFeatureFlags.enableSchedulerTracking) { + if (ReactFeatureFlags.enableSchedulerTracing) { expect(call[6]).toMatchInteractions([]); } - expect(onInteractionTracked).toHaveBeenCalledTimes(2); + expect(onInteractionTraced).toHaveBeenCalledTimes(2); expect(onInteractionScheduledWorkCompleted).toHaveBeenCalledTimes(2); expect( onInteractionScheduledWorkCompleted, @@ -1607,13 +1601,13 @@ describe('Profiler', () => { advanceTimeBy(3); - // Verify that root updates are also associated with tracked events. + // Verify that root updates are also associated with traced events. const interactionTwo = { id: 2, name: 'root update event', timestamp: mockNow(), }; - SchedulerTracking.unstable_track(interactionTwo.name, mockNow(), () => { + SchedulerTracing.unstable_trace(interactionTwo.name, mockNow(), () => { renderer.update( @@ -1621,13 +1615,13 @@ describe('Profiler', () => { ); }); - expect(onInteractionTracked).toHaveBeenCalledTimes(3); - expect(onInteractionTracked).toHaveBeenLastNotifiedOfInteraction( + expect(onInteractionTraced).toHaveBeenCalledTimes(3); + expect(onInteractionTraced).toHaveBeenLastNotifiedOfInteraction( interactionTwo, ); expect(onInteractionScheduledWorkCompleted).toHaveBeenCalledTimes(2); - // The schedule/tracking package will notify of work started for the default thread, + // The schedule/tracing package will notify of work started for the default thread, // But React shouldn't notify until it's been flushed. expect(getWorkForReactThreads(onWorkStarted)).toHaveLength(0); expect(getWorkForReactThreads(onWorkStopped)).toHaveLength(0); @@ -1647,11 +1641,11 @@ describe('Profiler', () => { call = onRender.mock.calls[0]; expect(call[0]).toEqual('test-profiler'); expect(call[5]).toEqual(mockNow()); - if (ReactFeatureFlags.enableSchedulerTracking) { + if (ReactFeatureFlags.enableSchedulerTracing) { expect(call[6]).toMatchInteractions([interactionTwo]); } - expect(onInteractionTracked).toHaveBeenCalledTimes(3); + expect(onInteractionTraced).toHaveBeenCalledTimes(3); expect(onInteractionScheduledWorkCompleted).toHaveBeenCalledTimes(3); expect( onInteractionScheduledWorkCompleted, @@ -1701,7 +1695,7 @@ describe('Profiler', () => { // Initial mount. renderer.unstable_flushAll(['FirstComponent', 'SecondComponent']); - expect(onInteractionTracked).not.toHaveBeenCalled(); + expect(onInteractionTraced).not.toHaveBeenCalled(); expect(onInteractionScheduledWorkCompleted).not.toHaveBeenCalled(); onRender.mockClear(); @@ -1714,121 +1708,115 @@ describe('Profiler', () => { timestamp: mockNow(), }; - SchedulerTracking.unstable_track( - interactionLowPri.name, - mockNow(), - () => { - // Render a partially update, but don't finish. - first.setState({count: 1}); + SchedulerTracing.unstable_trace(interactionLowPri.name, mockNow(), () => { + // Render a partially update, but don't finish. + first.setState({count: 1}); - expect(onWorkScheduled).toHaveBeenCalled(); - expect(onWorkScheduled.mock.calls[0][0]).toMatchInteractions([ - interactionLowPri, - ]); + expect(onWorkScheduled).toHaveBeenCalled(); + expect(onWorkScheduled.mock.calls[0][0]).toMatchInteractions([ + interactionLowPri, + ]); - expect(renderer).toFlushThrough(['FirstComponent']); - expect(onRender).not.toHaveBeenCalled(); + expect(renderer).toFlushThrough(['FirstComponent']); + expect(onRender).not.toHaveBeenCalled(); - expect(onInteractionTracked).toHaveBeenCalledTimes(1); - expect(onInteractionTracked).toHaveBeenLastNotifiedOfInteraction( - interactionLowPri, - ); - expect(onInteractionScheduledWorkCompleted).not.toHaveBeenCalled(); - expect(getWorkForReactThreads(onWorkStarted)).toHaveLength(1); - expect( - getWorkForReactThreads(onWorkStarted)[0][0], - ).toMatchInteractions([interactionLowPri]); - expect(getWorkForReactThreads(onWorkStopped)).toHaveLength(0); - - advanceTimeBy(100); - - const interactionHighPri = { - id: 1, - name: 'highPri', - timestamp: mockNow(), - }; + expect(onInteractionTraced).toHaveBeenCalledTimes(1); + expect(onInteractionTraced).toHaveBeenLastNotifiedOfInteraction( + interactionLowPri, + ); + expect(onInteractionScheduledWorkCompleted).not.toHaveBeenCalled(); + expect(getWorkForReactThreads(onWorkStarted)).toHaveLength(1); + expect(getWorkForReactThreads(onWorkStarted)[0][0]).toMatchInteractions( + [interactionLowPri], + ); + expect(getWorkForReactThreads(onWorkStopped)).toHaveLength(0); - // Interrupt with higher priority work. - // This simulates a total of 37ms of actual render time. - renderer.unstable_flushSync(() => { - SchedulerTracking.unstable_track( - interactionHighPri.name, - mockNow(), - () => { - second.setState({count: 1}); - - expect(onInteractionTracked).toHaveBeenCalledTimes(2); - expect( - onInteractionTracked, - ).toHaveBeenLastNotifiedOfInteraction(interactionHighPri); - expect( - onInteractionScheduledWorkCompleted, - ).not.toHaveBeenCalled(); - - expect(getWorkForReactThreads(onWorkStarted)).toHaveLength(1); - expect(getWorkForReactThreads(onWorkStopped)).toHaveLength(0); - }, - ); - }); - expect(ReactTestRenderer).toClearYields(['SecondComponent']); - - expect(onInteractionTracked).toHaveBeenCalledTimes(2); - expect(onInteractionScheduledWorkCompleted).toHaveBeenCalledTimes(1); - expect( - onInteractionScheduledWorkCompleted, - ).toHaveBeenLastNotifiedOfInteraction(interactionHighPri); - - // Verify the high priority update was associated with the high priority event. - expect(onRender).toHaveBeenCalledTimes(1); - let call = onRender.mock.calls[0]; - expect(call[0]).toEqual('test'); - expect(call[5]).toEqual(mockNow()); - expect(call[6]).toMatchInteractions( - ReactFeatureFlags.enableSchedulerTracking - ? [interactionLowPri, interactionHighPri] - : [], - ); + advanceTimeBy(100); - onRender.mockClear(); + const interactionHighPri = { + id: 1, + name: 'highPri', + timestamp: mockNow(), + }; - advanceTimeBy(100); + // Interrupt with higher priority work. + // This simulates a total of 37ms of actual render time. + renderer.unstable_flushSync(() => { + SchedulerTracing.unstable_trace( + interactionHighPri.name, + mockNow(), + () => { + second.setState({count: 1}); + + expect(onInteractionTraced).toHaveBeenCalledTimes(2); + expect(onInteractionTraced).toHaveBeenLastNotifiedOfInteraction( + interactionHighPri, + ); + expect( + onInteractionScheduledWorkCompleted, + ).not.toHaveBeenCalled(); - // Resume the original low priority update, with rebased state. - // Verify the low priority update was retained. - renderer.unstable_flushAll(['FirstComponent']); - expect(onRender).toHaveBeenCalledTimes(1); - call = onRender.mock.calls[0]; - expect(call[0]).toEqual('test'); - expect(call[5]).toEqual(mockNow()); - expect(call[6]).toMatchInteractions( - ReactFeatureFlags.enableSchedulerTracking - ? [interactionLowPri] - : [], + expect(getWorkForReactThreads(onWorkStarted)).toHaveLength(1); + expect(getWorkForReactThreads(onWorkStopped)).toHaveLength(0); + }, ); + }); + expect(ReactTestRenderer).toClearYields(['SecondComponent']); - expect(onInteractionTracked).toHaveBeenCalledTimes(2); - expect(onInteractionScheduledWorkCompleted).toHaveBeenCalledTimes(1); - - // Work might be started multiple times before being completed. - // This is okay; it's part of the schedule/tracking contract. - expect(getWorkForReactThreads(onWorkStarted)).toHaveLength(3); - expect( - getWorkForReactThreads(onWorkStarted)[1][0], - ).toMatchInteractions([interactionLowPri, interactionHighPri]); - expect( - getWorkForReactThreads(onWorkStarted)[2][0], - ).toMatchInteractions([interactionLowPri]); - expect(getWorkForReactThreads(onWorkStopped)).toHaveLength(2); - expect( - getWorkForReactThreads(onWorkStopped)[0][0], - ).toMatchInteractions([interactionLowPri, interactionHighPri]); - expect( - getWorkForReactThreads(onWorkStopped)[1][0], - ).toMatchInteractions([interactionLowPri]); - }, - ); + expect(onInteractionTraced).toHaveBeenCalledTimes(2); + expect(onInteractionScheduledWorkCompleted).toHaveBeenCalledTimes(1); + expect( + onInteractionScheduledWorkCompleted, + ).toHaveBeenLastNotifiedOfInteraction(interactionHighPri); + + // Verify the high priority update was associated with the high priority event. + expect(onRender).toHaveBeenCalledTimes(1); + let call = onRender.mock.calls[0]; + expect(call[0]).toEqual('test'); + expect(call[5]).toEqual(mockNow()); + expect(call[6]).toMatchInteractions( + ReactFeatureFlags.enableSchedulerTracing + ? [interactionLowPri, interactionHighPri] + : [], + ); + + onRender.mockClear(); + + advanceTimeBy(100); + + // Resume the original low priority update, with rebased state. + // Verify the low priority update was retained. + renderer.unstable_flushAll(['FirstComponent']); + expect(onRender).toHaveBeenCalledTimes(1); + call = onRender.mock.calls[0]; + expect(call[0]).toEqual('test'); + expect(call[5]).toEqual(mockNow()); + expect(call[6]).toMatchInteractions( + ReactFeatureFlags.enableSchedulerTracing ? [interactionLowPri] : [], + ); + + expect(onInteractionTraced).toHaveBeenCalledTimes(2); + expect(onInteractionScheduledWorkCompleted).toHaveBeenCalledTimes(1); + + // Work might be started multiple times before being completed. + // This is okay; it's part of the schedule/tracing contract. + expect(getWorkForReactThreads(onWorkStarted)).toHaveLength(3); + expect(getWorkForReactThreads(onWorkStarted)[1][0]).toMatchInteractions( + [interactionLowPri, interactionHighPri], + ); + expect(getWorkForReactThreads(onWorkStarted)[2][0]).toMatchInteractions( + [interactionLowPri], + ); + expect(getWorkForReactThreads(onWorkStopped)).toHaveLength(2); + expect(getWorkForReactThreads(onWorkStopped)[0][0]).toMatchInteractions( + [interactionLowPri, interactionHighPri], + ); + expect(getWorkForReactThreads(onWorkStopped)[1][0]).toMatchInteractions( + [interactionLowPri], + ); + }); - expect(onInteractionTracked).toHaveBeenCalledTimes(2); + expect(onInteractionTraced).toHaveBeenCalledTimes(2); expect(onInteractionScheduledWorkCompleted).toHaveBeenCalledTimes(2); expect( onInteractionScheduledWorkCompleted, @@ -1837,7 +1825,7 @@ describe('Profiler', () => { expect(getWorkForReactThreads(onWorkStopped)).toHaveLength(2); }); - it('should track work spawned by a commit phase lifecycle and setState callback', () => { + it('should trace work spawned by a commit phase lifecycle and setState callback', () => { let instance; class Example extends React.Component { state = { @@ -1870,7 +1858,7 @@ describe('Profiler', () => { const onRender = jest.fn(); let firstCommitTime = mockNow(); let renderer; - SchedulerTracking.unstable_track(interactionOne.name, mockNow(), () => { + SchedulerTracing.unstable_trace(interactionOne.name, mockNow(), () => { renderer = ReactTestRenderer.create( @@ -1879,8 +1867,8 @@ describe('Profiler', () => { ); }); - expect(onInteractionTracked).toHaveBeenCalledTimes(1); - expect(onInteractionTracked).toHaveBeenLastNotifiedOfInteraction( + expect(onInteractionTraced).toHaveBeenCalledTimes(1); + expect(onInteractionTraced).toHaveBeenLastNotifiedOfInteraction( interactionOne, ); expect(onInteractionScheduledWorkCompleted).not.toHaveBeenCalled(); @@ -1889,7 +1877,7 @@ describe('Profiler', () => { renderer.unstable_flushAll(['Example:0', 'Example:1']); - expect(onInteractionTracked).toHaveBeenCalledTimes(1); + expect(onInteractionTraced).toHaveBeenCalledTimes(1); expect(onInteractionScheduledWorkCompleted).toHaveBeenCalledTimes(1); expect( onInteractionScheduledWorkCompleted, @@ -1914,13 +1902,13 @@ describe('Profiler', () => { expect(call[0]).toEqual('test'); expect(call[5]).toEqual(firstCommitTime); expect(call[6]).toMatchInteractions( - ReactFeatureFlags.enableSchedulerTracking ? [interactionOne] : [], + ReactFeatureFlags.enableSchedulerTracing ? [interactionOne] : [], ); call = onRender.mock.calls[1]; expect(call[0]).toEqual('test'); expect(call[5]).toEqual(mockNow()); expect(call[6]).toMatchInteractions( - ReactFeatureFlags.enableSchedulerTracking ? [interactionOne] : [], + ReactFeatureFlags.enableSchedulerTracing ? [interactionOne] : [], ); onRender.mockClear(); @@ -1931,13 +1919,13 @@ describe('Profiler', () => { timestamp: mockNow(), }; - // Cause an tracked, async update - SchedulerTracking.unstable_track(interactionTwo.name, mockNow(), () => { + // Cause an traced, async update + SchedulerTracing.unstable_trace(interactionTwo.name, mockNow(), () => { instance.setState({count: 2}); }); expect(onRender).not.toHaveBeenCalled(); - expect(onInteractionTracked).toHaveBeenCalledTimes(2); - expect(onInteractionTracked).toHaveBeenLastNotifiedOfInteraction( + expect(onInteractionTraced).toHaveBeenCalledTimes(2); + expect(onInteractionTraced).toHaveBeenLastNotifiedOfInteraction( interactionTwo, ); expect(onInteractionScheduledWorkCompleted).toHaveBeenCalledTimes(1); @@ -1946,12 +1934,12 @@ describe('Profiler', () => { advanceTimeBy(5); - // Flush async work (outside of tracked scope) + // Flush async work (outside of traced scope) // This will cause an intentional cascading update from did-update firstCommitTime = mockNow(); renderer.unstable_flushAll(['Example:2', 'Example:3']); - expect(onInteractionTracked).toHaveBeenCalledTimes(2); + expect(onInteractionTraced).toHaveBeenCalledTimes(2); expect(onInteractionScheduledWorkCompleted).toHaveBeenCalledTimes(2); expect( onInteractionScheduledWorkCompleted, @@ -1977,13 +1965,13 @@ describe('Profiler', () => { expect(call[0]).toEqual('test'); expect(call[5]).toEqual(firstCommitTime); expect(call[6]).toMatchInteractions( - ReactFeatureFlags.enableSchedulerTracking ? [interactionTwo] : [], + ReactFeatureFlags.enableSchedulerTracing ? [interactionTwo] : [], ); call = onRender.mock.calls[1]; expect(call[0]).toEqual('test'); expect(call[5]).toEqual(mockNow()); expect(call[6]).toMatchInteractions( - ReactFeatureFlags.enableSchedulerTracking ? [interactionTwo] : [], + ReactFeatureFlags.enableSchedulerTracing ? [interactionTwo] : [], ); onRender.mockClear(); @@ -1998,25 +1986,25 @@ describe('Profiler', () => { function callback() { instance.setState({count: 6}); } - SchedulerTracking.unstable_track(interactionThree.name, mockNow(), () => { + SchedulerTracing.unstable_trace(interactionThree.name, mockNow(), () => { instance.setState({count: 5}, callback); }); expect(onRender).not.toHaveBeenCalled(); - expect(onInteractionTracked).toHaveBeenCalledTimes(3); - expect(onInteractionTracked).toHaveBeenLastNotifiedOfInteraction( + expect(onInteractionTraced).toHaveBeenCalledTimes(3); + expect(onInteractionTraced).toHaveBeenLastNotifiedOfInteraction( interactionThree, ); expect(onInteractionScheduledWorkCompleted).toHaveBeenCalledTimes(2); expect(getWorkForReactThreads(onWorkStarted)).toHaveLength(4); expect(getWorkForReactThreads(onWorkStopped)).toHaveLength(4); - // Flush async work (outside of tracked scope) + // Flush async work (outside of traced scope) // This will cause an intentional cascading update from the setState callback firstCommitTime = mockNow(); renderer.unstable_flushAll(['Example:5', 'Example:6']); - expect(onInteractionTracked).toHaveBeenCalledTimes(3); + expect(onInteractionTraced).toHaveBeenCalledTimes(3); expect(onInteractionScheduledWorkCompleted).toHaveBeenCalledTimes(3); expect( onInteractionScheduledWorkCompleted, @@ -2042,17 +2030,17 @@ describe('Profiler', () => { expect(call[0]).toEqual('test'); expect(call[5]).toEqual(firstCommitTime); expect(call[6]).toMatchInteractions( - ReactFeatureFlags.enableSchedulerTracking ? [interactionThree] : [], + ReactFeatureFlags.enableSchedulerTracing ? [interactionThree] : [], ); call = onRender.mock.calls[1]; expect(call[0]).toEqual('test'); expect(call[5]).toEqual(mockNow()); expect(call[6]).toMatchInteractions( - ReactFeatureFlags.enableSchedulerTracking ? [interactionThree] : [], + ReactFeatureFlags.enableSchedulerTracing ? [interactionThree] : [], ); }); - it('should track interactions associated with a parent component state update', () => { + it('should trace interactions associated with a parent component state update', () => { const onRender = jest.fn(); let parentInstance = null; @@ -2091,12 +2079,12 @@ describe('Profiler', () => { timestamp: mockNow(), }; - SchedulerTracking.unstable_track(interaction.name, mockNow(), () => { + SchedulerTracing.unstable_trace(interaction.name, mockNow(), () => { parentInstance.setState({count: 1}); }); - expect(onInteractionTracked).toHaveBeenCalledTimes(1); - expect(onInteractionTracked).toHaveBeenLastNotifiedOfInteraction( + expect(onInteractionTraced).toHaveBeenCalledTimes(1); + expect(onInteractionTraced).toHaveBeenLastNotifiedOfInteraction( interaction, ); expect(onInteractionScheduledWorkCompleted).not.toHaveBeenCalled(); @@ -2109,10 +2097,10 @@ describe('Profiler', () => { let call = onRender.mock.calls[0]; expect(call[0]).toEqual('test-profiler'); expect(call[6]).toMatchInteractions( - ReactFeatureFlags.enableSchedulerTracking ? [interaction] : [], + ReactFeatureFlags.enableSchedulerTracing ? [interaction] : [], ); - expect(onInteractionTracked).toHaveBeenCalledTimes(1); + expect(onInteractionTraced).toHaveBeenCalledTimes(1); expect(onInteractionScheduledWorkCompleted).toHaveBeenCalledTimes(1); expect( onInteractionScheduledWorkCompleted, @@ -2127,19 +2115,19 @@ describe('Profiler', () => { ]); }); - it('tracks both the temporary placeholder and the finished render for an interaction', async () => { + it('traces both the temporary placeholder and the finished render for an interaction', async () => { jest.resetModules(); loadModules({ useNoopRenderer: true, enableSuspense: true, - enableSchedulerTracking: true, + enableSchedulerTracing: true, }); // Re-register since we've reloaded modules - SchedulerTracking.unstable_subscribe({ + SchedulerTracing.unstable_subscribe({ onInteractionScheduledWorkCompleted, - onInteractionTracked, + onInteractionTraced, onWorkCanceled, onWorkScheduled, onWorkStarted, @@ -2204,7 +2192,7 @@ describe('Profiler', () => { }; const onRender = jest.fn(); - SchedulerTracking.unstable_track(interaction.name, mockNow(), () => { + SchedulerTracing.unstable_trace(interaction.name, mockNow(), () => { ReactNoop.render( }> @@ -2215,8 +2203,8 @@ describe('Profiler', () => { ); }); - expect(onInteractionTracked).toHaveBeenCalledTimes(1); - expect(onInteractionTracked).toHaveBeenLastNotifiedOfInteraction( + expect(onInteractionTraced).toHaveBeenCalledTimes(1); + expect(onInteractionTraced).toHaveBeenLastNotifiedOfInteraction( interaction, ); expect(onInteractionScheduledWorkCompleted).not.toHaveBeenCalled(); @@ -2249,10 +2237,10 @@ describe('Profiler', () => { let call = onRender.mock.calls[0]; expect(call[0]).toEqual('test-profiler'); expect(call[6]).toMatchInteractions( - ReactFeatureFlags.enableSchedulerTracking ? [interaction] : [], + ReactFeatureFlags.enableSchedulerTracing ? [interaction] : [], ); - expect(onInteractionTracked).toHaveBeenCalledTimes(1); + expect(onInteractionTraced).toHaveBeenCalledTimes(1); expect(onInteractionScheduledWorkCompleted).not.toHaveBeenCalled(); // Once the promise resolves, we render the suspended view @@ -2264,10 +2252,10 @@ describe('Profiler', () => { call = onRender.mock.calls[1]; expect(call[0]).toEqual('test-profiler'); expect(call[6]).toMatchInteractions( - ReactFeatureFlags.enableSchedulerTracking ? [interaction] : [], + ReactFeatureFlags.enableSchedulerTracing ? [interaction] : [], ); - expect(onInteractionTracked).toHaveBeenCalledTimes(1); + expect(onInteractionTraced).toHaveBeenCalledTimes(1); expect(onInteractionScheduledWorkCompleted).toHaveBeenCalledTimes(1); expect( onInteractionScheduledWorkCompleted, diff --git a/packages/react/src/__tests__/ReactProfilerDevToolsIntegration-test.internal.js b/packages/react/src/__tests__/ReactProfilerDevToolsIntegration-test.internal.js index 04079492eba01..72478df0a37fa 100644 --- a/packages/react/src/__tests__/ReactProfilerDevToolsIntegration-test.internal.js +++ b/packages/react/src/__tests__/ReactProfilerDevToolsIntegration-test.internal.js @@ -14,7 +14,7 @@ describe('ReactProfiler DevTools integration', () => { let React; let ReactFeatureFlags; let ReactTestRenderer; - let SchedulerTracking; + let SchedulerTracing; let AdvanceTime; let advanceTimeBy; let hook; @@ -38,8 +38,8 @@ describe('ReactProfiler DevTools integration', () => { ReactFeatureFlags = require('shared/ReactFeatureFlags'); ReactFeatureFlags.enableProfilerTimer = true; - ReactFeatureFlags.enableSchedulerTracking = true; - SchedulerTracking = require('schedule/tracking'); + ReactFeatureFlags.enableSchedulerTracing = true; + SchedulerTracing = require('schedule/tracing'); React = require('react'); ReactTestRenderer = require('react-test-renderer'); @@ -168,7 +168,7 @@ describe('ReactProfiler DevTools integration', () => { ).toBe(7); }); - it('should store tracked interactions on the HostNode so DevTools can access them', () => { + it('should store traced interactions on the HostNode so DevTools can access them', () => { // Render without an interaction const rendered = ReactTestRenderer.create(
    ); @@ -180,7 +180,7 @@ describe('ReactProfiler DevTools integration', () => { const eventTime = mockNow(); // Render with an interaction - SchedulerTracking.unstable_track('some event', eventTime, () => { + SchedulerTracing.unstable_trace('some event', eventTime, () => { rendered.update(
    ); }); diff --git a/packages/react/src/__tests__/__snapshots__/ReactProfiler-test.internal.js.snap b/packages/react/src/__tests__/__snapshots__/ReactProfiler-test.internal.js.snap index 18f6f0ac516fa..02ebda64ddd26 100644 --- a/packages/react/src/__tests__/__snapshots__/ReactProfiler-test.internal.js.snap +++ b/packages/react/src/__tests__/__snapshots__/ReactProfiler-test.internal.js.snap @@ -1,6 +1,6 @@ // Jest Snapshot v1, https://goo.gl/fbAQLP -exports[`Profiler works in profiling and non-profiling bundles enableSchedulerTracking:disabled enableProfilerTimer:disabled should render children 1`] = ` +exports[`Profiler works in profiling and non-profiling bundles enableSchedulerTracing:disabled enableProfilerTimer:disabled should render children 1`] = `
    outside span @@ -14,11 +14,11 @@ exports[`Profiler works in profiling and non-profiling bundles enableSchedulerTr
    `; -exports[`Profiler works in profiling and non-profiling bundles enableSchedulerTracking:disabled enableProfilerTimer:disabled should support an empty Profiler (with no children) 1`] = `null`; +exports[`Profiler works in profiling and non-profiling bundles enableSchedulerTracing:disabled enableProfilerTimer:disabled should support an empty Profiler (with no children) 1`] = `null`; -exports[`Profiler works in profiling and non-profiling bundles enableSchedulerTracking:disabled enableProfilerTimer:disabled should support an empty Profiler (with no children) 2`] = `
    `; +exports[`Profiler works in profiling and non-profiling bundles enableSchedulerTracing:disabled enableProfilerTimer:disabled should support an empty Profiler (with no children) 2`] = `
    `; -exports[`Profiler works in profiling and non-profiling bundles enableSchedulerTracking:disabled enableProfilerTimer:disabled should support nested Profilers 1`] = ` +exports[`Profiler works in profiling and non-profiling bundles enableSchedulerTracing:disabled enableProfilerTimer:disabled should support nested Profilers 1`] = ` Array [
    outer functional component @@ -32,7 +32,7 @@ Array [ ] `; -exports[`Profiler works in profiling and non-profiling bundles enableSchedulerTracking:disabled enableProfilerTimer:enabled should render children 1`] = ` +exports[`Profiler works in profiling and non-profiling bundles enableSchedulerTracing:disabled enableProfilerTimer:enabled should render children 1`] = `
    outside span @@ -46,11 +46,11 @@ exports[`Profiler works in profiling and non-profiling bundles enableSchedulerTr
    `; -exports[`Profiler works in profiling and non-profiling bundles enableSchedulerTracking:disabled enableProfilerTimer:enabled should support an empty Profiler (with no children) 1`] = `null`; +exports[`Profiler works in profiling and non-profiling bundles enableSchedulerTracing:disabled enableProfilerTimer:enabled should support an empty Profiler (with no children) 1`] = `null`; -exports[`Profiler works in profiling and non-profiling bundles enableSchedulerTracking:disabled enableProfilerTimer:enabled should support an empty Profiler (with no children) 2`] = `
    `; +exports[`Profiler works in profiling and non-profiling bundles enableSchedulerTracing:disabled enableProfilerTimer:enabled should support an empty Profiler (with no children) 2`] = `
    `; -exports[`Profiler works in profiling and non-profiling bundles enableSchedulerTracking:disabled enableProfilerTimer:enabled should support nested Profilers 1`] = ` +exports[`Profiler works in profiling and non-profiling bundles enableSchedulerTracing:disabled enableProfilerTimer:enabled should support nested Profilers 1`] = ` Array [
    outer functional component @@ -64,7 +64,7 @@ Array [ ] `; -exports[`Profiler works in profiling and non-profiling bundles enableSchedulerTracking:enabled enableProfilerTimer:disabled should render children 1`] = ` +exports[`Profiler works in profiling and non-profiling bundles enableSchedulerTracing:enabled enableProfilerTimer:disabled should render children 1`] = `
    outside span @@ -78,11 +78,11 @@ exports[`Profiler works in profiling and non-profiling bundles enableSchedulerTr
    `; -exports[`Profiler works in profiling and non-profiling bundles enableSchedulerTracking:enabled enableProfilerTimer:disabled should support an empty Profiler (with no children) 1`] = `null`; +exports[`Profiler works in profiling and non-profiling bundles enableSchedulerTracing:enabled enableProfilerTimer:disabled should support an empty Profiler (with no children) 1`] = `null`; -exports[`Profiler works in profiling and non-profiling bundles enableSchedulerTracking:enabled enableProfilerTimer:disabled should support an empty Profiler (with no children) 2`] = `
    `; +exports[`Profiler works in profiling and non-profiling bundles enableSchedulerTracing:enabled enableProfilerTimer:disabled should support an empty Profiler (with no children) 2`] = `
    `; -exports[`Profiler works in profiling and non-profiling bundles enableSchedulerTracking:enabled enableProfilerTimer:disabled should support nested Profilers 1`] = ` +exports[`Profiler works in profiling and non-profiling bundles enableSchedulerTracing:enabled enableProfilerTimer:disabled should support nested Profilers 1`] = ` Array [
    outer functional component @@ -96,7 +96,7 @@ Array [ ] `; -exports[`Profiler works in profiling and non-profiling bundles enableSchedulerTracking:enabled enableProfilerTimer:enabled should render children 1`] = ` +exports[`Profiler works in profiling and non-profiling bundles enableSchedulerTracing:enabled enableProfilerTimer:enabled should render children 1`] = `
    outside span @@ -110,11 +110,11 @@ exports[`Profiler works in profiling and non-profiling bundles enableSchedulerTr
    `; -exports[`Profiler works in profiling and non-profiling bundles enableSchedulerTracking:enabled enableProfilerTimer:enabled should support an empty Profiler (with no children) 1`] = `null`; +exports[`Profiler works in profiling and non-profiling bundles enableSchedulerTracing:enabled enableProfilerTimer:enabled should support an empty Profiler (with no children) 1`] = `null`; -exports[`Profiler works in profiling and non-profiling bundles enableSchedulerTracking:enabled enableProfilerTimer:enabled should support an empty Profiler (with no children) 2`] = `
    `; +exports[`Profiler works in profiling and non-profiling bundles enableSchedulerTracing:enabled enableProfilerTimer:enabled should support an empty Profiler (with no children) 2`] = `
    `; -exports[`Profiler works in profiling and non-profiling bundles enableSchedulerTracking:enabled enableProfilerTimer:enabled should support nested Profilers 1`] = ` +exports[`Profiler works in profiling and non-profiling bundles enableSchedulerTracing:enabled enableProfilerTimer:enabled should support nested Profilers 1`] = ` Array [
    outer functional component diff --git a/packages/schedule/npm/tracing-profiling.js b/packages/schedule/npm/tracing-profiling.js index c90851e796d23..f704f9ba13e81 100644 --- a/packages/schedule/npm/tracing-profiling.js +++ b/packages/schedule/npm/tracing-profiling.js @@ -1,7 +1,7 @@ 'use strict'; if (process.env.NODE_ENV === 'production') { - module.exports = require('./cjs/schedule-tracking.profiling.min.js'); + module.exports = require('./cjs/schedule-tracing.profiling.min.js'); } else { - module.exports = require('./cjs/schedule-tracking.development.js'); + module.exports = require('./cjs/schedule-tracing.development.js'); } diff --git a/packages/schedule/npm/tracing.js b/packages/schedule/npm/tracing.js index c1bb73e4f8af6..f33597849d8a7 100644 --- a/packages/schedule/npm/tracing.js +++ b/packages/schedule/npm/tracing.js @@ -1,7 +1,7 @@ 'use strict'; if (process.env.NODE_ENV === 'production') { - module.exports = require('./cjs/schedule-tracking.production.min.js'); + module.exports = require('./cjs/schedule-tracing.production.min.js'); } else { - module.exports = require('./cjs/schedule-tracking.development.js'); + module.exports = require('./cjs/schedule-tracing.development.js'); } diff --git a/packages/schedule/npm/umd/schedule-tracing.development.js b/packages/schedule/npm/umd/schedule-tracing.development.js index c5c488eec2a3e..e361c64ac666e 100644 --- a/packages/schedule/npm/umd/schedule-tracing.development.js +++ b/packages/schedule/npm/umd/schedule-tracing.development.js @@ -14,24 +14,24 @@ ? (module.exports = factory(require('react'))) : typeof define === 'function' && define.amd // eslint-disable-line no-undef ? define(['react'], factory) // eslint-disable-line no-undef - : (global.ScheduleTracking = factory(global)); + : (global.ScheduleTracing = factory(global)); })(this, function(global) { function unstable_clear() { - return global.React.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ScheduleTracking.unstable_clear.apply( + return global.React.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ScheduleTracing.unstable_clear.apply( this, arguments ); } function unstable_getCurrent() { - return global.React.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ScheduleTracking.unstable_getCurrent.apply( + return global.React.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ScheduleTracing.unstable_getCurrent.apply( this, arguments ); } function unstable_getThreadID() { - return global.React.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ScheduleTracking.unstable_getThreadID.apply( + return global.React.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ScheduleTracing.unstable_getThreadID.apply( this, arguments ); @@ -39,14 +39,14 @@ function unstable_subscribe() { // eslint-disable-next-line max-len - return global.React.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ScheduleTracking.unstable_subscribe.apply( + return global.React.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ScheduleTracing.unstable_subscribe.apply( this, arguments ); } - function unstable_track() { - return global.React.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ScheduleTracking.unstable_track.apply( + function unstable_trace() { + return global.React.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ScheduleTracing.unstable_trace.apply( this, arguments ); @@ -54,14 +54,14 @@ function unstable_unsubscribe() { // eslint-disable-next-line max-len - return global.React.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ScheduleTracking.unstable_unsubscribe.apply( + return global.React.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ScheduleTracing.unstable_unsubscribe.apply( this, arguments ); } function unstable_wrap() { - return global.React.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ScheduleTracking.unstable_wrap.apply( + return global.React.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ScheduleTracing.unstable_wrap.apply( this, arguments ); @@ -72,7 +72,7 @@ unstable_getCurrent: unstable_getCurrent, unstable_getThreadID: unstable_getThreadID, unstable_subscribe: unstable_subscribe, - unstable_track: unstable_track, + unstable_trace: unstable_trace, unstable_unsubscribe: unstable_unsubscribe, unstable_wrap: unstable_wrap, }); diff --git a/packages/schedule/npm/umd/schedule-tracing.production.min.js b/packages/schedule/npm/umd/schedule-tracing.production.min.js index c5c488eec2a3e..e361c64ac666e 100644 --- a/packages/schedule/npm/umd/schedule-tracing.production.min.js +++ b/packages/schedule/npm/umd/schedule-tracing.production.min.js @@ -14,24 +14,24 @@ ? (module.exports = factory(require('react'))) : typeof define === 'function' && define.amd // eslint-disable-line no-undef ? define(['react'], factory) // eslint-disable-line no-undef - : (global.ScheduleTracking = factory(global)); + : (global.ScheduleTracing = factory(global)); })(this, function(global) { function unstable_clear() { - return global.React.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ScheduleTracking.unstable_clear.apply( + return global.React.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ScheduleTracing.unstable_clear.apply( this, arguments ); } function unstable_getCurrent() { - return global.React.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ScheduleTracking.unstable_getCurrent.apply( + return global.React.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ScheduleTracing.unstable_getCurrent.apply( this, arguments ); } function unstable_getThreadID() { - return global.React.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ScheduleTracking.unstable_getThreadID.apply( + return global.React.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ScheduleTracing.unstable_getThreadID.apply( this, arguments ); @@ -39,14 +39,14 @@ function unstable_subscribe() { // eslint-disable-next-line max-len - return global.React.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ScheduleTracking.unstable_subscribe.apply( + return global.React.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ScheduleTracing.unstable_subscribe.apply( this, arguments ); } - function unstable_track() { - return global.React.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ScheduleTracking.unstable_track.apply( + function unstable_trace() { + return global.React.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ScheduleTracing.unstable_trace.apply( this, arguments ); @@ -54,14 +54,14 @@ function unstable_unsubscribe() { // eslint-disable-next-line max-len - return global.React.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ScheduleTracking.unstable_unsubscribe.apply( + return global.React.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ScheduleTracing.unstable_unsubscribe.apply( this, arguments ); } function unstable_wrap() { - return global.React.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ScheduleTracking.unstable_wrap.apply( + return global.React.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ScheduleTracing.unstable_wrap.apply( this, arguments ); @@ -72,7 +72,7 @@ unstable_getCurrent: unstable_getCurrent, unstable_getThreadID: unstable_getThreadID, unstable_subscribe: unstable_subscribe, - unstable_track: unstable_track, + unstable_trace: unstable_trace, unstable_unsubscribe: unstable_unsubscribe, unstable_wrap: unstable_wrap, }); diff --git a/packages/schedule/package.json b/packages/schedule/package.json index f0ce6c2a4c54c..24580fe7c915e 100644 --- a/packages/schedule/package.json +++ b/packages/schedule/package.json @@ -19,8 +19,8 @@ "LICENSE", "README.md", "index.js", - "tracking.js", - "tracking-profiling.js", + "tracing.js", + "tracing-profiling.js", "cjs/", "umd/" ] diff --git a/packages/schedule/src/Tracing.js b/packages/schedule/src/Tracing.js index 7356445e74eff..1223d44a2cf28 100644 --- a/packages/schedule/src/Tracing.js +++ b/packages/schedule/src/Tracing.js @@ -7,7 +7,7 @@ * @flow */ -import {enableSchedulerTracking} from 'shared/ReactFeatureFlags'; +import {enableSchedulerTracing} from 'shared/ReactFeatureFlags'; export type Interaction = {| __count: number, @@ -17,8 +17,8 @@ export type Interaction = {| |}; export type Subscriber = { - // A new interaction has been created via the track() method. - onInteractionTracked: (interaction: Interaction) => void, + // A new interaction has been created via the trace() method. + onInteractionTraced: (interaction: Interaction) => void, // All scheduled async work for an interaction has finished. onInteractionScheduledWorkCompleted: (interaction: Interaction) => void, @@ -61,16 +61,16 @@ const DEFAULT_THREAD_ID = 0; let interactionIDCounter: number = 0; let threadIDCounter: number = 0; -// Set of currently tracked interactions. +// Set of currently traced interactions. // Interactions "stack"– -// Meaning that newly tracked interactions are appended to the previously active set. +// Meaning that newly traced interactions are appended to the previously active set. // When an interaction goes out of scope, the previous set (if any) is restored. let interactionsRef: InteractionsRef = (null: any); // Listener(s) to notify when interactions begin and end. let subscriberRef: SubscriberRef = (null: any); -if (enableSchedulerTracking) { +if (enableSchedulerTracing) { interactionsRef = { current: new Set(), }; @@ -82,7 +82,7 @@ if (enableSchedulerTracking) { export {interactionsRef as __interactionsRef, subscriberRef as __subscriberRef}; export function unstable_clear(callback: Function): any { - if (!enableSchedulerTracking) { + if (!enableSchedulerTracing) { return callback(); } @@ -97,7 +97,7 @@ export function unstable_clear(callback: Function): any { } export function unstable_getCurrent(): Set | null { - if (!enableSchedulerTracking) { + if (!enableSchedulerTracing) { return null; } else { return interactionsRef.current; @@ -108,13 +108,13 @@ export function unstable_getThreadID(): number { return ++threadIDCounter; } -export function unstable_track( +export function unstable_trace( name: string, timestamp: number, callback: Function, threadID: number = DEFAULT_THREAD_ID, ): any { - if (!enableSchedulerTracking) { + if (!enableSchedulerTracing) { return callback(); } @@ -127,7 +127,7 @@ export function unstable_track( const prevInteractions = interactionsRef.current; - // Tracked interactions should stack/accumulate. + // Traced interactions should stack/accumulate. // To do that, clone the current interactions. // The previous set will be restored upon completion. const interactions = new Set(prevInteractions); @@ -139,7 +139,7 @@ export function unstable_track( try { if (subscriber !== null) { - subscriber.onInteractionTracked(interaction); + subscriber.onInteractionTraced(interaction); } } finally { try { @@ -176,7 +176,7 @@ export function unstable_wrap( callback: Function, threadID: number = DEFAULT_THREAD_ID, ): Function { - if (!enableSchedulerTracking) { + if (!enableSchedulerTracing) { return callback; } diff --git a/packages/schedule/src/TracingSubscriptions.js b/packages/schedule/src/TracingSubscriptions.js index 202043b74effd..ffddd4a4ebbf2 100644 --- a/packages/schedule/src/TracingSubscriptions.js +++ b/packages/schedule/src/TracingSubscriptions.js @@ -7,24 +7,24 @@ * @flow */ -import type {Interaction, Subscriber} from './Tracking'; +import type {Interaction, Subscriber} from './Tracing'; -import {enableSchedulerTracking} from 'shared/ReactFeatureFlags'; -import {__subscriberRef} from 'schedule/tracking'; +import {enableSchedulerTracing} from 'shared/ReactFeatureFlags'; +import {__subscriberRef} from 'schedule/tracing'; let subscribers: Set = (null: any); -if (enableSchedulerTracking) { +if (enableSchedulerTracing) { subscribers = new Set(); } export function unstable_subscribe(subscriber: Subscriber): void { - if (enableSchedulerTracking) { + if (enableSchedulerTracing) { subscribers.add(subscriber); if (subscribers.size === 1) { __subscriberRef.current = { onInteractionScheduledWorkCompleted, - onInteractionTracked, + onInteractionTraced, onWorkCanceled, onWorkScheduled, onWorkStarted, @@ -35,7 +35,7 @@ export function unstable_subscribe(subscriber: Subscriber): void { } export function unstable_unsubscribe(subscriber: Subscriber): void { - if (enableSchedulerTracking) { + if (enableSchedulerTracing) { subscribers.delete(subscriber); if (subscribers.size === 0) { @@ -44,13 +44,13 @@ export function unstable_unsubscribe(subscriber: Subscriber): void { } } -function onInteractionTracked(interaction: Interaction): void { +function onInteractionTraced(interaction: Interaction): void { let didCatchError = false; let caughtError = null; subscribers.forEach(subscriber => { try { - subscriber.onInteractionTracked(interaction); + subscriber.onInteractionTraced(interaction); } catch (error) { if (!didCatchError) { didCatchError = true; diff --git a/packages/schedule/src/__tests__/ScheduleUMDBundle-test.internal.js b/packages/schedule/src/__tests__/ScheduleUMDBundle-test.internal.js index abbda606eb5ad..2bdb38be097f8 100644 --- a/packages/schedule/src/__tests__/ScheduleUMDBundle-test.internal.js +++ b/packages/schedule/src/__tests__/ScheduleUMDBundle-test.internal.js @@ -41,15 +41,15 @@ describe('Scheduling UMD bundle', () => { validateForwardedAPIs(api, [umdAPIDev, umdAPIProd, secretAPI.Schedule]); }); - it('should define the same tracking API', () => { - const api = require('../../tracking'); - const umdAPIDev = require('../../npm/umd/schedule-tracking.development'); - const umdAPIProd = require('../../npm/umd/schedule-tracking.production.min'); + it('should define the same tracing API', () => { + const api = require('../../tracing'); + const umdAPIDev = require('../../npm/umd/schedule-tracing.development'); + const umdAPIProd = require('../../npm/umd/schedule-tracing.production.min'); const secretAPI = require('react/src/ReactSharedInternals').default; validateForwardedAPIs(api, [ umdAPIDev, umdAPIProd, - secretAPI.ScheduleTracking, + secretAPI.ScheduleTracing, ]); }); }); diff --git a/packages/schedule/src/__tests__/Tracing-test.internal.js b/packages/schedule/src/__tests__/Tracing-test.internal.js index 8de0cbc4858f3..60497138c77f5 100644 --- a/packages/schedule/src/__tests__/Tracing-test.internal.js +++ b/packages/schedule/src/__tests__/Tracing-test.internal.js @@ -8,14 +8,14 @@ */ 'use strict'; -describe('Tracking', () => { - let SchedulerTracking; +describe('Tracing', () => { + let SchedulerTracing; let ReactFeatureFlags; let advanceTimeBy; let currentTime; - function loadModules({enableSchedulerTracking}) { + function loadModules({enableSchedulerTracing}) { jest.resetModules(); jest.useFakeTimers(); @@ -27,36 +27,36 @@ describe('Tracking', () => { }; ReactFeatureFlags = require('shared/ReactFeatureFlags'); - ReactFeatureFlags.enableSchedulerTracking = enableSchedulerTracking; + ReactFeatureFlags.enableSchedulerTracing = enableSchedulerTracing; - SchedulerTracking = require('schedule/tracking'); + SchedulerTracing = require('schedule/tracing'); } - describe('enableSchedulerTracking enabled', () => { - beforeEach(() => loadModules({enableSchedulerTracking: true})); + describe('enableSchedulerTracing enabled', () => { + beforeEach(() => loadModules({enableSchedulerTracing: true})); - it('should return the value of a tracked function', () => { + it('should return the value of a traced function', () => { expect( - SchedulerTracking.unstable_track('arbitrary', currentTime, () => 123), + SchedulerTracing.unstable_trace('arbitrary', currentTime, () => 123), ).toBe(123); }); it('should return the value of a clear function', () => { - expect(SchedulerTracking.unstable_clear(() => 123)).toBe(123); + expect(SchedulerTracing.unstable_clear(() => 123)).toBe(123); }); it('should return the value of a wrapped function', () => { let wrapped; - SchedulerTracking.unstable_track('arbitrary', currentTime, () => { - wrapped = SchedulerTracking.unstable_wrap(() => 123); + SchedulerTracing.unstable_trace('arbitrary', currentTime, () => { + wrapped = SchedulerTracing.unstable_wrap(() => 123); }); expect(wrapped()).toBe(123); }); it('should pass arguments through to a wrapped function', done => { let wrapped; - SchedulerTracking.unstable_track('arbitrary', currentTime, () => { - wrapped = SchedulerTracking.unstable_wrap((param1, param2) => { + SchedulerTracing.unstable_trace('arbitrary', currentTime, () => { + wrapped = SchedulerTracing.unstable_wrap((param1, param2) => { expect(param1).toBe('foo'); expect(param2).toBe('bar'); done(); @@ -65,15 +65,15 @@ describe('Tracking', () => { wrapped('foo', 'bar'); }); - it('should return an empty set when outside of a tracked event', () => { - expect(SchedulerTracking.unstable_getCurrent()).toContainNoInteractions(); + it('should return an empty set when outside of a traced event', () => { + expect(SchedulerTracing.unstable_getCurrent()).toContainNoInteractions(); }); - it('should report the tracked interaction from within the track callback', done => { + it('should report the traced interaction from within the trace callback', done => { advanceTimeBy(100); - SchedulerTracking.unstable_track('some event', currentTime, () => { - const interactions = SchedulerTracking.unstable_getCurrent(); + SchedulerTracing.unstable_trace('some event', currentTime, () => { + const interactions = SchedulerTracing.unstable_getCurrent(); expect(interactions).toMatchInteractions([ {name: 'some event', timestamp: 100}, ]); @@ -82,11 +82,11 @@ describe('Tracking', () => { }); }); - it('should report the tracked interaction from within wrapped callbacks', done => { + it('should report the traced interaction from within wrapped callbacks', done => { let wrappedIndirection; function indirection() { - const interactions = SchedulerTracking.unstable_getCurrent(); + const interactions = SchedulerTracing.unstable_getCurrent(); expect(interactions).toMatchInteractions([ {name: 'some event', timestamp: 100}, ]); @@ -96,8 +96,8 @@ describe('Tracking', () => { advanceTimeBy(100); - SchedulerTracking.unstable_track('some event', currentTime, () => { - wrappedIndirection = SchedulerTracking.unstable_wrap(indirection); + SchedulerTracing.unstable_trace('some event', currentTime, () => { + wrappedIndirection = SchedulerTracing.unstable_wrap(indirection); }); advanceTimeBy(50); @@ -105,29 +105,29 @@ describe('Tracking', () => { wrappedIndirection(); }); - it('should clear the interaction stack for tracked callbacks', () => { + it('should clear the interaction stack for traced callbacks', () => { let innerTestReached = false; - SchedulerTracking.unstable_track('outer event', currentTime, () => { - expect(SchedulerTracking.unstable_getCurrent()).toMatchInteractions([ + SchedulerTracing.unstable_trace('outer event', currentTime, () => { + expect(SchedulerTracing.unstable_getCurrent()).toMatchInteractions([ {name: 'outer event'}, ]); - SchedulerTracking.unstable_clear(() => { - expect(SchedulerTracking.unstable_getCurrent()).toMatchInteractions( + SchedulerTracing.unstable_clear(() => { + expect(SchedulerTracing.unstable_getCurrent()).toMatchInteractions( [], ); - SchedulerTracking.unstable_track('inner event', currentTime, () => { - expect(SchedulerTracking.unstable_getCurrent()).toMatchInteractions( - [{name: 'inner event'}], - ); + SchedulerTracing.unstable_trace('inner event', currentTime, () => { + expect(SchedulerTracing.unstable_getCurrent()).toMatchInteractions([ + {name: 'inner event'}, + ]); innerTestReached = true; }); }); - expect(SchedulerTracking.unstable_getCurrent()).toMatchInteractions([ + expect(SchedulerTracing.unstable_getCurrent()).toMatchInteractions([ {name: 'outer event'}, ]); }); @@ -140,31 +140,31 @@ describe('Tracking', () => { let wrappedIndirection; const indirection = jest.fn(() => { - expect(SchedulerTracking.unstable_getCurrent()).toMatchInteractions([ + expect(SchedulerTracing.unstable_getCurrent()).toMatchInteractions([ {name: 'outer event'}, ]); - SchedulerTracking.unstable_clear(() => { - expect(SchedulerTracking.unstable_getCurrent()).toMatchInteractions( + SchedulerTracing.unstable_clear(() => { + expect(SchedulerTracing.unstable_getCurrent()).toMatchInteractions( [], ); - SchedulerTracking.unstable_track('inner event', currentTime, () => { - expect(SchedulerTracking.unstable_getCurrent()).toMatchInteractions( - [{name: 'inner event'}], - ); + SchedulerTracing.unstable_trace('inner event', currentTime, () => { + expect(SchedulerTracing.unstable_getCurrent()).toMatchInteractions([ + {name: 'inner event'}, + ]); innerTestReached = true; }); }); - expect(SchedulerTracking.unstable_getCurrent()).toMatchInteractions([ + expect(SchedulerTracing.unstable_getCurrent()).toMatchInteractions([ {name: 'outer event'}, ]); }); - SchedulerTracking.unstable_track('outer event', currentTime, () => { - wrappedIndirection = SchedulerTracking.unstable_wrap(indirection); + SchedulerTracing.unstable_trace('outer event', currentTime, () => { + wrappedIndirection = SchedulerTracing.unstable_wrap(indirection); }); wrappedIndirection(); @@ -172,94 +172,94 @@ describe('Tracking', () => { expect(innerTestReached).toBe(true); }); - it('should support nested tracked events', done => { + it('should support nested traced events', done => { advanceTimeBy(100); - let innerIndirectionTracked = false; - let outerIndirectionTracked = false; + let innerIndirectionTraced = false; + let outerIndirectionTraced = false; function innerIndirection() { - const interactions = SchedulerTracking.unstable_getCurrent(); + const interactions = SchedulerTracing.unstable_getCurrent(); expect(interactions).toMatchInteractions([ {name: 'outer event', timestamp: 100}, {name: 'inner event', timestamp: 150}, ]); - innerIndirectionTracked = true; + innerIndirectionTraced = true; } function outerIndirection() { - const interactions = SchedulerTracking.unstable_getCurrent(); + const interactions = SchedulerTracing.unstable_getCurrent(); expect(interactions).toMatchInteractions([ {name: 'outer event', timestamp: 100}, ]); - outerIndirectionTracked = true; + outerIndirectionTraced = true; } - SchedulerTracking.unstable_track('outer event', currentTime, () => { - // Verify the current tracked event - let interactions = SchedulerTracking.unstable_getCurrent(); + SchedulerTracing.unstable_trace('outer event', currentTime, () => { + // Verify the current traced event + let interactions = SchedulerTracing.unstable_getCurrent(); expect(interactions).toMatchInteractions([ {name: 'outer event', timestamp: 100}, ]); advanceTimeBy(50); - const wrapperOuterIndirection = SchedulerTracking.unstable_wrap( + const wrapperOuterIndirection = SchedulerTracing.unstable_wrap( outerIndirection, ); let wrapperInnerIndirection; - let innerEventTracked = false; + let innerEventTraced = false; - // Verify that a nested event is properly tracked - SchedulerTracking.unstable_track('inner event', currentTime, () => { - interactions = SchedulerTracking.unstable_getCurrent(); + // Verify that a nested event is properly traced + SchedulerTracing.unstable_trace('inner event', currentTime, () => { + interactions = SchedulerTracing.unstable_getCurrent(); expect(interactions).toMatchInteractions([ {name: 'outer event', timestamp: 100}, {name: 'inner event', timestamp: 150}, ]); - // Verify that a wrapped outer callback is properly tracked + // Verify that a wrapped outer callback is properly traced wrapperOuterIndirection(); - expect(outerIndirectionTracked).toBe(true); + expect(outerIndirectionTraced).toBe(true); - wrapperInnerIndirection = SchedulerTracking.unstable_wrap( + wrapperInnerIndirection = SchedulerTracing.unstable_wrap( innerIndirection, ); - innerEventTracked = true; + innerEventTraced = true; }); - expect(innerEventTracked).toBe(true); + expect(innerEventTraced).toBe(true); // Verify that the original event is restored - interactions = SchedulerTracking.unstable_getCurrent(); + interactions = SchedulerTracing.unstable_getCurrent(); expect(interactions).toMatchInteractions([ {name: 'outer event', timestamp: 100}, ]); - // Verify that a wrapped nested callback is properly tracked + // Verify that a wrapped nested callback is properly traced wrapperInnerIndirection(); - expect(innerIndirectionTracked).toBe(true); + expect(innerIndirectionTraced).toBe(true); done(); }); }); describe('error handling', () => { - it('should reset state appropriately when an error occurs in a track callback', done => { + it('should reset state appropriately when an error occurs in a trace callback', done => { advanceTimeBy(100); - SchedulerTracking.unstable_track('outer event', currentTime, () => { + SchedulerTracing.unstable_trace('outer event', currentTime, () => { expect(() => { - SchedulerTracking.unstable_track('inner event', currentTime, () => { + SchedulerTracing.unstable_trace('inner event', currentTime, () => { throw Error('intentional'); }); }).toThrow(); - expect(SchedulerTracking.unstable_getCurrent()).toMatchInteractions([ + expect(SchedulerTracing.unstable_getCurrent()).toMatchInteractions([ {name: 'outer event', timestamp: 100}, ]); @@ -270,18 +270,18 @@ describe('Tracking', () => { it('should reset state appropriately when an error occurs in a wrapped callback', done => { advanceTimeBy(100); - SchedulerTracking.unstable_track('outer event', currentTime, () => { + SchedulerTracing.unstable_trace('outer event', currentTime, () => { let wrappedCallback; - SchedulerTracking.unstable_track('inner event', currentTime, () => { - wrappedCallback = SchedulerTracking.unstable_wrap(() => { + SchedulerTracing.unstable_trace('inner event', currentTime, () => { + wrappedCallback = SchedulerTracing.unstable_wrap(() => { throw Error('intentional'); }); }); expect(wrappedCallback).toThrow(); - expect(SchedulerTracking.unstable_getCurrent()).toMatchInteractions([ + expect(SchedulerTracing.unstable_getCurrent()).toMatchInteractions([ {name: 'outer event', timestamp: 100}, ]); @@ -292,30 +292,30 @@ describe('Tracking', () => { describe('advanced integration', () => { it('should return a unique threadID per request', () => { - expect(SchedulerTracking.unstable_getThreadID()).not.toBe( - SchedulerTracking.unstable_getThreadID(), + expect(SchedulerTracing.unstable_getThreadID()).not.toBe( + SchedulerTracing.unstable_getThreadID(), ); }); it('should expose the current set of interactions to be externally manipulated', () => { - SchedulerTracking.unstable_track('outer event', currentTime, () => { - expect(SchedulerTracking.__interactionsRef.current).toBe( - SchedulerTracking.unstable_getCurrent(), + SchedulerTracing.unstable_trace('outer event', currentTime, () => { + expect(SchedulerTracing.__interactionsRef.current).toBe( + SchedulerTracing.unstable_getCurrent(), ); - SchedulerTracking.__interactionsRef.current = new Set([ + SchedulerTracing.__interactionsRef.current = new Set([ {name: 'override event'}, ]); - expect(SchedulerTracking.unstable_getCurrent()).toMatchInteractions([ + expect(SchedulerTracing.unstable_getCurrent()).toMatchInteractions([ {name: 'override event'}, ]); }); }); it('should expose a subscriber ref to be externally manipulated', () => { - SchedulerTracking.unstable_track('outer event', currentTime, () => { - expect(SchedulerTracking.__subscriberRef).toEqual({ + SchedulerTracing.unstable_trace('outer event', currentTime, () => { + expect(SchedulerTracing.__subscriberRef).toEqual({ current: null, }); }); @@ -323,42 +323,42 @@ describe('Tracking', () => { }); }); - describe('enableSchedulerTracking disabled', () => { - beforeEach(() => loadModules({enableSchedulerTracking: false})); + describe('enableSchedulerTracing disabled', () => { + beforeEach(() => loadModules({enableSchedulerTracing: false})); - it('should return the value of a tracked function', () => { + it('should return the value of a traced function', () => { expect( - SchedulerTracking.unstable_track('arbitrary', currentTime, () => 123), + SchedulerTracing.unstable_trace('arbitrary', currentTime, () => 123), ).toBe(123); }); it('should return the value of a wrapped function', () => { let wrapped; - SchedulerTracking.unstable_track('arbitrary', currentTime, () => { - wrapped = SchedulerTracking.unstable_wrap(() => 123); + SchedulerTracing.unstable_trace('arbitrary', currentTime, () => { + wrapped = SchedulerTracing.unstable_wrap(() => 123); }); expect(wrapped()).toBe(123); }); - it('should return null for tracked interactions', () => { - expect(SchedulerTracking.unstable_getCurrent()).toBe(null); + it('should return null for traced interactions', () => { + expect(SchedulerTracing.unstable_getCurrent()).toBe(null); }); - it('should execute tracked callbacks', done => { - SchedulerTracking.unstable_track('some event', currentTime, () => { - expect(SchedulerTracking.unstable_getCurrent()).toBe(null); + it('should execute traced callbacks', done => { + SchedulerTracing.unstable_trace('some event', currentTime, () => { + expect(SchedulerTracing.unstable_getCurrent()).toBe(null); done(); }); }); it('should return the value of a clear function', () => { - expect(SchedulerTracking.unstable_clear(() => 123)).toBe(123); + expect(SchedulerTracing.unstable_clear(() => 123)).toBe(123); }); it('should execute wrapped callbacks', done => { - const wrappedCallback = SchedulerTracking.unstable_wrap(() => { - expect(SchedulerTracking.unstable_getCurrent()).toBe(null); + const wrappedCallback = SchedulerTracing.unstable_wrap(() => { + expect(SchedulerTracing.unstable_getCurrent()).toBe(null); done(); }); @@ -368,7 +368,7 @@ describe('Tracking', () => { describe('advanced integration', () => { it('should not create unnecessary objects', () => { - expect(SchedulerTracking.__interactionsRef).toBe(null); + expect(SchedulerTracing.__interactionsRef).toBe(null); }); }); }); diff --git a/packages/schedule/src/__tests__/Tracing-test.js b/packages/schedule/src/__tests__/Tracing-test.js index 6b340f8434e69..3ccdff39c283f 100644 --- a/packages/schedule/src/__tests__/Tracing-test.js +++ b/packages/schedule/src/__tests__/Tracing-test.js @@ -8,41 +8,41 @@ */ 'use strict'; -describe('Tracking', () => { - let SchedulerTracking; +describe('Tracing', () => { + let SchedulerTracing; beforeEach(() => { jest.resetModules(); - SchedulerTracking = require('schedule/tracking'); + SchedulerTracing = require('schedule/tracing'); }); - it('should return the value of a tracked function', () => { - expect(SchedulerTracking.unstable_track('arbitrary', 0, () => 123)).toBe( + it('should return the value of a traced function', () => { + expect(SchedulerTracing.unstable_trace('arbitrary', 0, () => 123)).toBe( 123, ); }); it('should return the value of a wrapped function', () => { let wrapped; - SchedulerTracking.unstable_track('arbitrary', 0, () => { - wrapped = SchedulerTracking.unstable_wrap(() => 123); + SchedulerTracing.unstable_trace('arbitrary', 0, () => { + wrapped = SchedulerTracing.unstable_wrap(() => 123); }); expect(wrapped()).toBe(123); }); - it('should execute tracked callbacks', done => { - SchedulerTracking.unstable_track('some event', 0, () => { + it('should execute traced callbacks', done => { + SchedulerTracing.unstable_trace('some event', 0, () => { done(); }); }); it('should return the value of a clear function', () => { - expect(SchedulerTracking.unstable_clear(() => 123)).toBe(123); + expect(SchedulerTracing.unstable_clear(() => 123)).toBe(123); }); it('should execute wrapped callbacks', done => { - const wrappedCallback = SchedulerTracking.unstable_wrap(() => { + const wrappedCallback = SchedulerTracing.unstable_wrap(() => { done(); }); diff --git a/packages/schedule/src/__tests__/TracingSubscriptions-test.internal.js b/packages/schedule/src/__tests__/TracingSubscriptions-test.internal.js index 674751dc00535..f9a67816952d5 100644 --- a/packages/schedule/src/__tests__/TracingSubscriptions-test.internal.js +++ b/packages/schedule/src/__tests__/TracingSubscriptions-test.internal.js @@ -8,20 +8,20 @@ */ 'use strict'; -describe('TrackingSubscriptions', () => { - let SchedulerTracking; +describe('TracingSubscriptions', () => { + let SchedulerTracing; let ReactFeatureFlags; let currentTime; let onInteractionScheduledWorkCompleted; - let onInteractionTracked; + let onInteractionTraced; let onWorkCanceled; let onWorkScheduled; let onWorkStarted; let onWorkStopped; let throwInOnInteractionScheduledWorkCompleted; - let throwInOnInteractionTracked; + let throwInOnInteractionTraced; let throwInOnWorkCanceled; let throwInOnWorkScheduled; let throwInOnWorkStarted; @@ -33,19 +33,19 @@ describe('TrackingSubscriptions', () => { const secondEvent = {id: 1, name: 'second', timestamp: 0}; const threadID = 123; - function loadModules({enableSchedulerTracking, autoSubscribe = true}) { + function loadModules({enableSchedulerTracing, autoSubscribe = true}) { jest.resetModules(); jest.useFakeTimers(); currentTime = 0; ReactFeatureFlags = require('shared/ReactFeatureFlags'); - ReactFeatureFlags.enableSchedulerTracking = enableSchedulerTracking; + ReactFeatureFlags.enableSchedulerTracing = enableSchedulerTracing; - SchedulerTracking = require('schedule/tracking'); + SchedulerTracing = require('schedule/tracing'); throwInOnInteractionScheduledWorkCompleted = false; - throwInOnInteractionTracked = false; + throwInOnInteractionTraced = false; throwInOnWorkCanceled = false; throwInOnWorkScheduled = false; throwInOnWorkStarted = false; @@ -56,9 +56,9 @@ describe('TrackingSubscriptions', () => { throw Error('Expected error onInteractionScheduledWorkCompleted'); } }); - onInteractionTracked = jest.fn(() => { - if (throwInOnInteractionTracked) { - throw Error('Expected error onInteractionTracked'); + onInteractionTraced = jest.fn(() => { + if (throwInOnInteractionTraced) { + throw Error('Expected error onInteractionTraced'); } }); onWorkCanceled = jest.fn(() => { @@ -84,7 +84,7 @@ describe('TrackingSubscriptions', () => { firstSubscriber = { onInteractionScheduledWorkCompleted, - onInteractionTracked, + onInteractionTraced, onWorkCanceled, onWorkScheduled, onWorkStarted, @@ -93,7 +93,7 @@ describe('TrackingSubscriptions', () => { secondSubscriber = { onInteractionScheduledWorkCompleted: jest.fn(), - onInteractionTracked: jest.fn(), + onInteractionTraced: jest.fn(), onWorkCanceled: jest.fn(), onWorkScheduled: jest.fn(), onWorkStarted: jest.fn(), @@ -101,49 +101,49 @@ describe('TrackingSubscriptions', () => { }; if (autoSubscribe) { - SchedulerTracking.unstable_subscribe(firstSubscriber); - SchedulerTracking.unstable_subscribe(secondSubscriber); + SchedulerTracing.unstable_subscribe(firstSubscriber); + SchedulerTracing.unstable_subscribe(secondSubscriber); } } describe('enabled', () => { - beforeEach(() => loadModules({enableSchedulerTracking: true})); - - it('should lazily subscribe to tracking and unsubscribe again if there are no external subscribers', () => { - loadModules({enableSchedulerTracking: true, autoSubscribe: false}); - - expect(SchedulerTracking.__subscriberRef.current).toBe(null); - SchedulerTracking.unstable_subscribe(firstSubscriber); - expect(SchedulerTracking.__subscriberRef.current).toBeDefined(); - SchedulerTracking.unstable_subscribe(secondSubscriber); - expect(SchedulerTracking.__subscriberRef.current).toBeDefined(); - SchedulerTracking.unstable_unsubscribe(secondSubscriber); - expect(SchedulerTracking.__subscriberRef.current).toBeDefined(); - SchedulerTracking.unstable_unsubscribe(firstSubscriber); - expect(SchedulerTracking.__subscriberRef.current).toBe(null); + beforeEach(() => loadModules({enableSchedulerTracing: true})); + + it('should lazily subscribe to tracing and unsubscribe again if there are no external subscribers', () => { + loadModules({enableSchedulerTracing: true, autoSubscribe: false}); + + expect(SchedulerTracing.__subscriberRef.current).toBe(null); + SchedulerTracing.unstable_subscribe(firstSubscriber); + expect(SchedulerTracing.__subscriberRef.current).toBeDefined(); + SchedulerTracing.unstable_subscribe(secondSubscriber); + expect(SchedulerTracing.__subscriberRef.current).toBeDefined(); + SchedulerTracing.unstable_unsubscribe(secondSubscriber); + expect(SchedulerTracing.__subscriberRef.current).toBeDefined(); + SchedulerTracing.unstable_unsubscribe(firstSubscriber); + expect(SchedulerTracing.__subscriberRef.current).toBe(null); }); describe('error handling', () => { - it('should cover onInteractionTracked/onWorkStarted within', done => { - SchedulerTracking.unstable_track(firstEvent.name, currentTime, () => { + it('should cover onInteractionTraced/onWorkStarted within', done => { + SchedulerTracing.unstable_trace(firstEvent.name, currentTime, () => { const mock = jest.fn(); // It should call the callback before re-throwing - throwInOnInteractionTracked = true; + throwInOnInteractionTraced = true; expect(() => - SchedulerTracking.unstable_track( + SchedulerTracing.unstable_trace( secondEvent.name, currentTime, mock, threadID, ), - ).toThrow('Expected error onInteractionTracked'); - throwInOnInteractionTracked = false; + ).toThrow('Expected error onInteractionTraced'); + throwInOnInteractionTraced = false; expect(mock).toHaveBeenCalledTimes(1); throwInOnWorkStarted = true; expect(() => - SchedulerTracking.unstable_track( + SchedulerTracing.unstable_trace( secondEvent.name, currentTime, mock, @@ -153,32 +153,30 @@ describe('TrackingSubscriptions', () => { expect(mock).toHaveBeenCalledTimes(2); // It should restore the previous/outer interactions - expect(SchedulerTracking.unstable_getCurrent()).toMatchInteractions([ + expect(SchedulerTracing.unstable_getCurrent()).toMatchInteractions([ firstEvent, ]); // It should call other subscribers despite the earlier error - expect(secondSubscriber.onInteractionTracked).toHaveBeenCalledTimes( - 3, - ); + expect(secondSubscriber.onInteractionTraced).toHaveBeenCalledTimes(3); expect(secondSubscriber.onWorkStarted).toHaveBeenCalledTimes(3); done(); }); }); - it('should cover onWorkStopped within track', done => { - SchedulerTracking.unstable_track(firstEvent.name, currentTime, () => { + it('should cover onWorkStopped within trace', done => { + SchedulerTracing.unstable_trace(firstEvent.name, currentTime, () => { let innerInteraction; const mock = jest.fn(() => { innerInteraction = Array.from( - SchedulerTracking.unstable_getCurrent(), + SchedulerTracing.unstable_getCurrent(), )[1]; }); throwInOnWorkStopped = true; expect(() => - SchedulerTracking.unstable_track( + SchedulerTracing.unstable_trace( secondEvent.name, currentTime, mock, @@ -187,7 +185,7 @@ describe('TrackingSubscriptions', () => { throwInOnWorkStopped = false; // It should restore the previous/outer interactions - expect(SchedulerTracking.unstable_getCurrent()).toMatchInteractions([ + expect(SchedulerTracing.unstable_getCurrent()).toMatchInteractions([ firstEvent, ]); @@ -201,13 +199,13 @@ describe('TrackingSubscriptions', () => { }); }); - it('should cover onInteractionScheduledWorkCompleted within track', done => { - SchedulerTracking.unstable_track(firstEvent.name, currentTime, () => { + it('should cover onInteractionScheduledWorkCompleted within trace', done => { + SchedulerTracing.unstable_trace(firstEvent.name, currentTime, () => { const mock = jest.fn(); throwInOnInteractionScheduledWorkCompleted = true; expect(() => - SchedulerTracking.unstable_track( + SchedulerTracing.unstable_trace( secondEvent.name, currentTime, mock, @@ -216,7 +214,7 @@ describe('TrackingSubscriptions', () => { throwInOnInteractionScheduledWorkCompleted = false; // It should restore the previous/outer interactions - expect(SchedulerTracking.unstable_getCurrent()).toMatchInteractions([ + expect(SchedulerTracing.unstable_getCurrent()).toMatchInteractions([ firstEvent, ]); @@ -229,12 +227,12 @@ describe('TrackingSubscriptions', () => { }); }); - it('should cover the callback within track', done => { + it('should cover the callback within trace', done => { expect(onWorkStarted).not.toHaveBeenCalled(); expect(onWorkStopped).not.toHaveBeenCalled(); expect(() => { - SchedulerTracking.unstable_track(firstEvent.name, currentTime, () => { + SchedulerTracing.unstable_trace(firstEvent.name, currentTime, () => { throw Error('Expected error callback'); }); }).toThrow('Expected error callback'); @@ -246,14 +244,14 @@ describe('TrackingSubscriptions', () => { }); it('should cover onWorkScheduled within wrap', done => { - SchedulerTracking.unstable_track(firstEvent.name, currentTime, () => { + SchedulerTracing.unstable_trace(firstEvent.name, currentTime, () => { const interaction = Array.from( - SchedulerTracking.unstable_getCurrent(), + SchedulerTracing.unstable_getCurrent(), )[0]; const beforeCount = interaction.__count; throwInOnWorkScheduled = true; - expect(() => SchedulerTracking.unstable_wrap(() => {})).toThrow( + expect(() => SchedulerTracing.unstable_wrap(() => {})).toThrow( 'Expected error onWorkScheduled', ); @@ -270,9 +268,9 @@ describe('TrackingSubscriptions', () => { it('should cover onWorkStarted within wrap', () => { const mock = jest.fn(); let interaction, wrapped; - SchedulerTracking.unstable_track(firstEvent.name, currentTime, () => { - interaction = Array.from(SchedulerTracking.unstable_getCurrent())[0]; - wrapped = SchedulerTracking.unstable_wrap(mock); + SchedulerTracing.unstable_trace(firstEvent.name, currentTime, () => { + interaction = Array.from(SchedulerTracing.unstable_getCurrent())[0]; + wrapped = SchedulerTracing.unstable_wrap(mock); }); expect(interaction.__count).toBe(1); @@ -290,30 +288,26 @@ describe('TrackingSubscriptions', () => { }); it('should cover onWorkStopped within wrap', done => { - SchedulerTracking.unstable_track(firstEvent.name, currentTime, () => { + SchedulerTracing.unstable_trace(firstEvent.name, currentTime, () => { const outerInteraction = Array.from( - SchedulerTracking.unstable_getCurrent(), + SchedulerTracing.unstable_getCurrent(), )[0]; expect(outerInteraction.__count).toBe(1); let wrapped; let innerInteraction; - SchedulerTracking.unstable_track( - secondEvent.name, - currentTime, - () => { - innerInteraction = Array.from( - SchedulerTracking.unstable_getCurrent(), - )[1]; - expect(outerInteraction.__count).toBe(1); - expect(innerInteraction.__count).toBe(1); - - wrapped = SchedulerTracking.unstable_wrap(jest.fn()); - expect(outerInteraction.__count).toBe(2); - expect(innerInteraction.__count).toBe(2); - }, - ); + SchedulerTracing.unstable_trace(secondEvent.name, currentTime, () => { + innerInteraction = Array.from( + SchedulerTracing.unstable_getCurrent(), + )[1]; + expect(outerInteraction.__count).toBe(1); + expect(innerInteraction.__count).toBe(1); + + wrapped = SchedulerTracing.unstable_wrap(jest.fn()); + expect(outerInteraction.__count).toBe(2); + expect(innerInteraction.__count).toBe(2); + }); expect(outerInteraction.__count).toBe(2); expect(innerInteraction.__count).toBe(1); @@ -323,7 +317,7 @@ describe('TrackingSubscriptions', () => { throwInOnWorkStopped = false; // It should restore the previous interactions - expect(SchedulerTracking.unstable_getCurrent()).toMatchInteractions([ + expect(SchedulerTracing.unstable_getCurrent()).toMatchInteractions([ outerInteraction, ]); @@ -343,9 +337,9 @@ describe('TrackingSubscriptions', () => { let wrapped; let interaction; - SchedulerTracking.unstable_track(firstEvent.name, currentTime, () => { - interaction = Array.from(SchedulerTracking.unstable_getCurrent())[0]; - wrapped = SchedulerTracking.unstable_wrap(() => { + SchedulerTracing.unstable_trace(firstEvent.name, currentTime, () => { + interaction = Array.from(SchedulerTracing.unstable_getCurrent())[0]; + wrapped = SchedulerTracing.unstable_wrap(() => { throw Error('Expected error wrap'); }); }); @@ -364,9 +358,9 @@ describe('TrackingSubscriptions', () => { it('should cover onWorkCanceled within wrap', () => { let interaction, wrapped; - SchedulerTracking.unstable_track(firstEvent.name, currentTime, () => { - interaction = Array.from(SchedulerTracking.unstable_getCurrent())[0]; - wrapped = SchedulerTracking.unstable_wrap(jest.fn()); + SchedulerTracing.unstable_trace(firstEvent.name, currentTime, () => { + interaction = Array.from(SchedulerTracing.unstable_getCurrent())[0]; + wrapped = SchedulerTracing.unstable_wrap(jest.fn()); }); expect(interaction.__count).toBe(1); @@ -386,16 +380,16 @@ describe('TrackingSubscriptions', () => { }); }); - it('calls lifecycle methods for track', () => { - expect(onInteractionTracked).not.toHaveBeenCalled(); + it('calls lifecycle methods for trace', () => { + expect(onInteractionTraced).not.toHaveBeenCalled(); expect(onInteractionScheduledWorkCompleted).not.toHaveBeenCalled(); - SchedulerTracking.unstable_track( + SchedulerTracing.unstable_trace( firstEvent.name, currentTime, () => { - expect(onInteractionTracked).toHaveBeenCalledTimes(1); - expect(onInteractionTracked).toHaveBeenLastNotifiedOfInteraction( + expect(onInteractionTraced).toHaveBeenCalledTimes(1); + expect(onInteractionTraced).toHaveBeenLastNotifiedOfInteraction( firstEvent, ); expect(onInteractionScheduledWorkCompleted).not.toHaveBeenCalled(); @@ -406,12 +400,12 @@ describe('TrackingSubscriptions', () => { ); expect(onWorkStopped).not.toHaveBeenCalled(); - SchedulerTracking.unstable_track( + SchedulerTracing.unstable_trace( secondEvent.name, currentTime, () => { - expect(onInteractionTracked).toHaveBeenCalledTimes(2); - expect(onInteractionTracked).toHaveBeenLastNotifiedOfInteraction( + expect(onInteractionTraced).toHaveBeenCalledTimes(2); + expect(onInteractionTraced).toHaveBeenLastNotifiedOfInteraction( secondEvent, ); expect( @@ -458,19 +452,19 @@ describe('TrackingSubscriptions', () => { const unwrapped = jest.fn(); let wrapped; - SchedulerTracking.unstable_track(firstEvent.name, currentTime, () => { - expect(onInteractionTracked).toHaveBeenCalledTimes(1); - expect(onInteractionTracked).toHaveBeenLastNotifiedOfInteraction( + SchedulerTracing.unstable_trace(firstEvent.name, currentTime, () => { + expect(onInteractionTraced).toHaveBeenCalledTimes(1); + expect(onInteractionTraced).toHaveBeenLastNotifiedOfInteraction( firstEvent, ); - SchedulerTracking.unstable_track(secondEvent.name, currentTime, () => { - expect(onInteractionTracked).toHaveBeenCalledTimes(2); - expect(onInteractionTracked).toHaveBeenLastNotifiedOfInteraction( + SchedulerTracing.unstable_trace(secondEvent.name, currentTime, () => { + expect(onInteractionTraced).toHaveBeenCalledTimes(2); + expect(onInteractionTraced).toHaveBeenLastNotifiedOfInteraction( secondEvent, ); - wrapped = SchedulerTracking.unstable_wrap(unwrapped, threadID); + wrapped = SchedulerTracing.unstable_wrap(unwrapped, threadID); expect(onWorkScheduled).toHaveBeenCalledTimes(1); expect(onWorkScheduled).toHaveBeenLastNotifiedOfWork( new Set([firstEvent, secondEvent]), @@ -479,7 +473,7 @@ describe('TrackingSubscriptions', () => { }); }); - expect(onInteractionTracked).toHaveBeenCalledTimes(2); + expect(onInteractionTraced).toHaveBeenCalledTimes(2); expect(onInteractionScheduledWorkCompleted).not.toHaveBeenCalled(); wrapped(); @@ -510,14 +504,14 @@ describe('TrackingSubscriptions', () => { const fnOne = jest.fn(); const fnTwo = jest.fn(); let wrappedOne, wrappedTwo; - SchedulerTracking.unstable_track(firstEvent.name, currentTime, () => { - wrappedOne = SchedulerTracking.unstable_wrap(fnOne, threadID); - SchedulerTracking.unstable_track(secondEvent.name, currentTime, () => { - wrappedTwo = SchedulerTracking.unstable_wrap(fnTwo, threadID); + SchedulerTracing.unstable_trace(firstEvent.name, currentTime, () => { + wrappedOne = SchedulerTracing.unstable_wrap(fnOne, threadID); + SchedulerTracing.unstable_trace(secondEvent.name, currentTime, () => { + wrappedTwo = SchedulerTracing.unstable_wrap(fnTwo, threadID); }); }); - expect(onInteractionTracked).toHaveBeenCalledTimes(2); + expect(onInteractionTraced).toHaveBeenCalledTimes(2); expect(onInteractionScheduledWorkCompleted).not.toHaveBeenCalled(); expect(onWorkCanceled).not.toHaveBeenCalled(); expect(onWorkStarted).toHaveBeenCalledTimes(2); @@ -553,25 +547,25 @@ describe('TrackingSubscriptions', () => { it('should not end an interaction twice if wrap is used to schedule follow up work within another wrap', () => { const fnOne = jest.fn(() => { - wrappedTwo = SchedulerTracking.unstable_wrap(fnTwo, threadID); + wrappedTwo = SchedulerTracing.unstable_wrap(fnTwo, threadID); }); const fnTwo = jest.fn(); let wrappedOne, wrappedTwo; - SchedulerTracking.unstable_track(firstEvent.name, currentTime, () => { - wrappedOne = SchedulerTracking.unstable_wrap(fnOne, threadID); + SchedulerTracing.unstable_trace(firstEvent.name, currentTime, () => { + wrappedOne = SchedulerTracing.unstable_wrap(fnOne, threadID); }); - expect(onInteractionTracked).toHaveBeenCalledTimes(1); + expect(onInteractionTraced).toHaveBeenCalledTimes(1); expect(onInteractionScheduledWorkCompleted).not.toHaveBeenCalled(); wrappedOne(); - expect(onInteractionTracked).toHaveBeenCalledTimes(1); + expect(onInteractionTraced).toHaveBeenCalledTimes(1); expect(onInteractionScheduledWorkCompleted).not.toHaveBeenCalled(); wrappedTwo(); - expect(onInteractionTracked).toHaveBeenCalledTimes(1); + expect(onInteractionTraced).toHaveBeenCalledTimes(1); expect(onInteractionScheduledWorkCompleted).toHaveBeenCalledTimes(1); expect( onInteractionScheduledWorkCompleted, @@ -582,29 +576,29 @@ describe('TrackingSubscriptions', () => { const unwrappedOne = jest.fn(); const unwrappedTwo = jest.fn(); let wrappedOne, wrappedTwo; - SchedulerTracking.unstable_track(firstEvent.name, currentTime, () => { - wrappedOne = SchedulerTracking.unstable_wrap(unwrappedOne, threadID); - wrappedTwo = SchedulerTracking.unstable_wrap(unwrappedTwo, threadID); + SchedulerTracing.unstable_trace(firstEvent.name, currentTime, () => { + wrappedOne = SchedulerTracing.unstable_wrap(unwrappedOne, threadID); + wrappedTwo = SchedulerTracing.unstable_wrap(unwrappedTwo, threadID); }); - expect(onInteractionTracked).toHaveBeenCalledTimes(1); + expect(onInteractionTraced).toHaveBeenCalledTimes(1); expect(onInteractionScheduledWorkCompleted).not.toHaveBeenCalled(); wrappedOne(); expect(unwrappedOne).toHaveBeenCalledTimes(1); - expect(onInteractionTracked).toHaveBeenCalledTimes(1); + expect(onInteractionTraced).toHaveBeenCalledTimes(1); expect(onInteractionScheduledWorkCompleted).not.toHaveBeenCalled(); wrappedOne(); expect(unwrappedOne).toHaveBeenCalledTimes(2); - expect(onInteractionTracked).toHaveBeenCalledTimes(1); + expect(onInteractionTraced).toHaveBeenCalledTimes(1); expect(onInteractionScheduledWorkCompleted).not.toHaveBeenCalled(); wrappedTwo(); - expect(onInteractionTracked).toHaveBeenCalledTimes(1); + expect(onInteractionTraced).toHaveBeenCalledTimes(1); expect(onInteractionScheduledWorkCompleted).toHaveBeenCalledTimes(1); expect( onInteractionScheduledWorkCompleted, @@ -612,15 +606,15 @@ describe('TrackingSubscriptions', () => { }); it('should unsubscribe', () => { - SchedulerTracking.unstable_unsubscribe(firstSubscriber); - SchedulerTracking.unstable_track(firstEvent.name, currentTime, () => {}); + SchedulerTracing.unstable_unsubscribe(firstSubscriber); + SchedulerTracing.unstable_trace(firstEvent.name, currentTime, () => {}); - expect(onInteractionTracked).not.toHaveBeenCalled(); + expect(onInteractionTraced).not.toHaveBeenCalled(); }); }); describe('disabled', () => { - beforeEach(() => loadModules({enableSchedulerTracking: false})); + beforeEach(() => loadModules({enableSchedulerTracing: false})); // TODO }); diff --git a/packages/schedule/tracing.js b/packages/schedule/tracing.js index 79e945a21b968..e3001a8ecffd1 100644 --- a/packages/schedule/tracing.js +++ b/packages/schedule/tracing.js @@ -9,5 +9,5 @@ 'use strict'; -export * from './src/Tracking'; -export * from './src/TrackingSubscriptions'; +export * from './src/Tracing'; +export * from './src/TracingSubscriptions'; diff --git a/packages/shared/ReactFeatureFlags.js b/packages/shared/ReactFeatureFlags.js index fd9a971c1ccea..aae29ada1838b 100644 --- a/packages/shared/ReactFeatureFlags.js +++ b/packages/shared/ReactFeatureFlags.js @@ -37,8 +37,8 @@ export const warnAboutLegacyContextAPI = false; // Gather advanced timing metrics for Profiler subtrees. export const enableProfilerTimer = __PROFILE__; -// Track which interactions trigger each commit. -export const enableSchedulerTracking = __PROFILE__; +// Trace which interactions trigger each commit. +export const enableSchedulerTracing = __PROFILE__; // Only used in www builds. export const enableSuspenseServerRenderer = false; diff --git a/packages/shared/forks/ReactFeatureFlags.native-fabric-fb.js b/packages/shared/forks/ReactFeatureFlags.native-fabric-fb.js index 4eae387909047..69bb61eca4d47 100644 --- a/packages/shared/forks/ReactFeatureFlags.native-fabric-fb.js +++ b/packages/shared/forks/ReactFeatureFlags.native-fabric-fb.js @@ -21,7 +21,7 @@ export const warnAboutDeprecatedLifecycles = false; export const warnAboutLegacyContextAPI = __DEV__; export const replayFailedUnitOfWorkWithInvokeGuardedCallback = __DEV__; export const enableProfilerTimer = __PROFILE__; -export const enableSchedulerTracking = __PROFILE__; +export const enableSchedulerTracing = __PROFILE__; export const enableSuspenseServerRenderer = false; export const disableInputAttributeSyncing = false; diff --git a/packages/shared/forks/ReactFeatureFlags.native-fabric-oss.js b/packages/shared/forks/ReactFeatureFlags.native-fabric-oss.js index 3b30e2d4a7cff..66f1b4714ad4d 100644 --- a/packages/shared/forks/ReactFeatureFlags.native-fabric-oss.js +++ b/packages/shared/forks/ReactFeatureFlags.native-fabric-oss.js @@ -21,7 +21,7 @@ export const warnAboutDeprecatedLifecycles = false; export const warnAboutLegacyContextAPI = false; export const replayFailedUnitOfWorkWithInvokeGuardedCallback = __DEV__; export const enableProfilerTimer = __PROFILE__; -export const enableSchedulerTracking = __PROFILE__; +export const enableSchedulerTracing = __PROFILE__; export const enableSuspenseServerRenderer = false; export const disableInputAttributeSyncing = false; diff --git a/packages/shared/forks/ReactFeatureFlags.native-fb.js b/packages/shared/forks/ReactFeatureFlags.native-fb.js index 8c1823f343c22..be63c527a8ee4 100644 --- a/packages/shared/forks/ReactFeatureFlags.native-fb.js +++ b/packages/shared/forks/ReactFeatureFlags.native-fb.js @@ -27,7 +27,7 @@ export const { export const enableUserTimingAPI = __DEV__; export const warnAboutLegacyContextAPI = __DEV__; export const enableProfilerTimer = __PROFILE__; -export const enableSchedulerTracking = __PROFILE__; +export const enableSchedulerTracing = __PROFILE__; export const enableSuspenseServerRenderer = false; // Only used in www builds. diff --git a/packages/shared/forks/ReactFeatureFlags.native-oss.js b/packages/shared/forks/ReactFeatureFlags.native-oss.js index 34ceb41312ac1..7a2e325723a70 100644 --- a/packages/shared/forks/ReactFeatureFlags.native-oss.js +++ b/packages/shared/forks/ReactFeatureFlags.native-oss.js @@ -21,7 +21,7 @@ export const replayFailedUnitOfWorkWithInvokeGuardedCallback = __DEV__; export const warnAboutDeprecatedLifecycles = false; export const warnAboutLegacyContextAPI = false; export const enableProfilerTimer = __PROFILE__; -export const enableSchedulerTracking = __PROFILE__; +export const enableSchedulerTracing = __PROFILE__; export const enableSuspenseServerRenderer = false; export const disableInputAttributeSyncing = false; diff --git a/packages/shared/forks/ReactFeatureFlags.persistent.js b/packages/shared/forks/ReactFeatureFlags.persistent.js index 4aad9b9bc329f..4b1b1c4c34f2a 100644 --- a/packages/shared/forks/ReactFeatureFlags.persistent.js +++ b/packages/shared/forks/ReactFeatureFlags.persistent.js @@ -21,7 +21,7 @@ export const warnAboutDeprecatedLifecycles = false; export const warnAboutLegacyContextAPI = false; export const replayFailedUnitOfWorkWithInvokeGuardedCallback = __DEV__; export const enableProfilerTimer = __PROFILE__; -export const enableSchedulerTracking = __PROFILE__; +export const enableSchedulerTracing = __PROFILE__; export const enableSuspenseServerRenderer = false; export const disableInputAttributeSyncing = false; diff --git a/packages/shared/forks/ReactFeatureFlags.test-renderer.js b/packages/shared/forks/ReactFeatureFlags.test-renderer.js index d069a962aa32c..fb828d661dfbe 100644 --- a/packages/shared/forks/ReactFeatureFlags.test-renderer.js +++ b/packages/shared/forks/ReactFeatureFlags.test-renderer.js @@ -21,7 +21,7 @@ export const warnAboutDeprecatedLifecycles = false; export const warnAboutLegacyContextAPI = false; export const replayFailedUnitOfWorkWithInvokeGuardedCallback = false; export const enableProfilerTimer = false; -export const enableSchedulerTracking = false; +export const enableSchedulerTracing = false; export const enableSuspenseServerRenderer = false; export const disableInputAttributeSyncing = false; diff --git a/packages/shared/forks/ReactFeatureFlags.test-renderer.www.js b/packages/shared/forks/ReactFeatureFlags.test-renderer.www.js index f4b2cc2f84c78..213d9ef75c4e9 100644 --- a/packages/shared/forks/ReactFeatureFlags.test-renderer.www.js +++ b/packages/shared/forks/ReactFeatureFlags.test-renderer.www.js @@ -21,7 +21,7 @@ export const warnAboutDeprecatedLifecycles = false; export const warnAboutLegacyContextAPI = false; export const replayFailedUnitOfWorkWithInvokeGuardedCallback = false; export const enableProfilerTimer = false; -export const enableSchedulerTracking = false; +export const enableSchedulerTracing = false; export const enableSuspenseServerRenderer = false; // Only used in www builds. diff --git a/packages/shared/forks/ReactFeatureFlags.www.js b/packages/shared/forks/ReactFeatureFlags.www.js index 66bac45cd2af1..3f9d960d69f1a 100644 --- a/packages/shared/forks/ReactFeatureFlags.www.js +++ b/packages/shared/forks/ReactFeatureFlags.www.js @@ -34,7 +34,7 @@ export const warnAboutLegacyContextAPI = __DEV__; export let enableUserTimingAPI = __DEV__; export const enableProfilerTimer = __PROFILE__; -export const enableSchedulerTracking = __PROFILE__; +export const enableSchedulerTracing = __PROFILE__; let refCount = 0; export function addUserTimingListener() { diff --git a/packages/shared/forks/ScheduleTracing.umd.js b/packages/shared/forks/ScheduleTracing.umd.js index 8587f6c4da585..fd406bbab9f3b 100644 --- a/packages/shared/forks/ScheduleTracing.umd.js +++ b/packages/shared/forks/ScheduleTracing.umd.js @@ -18,10 +18,10 @@ const { unstable_getCurrent, unstable_getThreadID, unstable_subscribe, - unstable_track, + unstable_trace, unstable_unsubscribe, unstable_wrap, -} = ReactInternals.ScheduleTracking; +} = ReactInternals.ScheduleTracing; export { __interactionsRef, @@ -30,7 +30,7 @@ export { unstable_getCurrent, unstable_getThreadID, unstable_subscribe, - unstable_track, + unstable_trace, unstable_unsubscribe, unstable_wrap, }; diff --git a/scripts/jest/setupTests.js b/scripts/jest/setupTests.js index 27bb0101008bf..c0f32f561d7a9 100644 --- a/scripts/jest/setupTests.js +++ b/scripts/jest/setupTests.js @@ -44,7 +44,7 @@ if (process.env.REACT_CLASS_EQUIVALENCE_TEST) { } expect.extend({ - ...require('./matchers/interactionTracking'), + ...require('./matchers/interactionTracing'), ...require('./matchers/toWarnDev'), ...require('./matchers/testRenderer'), }); diff --git a/scripts/jest/spec-equivalence-reporter/setupTests.js b/scripts/jest/spec-equivalence-reporter/setupTests.js index 751affc68ed45..d0d495041dbe8 100644 --- a/scripts/jest/spec-equivalence-reporter/setupTests.js +++ b/scripts/jest/spec-equivalence-reporter/setupTests.js @@ -46,7 +46,7 @@ global.spyOnProd = function(...args) { }; expect.extend({ - ...require('../matchers/interactionTracking'), + ...require('../matchers/interactionTracing'), ...require('../matchers/toWarnDev'), ...require('../matchers/testRenderer'), }); diff --git a/scripts/rollup/bundles.js b/scripts/rollup/bundles.js index ffb380cc06d48..1279ebbc10f43 100644 --- a/scripts/rollup/bundles.js +++ b/scripts/rollup/bundles.js @@ -391,7 +391,7 @@ const bundles = [ }, { - label: 'schedule-tracking', + label: 'schedule-tracing', bundleTypes: [ FB_WWW_DEV, FB_WWW_PROD, @@ -401,8 +401,8 @@ const bundles = [ NODE_PROFILING, ], moduleType: ISOMORPHIC, - entry: 'schedule/tracking', - global: 'ScheduleTracking', + entry: 'schedule/tracing', + global: 'ScheduleTracing', externals: [], }, ]; diff --git a/scripts/rollup/forks.js b/scripts/rollup/forks.js index e55992978992d..9c4f4d024cf57 100644 --- a/scripts/rollup/forks.js +++ b/scripts/rollup/forks.js @@ -132,7 +132,7 @@ const forks = Object.freeze({ } }, - 'schedule/tracking': (bundleType, entry, dependencies) => { + 'schedule/tracing': (bundleType, entry, dependencies) => { switch (bundleType) { case UMD_DEV: case UMD_PROD: @@ -143,7 +143,7 @@ const forks = Object.freeze({ } // Optimization: for UMDs, use the API that is already a part of the React // package instead of requiring it to be loaded via a separate