Skip to content
Merged
5 changes: 5 additions & 0 deletions .changeset/late-windows-joke.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@khanacademy/perseus": patch
---

[Analytics] Updating rendering analytics events to use accurate widgetIds
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ describe("categorizer widget", () => {
payload: {
widgetSubType: "null",
widgetType: "categorizer",
widgetId: "categorizer",
widgetId: "categorizer 1",
},
});
});
Expand Down
2 changes: 1 addition & 1 deletion packages/perseus/src/widgets/categorizer/categorizer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ export class Categorizer
payload: {
widgetSubType: "null",
widgetType: "categorizer",
widgetId: "categorizer",
widgetId: this.props.widgetId,
},
});
}
Expand Down
2 changes: 1 addition & 1 deletion packages/perseus/src/widgets/definition/definition.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ describe("Definition widget", () => {
payload: {
widgetSubType: "null",
widgetType: "definition",
widgetId: "definition",
widgetId: "definition 1",
},
});
});
Expand Down
2 changes: 1 addition & 1 deletion packages/perseus/src/widgets/definition/definition.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ class Definition extends React.Component<DefinitionProps> implements Widget {
payload: {
widgetSubType: "null",
widgetType: "definition",
widgetId: "definition",
widgetId: this.props.widgetId,
},
});
}
Expand Down
2 changes: 1 addition & 1 deletion packages/perseus/src/widgets/dropdown/dropdown.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ describe("Dropdown widget", () => {
payload: {
widgetSubType: "null",
widgetType: "dropdown",
widgetId: "dropdown",
widgetId: "dropdown 1",
},
});
});
Expand Down
2 changes: 1 addition & 1 deletion packages/perseus/src/widgets/dropdown/dropdown.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ class Dropdown extends React.Component<Props> implements Widget {
payload: {
widgetSubType: "null",
widgetType: "dropdown",
widgetId: "dropdown",
widgetId: this.props.widgetId,
},
});
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ describe("Explanation", function () {
payload: {
widgetSubType: "null",
widgetType: "explanation",
widgetId: "explanation",
widgetId: "explanation 1",
},
});
});
Expand Down
2 changes: 1 addition & 1 deletion packages/perseus/src/widgets/explanation/explanation.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ class Explanation extends React.Component<Props, State> implements Widget {
payload: {
widgetSubType: "null",
widgetType: "explanation",
widgetId: "explanation",
widgetId: this.props.widgetId,
},
});
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -477,7 +477,7 @@ describe("Expression Widget", function () {
payload: {
widgetSubType: "null",
widgetType: "expression",
widgetId: "expression",
widgetId: "expression 1",
},
});
});
Expand Down
2 changes: 1 addition & 1 deletion packages/perseus/src/widgets/expression/expression.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ export class Expression extends React.Component<Props> implements Widget {
payload: {
widgetSubType: "null",
widgetType: "expression",
widgetId: "expression",
widgetId: this.props.widgetId,
},
});

Expand Down
2 changes: 1 addition & 1 deletion packages/perseus/src/widgets/image/image.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ describe.each([[true], [false]])("image widget - isMobile(%j)", (isMobile) => {
payload: {
widgetSubType: "null",
widgetType: "image",
widgetId: "image",
widgetId: "image 1",
},
});
});
Expand Down
3 changes: 2 additions & 1 deletion packages/perseus/src/widgets/image/image.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ export const ImageComponent = (props: ImageWidgetProps) => {
range,
title,
trackInteraction,
widgetId,
} = props;
const context = React.useContext(PerseusI18nContext);
const imageUpgradeFF = isFeatureOn({apiOptions}, "image-widget-upgrade");
Expand All @@ -47,7 +48,7 @@ export const ImageComponent = (props: ImageWidgetProps) => {
payload: {
widgetSubType: "null",
widgetType: "image",
widgetId: "image",
widgetId: widgetId,
},
});
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ describe("input-number", function () {
payload: {
widgetSubType: "null",
widgetType: "input-number",
widgetId: "input-number",
widgetId: "input-number 1",
},
});
});
Expand Down
2 changes: 1 addition & 1 deletion packages/perseus/src/widgets/input-number/input-number.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ class InputNumber extends React.Component<Props> implements Widget {
payload: {
widgetSubType: "null",
widgetType: "input-number",
widgetId: "input-number",
widgetId: this.props.widgetId,
},
});
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -346,6 +346,7 @@ class InteractiveGraph extends React.Component<Props, State> {
box={box}
showTooltips={!!this.props.showTooltips}
readOnly={this.props.apiOptions?.readOnly}
widgetId={this.props.widgetId}
/>
);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ describe("MafsGraph", () => {
payload: {
widgetSubType: "segment",
widgetType: "interactive-graph",
widgetId: "interactive-graph",
widgetId: "test-widget-id",
},
});
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@ export type MafsGraphProps = {
dispatch: React.Dispatch<InteractiveGraphAction>;
readOnly: boolean;
static: boolean | null | undefined;
widgetId: string;
};

export const MafsGraph = (props: MafsGraphProps) => {
Expand All @@ -101,6 +102,7 @@ export const MafsGraph = (props: MafsGraphProps) => {
readOnly,
fullGraphAriaLabel,
fullGraphAriaDescription,
widgetId,
} = props;
const {type} = state;
const [width, height] = props.box;
Expand Down Expand Up @@ -143,7 +145,7 @@ export const MafsGraph = (props: MafsGraphProps) => {
payload: {
widgetSubType: type,
widgetType: "interactive-graph",
widgetId: "interactive-graph",
widgetId: widgetId,
},
});
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ function getBaseStatefulMafsGraphProps(): StatefulMafsGraphProps {
correct: {type: "segment"},
static: false,
lockedFigures: [],
widgetId: "test-widget-id",
};
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ export type StatefulMafsGraphProps = {
readOnly: boolean;
static: InteractiveGraphProps["static"];
showAxisArrows: InteractiveGraphProps["showAxisArrows"];
widgetId: string;
};

export type StatefulMafsGraphType = {
Expand Down
1 change: 1 addition & 0 deletions packages/perseus/src/widgets/interactive-graphs/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,7 @@ export function getBaseMafsGraphPropsForTests(): MafsGraphProps {
[-10, 10],
],
},
widgetId: "test-widget-id",
};
}
// Calculate the difference between the min and max values of a range
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -840,7 +840,7 @@ describe("LabelImage", function () {
payload: {
widgetSubType: "null",
widgetType: "label-image",
widgetId: "label-image",
widgetId: "label-image 1",
},
});
});
Expand Down
2 changes: 1 addition & 1 deletion packages/perseus/src/widgets/label-image/label-image.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -357,7 +357,7 @@ export class LabelImage
payload: {
widgetSubType: "null",
widgetType: "label-image",
widgetId: "label-image",
widgetId: this.props.widgetId,
},
});
this._mounted = true;
Expand Down
2 changes: 1 addition & 1 deletion packages/perseus/src/widgets/matcher/matcher.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ describe("matcher widget", () => {
payload: {
widgetSubType: "null",
widgetType: "matcher",
widgetId: "matcher",
widgetId: "matcher 1",
},
});
});
Expand Down
2 changes: 1 addition & 1 deletion packages/perseus/src/widgets/matcher/matcher.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ export class Matcher extends React.Component<Props, State> implements Widget {
payload: {
widgetSubType: "null",
widgetType: "matcher",
widgetId: "matcher",
widgetId: this.props.widgetId,
},
});
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,7 @@ describe("number-line widget", () => {
payload: {
widgetSubType: "null",
widgetType: "number-line",
widgetId: "number-line",
widgetId: "number-line 1",
},
});
});
Expand Down
2 changes: 1 addition & 1 deletion packages/perseus/src/widgets/number-line/number-line.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -254,7 +254,7 @@ class NumberLine extends React.Component<Props, State> implements Widget {
payload: {
widgetSubType: "null",
widgetType: "number-line",
widgetId: "number-line",
widgetId: this.props.widgetId,
},
});
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ describe("numeric-input widget", () => {
payload: {
widgetSubType: "null",
widgetType: "numeric-input",
widgetId: "numeric-input",
widgetId: "numeric-input 1",
},
});
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ export const NumericInputComponent = forwardRef<Focusable, NumericInputProps>(
payload: {
widgetSubType: "null",
widgetType: "numeric-input",
widgetId: "numeric-input",
widgetId: props.widgetId,
},
});
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -496,7 +496,7 @@ describe("Multiple Choice Widget", () => {
payload: {
widgetSubType: "single-select",
widgetType: "radio",
widgetId: "radio",
widgetId: "radio 1",
},
});
});
Expand Down Expand Up @@ -819,7 +819,7 @@ describe("Multiple Choice Widget", () => {
payload: {
widgetSubType: "multiple-select",
widgetType: "radio",
widgetId: "radio",
widgetId: "radio 1",
},
});
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@ const MultipleChoiceWidget = forwardRef<Widget, Props>(
trackInteraction,
findWidgets,
reviewMode,
widgetId,
} = props;

const {strings} = usePerseusI18n();
Expand All @@ -110,7 +111,7 @@ const MultipleChoiceWidget = forwardRef<Widget, Props>(
? "multiple-select"
: "single-select",
widgetType: "radio",
widgetId: "radio",
widgetId: widgetId,
},
});
});
Expand Down
2 changes: 1 addition & 1 deletion packages/perseus/src/widgets/sorter/sorter.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ class Sorter extends React.Component<Props> implements Widget {
payload: {
widgetSubType: "null",
widgetType: "sorter",
widgetId: "sorter",
widgetId: this.props.widgetId,
},
});
}
Expand Down
2 changes: 1 addition & 1 deletion packages/perseus/src/widgets/video/video.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ describe("video widget", () => {
payload: {
widgetSubType: "null",
widgetType: "video",
widgetId: "video",
widgetId: "video 1",
},
});
});
Expand Down
2 changes: 1 addition & 1 deletion packages/perseus/src/widgets/video/video.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ class Video extends React.Component<Props> implements Widget {
payload: {
widgetSubType: "null",
widgetType: "video",
widgetId: "video",
widgetId: this.props.widgetId,
},
});
}
Expand Down
Loading