Skip to content

Commit

Permalink
chore(data-warehouse): Added tracking events to data warehouse (#23223)
Browse files Browse the repository at this point in the history
* Added tracking events to data warehouse

* Added has_data_warehouse_series
  • Loading branch information
Gilbert09 authored Jul 1, 2024
1 parent 01dabd0 commit 51ccb84
Show file tree
Hide file tree
Showing 7 changed files with 37 additions and 0 deletions.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions frontend/src/lib/utils/eventUsageLogic.ts
Original file line number Diff line number Diff line change
Expand Up @@ -246,6 +246,7 @@ function sanitizeQuery(query: Node | null): Record<string, string | number | boo
payload.event_entity_count = getSeries(querySource)?.filter((e) => isEventsNode(e)).length
payload.action_entity_count = getSeries(querySource)?.filter((e) => isActionsNode(e)).length
payload.data_warehouse_entity_count = getSeries(querySource)?.filter((e) => isDataWarehouseNode(e)).length
payload.has_data_warehouse_series = !!getSeries(querySource)?.find((e) => isDataWarehouseNode(e))

// properties
payload.has_properties = !!properties
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { lemonToast } from '@posthog/lemon-ui'
import { actions, connect, kea, listeners, path, reducers, selectors } from 'kea'
import api from 'lib/api'
import posthog from 'posthog-js'
import { databaseTableListLogic } from 'scenes/data-management/database/databaseTableListLogic'

import { DatabaseSchemaTable, DatabaseSerializedFieldType } from '~/queries/schema'
Expand Down Expand Up @@ -189,6 +190,13 @@ export const dataWarehouseSceneLogic = kea<dataWarehouseSceneLogicType>([
try {
await api.dataWarehouseTables.updateSchema(tableId, schemaUpdates)
actions.loadDatabase()

if (values.selectedRow) {
posthog.capture('source schema saved', {
name: values.selectedRow.name,
tableType: values.selectedRow.type,
})
}
} catch (e: any) {
lemonToast.error(e.message)
actions.setEditSchemaIsLoading(false)
Expand All @@ -212,5 +220,13 @@ export const dataWarehouseSceneLogic = kea<dataWarehouseSceneLogicType>([
actions.selectRow(null)
lemonToast.success('Table successfully deleted')
},
toggleSchemaModal: () => {
if (values.schemaModalIsOpen && values.selectedRow) {
posthog.capture('source schema viewed', {
name: values.selectedRow.name,
tableType: values.selectedRow.type,
})
}
},
})),
])
3 changes: 3 additions & 0 deletions frontend/src/scenes/data-warehouse/new/sourceWizardLogic.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { actions, connect, kea, listeners, path, reducers, selectors } from 'kea
import { forms } from 'kea-forms'
import { router, urlToAction } from 'kea-router'
import api from 'lib/api'
import posthog from 'posthog-js'
import { preflightLogic } from 'scenes/PreflightCheck/preflightLogic'
import { Scene } from 'scenes/sceneTypes'
import { urls } from 'scenes/urls'
Expand Down Expand Up @@ -666,6 +667,7 @@ export const sourceWizardLogic = kea<sourceWizardLogicType>([
actions.submitSourceConnectionDetails()
} else if (values.currentStep === 2 && values.isManualLinkFormVisible) {
dataWarehouseTableLogic.actions.submitTable()
posthog.capture('source created', { sourceType: 'Manual' })
}

if (values.currentStep === 3 && values.selectedConnector?.name) {
Expand All @@ -682,6 +684,7 @@ export const sourceWizardLogic = kea<sourceWizardLogicType>([
})
actions.setIsLoading(true)
actions.createSource()
posthog.capture('source created', { sourceType: values.selectedConnector.name })
}

if (values.currentStep === 4) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { loaders } from 'kea-loaders'
import { actionToUrl, urlToAction } from 'kea-router'
import api, { ApiMethodOptions, PaginatedResponse } from 'lib/api'
import { lemonToast } from 'lib/lemon-ui/LemonToast/LemonToast'
import posthog from 'posthog-js'
import { databaseTableListLogic } from 'scenes/data-management/database/databaseTableListLogic'
import { Scene } from 'scenes/sceneTypes'
import { urls } from 'scenes/urls'
Expand Down Expand Up @@ -194,6 +195,8 @@ export const dataWarehouseSettingsLogic = kea<dataWarehouseSettingsLogicType>([
await api.externalDataSources.delete(source.id)
actions.loadSources(null)
actions.sourceLoadingFinished(source)

posthog.capture('source deleted', { sourceType: source.source_type })
},
reloadSource: async ({ source }) => {
// Optimistic UI updates before sending updates to the backend
Expand Down Expand Up @@ -221,6 +224,8 @@ export const dataWarehouseSettingsLogic = kea<dataWarehouseSettingsLogicType>([
try {
await api.externalDataSources.reload(source.id)
actions.loadSources(null)

posthog.capture('source reloaded', { sourceType: source.source_type })
} catch (e: any) {
if (e.message) {
lemonToast.error(e.message)
Expand Down Expand Up @@ -249,6 +254,8 @@ export const dataWarehouseSettingsLogic = kea<dataWarehouseSettingsLogicType>([
await api.externalDataSchemas.reload(schema.id)
actions.schemaLoadingFinished(schema)
actions.loadSources(null)

posthog.capture('schema reloaded', { sourceType: clonedSources[sourceIndex].source_type })
} catch (e: any) {
if (e.message) {
lemonToast.error(e.message)
Expand Down Expand Up @@ -276,6 +283,8 @@ export const dataWarehouseSettingsLogic = kea<dataWarehouseSettingsLogicType>([
await api.externalDataSchemas.resync(schema.id)
actions.schemaLoadingFinished(schema)
actions.loadSources(null)

posthog.capture('schema resynced', { sourceType: clonedSources[sourceIndex].source_type })
} catch (e: any) {
if (e.message) {
lemonToast.error(e.message)
Expand All @@ -290,6 +299,9 @@ export const dataWarehouseSettingsLogic = kea<dataWarehouseSettingsLogicType>([
cache.abortController = null
}
},
updateSchema: (schema) => {
posthog.capture('schema updated', { shouldSync: schema.should_sync, syncType: schema.sync_type })
},
})),
afterMount(({ actions }) => {
actions.loadSources(null)
Expand Down
5 changes: 5 additions & 0 deletions frontend/src/scenes/data-warehouse/viewLinkLogic.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { actions, connect, kea, listeners, path, reducers, selectors } from 'kea
import { forms } from 'kea-forms'
import { subscriptions } from 'kea-subscriptions'
import api from 'lib/api'
import posthog from 'posthog-js'
import { databaseTableListLogic } from 'scenes/data-management/database/databaseTableListLogic'

import { DataWarehouseViewLink } from '~/types'
Expand Down Expand Up @@ -141,6 +142,8 @@ export const viewLinkLogic = kea<viewLinkLogicType>([
actions.loadJoins()

actions.loadDatabase()

posthog.capture('join updated')
} catch (error: any) {
actions.setError(error.detail)
}
Expand All @@ -159,6 +162,8 @@ export const viewLinkLogic = kea<viewLinkLogicType>([
actions.loadJoins()

actions.loadDatabase()

posthog.capture('join created')
} catch (error: any) {
actions.setError(error.detail)
}
Expand Down

0 comments on commit 51ccb84

Please sign in to comment.