Files
zeekay ec6f6b50c1 chore: kill ALL posthog — zero refs, zero filenames (1452 -> 0)
We own the ingestion server (hanzoai/insights: Django + rust/capture + nodejs
plugin) AND this SDK, so there is no external wire contract to preserve. The
server is already 100% posthog-free; this SDK was the last laggard.

- $last_posthog_reset -> $last_insights_reset. This FIXES A LIVE MISMATCH: the
  server taxonomy (insights/taxonomy/taxonomy.py, insights/insightsql/ai.py)
  already expected the insights form while the SDK emitted the posthog form.
- __PosthogExtensions__ -> __InsightsExtensions__; all PostHog/posthog/POSTHOG
  identifiers -> Insights/insights/INSIGHTS (src, tests, playground, playwright,
  scripts, rrweb subpackages, package.json keywords).
- Hosts: DEFAULT_PLUGIN_HOST + DEFAULT_NUXT_HOST + the core host default pointed
  at PostHog's cloud (us.i.posthog.com) — a real bug. All -> insights.hanzo.ai.
- Removed the us-assets/eu-assets CDN split in getRemoteConfig (PostHog-specific;
  Hanzo serves remote config from the same host) — it had degenerated to a no-op.
- Fixed generate-docs writing to a stray references/@hanzo/ subdir.
- Renamed the 3 posthog-named test files; dropped 58MB of stale reference
  snapshots named for upstream posthog versions we never shipped (they are
  generated output — references/ is now gitignored).

Verified: typecheck errors 42 (HEAD) -> 18 (all pre-existing test-mock
looseness); types package 0; every package.json valid with @hanzo/* names.
Guard: grep -rioE 'posthog' packages ... | wc -l  => 0
2026-07-16 09:09:18 -07:00

94 lines
2.6 KiB
TypeScript

import { describe, expect, it } from '@jest/globals'
import { Survey, SurveyQuestionType, SurveyType } from '@hanzo/insights-core'
import { applySurveyTranslationForUser, detectUserLanguage } from '../src/surveys/survey-translations'
import { Insights } from '../src/insights-rn'
const createBaseSurvey = (): Survey => ({
id: 'test-survey',
name: 'Test Survey',
type: SurveyType.Popover,
questions: [
{
id: 'q1',
type: SurveyQuestionType.Open,
question: 'What do you think?',
originalQuestionIndex: 0,
},
],
appearance: {
thankYouMessageHeader: 'Thank you!',
thankYouMessageDescription: 'We appreciate your feedback',
thankYouMessageCloseButtonText: 'Close',
},
})
const createMockInsights = ({
overrideLanguage,
storedPersonProperties,
locale,
}: {
overrideLanguage?: string | null
storedPersonProperties?: unknown
locale?: string | null
}): Insights =>
({
getSurveyDisplayLanguageOverride: () => overrideLanguage ?? null,
getPersistedProperty: jest.fn(() => storedPersonProperties),
getCommonEventProperties: jest.fn(() => ({ $locale: locale ?? null })),
}) as unknown as Insights
describe('react native survey translations', () => {
it('prioritizes overrideDisplayLanguage over person properties and locale', () => {
const insights = createMockInsights({
overrideLanguage: 'de',
storedPersonProperties: { language: 'es' },
locale: 'fr',
})
expect(detectUserLanguage(insights)).toBe('de')
})
it('falls back to person properties and then locale', () => {
expect(
detectUserLanguage(
createMockInsights({
storedPersonProperties: { language: 'es' },
locale: 'fr',
})
)
).toBe('es')
expect(
detectUserLanguage(
createMockInsights({
storedPersonProperties: { some_other_property: 'value' },
locale: 'pt-BR',
})
)
).toBe('pt-BR')
})
it('applies translated survey copy for the detected user language', () => {
const insights = createMockInsights({ locale: 'pt-BR' })
const survey = createBaseSurvey()
survey.translations = {
pt: {
name: 'Pesquisa Teste',
thankYouMessageHeader: 'Obrigado!',
},
}
survey.questions[0].translations = {
pt: {
question: 'O que voce acha?',
},
}
const result = applySurveyTranslationForUser(survey, insights)
expect(result.survey.name).toBe('Pesquisa Teste')
expect(result.survey.questions[0].question).toBe('O que voce acha?')
expect(result.survey.appearance?.thankYouMessageHeader).toBe('Obrigado!')
expect(result.language).toBe('pt')
})
})