apollo-link-firebase-performance-monitoring
TypeScript icon, indicating that this package has built-in type declarations

1.0.9 • Public • Published

apollo-link-firebase-performance-monitoring

Firebase Performance Monitoring for Apollo GraphQL Client using Apollo Link

version downloads MIT License Watch on GitHub Star on GitHub

Installing / Getting Started

npm install apollo-link-firebase-performance-monitoring

Prerequisites

  • Apollo Link: ^1.2.14
  • Firebase: ^6.6.1 || ^7.2.1 || ^7.15.5
// Firebase App (the core Firebase SDK) is always required and must be listed first
import * as firebase from "firebase/app";

// Add the Performance Monitoring library
import "firebase/performance";

// Add import for Apollo Link
import { from } from 'apollo-link';

// Add the import for this library
import createFPMLink from 'apollo-link-firebase-performance-monitoring';

// TODO: Replace the following with your app's Firebase project configuration
const firebaseConfig = {
  // ...
};

// Initialize Firebase
firebase.initializeApp(firebaseConfig);

// Initialize Performance Monitoring and get a reference to the service
const perf = firebase.performance();

// ...
ApolloLink.from([
  createFPMLink(() => perf, true /* debug: true/false for logging to console */),
  // ...
]);

Do notice that you have to give a function that returns Firebase performance instance or undefined. Thats because the object is not available when using SSR. If you use debug logging you may also want to only activate it when in the browser environment so that you don't fill up the logs on your server.

License

This project is licensed under the MIT License - see the license file for details.

Package Sidebar

Install

npm i apollo-link-firebase-performance-monitoring

Weekly Downloads

22

Version

1.0.9

License

MIT

Unpacked Size

15 kB

Total Files

12

Last publish

Collaborators

  • gerrel