import { MetricEvents, PluginTable } from "../Metrics/types.cjs"; import { Metric } from "../Metrics/Metric.cjs"; import { IExperience } from "./types.cjs"; //#region src/Experiences/ExperienceMetric.d.ts /** * Experience Metric * * A composition tool for constructing metrics from one or more * child metrics * * ```typescript * const metric1 = new Metric("Metric 1"); * const metric2 = new Metric("Metric 2"); * const metric3 = new Metric("Metric 3"); * * const experience = new ExperienceMetric({ * name: "My Experience", * metrics: [metric1, metric2, metric3], * plugins: { ...plugins } * }); * * metric1.start(); // The earliest start time becomes the Experience's start time * metric2.start(); * metric3.start(); * * metric1.stop(); * metric2.stop(); * metric3.stop(); // The latest stop time becomes the Experience's stop time * * experience.on("start" | "stop" | "reset", experience => { * // Adds an event listener to your Experience's events * await fetch({ * url: "/analytics-service", * data: JSON.stringify(experience) * }); * }); * ``` */ declare class ExperienceMetric[] = Metric[], P extends PluginTable = PluginTable> extends Metric { readonly metrics: M; private readonly IDs; private readonly completedMetrics; private reference; constructor({ name, metrics, plugins }: IExperience); /** * Reset * * Resets the Experience's and its sub-metric's `startTime`, `stopTime`, * `duration`, and `status` back to their original state. Emits the * Experiences's `reset` event */ reset(): void; /** * Index Metrics * * Assigns a unique identifier to each child Metric and hashes * them on the instance */ private indexMetrics; /** * Listen For Stops * * Registers a `stop` listener on each child metric and invokes * the `Experience's` `stop` event once all child metrics complete. * The `Experience` will assume the greatest stop time out of each * the child metrics */ private listenForStops; /** * Listen For Starts * * Registers a `start` listener on each child metric and invokes * the `Experience's` `start` event as soon as the first child * `Metric` begins. The `Experience` will assume the lowest * start time out of each of the child metrics */ private listenForStarts; } //#endregion export { ExperienceMetric };