@atlaskit/editor-plugin-collab-edit
Version:
Collab Edit plugin for @atlaskit/editor-core
49 lines (48 loc) • 2.06 kB
TypeScript
import type { ExtractInjectionAPI } from '@atlaskit/editor-common/types';
import type { Step } from '@atlaskit/editor-prosemirror/transform';
import type { CollabEditPlugin } from '../collabEditPluginType';
type StepSessionMetrics = {
maxStepSize: number;
numberOfSteps: number;
stepSizeSumForP90: number[];
totalStepSize: number;
};
/**
* Gets the current step session metrics for a given session ID
* If the session ID does not exist, it initializes a new metrics object.
* It calculates the total size of the steps, the number of steps,
* the maximum step size, and the sum of step sizes for P90 calculation.
*
* @param metrics - The existing metrics object from local storage.
* @param sessionId - The session ID for which to get the metrics.
* @param steps - The steps to calculate the metrics from.
* @returns The updated step session metrics for the given session ID.
*/
export declare const getNcsSessionStepMetrics: (metrics: {
[sessionId: string]: StepSessionMetrics;
}, sessionId: string, steps: Step[]) => StepSessionMetrics;
/**
* Gets the current active sessions from local storage
* If the session ID does not exist, it initializes a new active session.
*
* This is used in the ncsStepMetricsPlugin to determine if the session is still active
* before sending the ncs steps analytics event.
*
* @param sessionId - The session ID to check or update in local storage.
* @returns void
*/
export declare const updateNcsActiveSessions: (sessionId: string) => void;
type UpdateNcsSessionStepMetricProps = {
api: ExtractInjectionAPI<CollabEditPlugin> | undefined;
steps: Step[];
};
/**
* Updates the step session metrics in local storage for a given session ID.
* It calculates the metrics based on the provided steps and updates the storage.
*
* @param api - The API to access the collab edit plugin.
* @param steps - The steps to calculate the metrics from.
* @return void
*/
export declare const updateNcsSessionStepMetrics: ({ api, steps, }: UpdateNcsSessionStepMetricProps) => void;
export {};