Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

gatsby-plugin-web-vitals

Package Overview
Dependencies
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

gatsby-plugin-web-vitals - npm Package Compare versions

Comparing version 1.0.1 to 1.0.2

3

gatsby-browser.js

@@ -21,2 +21,3 @@ "use strict";

debug: false,
eventCategory: "Web Vitals",
metrics: ["FID", "TTFB", "LCP", "CLS", "FCP"]

@@ -30,3 +31,3 @@ }, pluginOptions);

if (options.includeInDevelopment || process.env.NODE_ENV === "production") {
(0, _webVitals.webVitals)(location.href, {
(0, _webVitals.webVitals)({
options: options

@@ -33,0 +34,0 @@ });

{
"name": "gatsby-plugin-web-vitals",
"version": "1.0.1",
"version": "1.0.2",
"description": "",

@@ -5,0 +5,0 @@ "main": "index.js",

@@ -24,10 +24,11 @@ # gatsby-plugin-web-vitals

trackingId: 'YOUR_GOOGLE_ANALYTICS_TRACKING_ID',
// Prints metrics in the console when true
debug: false,
// An array with metrics you want to track and send to analytics
// By default all metrics are sending
metrics: [`FID`, `TTFB`, `LCP`, `CLS`, `FCP`],
// Event Category (optional) { string }, default 'Web Vitals'
eventCategory: 'Performance',
// Include Web Vitals tracking in development
// Defaults to false meaning Vitals will only be tracked in production.
includeInDevelopment: false
includeInDevelopment: false,
// Prints metrics in the console when true
debug: false,
}

@@ -39,2 +40,2 @@ }

Plugin inspired by [`nuxt-vitals`](https://github.com/daliborgogic/nuxt-vitals).
Plugin based on [`nuxt-vitals`](https://github.com/daliborgogic/nuxt-vitals).

@@ -20,3 +20,3 @@ "use strict";

function onError(err) {
console.error("[web-vitals]", err); // eslint-disable-line no-console
console.error("[gatsby-plugin-web-vitals]", err); // eslint-disable-line no-console
}

@@ -41,3 +41,3 @@

function sendToAnalytics(fullPath, metric, options) {
function sendToAnalytics(metric, options) {
var name = metric.name,

@@ -58,3 +58,4 @@ delta = metric.delta,

ev: parseInt(delta),
dp: fullPath,
dl: location.origin,
dp: location.pathname,
ni: true

@@ -94,3 +95,3 @@ }; // Calculate the request time by subtracting from TTFB

function webVitals(_x, _x2) {
function webVitals(_x) {
return _webVitals.apply(this, arguments);

@@ -100,3 +101,3 @@ }

function _webVitals() {
_webVitals = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee(fullPath, _ref) {
_webVitals = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee(_ref) {
var options;

@@ -110,19 +111,17 @@ return _regenerator.default.wrap(function _callee$(_context) {

try {
if (options.trackingId) {
(0, _webVitals2.getFID)(function (metric) {
return sendToAnalytics(fullPath, metric, options);
});
(0, _webVitals2.getTTFB)(function (metric) {
return sendToAnalytics(fullPath, metric, options);
});
(0, _webVitals2.getLCP)(function (metric) {
return sendToAnalytics(fullPath, metric, options);
});
(0, _webVitals2.getCLS)(function (metric) {
return sendToAnalytics(fullPath, metric, options);
});
(0, _webVitals2.getFCP)(function (metric) {
return sendToAnalytics(fullPath, metric, options);
});
}
(0, _webVitals2.getFID)(function (metric) {
return sendToAnalytics(metric, options);
});
(0, _webVitals2.getTTFB)(function (metric) {
return sendToAnalytics(metric, options);
});
(0, _webVitals2.getLCP)(function (metric) {
return sendToAnalytics(metric, options);
});
(0, _webVitals2.getCLS)(function (metric) {
return sendToAnalytics(metric, options);
});
(0, _webVitals2.getFCP)(function (metric) {
return sendToAnalytics(metric, options);
});
} catch (err) {

@@ -129,0 +128,0 @@ onError(err);

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc