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

ember-user-performance-monitoring

v0.0.24

Published

Adds performance timing to your Ember application

Downloads

7

Readme

ember-user-performance-monitoring

Use this addon to add performance timing to your Ember application. It does not deal with sending data out of your application, but lets you set up event listeners on timing events, which you can use to integrate with a metric collecting tool of your choice.

One of it's features is it's use of PerformanceObserver and the ability to measure pre-application boot events by injecting the code into your apps HEAD (optionally. depending on what config settings you've added). This data is saved as window variables and then 'emitted' as events when you eventually call listen() on the service.

Compatibility

  • Ember.js v3.4 or above
  • Ember CLI v2.13 or above
  • Node.js v8 or above

Installation

ember install ember-user-performance-monitoring

Usage

Once installed, you'll need to add event listeners to the provided userPerformanceMonitoring service and then call .listen once all listeners are attached.

You can call this anywhere, but listen should be called once.

For example, adding it to the application routes init():

// app/routes/application.js
import { inject as service } from '@ember/service';
import Route from '@ember/routing/route';

export default Route.extend({
  userPerformanceMonitoring: service(),

  init() {
    this.initUserPerformance();
  },

  async initUserPerformance() {
    this.userPerformanceMonitoring.on('timingEvent', (eventName, eventDetails, additionalDetails) => {
      // console.log(eventName, eventDetails)
      // Other details:
      // const { currentURL } = additionalDetails;
      // const { load } = additionalDetails;
      // const { connection } = additionalDetails;
      // const { assetTimings } = additionalDetails;
    });
    this.userPerformanceMonitoring.listen();
  }
});

Timing Assets

You can time any assets that get loaded during the start of your app by using the following config:

ENV['ember-user-performance-monitoring'] = {
  includeAssetTimings: true,
  assetTimingOptions: {
    watchedAssets: {
      app_js: {
        matches: 'assets/app.*js$'
      },
      app_css: {
        matches: 'assets/app.*css$'
      },
      vendor_js: {
        matches: 'assets/vendor.*js$'
      },
      vendor_css: {
        matches: 'assets/vendor.*css$'
      }
    }
  }

This will match any resource names against the provided regex and provide timings using the name (eg. app_js) when the paint event fires as additional details (so you can record asset timing in conjunction with DCLor TTI).

Timing Transitions

This hooks into the runloop to time transitions in your app, and can also time rendering (optionally, depending on the inclusion of a component at the end of your template).

ENV['ember-user-performance-monitoring'] = {
  watchTransitions: true,
  enablePerformanceMeasures: true // not necessary but helpful for debugging
}

Then, all transitions will automatically be caught via the router microlib. Transition time includes normalizeResponse and setupController.

If you wish to capture render time for the page as well, putting {{render-performance-monitor}} at the bottom of target routes uses didRender and then puts a timing at the end of the destroy queue, to offer lightweight approximate render times for the initial render of the page.

Then you can listen on timingEvent on the performance service.

// app/routes/application.js
import { inject as service } from '@ember/service';
import Route from '@ember/routing/route';

export default Route.extend({
  userPerformanceMonitoring: service(),

  init() {
    this.initUserPerformance();
  },

  async initUserPerformance() {
    this.userPerformanceMonitoring.on('timingEvent', (eventName, eventDetails, additionalDetails) => {
      /*
      if (eventName === "transitionWithoutRender") {
        console.log(eventDetails);
      }

      if (eventName === "transitionRender") {
        console.log(eventDetails);
      }
      */
    });
    this.userPerformanceMonitoring.listen();
  }
});

Result (for transitionWithRender):

{
  from: "homepage.index"
  to: "posts.list"
  render: 316
  renderCount: 2
  renderToCount: 5
  transition: 445
  transitionCount: 2
  transitionNumber: 10
  transitionToCount: 5
}

Breakdown:

  • from and to describe the transition
  • render and transition are the times for those stages, in milliseconds
  • renderCount and transitionCount are the count of times this specific transition has been hit. (useful for pre-fetch or reuse between specific routes).
  • renderToCount and transitionToCount are the count of times this page has been transitioned to (useful for generic background reload performance checks)

Metrics

The following lists the load metrics measured by this addon:

  • FP (first-paint)
  • FCP (first-contentful-paint)
  • FMP (first meaningful paint) - Experimental, but this is measured using a wrapper component around the hero component for a page. Since it's manually defined, it should be more accurate then the version that uses largest element, etc.
  • TTI (Time to first consistently interactive) - experimental, provided by google chrome labs

Additional data collected that can be sent back:

  • Visibility / Hidden duration (for when a user navigates away during load)
  • Connection (from navigator.connection API if available)
  • Asset Timings (uses resource timing api, records transfer and timing, as well as whether local cache was hit)

Contributing

See the Contributing guide for details.

License

This project is licensed under the MIT License.