GithubHelp home page GithubHelp logo

fusionjs / fusion-plugin-browser-performance-emitter Goto Github PK

View Code? Open in Web Editor NEW
0.0 6.0 13.0 852 KB

Migrated to https://github.com/fusionjs/fusionjs

License: MIT License

JavaScript 97.71% Shell 1.81% Dockerfile 0.49%
fusion fusionjs

fusion-plugin-browser-performance-emitter's Introduction

fusion-plugin-browser-performance-emitter

Build status

The plugin emits events of performance stats from the browser on initial page loads - with the following API when avaliable: (see https://developer.mozilla.org/en-US/docs/Web/API/Window/performance)

On the server-side, it calculate performance opinionate metrics from the stats emitted from the browser, then re-emits a new event. Refer to Events section for a list of events emitted.


Table of contents


Installation

yarn add fusion-plugin-browser-performance-emitter

Usage

To consume the calculated stats, listen to browser-performance-emitter:stats event on the server-side.

import {createPlugin} from 'fusion-core';
import {UniversalEventsToken} from 'fusion-plugin-universal-events';

export default createPlugin({
  deps: { emitter: UniversalEventsToken },
  provides: deps => {
    const emitter = deps.emitter;
    emitter.on('browser-performance-emitter:stats', e => {
      console.log(e); // log events to console
    });
  }
});

Setup

// src/main.js
import App from 'fusion-react';
import UniversalEvents, {UniversalEventsToken} from 'fusion-plugin-universal-events';
import BrowserPerformanceEmitter from 'fusion-plugin-browser-performance-emitter';

import PerformanceLogging from './performance-logging';

export default () => {
  const app = new App();
  // ...
  app.register(UniversalEventsToken, UniversalEvents);
  app.register(BrowserPerformanceEmitter);

  // (optional) a plugin to consume browser performance events
  app.register(PerformanceLogging);
  // ...
  return app;
}

API

Registration API

BrowserPerformanceEmitter
import BrowserPerformanceEmitter from 'fusion-plugin-browser-performance-emitter';

The browser performance emitter plugin. Typically, it doesn't need to be associated with a token.

Dependencies

UniversalEventsToken
import UniversalEvents, {UniversalEventsToken} from 'fusion-plugin-universal-events';

app.register(UniversalEventsToken, UniversalEvents);

An event emitter plugin to emit stats to, such as the one provided by fusion-plugin-universal-events.

Service API

This package has no public API methods. To consume performance events, add an event listener for the browser-performance-emitter:stats event on the server-side.


Events

Events emitted

browser-performance-emitter:stats
{
  calculatedStats: {
    // Metrics
  },
  timingValues: {
    // "Raw" timing values from `window.performance.timing`
  },
  resourceEntries: {
    // An array of serialized Resource Timing entries
  }
}
calculatedStats
name calculation
redirection_time fetchStart - navigationStart
time_to_first_byte responseStart - navigationStart
dom_content_loaded domContentLoadedEventEnd - fetchStart
full_page_load loadEventEnd - fetchStart
dns domainLookupEnd - domainLookupStart
tcp_connection_time connectEnd - connectStart
browser_request_time responseEnd - responseStart
browser_request_first_byte responseStart - requestStart
browser_request_response_time responseEnd - responseStart
dom_interactive_time domInteractive - responseEnd
total_resource_load_time loadEventStart - responseEnd
total_blocking_resource_load_time domContentLoadedEventStart - responseEnd
resources_avg_load_time One metric per resource type (e.g. CSS/JS/Image) that represents the mean time for resources of that type to be loaded. Example: {js: 154, image: 405}
timingValues

see https://www.w3.org/TR/navigation-timing/#sec-navigation-timing-interface for a complete list of properties

resourceEntries

see https://w3c.github.io/resource-timing/#sec-performanceresourcetiming for a complete list of properties

[
  {
    name: 'http://localhost:3000/_static/client-main.js',
    entryType: 'resource',
    // ...other resource timing properties
  },
  // more entries
]

fusion-plugin-browser-performance-emitter's People

Contributors

renovate[bot] avatar angus-c avatar kevingrandon avatar alexmsmithca avatar ganemone avatar lhorie avatar rtsao avatar dennisgl avatar nadiia avatar koulmomo avatar derekjuber avatar renovate-bot avatar

Watchers

 avatar James Cloos avatar Rajesh Segu avatar Derek Ju avatar  avatar  avatar

fusion-plugin-browser-performance-emitter's Issues

Action Required: Fix Renovate Configuration

There is an error with this repository's Renovate configuration that needs to be fixed. As a precaution, Renovate will stop PRs until it is resolved.

Error type: Preset name not found within published preset config (monorepo:angularmaterial). Note: this is a nested preset so please contact the preset author if you are unable to fix it yourself.

Add Token dependencies to readme

Problem/Rationale

Documentation regarding Fusion API is out of date given recent changes to leverage new Dependency Injection architecture.

Solution/Change/Deliverable

Update documentation

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.