rebrand: purge remaining PostHog references

This commit is contained in:
Hanzo Dev
2026-03-13 17:25:49 -07:00
parent c3efd3a149
commit 923e6dbcdd
7 changed files with 42 additions and 46 deletions
+2 -2
View File
@@ -21,8 +21,8 @@ OIDC_MANAGEMENT_API_AUDIENCE=
DEFAULT_SNAPSHOT=ubuntu:22.04
DASHBOARD_URL=http://localhost:3000/dashboard
POSTHOG_API_KEY=
POSTHOG_HOST=
INSIGHTS_API_KEY=
INSIGHTS_HOST=
TRANSIENT_REGISTRY_URL=http://registry:5000
TRANSIENT_REGISTRY_ADMIN=admin
@@ -13,7 +13,7 @@ import { SandboxPublicStatusUpdatedEvent } from '../../sandbox/events/sandbox-pu
import { SandboxStartedEvent } from '../../sandbox/events/sandbox-started.event'
import { SandboxStateUpdatedEvent } from '../../sandbox/events/sandbox-state-updated.event'
import { SandboxStoppedEvent } from '../../sandbox/events/sandbox-stopped.event'
import { PostHog } from 'posthog-node'
import { PostHog as Insights } from '@hanzo/insights-node'
import { OnAsyncEvent } from '../../common/decorators/on-async-event.decorator'
import { Organization } from '../../organization/entities/organization.entity'
import { OrganizationEvents } from '../../organization/constants/organization-events.constant'
@@ -21,21 +21,19 @@ import { OrganizationEvents } from '../../organization/constants/organization-ev
@Injectable()
export class AnalyticsService {
private readonly logger = new Logger(AnalyticsService.name)
private readonly posthog?: PostHog
private readonly insights?: Insights
constructor() {
if (!process.env.POSTHOG_API_KEY) {
if (!process.env.INSIGHTS_API_KEY) {
return
}
if (!process.env.POSTHOG_HOST) {
if (!process.env.INSIGHTS_HOST) {
return
}
// Initialize PostHog client
// Make sure to set POSTHOG_API_KEY in your environment variables
this.posthog = new PostHog(process.env.POSTHOG_API_KEY, {
host: process.env.POSTHOG_HOST,
this.insights = new Insights(process.env.INSIGHTS_API_KEY, {
host: process.env.INSIGHTS_HOST,
})
}
@@ -82,11 +80,11 @@ export class AnalyticsService {
return
}
if (!this.posthog) {
if (!this.insights) {
return
}
this.posthog.groupIdentify({
this.insights.groupIdentify({
groupType: 'organization',
groupKey: payload.id,
properties: {
@@ -13,7 +13,7 @@ import {
} from '@nestjs/common'
import { Observable } from 'rxjs'
import { tap } from 'rxjs/operators'
import { PostHog } from 'posthog-node'
import { PostHog as Insights } from '@hanzo/insights-node'
import { SandboxDto } from '../sandbox/dto/sandbox.dto'
import { DockerRegistryDto } from '../docker-registry/dto/docker-registry.dto'
import { CreateSandboxDto } from '../sandbox/dto/create-sandbox.dto'
@@ -51,29 +51,27 @@ type CommonCaptureProps = {
@Injectable()
export class MetricsInterceptor implements NestInterceptor, OnApplicationShutdown {
private readonly posthog?: PostHog
private readonly insights?: Insights
private readonly logger = new Logger(MetricsInterceptor.name)
constructor() {
if (!process.env.POSTHOG_API_KEY) {
this.logger.warn('POSTHOG_API_KEY is not set, metrics will not be recorded')
if (!process.env.INSIGHTS_API_KEY) {
this.logger.warn('INSIGHTS_API_KEY is not set, metrics will not be recorded')
return
}
if (!process.env.POSTHOG_HOST) {
this.logger.warn('POSTHOG_HOST is not set, metrics will not be recorded')
if (!process.env.INSIGHTS_HOST) {
this.logger.warn('INSIGHTS_HOST is not set, metrics will not be recorded')
return
}
// Initialize PostHog client
// Make sure to set POSTHOG_API_KEY in your environment variables
this.posthog = new PostHog(process.env.POSTHOG_API_KEY, {
host: process.env.POSTHOG_HOST,
this.insights = new Insights(process.env.INSIGHTS_API_KEY, {
host: process.env.INSIGHTS_HOST,
})
}
intercept(context: ExecutionContext, next: CallHandler): Observable<any> {
if (!this.posthog) {
if (!this.insights) {
return next.handle()
}
@@ -625,11 +623,11 @@ export class MetricsInterceptor implements NestInterceptor, OnApplicationShutdow
request: CreateOrganizationDto,
response: OrganizationDto,
) {
if (!this.posthog) {
if (!this.insights) {
return
}
this.posthog.groupIdentify({
this.insights.groupIdentify({
groupType: 'organization',
groupKey: response.id,
properties: {
@@ -813,11 +811,11 @@ export class MetricsInterceptor implements NestInterceptor, OnApplicationShutdow
}
private capture(event: string, props: CommonCaptureProps, errorEvent?: string, extraProps?: Record<string, any>) {
if (!this.posthog) {
if (!this.insights) {
return
}
this.posthog.capture({
this.insights.capture({
distinctId: props.distinctId,
event: props.error ? errorEvent || event : event,
groups: this.captureCommonGroups(props),
@@ -842,8 +840,8 @@ export class MetricsInterceptor implements NestInterceptor, OnApplicationShutdow
}
onApplicationShutdown(/*signal?: string*/) {
if (this.posthog) {
this.posthog.shutdown()
if (this.insights) {
this.insights.shutdown()
}
}
}
+2 -2
View File
@@ -2,8 +2,8 @@ VITE_OIDC_DOMAIN=http://localhost:5556/dex
VITE_OIDC_CLIENT_ID=runtime
VITE_OIDC_AUDIENCE=runtime
VITE_POSTHOG_KEY=
VITE_POSTHOG_HOST=
VITE_INSIGHTS_KEY=
VITE_INSIGHTS_HOST=
VITE_API_URL=http://localhost:3000/api
+8 -8
View File
@@ -13,7 +13,7 @@ import { useAuth } from 'react-oidc-context'
import LoadingFallback from './components/LoadingFallback'
import Snapshots from './pages/Snapshots'
import Registries from './pages/Registries'
import { usePostHog } from 'posthog-js/react'
import { useInsights } from '@hanzo/insights/react'
import {
Dialog,
DialogContent,
@@ -63,12 +63,12 @@ const SlackRedirect = () => {
function App() {
const location = useLocation()
const posthog = usePostHog()
const insights = useInsights()
const { error: authError, isAuthenticated, user, signoutRedirect } = useAuth()
useEffect(() => {
if (import.meta.env.PROD && isAuthenticated && user && posthog?.get_distinct_id() !== user.profile.sub) {
posthog?.identify(user.profile.sub, {
if (import.meta.env.PROD && isAuthenticated && user && insights?.get_distinct_id() !== user.profile.sub) {
insights?.identify(user.profile.sub, {
email: user.profile.email,
name: user.profile.name,
})
@@ -84,16 +84,16 @@ function App() {
},
}
}
}, [isAuthenticated, user, posthog])
}, [isAuthenticated, user, insights])
// Hack for tracking PostHog pageviews in SPAs
// Track pageviews in SPAs
useEffect(() => {
if (import.meta.env.PROD) {
posthog?.capture('$pageview', {
insights?.capture('$pageview', {
$current_url: window.location.href,
})
}
}, [location, posthog])
}, [location, insights])
if (authError) {
return (
@@ -12,7 +12,7 @@ import { useApi } from '@/hooks/useApi'
import { ISelectedOrganizationContext, SelectedOrganizationContext } from '@/contexts/SelectedOrganizationContext'
import { LocalStorageKey } from '@/enums/LocalStorageKey'
import { useOrganizations } from '@/hooks/useOrganizations'
import { usePostHog } from 'posthog-js/react'
import { useInsights } from '@hanzo/insights/react'
import { handleApiError } from '@/lib/error-handling'
type Props = {
@@ -22,7 +22,7 @@ type Props = {
export function SelectedOrganizationProvider(props: Props) {
const { user } = useAuth()
const { organizationsApi } = useApi()
const posthog = usePostHog()
const insights = useInsights()
const { organizations } = useOrganizations()
@@ -59,12 +59,12 @@ export function SelectedOrganizationProvider(props: Props) {
}, [organizations, selectedOrganizationId])
useEffect(() => {
if (!posthog || !selectedOrganizationId) {
if (!insights || !selectedOrganizationId) {
return
}
posthog.group('organization', selectedOrganizationId)
}, [posthog, selectedOrganizationId])
insights.group('organization', selectedOrganizationId)
}, [insights, selectedOrganizationId])
const getOrganizationMembers = useCallback(
async (selectedOrganizationId: string | null) => {
+2 -2
View File
@@ -116,8 +116,8 @@
"passport-http-bearer": "^1.0.1",
"passport-jwt": "^4.0.1",
"pg": "^8.13.3",
"posthog-js": "^1.217.6",
"posthog-node": "^4.10.1",
"@hanzo/insights": "^1.357.1",
"@hanzo/insights-node": "^1.0.0",
"prism-react-renderer": "^2.4.1",
"raw-body": "^3.0.0",
"react": "^19.1.0",