Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions packages/insomnia-analytics/src/events.ts
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ export enum AnalyticsEvent {
aiFeatureEnabled = 'AI Feature Enabled',
aiFeatureDisabled = 'AI Feature Disabled',
installPlugin = 'Plugin Installed',
AppMenuPreferencesClicked = 'App Menu Preferences Clicked',

homepageFiltered = 'homepage-filtered',
quickSearchOpenedByKeyboard = 'quick-search-opened-by-keyboard',
Expand Down
2 changes: 2 additions & 0 deletions packages/insomnia/src/main/window-utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import { getAppBuildDate, getAppVersion, getProductName, isDevelopment, MNEMONIC
import { docsBase } from '../common/documentation';
import { isLinux, isMac } from '../common/platform';
import { invariant } from '../utils/invariant';
import { AnalyticsEvent, trackAnalyticsEvent } from './analytics';
import { getElectronStorage } from './electron-storage';
import { ipcMainOn } from './ipc/electron';
import { getLogDirectory } from './log';
Expand Down Expand Up @@ -267,6 +268,7 @@ export function createWindow(): ElectronBrowserWindow {
{
label: `${MNEMONIC_SYM}Preferences`,
click: () => {
trackAnalyticsEvent(AnalyticsEvent.AppMenuPreferencesClicked);
mainBrowserWindow.webContents?.send('toggle-preferences');
},
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,20 +10,24 @@ import {
} from '~/common/constants';
import type { Request, RequestBody, RequestParameter } from '~/insomnia-data';
import { services } from '~/insomnia-data';
import type { RequestCreatedMetricsProperties } from '~/ui/analytics';
import { AnalyticsEvent } from '~/ui/analytics';
import type { CreateRequestType } from '~/ui/hooks/use-request';
import { invariant } from '~/utils/invariant';
import { createFetcherSubmitHook } from '~/utils/router';

import type { Route } from './+types/organization.$organizationId.project.$projectId.workspace.$workspaceId.debug.request.new';



export async function clientAction({ params, request }: Route.ClientActionArgs) {
const { organizationId, projectId, workspaceId } = params;

const { requestType, parentId, req } = (await request.json()) as {
const { requestType, parentId, req, metrics } = (await request.json()) as {
requestType: CreateRequestType;
parentId?: string;
req?: Request;
metrics?: RequestCreatedMetricsProperties;
};

const settings = await services.settings.getOrCreate();
Expand Down Expand Up @@ -148,6 +152,7 @@ export async function clientAction({ params, request }: Route.ClientActionArgs)
? req.authentication.type
: 'none',
has_docs: !!req?.description,
source: metrics?.source,
},
});

Expand All @@ -170,21 +175,23 @@ export const useRequestNewActionFetcher = createFetcherSubmitHook(
requestType,
parentId,
req,
metrics,
}: {
organizationId: string;
projectId: string;
workspaceId: string;
requestType: CreateRequestType;
parentId?: string;
req?: Partial<Request>;
metrics?: RequestCreatedMetricsProperties;
}) => {
const url = href('/organization/:organizationId/project/:projectId/workspace/:workspaceId/debug/request/new', {
organizationId,
projectId,
workspaceId,
});

return submit(JSON.stringify({ requestType, parentId, req }), {
return submit(JSON.stringify({ requestType, parentId, req, metrics }), {
action: url,
method: 'POST',
encType: 'application/json',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -453,6 +453,9 @@ const Debug = () => {
workspaceId,
requestType: 'HTTP',
parentId,
metrics: {
source: 'shortcut',
},
});
},
request_showCreateFolder: () => {
Expand Down Expand Up @@ -527,6 +530,9 @@ const Debug = () => {
requestType,
parentId,
req,
metrics: {
source: 'sidebar',
}
});

const reorderFetcher = useDebugReorderActionFetcher();
Expand Down Expand Up @@ -680,61 +686,67 @@ const Debug = () => {
name: 'HTTP Request',
icon: 'plus-circle',
hint: hotKeyRegistry.request_createHTTP,
action: () =>
action: () => {
createRequest({
requestType: 'HTTP',
parentId: workspaceId,
}),
});
},
},
{
id: 'Event Stream',
name: 'Event Stream Request (SSE)',
icon: 'plus-circle',
action: () =>
action: () => {
createRequest({
requestType: 'Event Stream',
parentId: workspaceId,
}),
});
},
},
{
id: 'GraphQL Request',
name: 'GraphQL Request',
icon: 'plus-circle',
action: () =>
action: () => {
createRequest({
requestType: 'GraphQL',
parentId: workspaceId,
}),
});
},
},
{
id: 'gRPC Request',
name: 'gRPC Request',
icon: 'plus-circle',
action: () =>
action: () => {
createRequest({
requestType: 'gRPC',
parentId: workspaceId,
}),
});
},
},
{
id: 'WebSocket Request',
name: 'WebSocket Request',
icon: 'plus-circle',
action: () =>
action: () => {
createRequest({
requestType: 'WebSocket',
parentId: workspaceId,
}),
});
},
},
{
id: 'Socket.IO Request',
name: 'Socket.IO Request',
icon: 'plus-circle',
action: () =>
action: () => {
createRequest({
requestType: 'SocketIO',
parentId: workspaceId,
}),
});
},
},
],
},
Expand Down
4 changes: 4 additions & 0 deletions packages/insomnia/src/ui/analytics.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,3 +47,7 @@ export function trackImportEvent(event: AnalyticsEvent, properties: Record<strin
properties: { ...readPendingImportAttribution(), ...properties },
});
}

export interface RequestCreatedMetricsProperties {
source: 'sidebar' | 'shortcut' | 'tab-list' | 'placeholder-request-pane' | 'add-request-to-collection-modal';
}
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,9 @@ export const RequestGroupActionsDropdown = ({ requestGroup, isOpen, triggerRef,
requestType,
parentId,
req,
metrics: {
source: 'sidebar',
}
});

const onOpen = async () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,9 @@ export const AddRequestToCollectionModal: FC<AddRequestModalProps> = ({ onHide }
workspaceId: selectedWorkspaceId,
requestType: 'HTTP',
parentId: selectedWorkspaceId,
metrics: {
source: 'add-request-to-collection-modal',
}
});
previousRequestFetcherState.current = 'loading';
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,9 @@ export const PlaceholderRequestPane: FC = () => {
workspaceId,
requestType: 'HTTP',
parentId: workspaceId,
metrics: {
source: 'placeholder-request-pane',
}
}),
[requestFetcher, organizationId, projectId, workspaceId],
);
Expand Down
3 changes: 3 additions & 0 deletions packages/insomnia/src/ui/components/tabs/tab-list.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -260,6 +260,9 @@ export const OrganizationTabList = ({ showActiveStatus = true, currentPage = ''
workspaceId,
requestType: 'HTTP',
parentId: workspaceId,
metrics: {
source: 'tab-list',
}
});
}
};
Expand Down
Loading