Skip to content

Commit 8e7e6da

Browse files
committed
Color and badge non-primary environments
1 parent 84e4b52 commit 8e7e6da

File tree

2 files changed

+27
-6
lines changed

2 files changed

+27
-6
lines changed

packages/react-client/src/ReactFlightClient.js

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -649,7 +649,13 @@ export function reportGlobalError(response: Response, error: Error): void {
649649
});
650650
if (enableProfilerTimer && enableComponentPerformanceTrack) {
651651
markAllTracksInOrder();
652-
flushComponentPerformance(getChunk(response, 0), 0, -Infinity, -Infinity);
652+
flushComponentPerformance(
653+
response,
654+
getChunk(response, 0),
655+
0,
656+
-Infinity,
657+
-Infinity,
658+
);
653659
}
654660
}
655661

@@ -2748,6 +2754,7 @@ function resolveTypedArray(
27482754
}
27492755

27502756
function flushComponentPerformance(
2757+
response: Response,
27512758
root: SomeChunk<any>,
27522759
trackIdx: number, // Next available track
27532760
trackTime: number, // The time after which it is available,
@@ -2838,6 +2845,7 @@ function flushComponentPerformance(
28382845
let childTrackTime = trackTime;
28392846
for (let i = 0; i < children.length; i++) {
28402847
const childResult = flushComponentPerformance(
2848+
response,
28412849
children[i],
28422850
childTrackIdx,
28432851
childTrackTime,
@@ -2876,6 +2884,7 @@ function flushComponentPerformance(
28762884
startTime,
28772885
endTime,
28782886
childrenEndTime,
2887+
response._rootEnvironmentName,
28792888
);
28802889
// Track the root most component of the result for deduping logging.
28812890
result.component = componentInfo;

packages/react-client/src/ReactFlightPerformanceTrack.js

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -72,22 +72,33 @@ export function logComponentRender(
7272
startTime: number,
7373
endTime: number,
7474
childrenEndTime: number,
75+
rootEnv: string,
7576
): void {
7677
if (supportsUserTiming && childrenEndTime >= 0 && trackIdx < 10) {
78+
const env = componentInfo.env;
7779
const name = componentInfo.name;
80+
const isPrimaryEnv = env === rootEnv;
7881
const selfTime = endTime - startTime;
7982
reusableComponentDevToolDetails.color =
8083
selfTime < 0.5
81-
? 'primary-light'
84+
? isPrimaryEnv
85+
? 'primary-light'
86+
: 'secondary-light'
8287
: selfTime < 50
83-
? 'primary'
88+
? isPrimaryEnv
89+
? 'primary'
90+
: 'secondary'
8491
: selfTime < 500
85-
? 'primary-dark'
92+
? isPrimaryEnv
93+
? 'primary-dark'
94+
: 'secondary-dark'
8695
: 'error';
8796
reusableComponentDevToolDetails.track = trackNames[trackIdx];
8897
reusableComponentOptions.start = startTime < 0 ? 0 : startTime;
8998
reusableComponentOptions.end = childrenEndTime;
90-
performance.measure(name, reusableComponentOptions);
99+
const entryName =
100+
isPrimaryEnv || env === undefined ? name : name + ' [' + env + ']';
101+
performance.measure(entryName, reusableComponentOptions);
91102
}
92103
}
93104

@@ -103,6 +114,7 @@ export function logDedupedComponentRender(
103114
reusableComponentDevToolDetails.track = trackNames[trackIdx];
104115
reusableComponentOptions.start = startTime < 0 ? 0 : startTime;
105116
reusableComponentOptions.end = endTime;
106-
performance.measure(name + ' [deduped]', reusableComponentOptions);
117+
const entryName = name + ' [deduped]';
118+
performance.measure(entryName, reusableComponentOptions);
107119
}
108120
}

0 commit comments

Comments
 (0)