Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Clear performance marker on cancel/error #71

Closed
johnwcallahan opened this issue Jun 10, 2019 · 2 comments
Closed

Clear performance marker on cancel/error #71

johnwcallahan opened this issue Jun 10, 2019 · 2 comments
Assignees
Labels
Milestone

Comments

@johnwcallahan
Copy link

Thanks for the great library!

I'm looking for a way to clear (i.e. cancel) a performance marker. My use case is that I don't want to log a timing event if what I'm measuring is interrupted (or fails). Here's a simple example using React:

class MyComponent extends React.Component {
  constructor() {
    perfume.start('MeasureMyComponent');
  }

  componentDidMount() {
    loadData().then(() => {
      perfume.end('MeasureMyComponent');
    }).catch(err => {
      // ... clear the marker if there's an error
    });
  }

  componentWillUnmount() {
    // ... clear the marker if the component unmounts before loadData() is done
  }
}

Is there a way to do this with perfume.js? I haven't been able to find it in the docs or source code, but maybe I'm missing something.

@Zizzamia
Copy link
Owner

Thank you for the issue.
That's something I didn't think about it before, but it seems I should create a perfume.clear('MeasureMyComponent') based on the official Performance API.
https://developer.mozilla.org/en-US/docs/Web/API/Performance/clearMarks

@Zizzamia Zizzamia self-assigned this Jun 10, 2019
@Zizzamia Zizzamia added the feat label Jun 10, 2019
@Zizzamia Zizzamia added this to the v2.1.0 milestone Jun 10, 2019
@Zizzamia Zizzamia modified the milestones: v2.1.0, v3.0.0 Sep 9, 2019
@Zizzamia Zizzamia modified the milestones: v3.0.0, v3.1.0 Sep 26, 2019
@Zizzamia Zizzamia modified the milestones: v3.1.0, v3.2.0 Nov 12, 2019
@Zizzamia Zizzamia modified the milestones: v4.6.0, v4.4.0 Nov 28, 2019
Zizzamia added a commit that referenced this issue Dec 1, 2019
@Zizzamia
Copy link
Owner

Zizzamia commented Dec 1, 2019

This feature will be available with v4.4.0.
Really appreciated the feedback 🔥🔥🔥

@Zizzamia Zizzamia closed this as completed Dec 1, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants