npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@microsoft/mezzurite-react

v1.0.8

Published

Library for capturing SPA timings within React.

Downloads

37

Readme

npm version

Mezzurite-React

Requirements:

For component tracking:

    "@microsoft/mezzurite-core": "^1.0.1",
    "intersection-observer": "^0.5.0", // IE support
    "react": "^16.4.2"

for full app tracking:

    "@microsoft/mezzurite-core": "^1.0.1",
    "intersection-observer": "^0.5.0", // IE support
    "react": "^16.4.2",
    "react-dom": "^16.4.2",
    "react-router": "^4.3.1"

Onboarding

Installation

Install mezzurite from npm:

  npm install "@microsoft/mezzurite-react"

Full Application Implementation (ALT, VLT, Components)

** If you do not have access to the application's routing service, skip to next section on "Tracking Components" **

  1. Inside main App module, add following import statement:
import {withMezzuriteRouter} from '@microsoft/mezzurite-react';
  1. Wrap your exported component in the withMezzuriteRouter higher order component. This will add Mezzurite functionality to your app router:
// old export
export default App;

// new export
export default withMezzuriteRouter(App);

If using Redux, you will need to use the compose component:

// add to imports
import {compose} from 'redux';

...

// old Redux export
export default connect(mapStateToProps, mapDispatchToProps)(App);

// new Redux export using Mezzurite
export default compose(connect(mapStateToProps, mapDispatchToProps), withMezzuriteRouter)(App);

Tracking Components(CLT and VLT)

  1. In the component you want to track, add an import statement for mezzurite-react:
import {withMezzurite} from '@microsoft/mezzurite-react';
  1. Wrap your exported component in the withMezzurite higher order component. This will add Mezzurite functionality to this specific component:
// old export
export default ExampleComponent;

// new export
export default withMezzurite(ExampleComponent);

Unit Testing

For Mezzurite to work correctly in Jest/Enzyme test environments (such as create-react-app), jsdom use is required to gain access to the window object:

const jsdom = require("jsdom");
const { JSDOM } = jsdom;
const { window } = new JSDOM(`...`);

// then run code that would utilize Mezzurite

FAQ

1. What is a Higher-Order Component (HOC)?

A higher-order component (HOC) is an advanced technique in React for reusing component logic. They are functions that take in a component and return a modified component. We use HOC's within the Mezzurite React library to add tracking functionality to user components.

2. What is Component Tracking vs Full App Tracking?

Component tracking is an easy way to calaulate the Component Load Time(CLT) for a specific component irrespective of the performance of other components on the site and site itself. While, full app tracking is used to track initial Application Load Time(ALT). And, also for each route change in the app, it also calculates the Viewport Load Time(VLT) and Component Load Time(CLT) for all the tracked components within that viewport.

3. How do I check if my timings are logging correctly?

If running from localhost, a console.log should fire with the current timings. An alternate place to look is window.mezzurite.measures, which is where each component timing, as well as ALT and VLT, is saved.