Skip to content

Commit 97f7327

Browse files
committed
feat(Report): Update report feature and bump version
1 parent d6b14ad commit 97f7327

File tree

3 files changed

+46
-35
lines changed

3 files changed

+46
-35
lines changed

README.md

Lines changed: 34 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -168,19 +168,19 @@ scan({
168168
* Long task threshold in milliseconds, only show
169169
* when main thread is blocked for longer than this
170170
*/
171-
longTaskThreshold: 50;
171+
longTaskThreshold: 50,
172172

173173
/**
174-
* Clear aggregated fibers after this time in milliseconds
174+
* Report data to getReport()
175175
*/
176-
resetCountTimeout: 5000;
177-
178-
onCommitStart?: () => void;
179-
onRender?: (fiber, render) => void;
180-
onCommitFinish?: () => void;
181-
onPaintStart?: (outline) => void;
182-
onPaintFinish?: (outline) => void;
183-
})
176+
report: false,
177+
178+
onCommitStart: () => {},
179+
onRender: (fiber, render) => {},
180+
onCommitFinish: () => {},
181+
onPaintStart: (outline) => {},
182+
onPaintFinish: (outline) => {},
183+
});
184184
```
185185

186186
</details>
@@ -231,19 +231,19 @@ withScan(Component, {
231231
* Long task threshold in milliseconds, only show
232232
* when main thread is blocked for longer than this
233233
*/
234-
longTaskThreshold: 50;
234+
longTaskThreshold: 50,
235235

236236
/**
237-
* Clear aggregated fibers after this time in milliseconds
237+
* Report data to getReport()
238238
*/
239-
resetCountTimeout: 5000;
240-
241-
onCommitStart?: () => void;
242-
onRender?: (fiber, render) => void;
243-
onCommitFinish?: () => void;
244-
onPaintStart?: (outline) => void;
245-
onPaintFinish?: (outline) => void;
246-
})
239+
report: false,
240+
241+
onCommitStart: () => {},
242+
onRender: (fiber, render) => {},
243+
onCommitFinish: () => {},
244+
onPaintStart: (outline) => {},
245+
onPaintFinish: (outline) => {},
246+
});
247247
```
248248

249249
</details>
@@ -256,6 +256,8 @@ withScan(Component, {
256256
Get a aggregated report of all components and renders.
257257

258258
```jsx
259+
scan({ report: true });
260+
259261
const report = getReport();
260262

261263
for (const component in report) {
@@ -309,19 +311,19 @@ setOptions({
309311
* Long task threshold in milliseconds, only show
310312
* when main thread is blocked for longer than this
311313
*/
312-
longTaskThreshold: 50;
314+
longTaskThreshold: 50,
313315

314316
/**
315-
* Clear aggregated fibers after this time in milliseconds
317+
* Report data to getReport()
316318
*/
317-
resetCountTimeout: 5000;
318-
319-
onCommitStart?: () => void;
320-
onRender?: (fiber, render) => void;
321-
onCommitFinish?: () => void;
322-
onPaintStart?: (outline) => void;
323-
onPaintFinish?: (outline) => void;
324-
})
319+
report: false,
320+
321+
onCommitStart: () => {},
322+
onRender: (fiber, render) => {},
323+
onCommitFinish: () => {},
324+
onPaintStart: (outline) => {},
325+
onPaintFinish: (outline) => {},
326+
});
325327
```
326328

327329
</details>
@@ -417,7 +419,7 @@ We expect all contributors to abide by the terms of our [Code of Conduct](https:
417419
- [x] Give a general report of the app's performance
418420
- [ ] checkbox filtering API, leaderboard
419421
- [ ] Offscreen canvas on worker thread
420-
- [ ] heatmap decay (stacked renders will be more intense)
422+
- [x] heatmap decay (stacked renders will be more intense)
421423
- [ ] Investigate components (UI allowlist)
422424
- [ ] UI for turning on/off options
423425
- [ ] “PageSpeed insights” for React
@@ -426,8 +428,7 @@ We expect all contributors to abide by the terms of our [Code of Conduct](https:
426428
- [ ] Simple FPS counter
427429
- [ ] Drag and select areas of the screen to scan
428430
- [ ] Long task progress bar filter
429-
- [ ] Report should include all renders
430-
- [ ] ChatGPT / Claude video
431+
- [x] Report should include all renders
431432
- [ ] [Runtime version guarding](https://github.com/lahmatiy/react-render-tracker/blob/229ad0e9c28853615300724d5dc86c140f250f60/src/publisher/react-integration/utils/getInternalReactConstants.ts#L28)
432433
- [ ] React as peer dependency (lock version to range)
433434
- [ ] Add a funny mascot, like the ["Stop I'm Changing" dude](https://www.youtube.com/shorts/FwOZdX7bDKI?app=desktop)

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "react-scan",
3-
"version": "0.0.9",
3+
"version": "0.0.10",
44
"description": "Scan your React app for renders",
55
"keywords": [
66
"react",

src/core/index.ts

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,13 @@ interface Options {
7777
*/
7878
maxRenders?: number;
7979

80+
/**
81+
* Report data to getReport()
82+
*
83+
* @default false
84+
*/
85+
report?: boolean;
86+
8087
onCommitStart?: () => void;
8188
onRender?: (fiber: Fiber, render: Render) => void;
8289
onCommitFinish?: () => void;
@@ -98,6 +105,7 @@ interface Internals {
98105
{
99106
count: number;
100107
time: number;
108+
renders: Render[];
101109
}
102110
>;
103111
}
@@ -123,7 +131,7 @@ export const ReactScanInternals: Internals = {
123131
log: false,
124132
showToolbar: true,
125133
longTaskThreshold: 50,
126-
resetCountTimeout: 5000,
134+
report: false,
127135
},
128136
reportData: {},
129137
scheduledOutlines: [],
@@ -185,9 +193,11 @@ export const start = () => {
185193

186194
if (render.name) {
187195
const prev = ReactScanInternals.reportData[render.name];
196+
prev.renders.push(render);
188197
ReactScanInternals.reportData[render.name] = {
189198
count: (prev?.count ?? 0) + render.count,
190199
time: (prev?.time ?? 0) + render.time,
200+
renders: prev.renders,
191201
};
192202
}
193203

0 commit comments

Comments
 (0)