fix(analytics): change method return types from void to Promise<void> (#2409)

Co-authored-by: Patryk Kuniczak <p.kuniczak@gmail.com>
This commit is contained in:
Muhammed Mustafa AKŞAM
2026-06-30 01:13:08 +03:00
committed by GitHub
parent b235c8591e
commit eb2e151520
2 changed files with 9 additions and 5 deletions
@@ -25,7 +25,7 @@ type AnalyticsMethod =
type MethodForwarder = <K extends keyof Analytics>(
fn: K,
) => (...args: Parameters<Analytics[K]>) => void;
) => (...args: Parameters<Analytics[K]>) => Promise<void>;
const ANALYTICS_PORT = '@wxt-dev/analytics';
@@ -242,6 +242,7 @@ function createFrontendAnalytics(): Analytics {
(fn) =>
(...args) => {
port.postMessage({ fn, args: [...args, getFrontendMetadata()] });
return Promise.resolve();
};
const analytics: Analytics = {
@@ -1,20 +1,23 @@
export interface Analytics {
/** Report a page change. */
page: (url: string) => void;
page: (url: string) => Promise<void>;
/** Report a custom event. */
track: (
eventName: string,
eventProperties?: Record<string, string | undefined>,
) => void;
) => Promise<void>;
/** Save information about the user. */
identify: (userId: string, userProperties?: Record<string, string>) => void;
identify: (
userId: string,
userProperties?: Record<string, string>,
) => Promise<void>;
/**
* Automatically setup and track user interactions, returning a function to
* remove any listeners that were setup.
*/
autoTrack: (root: Document | ShadowRoot | Element) => () => void;
/** Calls `config.enabled.setValue`. */
setEnabled: (enabled: boolean) => void;
setEnabled: (enabled: boolean) => Promise<void>;
}
export interface AnalyticsConfig {