Track networking commands

This commit is contained in:
BorysLevytskyi
2021-01-21 19:59:19 +02:00
parent 4c9d0c6125
commit 2b76ea9f7f
3 changed files with 32 additions and 8 deletions

View File

@@ -1,6 +1,6 @@
import React from 'react';
import AppState from '../shell/AppState';
import { CmdShell, CommandInput } from '../shell/cmd';
import { CmdShell, CommandInput, CommandOptions } from '../shell/cmd';
import ErrorResultView from '../shell/components/ErrorResultView';
import IpAddressView from './components/IpAddressView';
import ipAddressParser, {ParsingError, ParsedIpObject} from './ip-parser';
@@ -8,6 +8,7 @@ import { IpAddress, IpAddressWithSubnetMask, SubnetCommand } from "./models";
import log from 'loglevel';
import SubnetView from './components/SubnetView';
import { createSubnetMaskIp } from './subnet-utils';
import {sendAnalyticsEvent} from '../shell/analytics';
const networkingAppModule = {
setup: function(appState: AppState, cmd: CmdShell) {
@@ -28,6 +29,7 @@ const networkingAppModule = {
if(result instanceof SubnetCommand) {
appState.addCommandResult(c.input, <SubnetView subnet={result} />);
trackCommand('SubnetCommand', c.options);
return;
}
@@ -43,6 +45,8 @@ const networkingAppModule = {
ipAddresses.push(r);
}
});
trackCommand("IpAddressesInput", c.options);
appState.addCommandResult(c.input, <IpAddressView ipAddresses={ipAddresses} />);
}
@@ -52,4 +56,13 @@ const networkingAppModule = {
}
}
function trackCommand(action: string, ops: CommandOptions) {
if(ops.doNotTrack !== true) {
sendAnalyticsEvent({
eventCategory: "NetworkingCommand",
eventAction: action
});
}
}
export default networkingAppModule;