Skip to content

Commit

Permalink
main content packs telemetry events
Browse files Browse the repository at this point in the history
  • Loading branch information
gally47 committed Oct 19, 2023
1 parent 70c4ec2 commit a1f2f42
Show file tree
Hide file tree
Showing 2 changed files with 48 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,10 @@ import BootstrapModalWrapper from 'components/bootstrap/BootstrapModalWrapper';
import ControlledTableList from 'components/common/ControlledTableList';
import ContentPackStatus from 'components/content-packs/ContentPackStatus';
import ContentPackDownloadControl from 'components/content-packs/ContentPackDownloadControl';
import withTelemetry from 'logic/telemetry/withTelemetry';
import { getPathnameWithoutId } from 'util/URLUtils';
import { TELEMETRY_EVENT_TYPE } from 'logic/telemetry/Constants';
import withLocation from 'routing/withLocation';

import ContentPackInstall from './ContentPackInstall';

Expand All @@ -46,6 +50,8 @@ class ContentPacksList extends React.Component {
contentPackMetadata: PropTypes.object,
onDeletePack: PropTypes.func,
onInstall: PropTypes.func,
sendTelemetry: PropTypes.func.isRequired,

Check warning on line 53 in graylog2-web-interface/src/components/content-packs/ContentPacksList.jsx

View workflow job for this annotation

GitHub Actions / Reviewbot

'sendTelemetry' PropType is defined but prop is never used

No further rule information available.
location: PropTypes.object.isRequired,

Check warning on line 54 in graylog2-web-interface/src/components/content-packs/ContentPacksList.jsx

View workflow job for this annotation

GitHub Actions / Reviewbot

'location' PropType is defined but prop is never used

No further rule information available.
};

static defaultProps = {
Expand Down Expand Up @@ -125,7 +131,7 @@ class ContentPacksList extends React.Component {
const shownItems = items.slice(begin, end);

return shownItems.map((item) => {
const { openFunc, installModal } = this._installModal(item);
const { openFunc, installModal, sendTelemetry, location } = this._installModal(item);
let downloadRef;
const downloadModal = (
<ContentPackDownloadControl ref={(node) => {
Expand All @@ -140,6 +146,36 @@ class ContentPacksList extends React.Component {
const states = installed ? ['installed'] : [];
const updateButton = states.includes('updatable') ? <Button bsSize="small" bsStyle="primary">Update</Button> : '';

const handleInstall = () => {
sendTelemetry(TELEMETRY_EVENT_TYPE.CONTENT_PACK.INSTALLED, {
app_pathname: getPathnameWithoutId(location.pathname),
app_section: 'content-packs',
app_action_value: 'install-button',
});

openFunc();
}

Check warning on line 158 in graylog2-web-interface/src/components/content-packs/ContentPacksList.jsx

View workflow job for this annotation

GitHub Actions / Reviewbot

Missing semicolon.

See https://eslint.org/docs/rules/semi for details.
const handleDownload = () => {
sendTelemetry(TELEMETRY_EVENT_TYPE.CONTENT_PACK.DOWNLOADED, {
app_pathname: getPathnameWithoutId(location.pathname),
app_section: 'content-packs',
app_action_value: 'download-menu-item',
});

downloadRef.open();
}

Check warning on line 168 in graylog2-web-interface/src/components/content-packs/ContentPacksList.jsx

View workflow job for this annotation

GitHub Actions / Reviewbot

Missing semicolon.

See https://eslint.org/docs/rules/semi for details.
const handleDeleteAllVersions = () => {
sendTelemetry(TELEMETRY_EVENT_TYPE.CONTENT_PACK.ALL_VERSIONS_DELETED, {
app_pathname: getPathnameWithoutId(location.pathname),
app_section: 'content-packs',
app_action_value: 'delete-all-versions-menu-item',
});

onDeletePack(item.id);
}

Check warning on line 178 in graylog2-web-interface/src/components/content-packs/ContentPacksList.jsx

View workflow job for this annotation

GitHub Actions / Reviewbot

Missing semicolon.

See https://eslint.org/docs/rules/semi for details.
return (
<ControlledTableList.Item key={item.id}>
<Row className="row-sm">
Expand All @@ -153,7 +189,7 @@ class ContentPacksList extends React.Component {
<Col md={3} className="text-right">
<ButtonToolbar className="pull-right">
{updateButton}
<Button bsSize="small" onClick={openFunc}>Install</Button>
<Button bsSize="small" onClick={handleInstall}>Install</Button>
{installModal}
<DropdownButton id={`more-actions-${item.id}`} title="More Actions" bsSize="small" pullRight>
<LinkContainer to={Routes.SYSTEM.CONTENTPACKS.show(item.id)}>
Expand All @@ -162,14 +198,12 @@ class ContentPacksList extends React.Component {
<LinkContainer to={Routes.SYSTEM.CONTENTPACKS.edit(encodeURIComponent(item.id), encodeURIComponent(item.rev))}>
<MenuItem>Create New Version</MenuItem>
</LinkContainer>
<MenuItem onSelect={() => {
downloadRef.open();
}}>Download
<MenuItem onSelect={handleDownload}>
Download
</MenuItem>
<MenuItem divider />
<MenuItem onSelect={() => {
onDeletePack(item.id);
}}>Delete All Versions
<MenuItem onSelect={handleDeleteAllVersions}>
Delete All Versions
</MenuItem>
</DropdownButton>
{downloadModal}
Expand Down Expand Up @@ -261,4 +295,4 @@ class ContentPacksList extends React.Component {
}
}

export default ContentPacksList;
export default withLocation(withTelemetry(ContentPacksList));
5 changes: 5 additions & 0 deletions graylog2-web-interface/src/logic/telemetry/Constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -435,6 +435,11 @@ export const TELEMETRY_EVENT_TYPE = {
},
SYSTEM_OVERVIEW_OUTGOING_TRAFFIC_DAYS_CHANGED: 'System Overview Outgoing Traffic Days Changed',
URLWHITELIST_CONFIGURATION_UPDATED: 'Urlwhitelist Configuration Updated',
CONTENT_PACK: {
INSTALLED: 'Content Pack Installed',
DOWNLOADED: 'Content Pack Downloaded',
ALL_VERSIONS_DELETED: 'Content Pack All Versions Deleted',
},
} as const;

type ExtractObjectValues<T extends object> = {
Expand Down

0 comments on commit a1f2f42

Please sign in to comment.