mirror of
https://github.com/PostHog/posthog.git
synced 2024-11-24 09:14:46 +01:00
bee0b07c41
* feat(insights): Add filtering properties on labels * Add tests for event property querying using an alias * Make comments bidirectional * Revert trying to be clever with unknown * Fix failing tests * Improve query performance for property filtering * Improve efficiency of querying properties by alias * Remove old property name alias code * Add code to output PROPERTY_NAME_ALIASES * Add script for regenerating property name aliases
36 lines
1.1 KiB
TypeScript
36 lines
1.1 KiB
TypeScript
import { KEY_MAPPING } from 'lib/taxonomy'
|
|
|
|
// Creates PROPERTY_NAME_ALIASES in posthog/api/property_definition.py
|
|
// eslint-disable-next-line no-console
|
|
console.log(
|
|
JSON.stringify(
|
|
Object.fromEntries(
|
|
Array.from(Object.entries(KEY_MAPPING.event))
|
|
.map(([key, value]) => [key, value.label])
|
|
.filter(([key, label]) => {
|
|
if (!key) {
|
|
return false
|
|
}
|
|
if (!label || label.includes('deprecated')) {
|
|
return false
|
|
}
|
|
|
|
const keyLower = key.toLowerCase()
|
|
const labelLower = label.toLowerCase()
|
|
|
|
if (keyLower.includes(labelLower)) {
|
|
return false
|
|
}
|
|
|
|
const keyLowerNoSpecial = keyLower.replace(/[$_]+/g, ' ')
|
|
const labelWords = labelLower.split(/\s+/)
|
|
|
|
return !labelWords.every((word) => keyLowerNoSpecial.includes(word))
|
|
})
|
|
.sort()
|
|
),
|
|
null,
|
|
4
|
|
)
|
|
)
|