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`] = `
`;
-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
new file mode 100644
index 0000000000000..f704f9ba13e81
--- /dev/null
+++ b/packages/schedule/npm/tracing-profiling.js
@@ -0,0 +1,7 @@
+'use strict';
+
+if (process.env.NODE_ENV === 'production') {
+ module.exports = require('./cjs/schedule-tracing.profiling.min.js');
+} else {
+ module.exports = require('./cjs/schedule-tracing.development.js');
+}
diff --git a/packages/schedule/npm/tracing.js b/packages/schedule/npm/tracing.js
new file mode 100644
index 0000000000000..f33597849d8a7
--- /dev/null
+++ b/packages/schedule/npm/tracing.js
@@ -0,0 +1,7 @@
+'use strict';
+
+if (process.env.NODE_ENV === 'production') {
+ module.exports = require('./cjs/schedule-tracing.production.min.js');
+} else {
+ module.exports = require('./cjs/schedule-tracing.development.js');
+}
diff --git a/packages/schedule/npm/tracking-profiling.js b/packages/schedule/npm/tracking-profiling.js
deleted file mode 100644
index c90851e796d23..0000000000000
--- a/packages/schedule/npm/tracking-profiling.js
+++ /dev/null
@@ -1,7 +0,0 @@
-'use strict';
-
-if (process.env.NODE_ENV === 'production') {
- module.exports = require('./cjs/schedule-tracking.profiling.min.js');
-} else {
- module.exports = require('./cjs/schedule-tracking.development.js');
-}
diff --git a/packages/schedule/npm/tracking.js b/packages/schedule/npm/tracking.js
deleted file mode 100644
index c1bb73e4f8af6..0000000000000
--- a/packages/schedule/npm/tracking.js
+++ /dev/null
@@ -1,7 +0,0 @@
-'use strict';
-
-if (process.env.NODE_ENV === 'production') {
- module.exports = require('./cjs/schedule-tracking.production.min.js');
-} else {
- module.exports = require('./cjs/schedule-tracking.development.js');
-}
diff --git a/packages/schedule/npm/umd/schedule-tracking.development.js b/packages/schedule/npm/umd/schedule-tracing.development.js
similarity index 79%
rename from packages/schedule/npm/umd/schedule-tracking.development.js
rename to packages/schedule/npm/umd/schedule-tracing.development.js
index c5c488eec2a3e..e361c64ac666e 100644
--- a/packages/schedule/npm/umd/schedule-tracking.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-tracking.production.min.js b/packages/schedule/npm/umd/schedule-tracing.production.min.js
similarity index 79%
rename from packages/schedule/npm/umd/schedule-tracking.production.min.js
rename to packages/schedule/npm/umd/schedule-tracing.production.min.js
index c5c488eec2a3e..e361c64ac666e 100644
--- a/packages/schedule/npm/umd/schedule-tracking.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/Tracking.js b/packages/schedule/src/Tracing.js
similarity index 91%
rename from packages/schedule/src/Tracking.js
rename to packages/schedule/src/Tracing.js
index 7356445e74eff..1223d44a2cf28 100644
--- a/packages/schedule/src/Tracking.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/TrackingSubscriptions.js b/packages/schedule/src/TracingSubscriptions.js
similarity index 88%
rename from packages/schedule/src/TrackingSubscriptions.js
rename to packages/schedule/src/TracingSubscriptions.js
index 202043b74effd..ffddd4a4ebbf2 100644
--- a/packages/schedule/src/TrackingSubscriptions.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
new file mode 100644
index 0000000000000..60497138c77f5
--- /dev/null
+++ b/packages/schedule/src/__tests__/Tracing-test.internal.js
@@ -0,0 +1,375 @@
+/**
+ * Copyright (c) Facebook, Inc. and its affiliates.
+ *
+ * This source code is licensed under the MIT license found in the
+ * LICENSE file in the root directory of this source tree.
+ *
+ * @jest-environment node
+ */
+'use strict';
+
+describe('Tracing', () => {
+ let SchedulerTracing;
+ let ReactFeatureFlags;
+
+ let advanceTimeBy;
+ let currentTime;
+
+ function loadModules({enableSchedulerTracing}) {
+ jest.resetModules();
+ jest.useFakeTimers();
+
+ currentTime = 0;
+ Date.now = jest.fn().mockImplementation(() => currentTime);
+
+ advanceTimeBy = amount => {
+ currentTime += amount;
+ };
+
+ ReactFeatureFlags = require('shared/ReactFeatureFlags');
+ ReactFeatureFlags.enableSchedulerTracing = enableSchedulerTracing;
+
+ SchedulerTracing = require('schedule/tracing');
+ }
+
+ describe('enableSchedulerTracing enabled', () => {
+ beforeEach(() => loadModules({enableSchedulerTracing: true}));
+
+ it('should return the value of a traced function', () => {
+ expect(
+ SchedulerTracing.unstable_trace('arbitrary', currentTime, () => 123),
+ ).toBe(123);
+ });
+
+ it('should return the value of a clear function', () => {
+ expect(SchedulerTracing.unstable_clear(() => 123)).toBe(123);
+ });
+
+ it('should return the value of a wrapped function', () => {
+ let wrapped;
+ 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;
+ SchedulerTracing.unstable_trace('arbitrary', currentTime, () => {
+ wrapped = SchedulerTracing.unstable_wrap((param1, param2) => {
+ expect(param1).toBe('foo');
+ expect(param2).toBe('bar');
+ done();
+ });
+ });
+ wrapped('foo', 'bar');
+ });
+
+ it('should return an empty set when outside of a traced event', () => {
+ expect(SchedulerTracing.unstable_getCurrent()).toContainNoInteractions();
+ });
+
+ it('should report the traced interaction from within the trace callback', done => {
+ advanceTimeBy(100);
+
+ SchedulerTracing.unstable_trace('some event', currentTime, () => {
+ const interactions = SchedulerTracing.unstable_getCurrent();
+ expect(interactions).toMatchInteractions([
+ {name: 'some event', timestamp: 100},
+ ]);
+
+ done();
+ });
+ });
+
+ it('should report the traced interaction from within wrapped callbacks', done => {
+ let wrappedIndirection;
+
+ function indirection() {
+ const interactions = SchedulerTracing.unstable_getCurrent();
+ expect(interactions).toMatchInteractions([
+ {name: 'some event', timestamp: 100},
+ ]);
+
+ done();
+ }
+
+ advanceTimeBy(100);
+
+ SchedulerTracing.unstable_trace('some event', currentTime, () => {
+ wrappedIndirection = SchedulerTracing.unstable_wrap(indirection);
+ });
+
+ advanceTimeBy(50);
+
+ wrappedIndirection();
+ });
+
+ it('should clear the interaction stack for traced callbacks', () => {
+ let innerTestReached = false;
+
+ SchedulerTracing.unstable_trace('outer event', currentTime, () => {
+ expect(SchedulerTracing.unstable_getCurrent()).toMatchInteractions([
+ {name: 'outer event'},
+ ]);
+
+ SchedulerTracing.unstable_clear(() => {
+ expect(SchedulerTracing.unstable_getCurrent()).toMatchInteractions(
+ [],
+ );
+
+ SchedulerTracing.unstable_trace('inner event', currentTime, () => {
+ expect(SchedulerTracing.unstable_getCurrent()).toMatchInteractions([
+ {name: 'inner event'},
+ ]);
+
+ innerTestReached = true;
+ });
+ });
+
+ expect(SchedulerTracing.unstable_getCurrent()).toMatchInteractions([
+ {name: 'outer event'},
+ ]);
+ });
+
+ expect(innerTestReached).toBe(true);
+ });
+
+ it('should clear the interaction stack for wrapped callbacks', () => {
+ let innerTestReached = false;
+ let wrappedIndirection;
+
+ const indirection = jest.fn(() => {
+ expect(SchedulerTracing.unstable_getCurrent()).toMatchInteractions([
+ {name: 'outer event'},
+ ]);
+
+ SchedulerTracing.unstable_clear(() => {
+ expect(SchedulerTracing.unstable_getCurrent()).toMatchInteractions(
+ [],
+ );
+
+ SchedulerTracing.unstable_trace('inner event', currentTime, () => {
+ expect(SchedulerTracing.unstable_getCurrent()).toMatchInteractions([
+ {name: 'inner event'},
+ ]);
+
+ innerTestReached = true;
+ });
+ });
+
+ expect(SchedulerTracing.unstable_getCurrent()).toMatchInteractions([
+ {name: 'outer event'},
+ ]);
+ });
+
+ SchedulerTracing.unstable_trace('outer event', currentTime, () => {
+ wrappedIndirection = SchedulerTracing.unstable_wrap(indirection);
+ });
+
+ wrappedIndirection();
+
+ expect(innerTestReached).toBe(true);
+ });
+
+ it('should support nested traced events', done => {
+ advanceTimeBy(100);
+
+ let innerIndirectionTraced = false;
+ let outerIndirectionTraced = false;
+
+ function innerIndirection() {
+ const interactions = SchedulerTracing.unstable_getCurrent();
+ expect(interactions).toMatchInteractions([
+ {name: 'outer event', timestamp: 100},
+ {name: 'inner event', timestamp: 150},
+ ]);
+
+ innerIndirectionTraced = true;
+ }
+
+ function outerIndirection() {
+ const interactions = SchedulerTracing.unstable_getCurrent();
+ expect(interactions).toMatchInteractions([
+ {name: 'outer event', timestamp: 100},
+ ]);
+
+ outerIndirectionTraced = true;
+ }
+
+ 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 = SchedulerTracing.unstable_wrap(
+ outerIndirection,
+ );
+
+ let wrapperInnerIndirection;
+ let innerEventTraced = false;
+
+ // 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 traced
+ wrapperOuterIndirection();
+ expect(outerIndirectionTraced).toBe(true);
+
+ wrapperInnerIndirection = SchedulerTracing.unstable_wrap(
+ innerIndirection,
+ );
+
+ innerEventTraced = true;
+ });
+
+ expect(innerEventTraced).toBe(true);
+
+ // Verify that the original event is restored
+ interactions = SchedulerTracing.unstable_getCurrent();
+ expect(interactions).toMatchInteractions([
+ {name: 'outer event', timestamp: 100},
+ ]);
+
+ // Verify that a wrapped nested callback is properly traced
+ wrapperInnerIndirection();
+ expect(innerIndirectionTraced).toBe(true);
+
+ done();
+ });
+ });
+
+ describe('error handling', () => {
+ it('should reset state appropriately when an error occurs in a trace callback', done => {
+ advanceTimeBy(100);
+
+ SchedulerTracing.unstable_trace('outer event', currentTime, () => {
+ expect(() => {
+ SchedulerTracing.unstable_trace('inner event', currentTime, () => {
+ throw Error('intentional');
+ });
+ }).toThrow();
+
+ expect(SchedulerTracing.unstable_getCurrent()).toMatchInteractions([
+ {name: 'outer event', timestamp: 100},
+ ]);
+
+ done();
+ });
+ });
+
+ it('should reset state appropriately when an error occurs in a wrapped callback', done => {
+ advanceTimeBy(100);
+
+ SchedulerTracing.unstable_trace('outer event', currentTime, () => {
+ let wrappedCallback;
+
+ SchedulerTracing.unstable_trace('inner event', currentTime, () => {
+ wrappedCallback = SchedulerTracing.unstable_wrap(() => {
+ throw Error('intentional');
+ });
+ });
+
+ expect(wrappedCallback).toThrow();
+
+ expect(SchedulerTracing.unstable_getCurrent()).toMatchInteractions([
+ {name: 'outer event', timestamp: 100},
+ ]);
+
+ done();
+ });
+ });
+ });
+
+ describe('advanced integration', () => {
+ it('should return a unique threadID per request', () => {
+ expect(SchedulerTracing.unstable_getThreadID()).not.toBe(
+ SchedulerTracing.unstable_getThreadID(),
+ );
+ });
+
+ it('should expose the current set of interactions to be externally manipulated', () => {
+ SchedulerTracing.unstable_trace('outer event', currentTime, () => {
+ expect(SchedulerTracing.__interactionsRef.current).toBe(
+ SchedulerTracing.unstable_getCurrent(),
+ );
+
+ SchedulerTracing.__interactionsRef.current = new Set([
+ {name: 'override event'},
+ ]);
+
+ expect(SchedulerTracing.unstable_getCurrent()).toMatchInteractions([
+ {name: 'override event'},
+ ]);
+ });
+ });
+
+ it('should expose a subscriber ref to be externally manipulated', () => {
+ SchedulerTracing.unstable_trace('outer event', currentTime, () => {
+ expect(SchedulerTracing.__subscriberRef).toEqual({
+ current: null,
+ });
+ });
+ });
+ });
+ });
+
+ describe('enableSchedulerTracing disabled', () => {
+ beforeEach(() => loadModules({enableSchedulerTracing: false}));
+
+ it('should return the value of a traced function', () => {
+ expect(
+ SchedulerTracing.unstable_trace('arbitrary', currentTime, () => 123),
+ ).toBe(123);
+ });
+
+ it('should return the value of a wrapped function', () => {
+ let wrapped;
+ SchedulerTracing.unstable_trace('arbitrary', currentTime, () => {
+ wrapped = SchedulerTracing.unstable_wrap(() => 123);
+ });
+ expect(wrapped()).toBe(123);
+ });
+
+ it('should return null for traced interactions', () => {
+ expect(SchedulerTracing.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(SchedulerTracing.unstable_clear(() => 123)).toBe(123);
+ });
+
+ it('should execute wrapped callbacks', done => {
+ const wrappedCallback = SchedulerTracing.unstable_wrap(() => {
+ expect(SchedulerTracing.unstable_getCurrent()).toBe(null);
+
+ done();
+ });
+
+ wrappedCallback();
+ });
+
+ describe('advanced integration', () => {
+ it('should not create unnecessary objects', () => {
+ expect(SchedulerTracing.__interactionsRef).toBe(null);
+ });
+ });
+ });
+});
diff --git a/packages/schedule/src/__tests__/Tracking-test.js b/packages/schedule/src/__tests__/Tracing-test.js
similarity index 51%
rename from packages/schedule/src/__tests__/Tracking-test.js
rename to packages/schedule/src/__tests__/Tracing-test.js
index 6b340f8434e69..3ccdff39c283f 100644
--- a/packages/schedule/src/__tests__/Tracking-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__/TrackingSubscriptions-test.internal.js b/packages/schedule/src/__tests__/TracingSubscriptions-test.internal.js
similarity index 68%
rename from packages/schedule/src/__tests__/TrackingSubscriptions-test.internal.js
rename to packages/schedule/src/__tests__/TracingSubscriptions-test.internal.js
index 674751dc00535..f9a67816952d5 100644
--- a/packages/schedule/src/__tests__/TrackingSubscriptions-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/src/__tests__/Tracking-test.internal.js b/packages/schedule/src/__tests__/Tracking-test.internal.js
deleted file mode 100644
index 8de0cbc4858f3..0000000000000
--- a/packages/schedule/src/__tests__/Tracking-test.internal.js
+++ /dev/null
@@ -1,375 +0,0 @@
-/**
- * Copyright (c) Facebook, Inc. and its affiliates.
- *
- * This source code is licensed under the MIT license found in the
- * LICENSE file in the root directory of this source tree.
- *
- * @jest-environment node
- */
-'use strict';
-
-describe('Tracking', () => {
- let SchedulerTracking;
- let ReactFeatureFlags;
-
- let advanceTimeBy;
- let currentTime;
-
- function loadModules({enableSchedulerTracking}) {
- jest.resetModules();
- jest.useFakeTimers();
-
- currentTime = 0;
- Date.now = jest.fn().mockImplementation(() => currentTime);
-
- advanceTimeBy = amount => {
- currentTime += amount;
- };
-
- ReactFeatureFlags = require('shared/ReactFeatureFlags');
- ReactFeatureFlags.enableSchedulerTracking = enableSchedulerTracking;
-
- SchedulerTracking = require('schedule/tracking');
- }
-
- describe('enableSchedulerTracking enabled', () => {
- beforeEach(() => loadModules({enableSchedulerTracking: true}));
-
- it('should return the value of a tracked function', () => {
- expect(
- SchedulerTracking.unstable_track('arbitrary', currentTime, () => 123),
- ).toBe(123);
- });
-
- it('should return the value of a clear function', () => {
- expect(SchedulerTracking.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);
- });
- 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) => {
- expect(param1).toBe('foo');
- expect(param2).toBe('bar');
- done();
- });
- });
- wrapped('foo', 'bar');
- });
-
- it('should return an empty set when outside of a tracked event', () => {
- expect(SchedulerTracking.unstable_getCurrent()).toContainNoInteractions();
- });
-
- it('should report the tracked interaction from within the track callback', done => {
- advanceTimeBy(100);
-
- SchedulerTracking.unstable_track('some event', currentTime, () => {
- const interactions = SchedulerTracking.unstable_getCurrent();
- expect(interactions).toMatchInteractions([
- {name: 'some event', timestamp: 100},
- ]);
-
- done();
- });
- });
-
- it('should report the tracked interaction from within wrapped callbacks', done => {
- let wrappedIndirection;
-
- function indirection() {
- const interactions = SchedulerTracking.unstable_getCurrent();
- expect(interactions).toMatchInteractions([
- {name: 'some event', timestamp: 100},
- ]);
-
- done();
- }
-
- advanceTimeBy(100);
-
- SchedulerTracking.unstable_track('some event', currentTime, () => {
- wrappedIndirection = SchedulerTracking.unstable_wrap(indirection);
- });
-
- advanceTimeBy(50);
-
- wrappedIndirection();
- });
-
- it('should clear the interaction stack for tracked callbacks', () => {
- let innerTestReached = false;
-
- SchedulerTracking.unstable_track('outer event', currentTime, () => {
- expect(SchedulerTracking.unstable_getCurrent()).toMatchInteractions([
- {name: 'outer event'},
- ]);
-
- SchedulerTracking.unstable_clear(() => {
- expect(SchedulerTracking.unstable_getCurrent()).toMatchInteractions(
- [],
- );
-
- SchedulerTracking.unstable_track('inner event', currentTime, () => {
- expect(SchedulerTracking.unstable_getCurrent()).toMatchInteractions(
- [{name: 'inner event'}],
- );
-
- innerTestReached = true;
- });
- });
-
- expect(SchedulerTracking.unstable_getCurrent()).toMatchInteractions([
- {name: 'outer event'},
- ]);
- });
-
- expect(innerTestReached).toBe(true);
- });
-
- it('should clear the interaction stack for wrapped callbacks', () => {
- let innerTestReached = false;
- let wrappedIndirection;
-
- const indirection = jest.fn(() => {
- expect(SchedulerTracking.unstable_getCurrent()).toMatchInteractions([
- {name: 'outer event'},
- ]);
-
- SchedulerTracking.unstable_clear(() => {
- expect(SchedulerTracking.unstable_getCurrent()).toMatchInteractions(
- [],
- );
-
- SchedulerTracking.unstable_track('inner event', currentTime, () => {
- expect(SchedulerTracking.unstable_getCurrent()).toMatchInteractions(
- [{name: 'inner event'}],
- );
-
- innerTestReached = true;
- });
- });
-
- expect(SchedulerTracking.unstable_getCurrent()).toMatchInteractions([
- {name: 'outer event'},
- ]);
- });
-
- SchedulerTracking.unstable_track('outer event', currentTime, () => {
- wrappedIndirection = SchedulerTracking.unstable_wrap(indirection);
- });
-
- wrappedIndirection();
-
- expect(innerTestReached).toBe(true);
- });
-
- it('should support nested tracked events', done => {
- advanceTimeBy(100);
-
- let innerIndirectionTracked = false;
- let outerIndirectionTracked = false;
-
- function innerIndirection() {
- const interactions = SchedulerTracking.unstable_getCurrent();
- expect(interactions).toMatchInteractions([
- {name: 'outer event', timestamp: 100},
- {name: 'inner event', timestamp: 150},
- ]);
-
- innerIndirectionTracked = true;
- }
-
- function outerIndirection() {
- const interactions = SchedulerTracking.unstable_getCurrent();
- expect(interactions).toMatchInteractions([
- {name: 'outer event', timestamp: 100},
- ]);
-
- outerIndirectionTracked = true;
- }
-
- SchedulerTracking.unstable_track('outer event', currentTime, () => {
- // Verify the current tracked event
- let interactions = SchedulerTracking.unstable_getCurrent();
- expect(interactions).toMatchInteractions([
- {name: 'outer event', timestamp: 100},
- ]);
-
- advanceTimeBy(50);
-
- const wrapperOuterIndirection = SchedulerTracking.unstable_wrap(
- outerIndirection,
- );
-
- let wrapperInnerIndirection;
- let innerEventTracked = false;
-
- // Verify that a nested event is properly tracked
- SchedulerTracking.unstable_track('inner event', currentTime, () => {
- interactions = SchedulerTracking.unstable_getCurrent();
- expect(interactions).toMatchInteractions([
- {name: 'outer event', timestamp: 100},
- {name: 'inner event', timestamp: 150},
- ]);
-
- // Verify that a wrapped outer callback is properly tracked
- wrapperOuterIndirection();
- expect(outerIndirectionTracked).toBe(true);
-
- wrapperInnerIndirection = SchedulerTracking.unstable_wrap(
- innerIndirection,
- );
-
- innerEventTracked = true;
- });
-
- expect(innerEventTracked).toBe(true);
-
- // Verify that the original event is restored
- interactions = SchedulerTracking.unstable_getCurrent();
- expect(interactions).toMatchInteractions([
- {name: 'outer event', timestamp: 100},
- ]);
-
- // Verify that a wrapped nested callback is properly tracked
- wrapperInnerIndirection();
- expect(innerIndirectionTracked).toBe(true);
-
- done();
- });
- });
-
- describe('error handling', () => {
- it('should reset state appropriately when an error occurs in a track callback', done => {
- advanceTimeBy(100);
-
- SchedulerTracking.unstable_track('outer event', currentTime, () => {
- expect(() => {
- SchedulerTracking.unstable_track('inner event', currentTime, () => {
- throw Error('intentional');
- });
- }).toThrow();
-
- expect(SchedulerTracking.unstable_getCurrent()).toMatchInteractions([
- {name: 'outer event', timestamp: 100},
- ]);
-
- done();
- });
- });
-
- it('should reset state appropriately when an error occurs in a wrapped callback', done => {
- advanceTimeBy(100);
-
- SchedulerTracking.unstable_track('outer event', currentTime, () => {
- let wrappedCallback;
-
- SchedulerTracking.unstable_track('inner event', currentTime, () => {
- wrappedCallback = SchedulerTracking.unstable_wrap(() => {
- throw Error('intentional');
- });
- });
-
- expect(wrappedCallback).toThrow();
-
- expect(SchedulerTracking.unstable_getCurrent()).toMatchInteractions([
- {name: 'outer event', timestamp: 100},
- ]);
-
- done();
- });
- });
- });
-
- describe('advanced integration', () => {
- it('should return a unique threadID per request', () => {
- expect(SchedulerTracking.unstable_getThreadID()).not.toBe(
- SchedulerTracking.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(),
- );
-
- SchedulerTracking.__interactionsRef.current = new Set([
- {name: 'override event'},
- ]);
-
- expect(SchedulerTracking.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({
- current: null,
- });
- });
- });
- });
- });
-
- describe('enableSchedulerTracking disabled', () => {
- beforeEach(() => loadModules({enableSchedulerTracking: false}));
-
- it('should return the value of a tracked function', () => {
- expect(
- SchedulerTracking.unstable_track('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);
- });
- expect(wrapped()).toBe(123);
- });
-
- it('should return null for tracked interactions', () => {
- expect(SchedulerTracking.unstable_getCurrent()).toBe(null);
- });
-
- it('should execute tracked callbacks', done => {
- SchedulerTracking.unstable_track('some event', currentTime, () => {
- expect(SchedulerTracking.unstable_getCurrent()).toBe(null);
-
- done();
- });
- });
-
- it('should return the value of a clear function', () => {
- expect(SchedulerTracking.unstable_clear(() => 123)).toBe(123);
- });
-
- it('should execute wrapped callbacks', done => {
- const wrappedCallback = SchedulerTracking.unstable_wrap(() => {
- expect(SchedulerTracking.unstable_getCurrent()).toBe(null);
-
- done();
- });
-
- wrappedCallback();
- });
-
- describe('advanced integration', () => {
- it('should not create unnecessary objects', () => {
- expect(SchedulerTracking.__interactionsRef).toBe(null);
- });
- });
- });
-});
diff --git a/packages/schedule/tracking.js b/packages/schedule/tracing.js
similarity index 73%
rename from packages/schedule/tracking.js
rename to packages/schedule/tracing.js
index 79e945a21b968..e3001a8ecffd1 100644
--- a/packages/schedule/tracking.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/ScheduleTracking.umd.js b/packages/shared/forks/ScheduleTracing.umd.js
similarity index 90%
rename from packages/shared/forks/ScheduleTracking.umd.js
rename to packages/shared/forks/ScheduleTracing.umd.js
index 8587f6c4da585..fd406bbab9f3b 100644
--- a/packages/shared/forks/ScheduleTracking.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/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
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