Skip to content

analyticsTracker as promise #268

@peterpeterparker

Description

@peterpeterparker

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});
};

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions