From 09d7ca96b2def4f47e71bb6e9dd7aa150dcce153 Mon Sep 17 00:00:00 2001 From: Filipe Freire Date: Tue, 28 May 2024 14:07:11 +0100 Subject: [PATCH] feat: mock create segment event [INS-3924] (#7461) --- packages/insomnia/src/ui/analytics.ts | 1 + packages/insomnia/src/ui/routes/actions.tsx | 14 ++++++++++---- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/packages/insomnia/src/ui/analytics.ts b/packages/insomnia/src/ui/analytics.ts index fc3396151d2..e20f37fbc3c 100644 --- a/packages/insomnia/src/ui/analytics.ts +++ b/packages/insomnia/src/ui/analytics.ts @@ -4,6 +4,7 @@ export enum SegmentEvent { dataExport = 'Data Exported', dataImport = 'Data Imported', documentCreate = 'Document Created', + mockCreate = 'Mock Created', exportAllCollections = 'Exported All Collections', kongConnected = 'Kong Connected', kongSync = 'Kong Synced', diff --git a/packages/insomnia/src/ui/routes/actions.tsx b/packages/insomnia/src/ui/routes/actions.tsx index 46e6018b284..534f0510d4d 100644 --- a/packages/insomnia/src/ui/routes/actions.tsx +++ b/packages/insomnia/src/ui/routes/actions.tsx @@ -17,7 +17,7 @@ import { isRequest, Request } from '../../models/request'; import { isRequestGroup, isRequestGroupId } from '../../models/request-group'; import { UnitTest } from '../../models/unit-test'; import { UnitTestSuite } from '../../models/unit-test-suite'; -import { isCollection, scopeToActivity, Workspace } from '../../models/workspace'; +import { isCollection, isMockServer, scopeToActivity, Workspace } from '../../models/workspace'; import { WorkspaceMeta } from '../../models/workspace-meta'; import { getSendRequestCallback } from '../../network/unit-test-feature'; import { initializeLocalBackendProjectAndMarkForSync } from '../../sync/vcs/initialize-backend-project'; @@ -391,10 +391,16 @@ export const createNewWorkspaceAction: ActionFunction = async ({ }); } + let event = SegmentEvent.documentCreate; + + if (isCollection(workspace)) { + event = SegmentEvent.collectionCreate; + } else if (isMockServer(workspace)) { + event = SegmentEvent.mockCreate; + } + window.main.trackSegmentEvent({ - event: isCollection(workspace) - ? SegmentEvent.collectionCreate - : SegmentEvent.documentCreate, + event: event, }); return redirect(`/organization/${organizationId}/project/${projectId}/workspace/${workspace._id}/${scopeToActivity(workspace.scope)}`);