Skip to content

Commit

Permalink
feat: mock create segment event [INS-3924] (#7461)
Browse files Browse the repository at this point in the history
  • Loading branch information
filfreire authored May 28, 2024
1 parent 09adb58 commit 09d7ca9
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 4 deletions.
1 change: 1 addition & 0 deletions packages/insomnia/src/ui/analytics.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down
14 changes: 10 additions & 4 deletions packages/insomnia/src/ui/routes/actions.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -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)}`);
Expand Down

0 comments on commit 09d7ca9

Please sign in to comment.