Skip to content

:hedgehog: PostHog is the leading platform for building self-driving products. Our developer tools – AI observability, analytics, session replay, flags, experiments, error tracking, logs, and more – capture all the context agents need to diagnose problems, uncover opportunities, and ship fixes. Steer it all from Slack, web, desktop, or the MCP.

feat(data-warehouse): report file-upload outcomes so the catalog funnel isn't blind (#80482)

Tom Owers59422652ce7d
diff --git a/products/data_warehouse/frontend/scenes/NewSourceScene/fileUploadSource.ts b/products/data_warehouse/frontend/scenes/NewSourceScene/fileUploadSource.ts
index 97cdf484bb40..a83d232ccb41 100644
--- a/products/data_warehouse/frontend/scenes/NewSourceScene/fileUploadSource.ts
+++ b/products/data_warehouse/frontend/scenes/NewSourceScene/fileUploadSource.ts
@@ -29,6 +29,17 @@ export const FILE_UPLOAD_FORMATS: { format: FileUploadFormat; label: string; key
{ format: 'parquet', label: 'Parquet file', keywords: ['parquet', 'pqt', 'columnar', 'upload'] },
]
+/**
+ * Identifier for one format's catalog tile, e.g. `FileUpload-csv`.
+ *
+ * The catalog tile and the analytics events both key off this, so a pick and the table it produced
+ * join on one value. There is no external data source row to join against instead — an upload
+ * becomes a self-managed table — so this string is the only link between the two halves.
+ */
+export function fileUploadSourceType(format: FileUploadFormat): string {
+ return `${FILE_UPLOAD_SOURCE_NAME}-${format}`
+}
+
export function fileUploadSourceUrl(format: FileUploadFormat): string {
const url = urls.dataWarehouseSourceNew(FILE_UPLOAD_SOURCE_NAME)
return `${url}${url.includes('?') ? '&' : '?'}format=${format}`
diff --git a/products/data_warehouse/frontend/scenes/NewSourceScene/fileUploadSourceLogic.tsx b/products/data_warehouse/frontend/scenes/NewSourceScene/fileUploadSourceLogic.tsx
index 22faa65b521f..e1839e33398a 100644
--- a/products/data_warehouse/frontend/scenes/NewSourceScene/fileUploadSourceLogic.tsx
+++ b/products/data_warehouse/frontend/scenes/NewSourceScene/fileUploadSourceLogic.tsx
@@ -2,6 +2,7 @@ import { MakeLogicType, actions, connect, kea, listeners, path, reducers } from
import { forms } from 'kea-forms'
import type { DeepPartial, DeepPartialMap, FieldName, ValidationErrorType } from 'kea-forms'
import { router, urlToAction } from 'kea-router'
+import posthog from 'posthog-js'
import { lemonToast } from '@posthog/lemon-ui'
@@ -9,7 +10,7 @@ import api from 'lib/api'
import { databaseTableListLogic } from 'scenes/data-management/database/databaseTableListLogic'
import { urls } from 'scenes/urls'
-import { FileUploadFormat } from './fileUploadSource'
+import { FileUploadFormat, fileUploadSourceType } from './fileUploadSource'
// Mirrors MAX_FILE_UPLOAD_SIZE_BYTES on the backend. Checked here too so an oversized file fails
// instantly instead of after uploading 50MB+ only to be rejected.
@@ -40,6 +41,20 @@ const EXTENSION_FORMATS: Record<string, FileUploadFormat> = {
const SPREADSHEET_EXTENSIONS = new Set(['xlsx', 'xls', 'xlsm', 'xlsb', 'ods', 'numbers'])
+/** Which step of the two-request upload failed. */
+type FileUploadStage = 'upload' | 'create_table'
+
+function captureFileUploadFailed(format: FileUploadFormat, stage: FileUploadStage, error: any): void {
+ posthog.capture('warehouse file upload failed', {
+ sourceType: fileUploadSourceType(format),
+ stage,
+ status: error?.status ?? null,
+ // Every message this endpoint returns is a fixed server-authored string, so it names the
+ // reason without carrying the filename or anything read out of the file.
+ error: error?.data?.message ?? error?.message ?? 'unknown',
+ })
+}
+
function fileExtension(filename: string): string {
const match = /\.([^.]+)$/.exec(filename.toLowerCase())
return match ? match[1] : ''
@@ -234,6 +249,7 @@ export const fileUploadSourceLogic = kea<fileUploadSourceLogicType>([
try {
upload = await api.dataWarehouseTables.uploadFile(formData)
} catch (e: any) {
+ captureFileUploadFailed(file_format, 'upload', e)
lemonToast.error(e.data?.message ?? e.message ?? 'Could not upload the file.')
return
}
@@ -246,10 +262,12 @@ export const fileUploadSourceLogic = kea<fileUploadSourceLogicType>([
table_name,
})
} catch (e: any) {
+ captureFileUploadFailed(file_format, 'create_table', e)
lemonToast.error(e.data?.message ?? e.message ?? 'Could not create the table.')
return
}
+ posthog.capture('source created', { sourceType: fileUploadSourceType(file_format) })
lemonToast.success(`Table ${table_name} created`)
actions.loadDatabase()
router.actions.replace(urls.sources())
diff --git a/products/data_warehouse/frontend/scenes/NewSourceScene/sourceCatalogLogic.ts b/products/data_warehouse/frontend/scenes/NewSourceScene/sourceCatalogLogic.ts
index b9546e5a5085..6101185ce5b2 100644
--- a/products/data_warehouse/frontend/scenes/NewSourceScene/sourceCatalogLogic.ts
+++ b/products/data_warehouse/frontend/scenes/NewSourceScene/sourceCatalogLogic.ts
@@ -27,6 +27,7 @@ import {
FILE_UPLOAD_FORMATS,
FILE_UPLOAD_SOURCE_CONFIG,
FILE_UPLOAD_SOURCE_NAME,
+ fileUploadSourceType,
fileUploadSourceUrl,
} from './fileUploadSource'
import { sourceWizardLogic } from './sourceWizardLogic'
@@ -1579,7 +1580,7 @@ export const sourceCatalogLogic = kea<sourceCatalogLogicType>([
// three tiles, one per format, since users search for "CSV" rather than "File upload".
const fileUpload = FILE_UPLOAD_FORMATS.map(
({ format, label, keywords }): CatalogItem => ({
- name: `${FILE_UPLOAD_SOURCE_NAME}-${format}`,
+ name: fileUploadSourceType(format),
label,
iconType: FILE_UPLOAD_SOURCE_NAME,
category: MANUAL_SOURCE_CATEGORY,