
Security News
Security Community Slams MIT-linked Report Claiming AI Powers 80% of Ransomware
Experts push back on new claims about AI-driven ransomware, warning that hype and sponsored research are distorting how the threat is understood.
@alithanar/react-automation-profiler
Advanced tools
Automated React profiling and data visualization using React's Profiler API, Puppeteer, and D3.
  
  
Analyze your React app's renders with automated user flows that generate comparison charts. Run flows before and after major changes to see how it effects components and renders, or run them on every build.
rap optionsTo try react-automation-profiler out:
git clone git@github.com:AlithAnar/react-automation-profiler.git
This will install all dependencies and start the example app.
npm run example
rapIn a separate terminal:
npm run rap
This will start react-automation-profiler, which will run the automation flows inside example/react.automation.yaml and then generate render charts. These charts should automatically open in your browser once automation is complete.
npm i -D react-automation-profiler
or
yarn add react-automation-profiler --dev
To profile specific component trees, import the AutomationProfiler component from react-automation-profiler. AutomationProfiler can wrap any component that you want to profile, similarly to how React's Profiler API works. It needs only one prop: id: string. Try to make the id short. This will help with readability on charts that display many renders.
You can wrap your whole application in your index file:
import React from 'react';
import { render } from 'react-dom';
import App from 'components/App';
import { AutomationProfiler } from 'react-automation-profiler';
render(
  <AutomationProfiler id="p-app">
    <App />
  </AutomationProfiler>,
  document.getElementById('root')
);
Or, you can wrap deeply nested components:
import React from 'react';
export default () => (
  <AutomationProfiler id="p-card">
    <DeeplyNestedComponent />
  </AutomationProfiler>
);
You can wrap as many components and at as many levels as you want. react-automation-profiler will track all of these components' renders and auto-generate charts based on render metrics of these components during specific user flows.
You can define your automation flows in a YAML file at the root of your repo using the name react.automation.yml (or .yaml extension).
Here's an example react.automation.yml file:
Toggle PlayArea Card Active:
  - click div.playArea div.card
  - click div.playArea
Click Each PlayArea Card:
  - click div.playArea div.card:nth-of-type(1)
  - click div.playArea div.card:nth-of-type(2)
  - click div.playArea div.card:nth-of-type(3)
  - click div.playArea div.card:nth-of-type(4)
  - click div.playArea div.card:nth-of-type(5)
  - click div.playArea
Draw Card:
  - click div.stackedCard
  - click div.playArea
In the file above, there are three keys that each represent a different automation flow:
Toggle PlayArea Card ActiveClick Each PlayArea CardDraw CardIn the example above, the first flow Toggle PlayArea Card Active has two actions: clicking the CSS selector div.playArea div.card, and then clicking the CSS selector div.playArea. This represents what a user would do when toggling a PlayArea Card's active state.
There are currently three action types that can be used in react.automation.yaml:
clickfocushoverNote that # marks the beginning of a comment in YAML, so the HTML tag should always prefix an isolated id:
- click button#cta
Note: The automation flows will run one after another in the order they are listed in the automation file. No subsequent page loads happen between each flow.
There are a few prerequisites before you can start generating charts:
AutomationProfiler must be wrapping at least one of your components.http://localhost:8000/index.html).After that, you can then call the rap command in a separate terminal to start generating charts:
npx rap --page=http://localhost:8000/index.html --watch
rap options| option | type | required | default | description | 
|---|---|---|---|---|
| page | string | yes | the page that automation will be run on. | |
| averageOf | number | no | 1 | runs each automation flow n number of times and generates averaged metrics for the flow. | 
| changeInterval | number | no | 1 | rerun after n number of changes. Note that there is a cooldown of 10 seconds before another change is counted. This flag effectively does nothing without use of the watchflag. | 
| includeMount | boolean | no | false | includes the initial mountphase renders that happen before any automation flows are initialized. | 
| port | number | no | 1235 | the port that charts will be displayed on. | 
| watch | boolean or string | no | false | rerun rapon any changes to the given folder. If set as a boolean (ex:--watch), rerun on any changes inside the repo. If set as a string (ex:--watch=src), rerun on any changes in the given folder. This will save charts from the previous run(s) and generate new charts based on the latest changes, resulting in a new version for each flow. Note thatwatchruns on a 10-second delay to allow the application's local development toolchain to finish building before re-running the automation against the new build. | 
  import { Automation } from 'react-automation-profiler/lib/api/index.js';
  async function myAppProfilingFn() {
    const results = await Automation.run({
      averageOf: 3,
      includeMount: false,
      page: 'http://my-app-host.com',
    });
    const postProcessedResults = someParsingFunction(results)
    externalService.send(postProcessedResults)
  }
If you would like to see the working example, please run:
  npm run example
  # in the second terminal
  node ./example/src/api.mjs
You still need to have react.automation.yaml defined in the directory where the script is executed.
Visit pptr.dev for the Puppeteer API.
FAQs
Automated React profiling and data visualization using React's Profiler API, Puppeteer, and D3.
We found that @alithanar/react-automation-profiler demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Security News
Experts push back on new claims about AI-driven ransomware, warning that hype and sponsored research are distorting how the threat is understood.

Security News
Ruby's creator Matz assumes control of RubyGems and Bundler repositories while former maintainers agree to step back and transfer all rights to end the dispute.

Research
/Security News
Socket researchers found 10 typosquatted npm packages that auto-run on install, show fake CAPTCHAs, fingerprint by IP, and deploy a credential stealer.