Skip to content

Commit

Permalink
refactor: function param
Browse files Browse the repository at this point in the history
  • Loading branch information
BohdanOne committed Nov 27, 2024
1 parent 56efe78 commit b5f7875
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ const TabZone: FC<TabZoneProps> = ({ tabId }) => {
toast.success(`${field.type === "Group" ? "Group" : "Field"} added`);
});

trackFieldAdded(id, newField);
trackFieldAdded({ id, field: newField });
};

const onDragEnd = (result: DropResult) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ const FieldZones: FC = () => {
toast.success(`${widgetTypeName === "Group" ? "Group" : "Field"} added`);
});

trackFieldAdded(id, newField);
trackFieldAdded({ id, field: newField });
};

const _onCreateOrSave = (widgetArea: WidgetsArea) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ export const CustomListItem = ({
isNewGroupField: true,
});

trackFieldAdded(id, newField);
trackFieldAdded({ id, field: newField });
};

const onSaveField = ({ apiId: previousKey, newKey, value }) => {
Expand Down
12 changes: 8 additions & 4 deletions packages/slice-machine/src/utils/tracking/trackFieldAdded.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,14 @@ import { SlicePrimaryFieldSM } from "@/legacy/lib/models/common/Slice";

import { getContentTypeForTracking } from "./getContentTypeForTracking";

export function trackFieldAdded(
id: string,
field: SlicePrimaryFieldSM | NestableWidget | UID | Group,
) {
type TrackFieldAddedParam = {
id: string;
field: SlicePrimaryFieldSM | NestableWidget | UID | Group;
};

export function trackFieldAdded(params: TrackFieldAddedParam) {
const { id, field } = params;

void telemetry.track({
event: "field:added",
id,
Expand Down

0 comments on commit b5f7875

Please sign in to comment.