Skip to content

Commit ff997f3

Browse files
committed
Color and badge non-primary environments
1 parent a094788 commit ff997f3

File tree

2 files changed

+26
-5
lines changed

2 files changed

+26
-5
lines changed

packages/react-client/src/ReactFlightClient.js

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -655,7 +655,13 @@ export function reportGlobalError(response: Response, error: Error): void {
655655
});
656656
if (enableProfilerTimer && enableComponentPerformanceTrack) {
657657
markAllTracksInOrder();
658-
flushComponentPerformance(getChunk(response, 0), 0, -Infinity, -Infinity);
658+
flushComponentPerformance(
659+
response,
660+
getChunk(response, 0),
661+
0,
662+
-Infinity,
663+
-Infinity,
664+
);
659665
}
660666
}
661667

@@ -2761,6 +2767,7 @@ function resolveTypedArray(
27612767
}
27622768

27632769
function flushComponentPerformance(
2770+
response: Response,
27642771
root: SomeChunk<any>,
27652772
trackIdx: number, // Next available track
27662773
trackTime: number, // The time after which it is available,
@@ -2852,6 +2859,7 @@ function flushComponentPerformance(
28522859
let childTrackTime = trackTime;
28532860
for (let i = 0; i < children.length; i++) {
28542861
const childResult = flushComponentPerformance(
2862+
response,
28552863
children[i],
28562864
childTrackIdx,
28572865
childTrackTime,
@@ -2890,6 +2898,7 @@ function flushComponentPerformance(
28902898
startTime,
28912899
endTime,
28922900
childrenEndTime,
2901+
response._rootEnvironmentName,
28932902
);
28942903
// Track the root most component of the result for deduping logging.
28952904
result.component = componentInfo;

packages/react-client/src/ReactFlightPerformanceTrack.js

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -72,22 +72,34 @@ 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+
performance.measure(
100+
isPrimaryEnv ? name : name + ' [' + env + ']',
101+
reusableComponentOptions,
102+
);
91103
}
92104
}
93105

0 commit comments

Comments
 (0)