@ledgerhq/live-common
Version:
Common ground for the Ledger Live apps
31 lines • 1.55 kB
TypeScript
import type { AppManifest } from "../types";
/**
* This signature is to be compatible with track method of `segment.js` file in LLM and LLD
* `track(event: string, properties: ?Object, mandatory: ?boolean)` in jsflow
* {@link @ledger-desktop/renderer/analytics/segment#track}
*/
type TrackExchange = (event: string, properties: Record<string, string> | null, mandatory: boolean | null) => void;
interface TrackEventPayload {
exchangeType: "SELL" | "FUND" | "SWAP";
provider: string;
}
/**
* Wrap call to underlying trackCall function.
* @param trackCall
* @returns a dictionary of event to trigger.
*/
export default function trackingWrapper(trackCall: TrackExchange): {
readonly startExchangeRequested: ({ provider, exchangeType }: TrackEventPayload) => void;
readonly startExchangeSuccess: ({ provider, exchangeType }: TrackEventPayload) => void;
readonly startExchangeFail: ({ provider, exchangeType }: TrackEventPayload) => void;
readonly startExchangeNoParams: (manifest: AppManifest) => void;
readonly completeExchangeRequested: ({ provider, exchangeType }: TrackEventPayload) => void;
readonly completeExchangeSuccess: ({ provider, exchangeType, currency, }: TrackEventPayload & {
currency: string;
}) => void;
readonly completeExchangeFail: ({ provider, exchangeType }: TrackEventPayload) => void;
readonly completeExchangeNoParams: (manifest: AppManifest) => void;
};
export type TrackingAPI = ReturnType<typeof trackingWrapper>;
export {};
//# sourceMappingURL=tracking.d.ts.map