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

analyticsTracker as promise #268

Open
peterpeterparker opened this issue Aug 16, 2024 · 0 comments
Open

analyticsTracker as promise #268

peterpeterparker opened this issue Aug 16, 2024 · 0 comments

Comments

@peterpeterparker
Copy link

peterpeterparker commented Aug 16, 2024

Motivation

I noticed that the analyticsTracker option of initPerfume is expected to be a void callback. It would be useful if it could accept a promise, WDYT?

Example

In my use case, I'm collecting data in IndexedDB using idb-keyval, which is a fully promisified library. It would be helpful if I could use await within the callback.

import {set} from "idb-keyval";
import {initPerfume} from "perfume.js";
 
const startMonitoring = () => {
  const analyticsTracker = async ({
    metricName,
    data
  }: IAnalyticsTrackerOptions): Promise<void> => {
      await set(crypto.randomUUID(), {metricName, data});
  };

  initPerfume({analyticsTracker});
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant