Skip to content

Commit c5c7bbb

Browse files
authored
fix: auditing more events (#4129)
1 parent e7bb4ec commit c5c7bbb

File tree

7 files changed

+52
-45
lines changed

7 files changed

+52
-45
lines changed

src/annotations/components/annotationForm/AnnotationForm.tsx

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -141,20 +141,25 @@ export const AnnotationForm: FC<Props> = (props: Props) => {
141141

142142
try {
143143
dispatch(deleteAnnotations(editedAnnotation))
144-
event(`${props.eventPrefix}.annotations.delete_annotation.success`)
144+
event(`annotations.delete_annotation.success`, {
145+
prefix: props.eventPrefix,
146+
})
145147
dispatch(notify(deleteAnnotationSuccess(editedAnnotation.summary)))
146148
props.onClose()
147149
} catch (err) {
148-
event(`${props.eventPrefix}.annotations.delete_annotation.failure`)
150+
event(`annotations.delete_annotation.failure`, {
151+
prefix: props.eventPrefix,
152+
})
149153
dispatch(notify(deleteAnnotationFailed(err)))
150154
}
151155
}
152156

153157
const handleCancel = () => {
154158
const annoMode = isEditing ? 'edit' : 'create'
155-
event(
156-
`${props.eventPrefix}.dashboards.annotations.${annoMode}_annotation.cancel`
157-
)
159+
event(`dashboards.annotations.cancel`, {
160+
prefix: props.eventPrefix,
161+
mode: annoMode,
162+
})
158163
props.onClose()
159164
}
160165

src/dataExplorer/components/SaveAsCellForm.tsx

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -208,17 +208,13 @@ class SaveAsCellForm extends PureComponent<Props, State> {
208208
)
209209
})
210210
this.props.setActiveTimeMachine('de', initialStateHelper())
211-
event(
212-
`data_explorer.${normalizeEventName(
213-
chartTypeName(view?.properties?.type)
214-
)}.save.as_dashboard_cell.success`
215-
)
211+
event(`data_explorer.save.as_dashboard_cell.success`, {
212+
which: normalizeEventName(chartTypeName(view?.properties?.type)),
213+
})
216214
} catch (error) {
217-
event(
218-
`data_explorer.${normalizeEventName(
219-
chartTypeName(view?.properties?.type)
220-
)}.save.as_dashboard_cell.failure`
221-
)
215+
event(`data_explorer.save.as_dashboard_cell.failure`, {
216+
which: normalizeEventName(chartTypeName(view?.properties?.type)),
217+
})
222218
console.error(error)
223219
dismiss()
224220
} finally {

src/dataLoaders/actions/dataLoaders.ts

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -420,10 +420,10 @@ export const createOrUpdateTelegrafConfigAsync = () => async (
420420

421421
dispatch(editTelegraf(normTelegraf))
422422
dispatch(setTelegrafConfigID(telegrafConfigID))
423-
event(
424-
`telegraf.config.${normalizeEventName(telegrafConfigName)}.edit.success`,
425-
{id: telegraf?.id}
426-
)
423+
event(`telegraf.config.edit.success`, {
424+
id: telegraf?.id,
425+
name: normalizeEventName(telegrafConfigName),
426+
})
427427
return
428428
}
429429

@@ -578,13 +578,15 @@ const createTelegraf = async (dispatch, getState: GetState, plugins) => {
578578
dispatch(setTelegrafConfigID(tc.id))
579579
dispatch(addTelegraf(normTelegraf))
580580
dispatch(notify(TelegrafConfigCreationSuccess))
581-
event(`telegraf.config.${normalizeEventName(configName)}.create.success`, {
581+
event(`telegraf.config.create.success`, {
582582
id: tc.id,
583583
bucket: bucketName,
584+
name: normalizeEventName(configName),
584585
})
585586
} catch (error) {
586-
event(`telegraf.config.${normalizeEventName(configName)}.create.failure`, {
587+
event(`telegraf.config.create.failure`, {
587588
bucket: bucketName,
589+
name: normalizeEventName(configName),
588590
})
589591
console.error(error.message)
590592
dispatch(notify(TelegrafConfigCreationError))

src/shared/components/cells/Cell.tsx

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -55,11 +55,9 @@ class CellComponent extends Component<Props, State> {
5555
public componentDidMount() {
5656
const {view} = this.props
5757
if (view) {
58-
event(
59-
`dashboard.cell.view.${normalizeEventName(
60-
chartTypeName(view?.properties?.type)
61-
)}`
62-
)
58+
event(`dashboard.cell.view`, {
59+
type: normalizeEventName(chartTypeName(view?.properties?.type)),
60+
})
6361
}
6462
}
6563

src/templates/components/CommunityTemplateInstallOverlay.test.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,7 @@ describe('the Community Templates Install Overlay', () => {
151151

152152
const [, , installEventCallArguments] = mocked(event).mock.calls
153153
const [eventName2] = installEventCallArguments
154-
expect(eventName2).toBe('community_template.fn-template.install.failure')
154+
expect(eventName2).toBe('community_template.install.failure')
155155

156156
const [notifyCallArguments] = mocked(notify).mock.calls
157157
const [notifyMessage] = notifyCallArguments
@@ -225,7 +225,7 @@ describe('the Community Templates Install Overlay', () => {
225225

226226
const [, , , ctInstallEventCallArguments] = mocked(event).mock.calls
227227
const [eventName4] = ctInstallEventCallArguments
228-
expect(eventName4).toBe('community_template.fn-template.install.success')
228+
expect(eventName4).toBe('community_template.install.success')
229229
})
230230
})
231231
})

src/templates/components/CommunityTemplateInstallOverlay.tsx

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -152,19 +152,15 @@ class CommunityTemplateInstallOverlayUnconnected extends PureComponent<Props> {
152152

153153
this.props.getBuckets()
154154
this.props.notify(communityTemplateInstallSucceeded(templateName))
155-
event(
156-
`community_template.${normalizeEventName(
157-
templateDetails.name
158-
)}.install.success`,
159-
{templateUrl}
160-
)
155+
event(`community_template.install.success`, {
156+
templateUrl,
157+
name: normalizeEventName(templateDetails.name),
158+
})
161159
} catch (err) {
162-
event(
163-
`community_template.${normalizeEventName(
164-
templateName
165-
)}.install.failure`,
166-
{templateUrl}
167-
)
160+
event(`community_template.install.failure`, {
161+
templateUrl,
162+
name: normalizeEventName(templateName),
163+
})
168164
this.props.notify(communityTemplateRenameFailed())
169165
} finally {
170166
this.props.fetchAndSetStacks(this.props.org.id)

src/visualization/utils/annotationUtils.ts

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -43,10 +43,16 @@ const makeCreateMethod = (
4343
},
4444
])
4545
)
46-
event(`${eventPrefix}.annotations.create_${type}_annotation.create`)
46+
event(`annotations.create_annotation.create`, {
47+
prefix: eventPrefix,
48+
type,
49+
})
4750
} catch (err) {
4851
dispatch(notify(createAnnotationFailed(getErrorMessage(err))))
49-
event(`${eventPrefix}.annotations.create_${type}_annotation.failure`)
52+
event(`annotations.create_annotation.failure`, {
53+
prefix: eventPrefix,
54+
type,
55+
})
5056
}
5157
}
5258

@@ -63,7 +69,7 @@ const makeAnnotationClickListener = (
6369
const createAnnotation = makeCreateMethod(dispatch, cellID, eventPrefix)
6470

6571
const singleClickHandler = (plotInteraction: InteractionHandlerArguments) => {
66-
event(`${eventPrefix}.annotations.create_annotation.show_overlay`)
72+
event(`annotations.create_annotation.show_overlay`, {prefix: eventPrefix})
6773

6874
dispatch(
6975
showOverlay(
@@ -92,7 +98,9 @@ const makeAnnotationRangeListener = (
9298
const createAnnotation = makeCreateMethod(dispatch, cellID, eventPrefix)
9399

94100
const rangeHandler = (start: number | string, end: number | string) => {
95-
event(`${eventPrefix}.annotations.create_range_annotation.show_overlay`)
101+
event(`annotations.create_range_annotation.show_overlay`, {
102+
prefix: eventPrefix,
103+
})
96104
dispatch(
97105
showOverlay(
98106
'add-annotation',
@@ -136,7 +144,9 @@ const makeAnnotationClickHandler = (
136144
annotation => annotation.id === id
137145
)
138146
if (annotationToEdit) {
139-
event(`${eventPrefix}.annotations.edit_annotation.show_overlay`)
147+
event(`annotations.edit_annotation.show_overlay`, {
148+
prefix: eventPrefix,
149+
})
140150
dispatch(
141151
showOverlay(
142152
'edit-annotation',

0 commit comments

Comments
 (0)