Skip to content

Instantly share code, notes, and snippets.

View ashsepra's full-sized avatar
🤠
Dev, Test, Deploy alone, Yolo like a cowboy

I PUTU ASHADI SEDANA PRATAMA ashsepra

🤠
Dev, Test, Deploy alone, Yolo like a cowboy
  • DANA Indonesia
  • Bali
View GitHub Profile
@JMPerez
JMPerez / performance-observer-ga.js
Created June 17, 2017 08:24
An example of Performance Observer reporting data to Google Analytics
const observer = new PerformanceObserver((list) => {
for (const entry of list.getEntries()) {
// `name` will be either 'first-paint' or 'first-contentful-paint'.
const metricName = entry.name;
const time = Math.round(entry.startTime + entry.duration);
ga('send', 'event', {
eventCategory: 'Performance Metrics',
eventAction: metricName,
eventValue: time,