Skip to content

Commit

Permalink
chore(feature flag copy): add event tracking (#19092)
Browse files Browse the repository at this point in the history
  • Loading branch information
jurajmajerik authored Dec 5, 2023
1 parent 3745d85 commit 10d0188
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
8 changes: 8 additions & 0 deletions frontend/src/lib/utils/eventUsageLogic.ts
Original file line number Diff line number Diff line change
Expand Up @@ -443,6 +443,8 @@ export const eventUsageLogic = kea<eventUsageLogicType>([
reportAutocaptureToggled: (autocapture_opt_out: boolean) => ({ autocapture_opt_out }),
reportAutocaptureExceptionsToggled: (autocapture_opt_in: boolean) => ({ autocapture_opt_in }),
reportFailedToCreateFeatureFlagWithCohort: (code: string, detail: string) => ({ code, detail }),
reportFeatureFlagCopySuccess: true,
reportFeatureFlagCopyFailure: (error) => ({ error }),
reportInviteMembersButtonClicked: true,
reportDashboardLoadingTime: (loadingMilliseconds: number, dashboardId: number) => ({
loadingMilliseconds,
Expand Down Expand Up @@ -1048,6 +1050,12 @@ export const eventUsageLogic = kea<eventUsageLogicType>([
reportFailedToCreateFeatureFlagWithCohort: ({ detail, code }) => {
posthog.capture('failed to create feature flag with cohort', { detail, code })
},
reportFeatureFlagCopySuccess: () => {
posthog.capture('feature flag copied')
},
reportFeatureFlagCopyFailure: ({ error }) => {
posthog.capture('feature flag copy failure', { error })
},
reportInviteMembersButtonClicked: () => {
posthog.capture('invite members button clicked')
},
Expand Down
7 changes: 4 additions & 3 deletions frontend/src/scenes/feature-flags/featureFlagLogic.ts
Original file line number Diff line number Diff line change
Expand Up @@ -795,10 +795,11 @@ export const featureFlagLogic = kea<featureFlagLogicType>([
? 'updated'
: 'copied'
lemonToast.success(`Feature flag ${operation} successfully!`)
eventUsageLogic.actions.reportFeatureFlagCopySuccess()
} else {
lemonToast.error(
`Error while saving feature flag: ${JSON.stringify(featureFlagCopy?.failed) || featureFlagCopy}`
)
const errorMessage = JSON.stringify(featureFlagCopy?.failed) || featureFlagCopy
lemonToast.error(`Error while saving feature flag: ${errorMessage}`)
eventUsageLogic.actions.reportFeatureFlagCopyFailure(errorMessage)
}

actions.loadProjectsWithCurrentFlag()
Expand Down

0 comments on commit 10d0188

Please sign in to comment.