Skip to content

Commit 77627fc

Browse files
authored
fix: use parsed list of types for telemetry (#7481)
1 parent 325e5f0 commit 77627fc

File tree

2 files changed

+30
-13
lines changed

2 files changed

+30
-13
lines changed

packages/compass-data-modeling/src/components/drawer/field-drawer-content.tsx

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -54,11 +54,17 @@ type FieldDrawerContentProps = {
5454
fromFieldPath: FieldPath,
5555
newName: string
5656
) => void;
57-
onChangeFieldType: (
58-
namespace: string,
59-
fieldPath: FieldPath,
60-
newTypes: string[]
61-
) => void;
57+
onChangeFieldType: ({
58+
ns,
59+
fieldPath,
60+
oldTypes,
61+
newTypes,
62+
}: {
63+
ns: string;
64+
fieldPath: FieldPath;
65+
oldTypes: string[];
66+
newTypes: string[];
67+
}) => void;
6268
};
6369

6470
const BSON_TYPES = Object.keys(BSONType);
@@ -149,7 +155,12 @@ const FieldDrawerContent: React.FunctionComponent<FieldDrawerContentProps> = ({
149155
return;
150156
}
151157
setFieldTypeEditErrorMessage(undefined);
152-
onChangeFieldType(namespace, fieldPath, newTypes);
158+
onChangeFieldType({
159+
ns: namespace,
160+
fieldPath,
161+
oldTypes: fieldTypes,
162+
newTypes,
163+
});
153164
};
154165

155166
const isReadOnly = useMemo(() => isIdField(fieldPath), [fieldPath]);

packages/compass-data-modeling/src/store/diagram.ts

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -817,11 +817,17 @@ export function getTypeNameForTelemetry(
817817
return bsonType;
818818
}
819819

820-
export function changeFieldType(
821-
ns: string,
822-
fieldPath: FieldPath,
823-
newTypes: string[]
824-
): DataModelingThunkAction<void, ApplyEditAction | RevertFailedEditAction> {
820+
export function changeFieldType({
821+
ns,
822+
fieldPath,
823+
oldTypes,
824+
newTypes,
825+
}: {
826+
ns: string;
827+
fieldPath: FieldPath;
828+
oldTypes: string[];
829+
newTypes: string[];
830+
}): DataModelingThunkAction<void, ApplyEditAction | RevertFailedEditAction> {
825831
return (dispatch, getState, { track }) => {
826832
const collectionSchema = selectCurrentModelFromState(
827833
getState()
@@ -836,8 +842,8 @@ export function changeFieldType(
836842

837843
track('Data Modeling Field Type Changed', {
838844
source: 'side_panel',
839-
from: getTypeNameForTelemetry(field.jsonSchema.bsonType),
840-
to: getTypeNameForTelemetry(to.bsonType),
845+
from: getTypeNameForTelemetry(oldTypes),
846+
to: getTypeNameForTelemetry(newTypes),
841847
});
842848

843849
dispatch(

0 commit comments

Comments
 (0)