Skip to content

Commit 5373059

Browse files
authored
fix: auditing some events (#3961)
1 parent 21eda68 commit 5373059

File tree

10 files changed

+107
-77
lines changed

10 files changed

+107
-77
lines changed

src/dataLoaders/components/collectorsWizard/select/TelegrafUIRefreshSelector.tsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,6 @@ class TelegrafUIRefreshSelector extends PureComponent<Props, State> {
171171
name={item.name}
172172
image={item.image}
173173
style={item.style}
174-
url={`${item.id}`}
175174
selected={this.isCardChecked(item.id)}
176175
onClick={this.handleToggle}
177176
testID={`telegraf-plugins--${item.name}`}

src/flows/context/flow.query.tsx

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -240,8 +240,6 @@ export const FlowQueryProvider: FC = ({children}) => {
240240
}
241241

242242
const query = (text: string, override?: QueryScope): Promise<FluxResult> => {
243-
event('runQuery', {context: 'flows'})
244-
245243
const _override: QueryScope = {
246244
region: window.location.origin,
247245
org: org.id,

src/flows/pipes/MetricSelector/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ export default register => {
1111
component: View,
1212
readOnlyComponent: ReadOnly,
1313
button: 'Metric Selector',
14-
disabled: true,
14+
featureFlag: 'flow-panel--metric-selector',
1515
initial: {
1616
field: '',
1717
measurement: '',

src/flows/pipes/QueryBuilder/AddButton.tsx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,13 @@ import {RemoteDataState} from 'src/types'
55

66
import {QueryBuilderContext} from 'src/flows/pipes/QueryBuilder/context'
77

8+
import {event} from 'src/cloud/utils/reporting'
9+
810
const AddButton: FC = () => {
911
const {cards, add} = useContext(QueryBuilderContext)
1012

1113
const onClick = useCallback(() => {
14+
event('Query Builder Card Added')
1215
add()
1316
}, [add])
1417

src/flows/pipes/QueryBuilder/BucketSelector.tsx

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ import BuilderCard from 'src/timeMachine/components/builderCard/BuilderCard'
88
import {BucketContext} from 'src/flows/context/bucket.scoped'
99
import {PipeContext} from 'src/flows/context/pipe'
1010

11+
import {event} from 'src/cloud/utils/reporting'
12+
1113
// this is used by notebooks
1214
const BucketSelector: FC = () => {
1315
const {data, update} = useContext(PipeContext)
@@ -42,6 +44,9 @@ const BucketSelector: FC = () => {
4244
} else if (item !== selected) {
4345
data.buckets = [buckets.find(b => b.name === item)]
4446
bucket = item
47+
event('Query Builder Bucket Selected', {
48+
usedSearch: !!search.length ? 'yus' : 'nah',
49+
})
4550
} else {
4651
data.buckets = []
4752
bucket = null

src/flows/pipes/QueryBuilder/CardList.tsx

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,8 @@ import WaitingText from 'src/shared/components/WaitingText'
3232
import BuilderCard from 'src/timeMachine/components/builderCard/BuilderCard'
3333
import SelectorList from 'src/timeMachine/components/SelectorList'
3434

35+
import {event} from 'src/cloud/utils/reporting'
36+
3537
const DEBOUNCE_TIMEOUT = 500
3638
const debounce_array = []
3739
type NOOP = () => void
@@ -69,6 +71,7 @@ const Card: FC<Props> = ({idx}) => {
6971
const _remove =
7072
idx !== 0 &&
7173
(() => {
74+
event('Query Builder Card Removed')
7275
remove(idx)
7376
})
7477

@@ -90,6 +93,10 @@ const Card: FC<Props> = ({idx}) => {
9093
)
9194

9295
const keySelect = val => {
96+
if (card.keys.selected[0] === val) {
97+
return
98+
}
99+
event('Query Builder key selected')
93100
update(idx, {
94101
keys: {
95102
...card.keys,
@@ -110,8 +117,10 @@ const Card: FC<Props> = ({idx}) => {
110117
const _vals = [...card.values.selected]
111118
const index = _vals.indexOf(val)
112119
if (index === -1) {
120+
event('Query Builder Value Selected')
113121
_vals.push(val)
114122
} else {
123+
event('Query Builder Value Unselected')
115124
_vals.splice(index, 1)
116125
}
117126
update(idx, {

src/writeData/components/ClientLibrarySection.tsx

Lines changed: 28 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,14 @@
11
// Libraries
22
import React, {useContext} from 'react'
3-
import {CLIENT_LIBS} from 'src/shared/constants/routes'
3+
import {useSelector} from 'react-redux'
4+
import {useHistory} from 'react-router-dom'
5+
import {ORGS, CLIENT_LIBS} from 'src/shared/constants/routes'
46
import {searchClients} from 'src/writeData'
57

8+
// Utils
9+
import {getOrg} from 'src/organizations/selectors'
10+
import {event} from 'src/cloud/utils/reporting'
11+
612
// Contexts
713
import {WriteDataSearchContext} from 'src/writeData/containers/WriteDataPage'
814

@@ -20,6 +26,9 @@ const ClientLibrarySection = () => {
2026
const {searchTerm} = useContext(WriteDataSearchContext)
2127
const items = searchClients(searchTerm)
2228

29+
const history = useHistory()
30+
const org = useSelector(getOrg)
31+
2332
if (!items.length) {
2433
return null
2534
}
@@ -44,15 +53,24 @@ const ClientLibrarySection = () => {
4453
Back-end, front-end, and mobile applications
4554
</Heading>
4655
<SquareGrid cardSize="170px" gutter={ComponentSize.Small}>
47-
{items.map(item => (
48-
<WriteDataItem
49-
key={item.id}
50-
id={item.id}
51-
name={item.name}
52-
image={item.logo}
53-
url={`${CLIENT_LIBS}/${item.id}`}
54-
/>
55-
))}
56+
{items.map(item => {
57+
const goto = () => {
58+
event('Load data client library clicked', {type: item.name})
59+
history.push(
60+
`/${ORGS}/${org.id}/load-data/${CLIENT_LIBS}/${item.id}`
61+
)
62+
}
63+
64+
return (
65+
<WriteDataItem
66+
key={item.id}
67+
id={item.id}
68+
name={item.name}
69+
image={item.logo}
70+
onClick={goto}
71+
/>
72+
)
73+
})}
5674
</SquareGrid>
5775
</div>
5876
)

src/writeData/components/FileUploadSection.tsx

Lines changed: 28 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,14 @@
11
// Libraries
22
import React, {useContext} from 'react'
3-
import {FILE_UPLOAD} from 'src/shared/constants/routes'
3+
import {useSelector} from 'react-redux'
4+
import {useHistory} from 'react-router-dom'
5+
import {ORGS, FILE_UPLOAD} from 'src/shared/constants/routes'
46
import {search} from 'src/writeData/constants/contentFileUploads'
57

8+
// Utils
9+
import {getOrg} from 'src/organizations/selectors'
10+
import {event} from 'src/cloud/utils/reporting'
11+
612
// Contexts
713
import {WriteDataSearchContext} from 'src/writeData/containers/WriteDataPage'
814

@@ -20,6 +26,9 @@ const FileUploadSection = () => {
2026
const {searchTerm} = useContext(WriteDataSearchContext)
2127
const items = search(searchTerm)
2228

29+
const history = useHistory()
30+
const org = useSelector(getOrg)
31+
2332
if (!items.length) {
2433
return null
2534
}
@@ -44,15 +53,24 @@ const FileUploadSection = () => {
4453
Upload line protocol or Annotated CSVs
4554
</Heading>
4655
<SquareGrid cardSize="170px" gutter={ComponentSize.Small}>
47-
{items.map(item => (
48-
<WriteDataItem
49-
key={item.id}
50-
id={item.id}
51-
name={item.name}
52-
image={item.image}
53-
url={`${FILE_UPLOAD}/${item.id}`}
54-
/>
55-
))}
56+
{items.map(item => {
57+
const goto = () => {
58+
event('Load data file upload clicked', {type: item.name})
59+
history.push(
60+
`/${ORGS}/${org.id}/load-data/${FILE_UPLOAD}/${item.id}`
61+
)
62+
}
63+
64+
return (
65+
<WriteDataItem
66+
key={item.id}
67+
id={item.id}
68+
name={item.name}
69+
image={item.image}
70+
onClick={goto}
71+
/>
72+
)
73+
})}
5674
</SquareGrid>
5775
</div>
5876
)

src/writeData/components/TelegrafPluginSection.tsx

Lines changed: 29 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,14 @@
11
// Libraries
22
import React, {useContext} from 'react'
3-
import {TELEGRAF_PLUGINS} from 'src/shared/constants/routes'
3+
import {useSelector} from 'react-redux'
4+
import {useHistory} from 'react-router-dom'
5+
import {ORGS, TELEGRAF_PLUGINS} from 'src/shared/constants/routes'
46
import {search} from 'src/writeData/constants/contentTelegrafPlugins'
57

8+
// Utils
9+
import {getOrg} from 'src/organizations/selectors'
10+
import {event} from 'src/cloud/utils/reporting'
11+
612
// Contexts
713
import {WriteDataSearchContext} from 'src/writeData/containers/WriteDataPage'
814

@@ -20,6 +26,9 @@ const TelegrafPluginSection = () => {
2026
const {searchTerm} = useContext(WriteDataSearchContext)
2127
const items = search(searchTerm)
2228

29+
const history = useHistory()
30+
const org = useSelector(getOrg)
31+
2332
if (!items.length) {
2433
return null
2534
}
@@ -46,16 +55,25 @@ const TelegrafPluginSection = () => {
4655
vast library of plugins
4756
</Heading>
4857
<SquareGrid cardSize="170px" gutter={ComponentSize.Small}>
49-
{items.map(item => (
50-
<WriteDataItem
51-
key={item.id}
52-
id={item.id}
53-
name={item.name}
54-
image={item.image}
55-
style={item.style}
56-
url={`${TELEGRAF_PLUGINS}/${item.id}`}
57-
/>
58-
))}
58+
{items.map(item => {
59+
const goto = () => {
60+
event('Load data Telegraf Plugin clicked', {type: item.name})
61+
history.push(
62+
`/${ORGS}/${org.id}/load-data/${TELEGRAF_PLUGINS}/${item.id}`
63+
)
64+
}
65+
66+
return (
67+
<WriteDataItem
68+
key={item.id}
69+
id={item.id}
70+
name={item.name}
71+
image={item.image}
72+
style={item.style}
73+
onClick={goto}
74+
/>
75+
)
76+
})}
5977
</SquareGrid>
6078
</div>
6179
)

src/writeData/components/WriteDataItem.tsx

Lines changed: 4 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -1,54 +1,35 @@
11
// Libraries
22
import React, {CSSProperties, FC, Suspense} from 'react'
3-
import {useSelector} from 'react-redux'
4-
import {useHistory} from 'react-router-dom'
53

64
// Components
75
import {SelectableCard, SquareGrid, ComponentSize} from '@influxdata/clockface'
86
const LazySVG = React.lazy(() => import('src/perf/components/LazySVG'))
97

10-
// Utils
11-
import {getOrg} from 'src/organizations/selectors'
12-
import {event} from 'src/cloud/utils/reporting'
13-
148
// Graphics
159
import placeholderLogo from 'src/writeData/graphics/placeholderLogo.svg'
1610

17-
// Constants
18-
import {ORGS} from 'src/shared/constants/routes'
19-
2011
// Styles
2112
import 'src/writeData/components/WriteDataItem.scss'
2213

2314
interface Props {
2415
id: string
2516
name: string
26-
url: string
2717
image?: string
2818
style?: CSSProperties
2919
selected?: boolean
30-
onClick?: any
20+
onClick: any
3121
testID?: string
3222
}
3323

3424
const WriteDataItem: FC<Props> = ({
3525
id,
3626
name,
37-
url,
3827
image,
3928
style,
4029
selected,
4130
onClick,
4231
testID,
4332
}) => {
44-
const history = useHistory()
45-
const org = useSelector(getOrg)
46-
47-
const handleClick = (): void => {
48-
event(`sources.load_data.${name}.clicked`)
49-
history.push(`/${ORGS}/${org.id}/load-data/${url}`)
50-
}
51-
5233
let thumb = <img src={placeholderLogo} />
5334
const svgStyle = style ? style : ({} as CSSProperties)
5435

@@ -60,34 +41,15 @@ const WriteDataItem: FC<Props> = ({
6041
)
6142
}
6243

63-
if (onClick) {
64-
return (
65-
<SquareGrid.Card key={id}>
66-
<SelectableCard
67-
id={id}
68-
formName="load-data-cards"
69-
label={name}
70-
selected={selected}
71-
onClick={onClick}
72-
testID={testID}
73-
fontSize={ComponentSize.ExtraSmall}
74-
className="write-data--item"
75-
>
76-
<div className="write-data--item-thumb">{thumb}</div>
77-
</SelectableCard>
78-
</SquareGrid.Card>
79-
)
80-
}
81-
8244
return (
8345
<SquareGrid.Card key={id}>
8446
<SelectableCard
8547
id={id}
8648
formName="load-data-cards"
8749
label={name}
88-
testID={`load-data-item ${id}`}
89-
selected={false}
90-
onClick={handleClick}
50+
selected={selected}
51+
onClick={onClick}
52+
testID={testID || `load-data-item ${id}`}
9153
fontSize={ComponentSize.ExtraSmall}
9254
className="write-data--item"
9355
>

0 commit comments

Comments
 (0)