: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.
Python ab-testingai-analyticsanalyticscdpdata-warehouseexperimentsfeature-flagsjavascriptproduct-analyticspythonreactsession-replaysurveystypescriptweb-analytics
// Must stay in sync with validate_saved_query_name in
// products/data_modeling/backend/models/datawarehouse_saved_query.py — the `.`
// is load-bearing and drives HogQL namespace nesting (see
// posthog/hogql/database/database.py splitting saved query names on `.`).
export const SAVED_QUERY_NAME_REGEX = /^[A-Za-z_$][A-Za-z0-9_.$]*$/
export const validateSavedQueryName = (name: string | undefined | null): string | undefined => {
if (!name) {
return 'You must enter a name'
}
if (name === 'models') {
return 'The models namespace needs a model name, for example models.revenue.'
}
if (!SAVED_QUERY_NAME_REGEX.test(name)) {
return "View names must start with a letter, '_', or '$' and can only contain letters, numbers, '_', '.', or '$'"
}
return undefined
}