mirror of
https://github.com/hanzoai/insights.git
synced 2026-10-30 16:15:31 +00:00
The tree was a debranded snapshot of upstream taken around 2026-02-20, and upstream has moved about five months since. This replaces it with upstream master, mechanically re-derived: bin/debrand does the rename, and the pipeline and squashed migrations are restored from the shipped tree. Not a merge. The previous import replaced the tree wholesale in a single commit, so there is no shared content history to merge against. Reproducing the rename on the new tree is what actually converges. What survives: .hanzo/workflows, the Dockerfiles and bin/docker* entrypoints, compose files, LLM.md, and insights/migrations. The squashed initial migration is load-bearing — the live database records it by name, so upstream's ~918 individual migrations cannot come back. Nine products are dropped as unreferenced. Twenty-one more that we do not run are kept anyway because the core app still imports them; unpicking those is a refactor and does not belong in a rebase. This base does not build yet, and the reasons are not in the rename: upstream now wants Python 3.13.13 against our 3.12.12 and Django 5.2 against our 4.2, and the dependency manifests still name upstream packages that we republish under our own names. Those are decisions, not renames.
226 lines
7.2 KiB
TypeScript
226 lines
7.2 KiB
TypeScript
import { MakeLogicType, actions, afterMount, connect, kea, key, listeners, path, props, selectors } from 'kea'
|
|
import { loaders } from 'kea-loaders'
|
|
|
|
import api from 'lib/api'
|
|
import { toast } from 'lib/elements/Toast/Toast'
|
|
import { teamLogic } from 'scenes/teamLogic'
|
|
|
|
import { CustomerProfileConfigType, CustomerProfileScope } from '~/types'
|
|
|
|
export interface CustomerProfileConfigLogicProps {
|
|
scope?: CustomerProfileScope
|
|
}
|
|
|
|
// Generated by kea-typegen. Update if you're an agent, ignore if you're human.
|
|
export interface customerProfileConfigLogicValues {
|
|
currentTeamId: number | null // teamLogic
|
|
configs: CustomerProfileConfigType[]
|
|
configsLoading: boolean
|
|
customerProfileConfig: CustomerProfileConfigType | undefined
|
|
}
|
|
|
|
// Generated by kea-typegen. Update if you're an agent, ignore if you're human.
|
|
export interface customerProfileConfigLogicActions {
|
|
createConfig: (config: Partial<CustomerProfileConfigType>) => {
|
|
config: Partial<CustomerProfileConfigType>
|
|
}
|
|
createConfigFailure: (
|
|
error: string,
|
|
errorObject?: any
|
|
) => {
|
|
error: string
|
|
errorObject?: any
|
|
}
|
|
createConfigSuccess: (
|
|
configs: CustomerProfileConfigType[],
|
|
payload?: {
|
|
config: Partial<CustomerProfileConfigType>
|
|
}
|
|
) => {
|
|
configs: CustomerProfileConfigType[]
|
|
payload?: {
|
|
config: Partial<CustomerProfileConfigType>
|
|
}
|
|
}
|
|
deleteConfig: (id: CustomerProfileConfigType['id']) => {
|
|
id: string
|
|
}
|
|
deleteConfigFailure: (
|
|
error: string,
|
|
errorObject?: any
|
|
) => {
|
|
error: string
|
|
errorObject?: any
|
|
}
|
|
deleteConfigSuccess: (
|
|
configs: CustomerProfileConfigType[],
|
|
payload?: {
|
|
id: string
|
|
}
|
|
) => {
|
|
configs: CustomerProfileConfigType[]
|
|
payload?: {
|
|
id: string
|
|
}
|
|
}
|
|
loadConfigs: () => {
|
|
value: true
|
|
}
|
|
loadConfigsFailure: (
|
|
error: string,
|
|
errorObject?: any
|
|
) => {
|
|
error: string
|
|
errorObject?: any
|
|
}
|
|
loadConfigsSuccess: (
|
|
configs: CustomerProfileConfigType[],
|
|
payload?: {
|
|
value: true
|
|
}
|
|
) => {
|
|
configs: CustomerProfileConfigType[]
|
|
payload?: {
|
|
value: true
|
|
}
|
|
}
|
|
setConfigs: (configs: CustomerProfileConfigType[]) => {
|
|
configs: CustomerProfileConfigType[]
|
|
}
|
|
updateConfig: (
|
|
id: CustomerProfileConfigType['id'],
|
|
config: Partial<CustomerProfileConfigType>
|
|
) => {
|
|
config: Partial<CustomerProfileConfigType>
|
|
id: string
|
|
}
|
|
updateConfigFailure: (
|
|
error: string,
|
|
errorObject?: any
|
|
) => {
|
|
error: string
|
|
errorObject?: any
|
|
}
|
|
updateConfigSuccess: (
|
|
configs: CustomerProfileConfigType[],
|
|
payload?: {
|
|
config: Partial<CustomerProfileConfigType>
|
|
id: string
|
|
}
|
|
) => {
|
|
configs: CustomerProfileConfigType[]
|
|
payload?: {
|
|
config: Partial<CustomerProfileConfigType>
|
|
id: string
|
|
}
|
|
}
|
|
}
|
|
|
|
// Generated by kea-typegen. Update if you're an agent, ignore if you're human.
|
|
export interface customerProfileConfigLogicMeta {
|
|
key: CustomerProfileScope | 'all'
|
|
__keaTypeGenInternalSelectorTypes: {
|
|
customerProfileConfig: (configs: CustomerProfileConfigType[], arg: any) => CustomerProfileConfigType | undefined
|
|
}
|
|
}
|
|
|
|
export type customerProfileConfigLogicType = MakeLogicType<
|
|
customerProfileConfigLogicValues,
|
|
customerProfileConfigLogicActions,
|
|
CustomerProfileConfigLogicProps,
|
|
customerProfileConfigLogicMeta
|
|
>
|
|
|
|
export const customerProfileConfigLogic = kea<customerProfileConfigLogicType>([
|
|
path(['products', 'customer_analytics', 'customerProfileConfigLogic']),
|
|
props({} as CustomerProfileConfigLogicProps),
|
|
key((props) => props.scope || 'all'),
|
|
|
|
connect(() => ({
|
|
values: [teamLogic, ['currentTeamId']],
|
|
})),
|
|
|
|
actions({
|
|
loadConfigs: true,
|
|
createConfig: (config: Partial<CustomerProfileConfigType>) => ({ config }),
|
|
updateConfig: (id: CustomerProfileConfigType['id'], config: Partial<CustomerProfileConfigType>) => ({
|
|
id,
|
|
config,
|
|
}),
|
|
deleteConfig: (id: CustomerProfileConfigType['id']) => ({ id }),
|
|
setConfigs: (configs: CustomerProfileConfigType[]) => ({ configs }),
|
|
}),
|
|
|
|
loaders(({ props, values }) => ({
|
|
configs: [
|
|
[] as CustomerProfileConfigType[],
|
|
{
|
|
loadConfigs: async () => {
|
|
try {
|
|
const params = props.scope ? { scope: props.scope } : {}
|
|
const response = await api.customerProfileConfigs.list(params)
|
|
return response.results
|
|
} catch (error) {
|
|
toast.error('Failed to load customer profile configs')
|
|
throw error
|
|
}
|
|
},
|
|
createConfig: async ({ config }) => {
|
|
try {
|
|
const newConfig = await api.customerProfileConfigs.create(config)
|
|
toast.success('Customer profile config created successfully')
|
|
return [...values.configs, newConfig]
|
|
} catch (error) {
|
|
toast.error('Failed to create customer profile config')
|
|
throw error
|
|
}
|
|
},
|
|
updateConfig: async ({ id, config }) => {
|
|
try {
|
|
const updatedConfig = await api.customerProfileConfigs.update(id, config)
|
|
toast.success('Customer profile config updated successfully')
|
|
return values.configs.map((c) => (c.id === id ? updatedConfig : c))
|
|
} catch (error) {
|
|
toast.error('Failed to update customer profile config')
|
|
throw error
|
|
}
|
|
},
|
|
deleteConfig: async ({ id }) => {
|
|
try {
|
|
await api.customerProfileConfigs.delete(id)
|
|
toast.success('Customer profile config deleted successfully')
|
|
return values.configs.filter((c) => c.id !== id)
|
|
} catch (error) {
|
|
toast.error('Failed to delete customer profile config')
|
|
throw error
|
|
}
|
|
},
|
|
},
|
|
],
|
|
})),
|
|
|
|
selectors({
|
|
customerProfileConfig: [
|
|
(s) => [s.configs, (_, props) => props.scope],
|
|
(configs: CustomerProfileConfigType[], scope): CustomerProfileConfigType | undefined =>
|
|
configs.find((c) => c.scope === scope),
|
|
],
|
|
}),
|
|
|
|
listeners(({ actions }) => ({
|
|
createConfigSuccess: () => {
|
|
actions.loadConfigs()
|
|
},
|
|
updateConfigSuccess: () => {
|
|
actions.loadConfigs()
|
|
},
|
|
deleteConfigSuccess: () => {
|
|
actions.loadConfigs()
|
|
},
|
|
})),
|
|
|
|
afterMount(({ actions }) => {
|
|
actions.loadConfigs()
|
|
}),
|
|
])
|