mirror of
https://github.com/Kong/insomnia.git
synced 2026-04-23 15:49:42 -04:00
Update mock implementation and move the segment event enum (#3913)
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
// WARNING: changing this to `export default` will break the mock and be incredibly hard to debug. Ask me how I know.
|
||||
const trackEvent = jest.fn();
|
||||
const trackSegmentEvent = jest.fn();
|
||||
module.exports = { trackEvent, trackSegmentEvent };
|
||||
const _analytics = jest.requireActual('../analytics');
|
||||
_analytics.trackEvent = jest.fn();
|
||||
_analytics.trackSegmentEvent = jest.fn();
|
||||
module.exports = _analytics;
|
||||
|
||||
@@ -19,7 +19,6 @@ import {
|
||||
isDevelopment,
|
||||
} from './constants';
|
||||
import { getScreenResolution, getUserLanguage, getViewportSize } from './electron-helpers';
|
||||
import { SegmentEvent } from './segment-event';
|
||||
|
||||
const DIMENSION_PLATFORM = 1;
|
||||
const DIMENSION_VERSION = 2;
|
||||
@@ -115,6 +114,23 @@ export async function getDeviceId() {
|
||||
|
||||
let segmentClient: Analytics | null = null;
|
||||
|
||||
export enum SegmentEvent {
|
||||
collectionCreate = 'Collection Created',
|
||||
documentCreate = 'Document Created',
|
||||
pluginExportLoadAllWokspace = 'Plugin export loading all workspace',
|
||||
pluginExportLoadWorkspacesInSpace = 'Plugin export loading workspaces for active space',
|
||||
requestCreate = 'Request Created',
|
||||
requestExecute = 'Request Executed',
|
||||
spaceLocalCreate = 'Local Space Created',
|
||||
spaceLocalDelete = 'Local Space Deleted',
|
||||
testSuiteCreate = 'Test Suite Created',
|
||||
testSuiteDelete = 'Test Suite Deleted',
|
||||
unitTestCreate = 'Unit Test Created',
|
||||
unitTestDelete = 'Unit Test Deleted',
|
||||
unitTestRun = 'Ran Individual Unit Test',
|
||||
unitTestRunAll = 'Ran All Unit Tests',
|
||||
}
|
||||
|
||||
export async function trackSegmentEvent(event: SegmentEvent, properties?: Record<string, any>) {
|
||||
const settings = await models.settings.getOrCreate();
|
||||
|
||||
|
||||
@@ -1,16 +0,0 @@
|
||||
export enum SegmentEvent {
|
||||
collectionCreate = 'Collection Created',
|
||||
documentCreate = 'Document Created',
|
||||
pluginExportLoadAllWokspace = 'Plugin export loading all workspace',
|
||||
pluginExportLoadWorkspacesInSpace = 'Plugin export loading workspaces for active space',
|
||||
requestCreate = 'Request Created',
|
||||
requestExecute = 'Request Executed',
|
||||
spaceLocalCreate = 'Local Space Created',
|
||||
spaceLocalDelete = 'Local Space Deleted',
|
||||
testSuiteCreate = 'Test Suite Created',
|
||||
testSuiteDelete = 'Test Suite Deleted',
|
||||
unitTestCreate = 'Unit Test Created',
|
||||
unitTestDelete = 'Unit Test Deleted',
|
||||
unitTestRun = 'Ran Individual Unit Test',
|
||||
unitTestRunAll = 'Ran All Unit Tests',
|
||||
}
|
||||
@@ -2,8 +2,7 @@ import * as grpc from '@grpc/grpc-js';
|
||||
import { Call, ServiceError } from '@grpc/grpc-js';
|
||||
import { ServiceClient } from '@grpc/grpc-js/build/src/make-client';
|
||||
|
||||
import { trackSegmentEvent } from '../../common/analytics';
|
||||
import { SegmentEvent } from '../../common/segment-event';
|
||||
import { SegmentEvent, trackSegmentEvent } from '../../common/analytics';
|
||||
import * as models from '../../models';
|
||||
import type { GrpcRequest } from '../../models/grpc-request';
|
||||
import callCache from './call-cache';
|
||||
|
||||
@@ -1,8 +1,7 @@
|
||||
import { trackSegmentEvent } from '../../common/analytics';
|
||||
import { SegmentEvent, trackSegmentEvent } from '../../common/analytics';
|
||||
import { exportWorkspacesData, exportWorkspacesHAR } from '../../common/export';
|
||||
import type { ImportRawConfig } from '../../common/import';
|
||||
import { importRaw, importUri } from '../../common/import';
|
||||
import { SegmentEvent } from '../../common/segment-event';
|
||||
import * as models from '../../models';
|
||||
import { BASE_SPACE_ID } from '../../models/space';
|
||||
import type { Workspace, WorkspaceScope } from '../../models/workspace';
|
||||
|
||||
@@ -11,10 +11,9 @@ import {
|
||||
import { generate, runTests, Test } from 'insomnia-testing';
|
||||
import React, { PureComponent, ReactNode } from 'react';
|
||||
|
||||
import { trackSegmentEvent } from '../../common/analytics';
|
||||
import { SegmentEvent, trackSegmentEvent } from '../../common/analytics';
|
||||
import type { GlobalActivity } from '../../common/constants';
|
||||
import { AUTOBIND_CFG } from '../../common/constants';
|
||||
import { SegmentEvent } from '../../common/segment-event';
|
||||
import { getSendRequestCallback } from '../../common/send-request';
|
||||
import * as models from '../../models';
|
||||
import { isRequest } from '../../models/request';
|
||||
|
||||
@@ -10,7 +10,7 @@ import { connect } from 'react-redux';
|
||||
import { Action, bindActionCreators, Dispatch } from 'redux';
|
||||
import { parse as urlParse } from 'url';
|
||||
|
||||
import { trackSegmentEvent } from '../../common/analytics';
|
||||
import { SegmentEvent, trackSegmentEvent } from '../../common/analytics';
|
||||
import {
|
||||
ACTIVITY_HOME,
|
||||
ACTIVITY_MIGRATION,
|
||||
@@ -42,7 +42,6 @@ import {
|
||||
} from '../../common/misc';
|
||||
import * as render from '../../common/render';
|
||||
import { RenderContextAndKeys } from '../../common/render';
|
||||
import { SegmentEvent } from '../../common/segment-event';
|
||||
import { sortMethodMap } from '../../common/sorting';
|
||||
import * as models from '../../models';
|
||||
import { isEnvironment } from '../../models/environment';
|
||||
|
||||
@@ -8,9 +8,8 @@ import { mocked } from 'ts-jest/utils';
|
||||
|
||||
import { globalBeforeEach } from '../../../../__jest__/before-each';
|
||||
import { reduxStateForTest } from '../../../../__jest__/redux-state-for-test';
|
||||
import { trackEvent, trackSegmentEvent } from '../../../../common/analytics';
|
||||
import { SegmentEvent, trackEvent, trackSegmentEvent } from '../../../../common/analytics';
|
||||
import { ACTIVITY_SPEC } from '../../../../common/constants';
|
||||
import { SegmentEvent } from '../../../../common/segment-event';
|
||||
import * as models from '../../../../models';
|
||||
import { gitRepositorySchema } from '../../../../models/__schemas__/model-schemas';
|
||||
import { BASE_SPACE_ID } from '../../../../models/space';
|
||||
|
||||
@@ -3,9 +3,8 @@ import thunk from 'redux-thunk';
|
||||
|
||||
import { globalBeforeEach } from '../../../../__jest__/before-each';
|
||||
import { reduxStateForTest } from '../../../../__jest__/redux-state-for-test';
|
||||
import { trackEvent, trackSegmentEvent } from '../../../../common/analytics';
|
||||
import { SegmentEvent, trackEvent, trackSegmentEvent } from '../../../../common/analytics';
|
||||
import { ACTIVITY_HOME } from '../../../../common/constants';
|
||||
import { SegmentEvent } from '../../../../common/segment-event';
|
||||
import * as models from '../../../../models';
|
||||
import { BASE_SPACE_ID } from '../../../../models/space';
|
||||
import { getAndClearShowAlertMockArgs, getAndClearShowPromptMockArgs } from '../../../../test-utils';
|
||||
|
||||
@@ -3,10 +3,9 @@ import thunk from 'redux-thunk';
|
||||
|
||||
import { globalBeforeEach } from '../../../../__jest__/before-each';
|
||||
import { reduxStateForTest } from '../../../../__jest__/redux-state-for-test';
|
||||
import { trackEvent, trackSegmentEvent } from '../../../../common/analytics';
|
||||
import { SegmentEvent, trackEvent, trackSegmentEvent } from '../../../../common/analytics';
|
||||
import { ACTIVITY_DEBUG, ACTIVITY_SPEC, ACTIVITY_UNIT_TEST } from '../../../../common/constants';
|
||||
import { database } from '../../../../common/database';
|
||||
import { SegmentEvent } from '../../../../common/segment-event';
|
||||
import * as models from '../../../../models';
|
||||
import { ApiSpec } from '../../../../models/api-spec';
|
||||
import { CookieJar } from '../../../../models/cookie-jar';
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
import { trackEvent, trackSegmentEvent } from '../../../common/analytics';
|
||||
import { SegmentEvent, trackEvent, trackSegmentEvent } from '../../../common/analytics';
|
||||
import { ACTIVITY_HOME } from '../../../common/constants';
|
||||
import { SegmentEvent } from '../../../common/segment-event';
|
||||
import { strings } from '../../../common/strings';
|
||||
import * as models from '../../../models';
|
||||
import { BASE_SPACE_ID, isRemoteSpace, Space } from '../../../models/space';
|
||||
|
||||
@@ -1,10 +1,9 @@
|
||||
import { Dispatch } from 'redux';
|
||||
import { RequireExactlyOne } from 'type-fest';
|
||||
|
||||
import { trackEvent, trackSegmentEvent } from '../../../common/analytics';
|
||||
import { SegmentEvent, trackEvent, trackSegmentEvent } from '../../../common/analytics';
|
||||
import { ACTIVITY_DEBUG, ACTIVITY_SPEC, GlobalActivity, isCollectionActivity, isDesignActivity } from '../../../common/constants';
|
||||
import { database } from '../../../common/database';
|
||||
import { SegmentEvent } from '../../../common/segment-event';
|
||||
import * as models from '../../../models';
|
||||
import { isCollection, isDesign, Workspace, WorkspaceScope } from '../../../models/workspace';
|
||||
import { showPrompt } from '../../components/modals';
|
||||
|
||||
Reference in New Issue
Block a user