@metamask/snaps-rpc-methods
Version:
MetaMask Snaps JSON-RPC method implementations
65 lines • 2.94 kB
text/typescript
import type { JsonRpcEngineEndCallback } from "@metamask/json-rpc-engine";
import type { Messenger } from "@metamask/messenger";
import type { TrackEventParams, TrackEventResult } from "@metamask/snaps-sdk";
import type { InferMatching } from "@metamask/snaps-utils";
import type { Json, PendingJsonRpcResponse } from "@metamask/utils";
import type { JsonRpcRequestWithOrigin, SnapControllerGetSnapAction } from "../types.mjs";
import type { MethodHooksObject } from "../utils.mjs";
export type TrackEventMethodHooks = {
/**
* Track an event.
*
* @param event - The event object containing event details and properties.
*/
trackEvent: (event: TrackEventObject) => void;
};
export type TrackEventMethodActions = SnapControllerGetSnapAction;
export type TrackEventObject = {
event: string;
properties?: Record<string, Json>;
sensitiveProperties?: Record<string, Json>;
};
declare const TrackEventParametersStruct: import("@metamask/superstruct").Struct<{
event: {
event: string;
properties?: Record<string, Json> | undefined;
sensitiveProperties?: Record<string, Json> | undefined;
};
}, {
event: import("@metamask/superstruct").Struct<{
event: string;
properties?: Record<string, Json> | undefined;
sensitiveProperties?: Record<string, Json> | undefined;
}, {
event: import("@metamask/superstruct").Struct<string, null>;
properties: import("@metamask/superstruct").Struct<Record<string, Json> | undefined, null>;
sensitiveProperties: import("@metamask/superstruct").Struct<Record<string, Json> | undefined, null>;
}>;
}>;
export type TrackEventParameters = InferMatching<typeof TrackEventParametersStruct, TrackEventParams>;
/**
* Handler for the `snap_trackEvent` method.
*
* @internal
*/
export declare const trackEventHandler: {
implementation: typeof getTrackEventImplementation;
hookNames: MethodHooksObject<TrackEventMethodHooks>;
actionNames: "SnapController:getSnap"[];
};
/**
* The `snap_trackEvent` method implementation.
* This method allows pre-installed Snaps to submit tracking events to the client.
*
* @param req - The JSON-RPC request object.
* @param res - The JSON-RPC response object.
* @param _next - The `json-rpc-engine` "next" callback. Not used by this function.
* @param end - The `json-rpc-engine` "end" callback.
* @param hooks - The RPC method hooks.
* @param hooks.trackEvent - The function to track the event.
* @param messenger - The messenger used to call controller actions.
* @returns Nothing.
*/
declare function getTrackEventImplementation(req: JsonRpcRequestWithOrigin<TrackEventParameters>, res: PendingJsonRpcResponse<TrackEventResult>, _next: unknown, end: JsonRpcEngineEndCallback, { trackEvent }: TrackEventMethodHooks, messenger: Messenger<string, TrackEventMethodActions>): void;
export {};
//# sourceMappingURL=trackEvent.d.mts.map