Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rename "tracking" API to "tracing" #13641

Merged
merged 2 commits into from
Sep 13, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 9 additions & 9 deletions fixtures/tracking/index.html → fixtures/tracing/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<html style="width: 100%; height: 100%;">
<head>
<meta charset="utf-8">
<title>Test tracking UMD</title>
<title>Test tracing UMD</title>
<style>
body {
font-family: sans-serif;
Expand Down Expand Up @@ -36,9 +36,9 @@
</style>
</head>
<body>
<h1>Test tracking UMD</h1>
<h1>Test tracing UMD</h1>
<p>
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.
</p>
<p>
Expand All @@ -52,19 +52,19 @@ <h3>
<li id="checkSchedulerAPI" data-value="...">
<strong>Test scheduler API</strong>
</li>
<li id="checkSchedulerTrackingAPI" data-value="...">
<strong>Test tracking API</strong>
<li id="checkSchedulerTracingAPI" data-value="...">
<strong>Test tracing API</strong>
</li>
<li id="checkSchedulerTrackingSubscriptionsAPI" data-value="...">
<strong>Test tracking subscriptions API</strong>
<li id="checkSchedulerTracingSubscriptionsAPI" data-value="...">
<strong>Test tracing subscriptions API</strong>
</li>
<li id="checkEndToEndIntegration" data-value="...">
<strong>Test end-to-end integration</strong>
</li>
</ol>
<!-- Load the tracking API before react to test that it's lazily evaluated -->
<!-- Load the tracing API before react to test that it's lazily evaluated -->
<script src="../../build/node_modules/schedule/umd/schedule.development.js"></script>
<script src="../../build/node_modules/schedule/umd/schedule-tracking.development.js"></script>
<script src="../../build/node_modules/schedule/umd/schedule-tracing.development.js"></script>
<script src="../../build/node_modules/react/umd/react.development.js"></script>
<script src="../../build/node_modules/react-dom/umd/react-dom.development.js"></script>
<script src="./script.js"></script>
Expand Down
84 changes: 42 additions & 42 deletions fixtures/tracking/script.js → fixtures/tracing/script.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,10 @@ function runAllTests() {
checkSchedulerAPI();
} finally {
try {
checkSchedulerTrackingAPI();
checkSchedulerTracingAPI();
} finally {
try {
checkSchedulerTrackingSubscriptionsAPI();
checkSchedulerTracingSubscriptionsAPI();
} finally {
checkEndToEndIntegration();
}
Expand All @@ -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;
Expand All @@ -73,79 +73,79 @@ 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 = [];
const onWorkStoppedCalls = [];
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),
onWorkStopped: (...args) => onWorkStoppedCalls.push(args),
};

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 ||
Expand All @@ -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) {
Expand All @@ -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,
Expand Down
13 changes: 5 additions & 8 deletions fixtures/unstable-async/suspense/src/components/App.js
Original file line number Diff line number Diff line change
@@ -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';
Expand Down Expand Up @@ -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,
})
Expand All @@ -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,
Expand Down
4 changes: 2 additions & 2 deletions fixtures/unstable-async/suspense/src/index.js
Original file line number Diff line number Diff line change
@@ -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,
Expand Down Expand Up @@ -65,7 +65,7 @@ class Debugger extends PureComponent {
}

handleReset = () => {
track('Clear cache', () => {
trace('Clear cache', () => {
cache.invalidate();
this.setState(state => ({
requests: {},
Expand Down
4 changes: 2 additions & 2 deletions packages/react-reconciler/src/ReactFiberCommitWork.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import type {ExpirationTime} from './ReactFiberExpirationTime';
import type {CapturedValue, CapturedError} from './ReactCapturedValue';

import {
enableSchedulerTracking,
enableSchedulerTracing,
enableProfilerTimer,
enableSuspense,
} from 'shared/ReactFeatureFlags';
Expand Down Expand Up @@ -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',
Expand Down
20 changes: 10 additions & 10 deletions packages/react-reconciler/src/ReactFiberRoot.js
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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<Interaction>,
Expand All @@ -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,
Expand All @@ -111,7 +111,7 @@ export function createFiberRoot(
const uninitializedFiber = createHostRootFiber(isAsync);

let root;
if (enableSchedulerTracking) {
if (enableSchedulerTracing) {
root = ({
current: uninitializedFiber,
containerInfo: containerInfo,
Expand Down Expand Up @@ -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);
}
Loading