From e7ab19a18b8d57b633ff3ddace085c197fa89d82 Mon Sep 17 00:00:00 2001 From: Leonardo Zizzamia Date: Mon, 14 Oct 2019 17:30:48 -0700 Subject: [PATCH] fix: check if window.performance.mark is supported when used .start() or .end() --- CHANGELOG.md | 12 ++++++++---- README-zh_CN.md | 2 +- README.md | 2 +- docs/package.json | 2 +- package.json | 2 +- src/perfume.ts | 6 +++--- 6 files changed, 15 insertions(+), 11 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 14830c4..6a9a149 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,9 @@ # Changelog +## 3.0.1 (2019-10-14) + +* **fix:** check if `window.performance.mark` is supported when used `.start()` or `.end()` + ## 3.0.0 (2019-10-14) * **feat:** added Navigation Timing [#83](https://github.com/Zizzamia/perfume.js/issues/83) @@ -12,8 +16,8 @@ ### Breaking Changes * **refactor:** removed default Google Analytics support, instead analyticsTracker will be the default method to communicate with the backend. -* **refactor:** log, sendTiming and analyticsTrackerg gets one solo options object instead of the original arguments -* **refactor:** Dropped support for EmulatedPerformance +* **refactor:** `log`, `sendTiming` and `analyticsTracker` gets one solo options object instead of the original arguments +* **refactor:** Dropped support for **EmulatedPerformance** * **feat:** Discard queued tasks if running them as microtasks isn't supported [#77](https://github.com/Zizzamia/perfume.js/pull/77) ## 3.0.0-rc.11 (2019-10-13) @@ -26,11 +30,11 @@ ## 3.0.0-rc.10 (2019-9-29) -* **feat:** added more flexibility for log, sendTiming and analyticsTracker arguments [#70](https://github.com/Zizzamia/perfume.js/issues/70) +* **feat:** added more flexibility for log, `sendTiming` and `analyticsTracker` arguments [#70](https://github.com/Zizzamia/perfume.js/issues/70) ### Breaking Changes -* **refactor:** log, sendTiming and analyticsTrackerg gets one solo options object instead of the original arguments +* **refactor:** `log`, `sendTiming` and `analyticsTracker` gets one solo options object instead of the original arguments ## 3.0.0-rc.5 (2019-9-26) diff --git a/README-zh_CN.md b/README-zh_CN.md index 3ae3618..15dda03 100644 --- a/README-zh_CN.md +++ b/README-zh_CN.md @@ -2,7 +2,7 @@ -# [Perfume.js v3.0.0](http://perfumejs.com) +# [Perfume.js v3.0.1](http://perfumejs.com) [![NPM version](https://badge.fury.io/js/perfume.js.svg)](https://www.npmjs.org/package/perfume.js) [![Build Status](https://travis-ci.org/Zizzamia/perfume.js.svg?branch=master)](https://travis-ci.org/Zizzamia/perfume.js) [![NPM Downloads](http://img.shields.io/npm/dm/perfume.js.svg)](https://www.npmjs.org/package/perfume.js) [![Test Coverage](https://api.codeclimate.com/v1/badges/f813d2f45b274d93b8c5/test_coverage)](https://codeclimate.com/github/Zizzamia/perfume.js/test_coverage) [![JS gzip size](https://img.badgesize.io/https://unpkg.com/perfume.js?compression=gzip&label=JS+gzip+size)](https://unpkg.com/perfume.js) diff --git a/README.md b/README.md index 7368d85..c2cf1c1 100644 --- a/README.md +++ b/README.md @@ -2,7 +2,7 @@ -# [Perfume.js v3.0.0](http://perfumejs.com) +# [Perfume.js v3.0.1](http://perfumejs.com) [![NPM version](https://badge.fury.io/js/perfume.js.svg)](https://www.npmjs.org/package/perfume.js) [![Build Status](https://travis-ci.org/Zizzamia/perfume.js.svg?branch=master)](https://travis-ci.org/Zizzamia/perfume.js) [![NPM Downloads](http://img.shields.io/npm/dm/perfume.js.svg)](https://www.npmjs.org/package/perfume.js) [![Test Coverage](https://api.codeclimate.com/v1/badges/f813d2f45b274d93b8c5/test_coverage)](https://codeclimate.com/github/Zizzamia/perfume.js/test_coverage) [![JS gzip size](https://img.badgesize.io/https://unpkg.com/perfume.js?compression=gzip&label=JS+gzip+size)](https://unpkg.com/perfume.js) diff --git a/docs/package.json b/docs/package.json index af23fdd..9bae3c3 100644 --- a/docs/package.json +++ b/docs/package.json @@ -1,6 +1,6 @@ { "name": "docs", - "version": "3.0.0", + "version": "3.0.1", "scripts": { "ng": "ng", "start": "ng serve", diff --git a/package.json b/package.json index 0baf858..c010845 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "perfume.js", - "version": "3.0.0", + "version": "3.0.1", "description": "JavaScript library that measures First (Contentful) Paint (FP/FCP) and First Input Delay (FID). Annotates components’ performance for Vanilla and Angular applications, into the DevTools timeline. Reports all the results to your favorite tracking tool.", "keywords": [ "performance-metrics", diff --git a/src/perfume.ts b/src/perfume.ts index 857d1fe..ed8e7be 100644 --- a/src/perfume.ts +++ b/src/perfume.ts @@ -1,5 +1,5 @@ /*! - * Perfume.js v3.0.0 (http://zizzamia.github.io/perfume) + * Perfume.js v3.0.1 (http://zizzamia.github.io/perfume) * Copyright 2018 The Perfume Authors (https://github.com/Zizzamia/perfume.js/graphs/contributors) * Licensed under MIT (https://github.com/Zizzamia/perfume.js/blob/master/LICENSE) * @license @@ -173,7 +173,7 @@ export default class Perfume { * Start performance measurement */ start(metricName: string): void { - if (!this.checkMetricName(metricName)) { + if (!this.checkMetricName(metricName) || !Performance.supported()) { return; } if (this.metrics[metricName]) { @@ -194,7 +194,7 @@ export default class Perfume { * End performance measurement */ end(metricName: string): void | number { - if (!this.checkMetricName(metricName)) { + if (!this.checkMetricName(metricName) || !Performance.supported()) { return; } const metric = this.metrics[metricName];