Skip to content

Commit

Permalink
Rework args to trackInteraction so it works when we generate Flow typ…
Browse files Browse the repository at this point in the history
…es for it
  • Loading branch information
jeremywiebe committed Jul 25, 2023
1 parent 54590cc commit 1f7b554
Showing 1 changed file with 14 additions and 9 deletions.
23 changes: 14 additions & 9 deletions packages/perseus/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,19 @@ export type Path = ReadonlyArray<string>;

type StubTagEditorType = any; // from "./components/stub-tag-editor";

type TrackInteractionArgs = {
// The widget type that this interaction originates from
type: string;
// The widget id that this interaction originates from
id: string;

correct?: boolean;

// Each widget can pass on additional, arbitrary, arguments.
// Currently, these are not defined in this type.
[key: string]: any;
};

// APIOptions provides different ways to customize the behaviour of Perseus.
export type APIOptions = Readonly<{
isArticle?: boolean;
Expand Down Expand Up @@ -182,15 +195,7 @@ export type APIOptions = Readonly<{
// A function that is called when the user has interacted with a widget. It
// also includes any extra parameters that the originating widget provided.
// This is used for keeping track of widget interactions.
trackInteraction?: (
args: {
// The widget type that this interaction originates from
type: string;
// The widget id that this interaction originates from
id: string;
correct?: boolean;
} & Record<string, unknown>,
) => void;
trackInteraction?: (args: TrackInteractionArgs) => void;
// A boolean that indicates whether or not a custom keypad is
// being used. For mobile web this will be the ProvidedKeypad
// component. In this situation we use the MathInput component
Expand Down

0 comments on commit 1f7b554

Please sign in to comment.