From 07fd9c3a4a15fb088f21ba0f94d861d7cf241d94 Mon Sep 17 00:00:00 2001 From: Waleed Date: Mon, 6 Oct 2025 10:59:46 -0700 Subject: [PATCH 1/2] feat(posthog): added posthog provider instead of using nextjs instrumentation (#1555) * fix(posthog): make instrumentation client not use next-runtime-env * feat(posthog): added posthog provider --- apps/sim/app/layout.tsx | 27 ++++++++------------ apps/sim/instrumentation-client.ts | 29 +-------------------- apps/sim/lib/posthog/provider.tsx | 41 ++++++++++++++++++++++++++++++ 3 files changed, 53 insertions(+), 44 deletions(-) create mode 100644 apps/sim/lib/posthog/provider.tsx diff --git a/apps/sim/app/layout.tsx b/apps/sim/app/layout.tsx index 50bbd857b3..f7363002a9 100644 --- a/apps/sim/app/layout.tsx +++ b/apps/sim/app/layout.tsx @@ -1,11 +1,10 @@ -import { Analytics } from '@vercel/analytics/next' import type { Metadata, Viewport } from 'next' import { PublicEnvScript } from 'next-runtime-env' import { BrandedLayout } from '@/components/branded-layout' import { generateThemeCSS } from '@/lib/branding/inject-theme' import { generateBrandedMetadata, generateStructuredData } from '@/lib/branding/metadata' -import { isHosted } from '@/lib/environment' import { createLogger } from '@/lib/logs/console/logger' +import { PostHogProvider } from '@/lib/posthog/provider' import '@/app/globals.css' import { SessionProvider } from '@/lib/session/session-context' @@ -55,7 +54,6 @@ export const viewport: Viewport = { ], } -// Generate dynamic metadata based on brand configuration export const metadata: Metadata = generateBrandedMetadata() export default function RootLayout({ children }: { children: React.ReactNode }) { @@ -91,19 +89,16 @@ export default function RootLayout({ children }: { children: React.ReactNode }) - - - - - {children} - {isHosted && ( - <> - - - )} - - - + + + + + + {children} + + + + ) diff --git a/apps/sim/instrumentation-client.ts b/apps/sim/instrumentation-client.ts index 6ba4db89b3..584abb63f5 100644 --- a/apps/sim/instrumentation-client.ts +++ b/apps/sim/instrumentation-client.ts @@ -5,34 +5,7 @@ * It respects the user's telemetry preferences stored in localStorage. * */ -import posthog from 'posthog-js' -import { env, getEnv, isTruthy } from './lib/env' - -// Initialize PostHog only if explicitly enabled -if (isTruthy(getEnv('NEXT_PUBLIC_POSTHOG_ENABLED')) && getEnv('NEXT_PUBLIC_POSTHOG_KEY')) { - posthog.init(getEnv('NEXT_PUBLIC_POSTHOG_KEY')!, { - api_host: '/ingest', - ui_host: 'https://us.posthog.com', - person_profiles: 'identified_only', - capture_pageview: true, - capture_pageleave: true, - capture_performance: true, - session_recording: { - maskAllInputs: false, - maskInputOptions: { - password: true, - email: false, - }, - recordCrossOriginIframes: false, - recordHeaders: true, - recordBody: true, - }, - autocapture: true, - capture_dead_clicks: true, - persistence: 'localStorage+cookie', - enable_heatmaps: true, - }) -} +import { env } from './lib/env' if (typeof window !== 'undefined') { const TELEMETRY_STATUS_KEY = 'simstudio-telemetry-status' diff --git a/apps/sim/lib/posthog/provider.tsx b/apps/sim/lib/posthog/provider.tsx new file mode 100644 index 0000000000..a016dfd546 --- /dev/null +++ b/apps/sim/lib/posthog/provider.tsx @@ -0,0 +1,41 @@ +'use client' + +import { useEffect } from 'react' +import posthog from 'posthog-js' +import { PostHogProvider as PHProvider } from 'posthog-js/react' +import { getEnv, isTruthy } from '../env' + +export function PostHogProvider({ children }: { children: React.ReactNode }) { + useEffect(() => { + const posthogEnabled = getEnv('NEXT_PUBLIC_POSTHOG_ENABLED') + const posthogKey = getEnv('NEXT_PUBLIC_POSTHOG_KEY') + + if (isTruthy(posthogEnabled) && posthogKey && !posthog.__loaded) { + posthog.init(posthogKey, { + api_host: '/ingest', + ui_host: 'https://us.posthog.com', + defaults: '2025-05-24', + person_profiles: 'identified_only', + capture_pageview: true, + capture_pageleave: true, + capture_performance: true, + session_recording: { + maskAllInputs: false, + maskInputOptions: { + password: true, + email: false, + }, + recordCrossOriginIframes: false, + recordHeaders: true, + recordBody: true, + }, + autocapture: true, + capture_dead_clicks: true, + persistence: 'localStorage+cookie', + enable_heatmaps: true, + }) + } + }, []) + + return {children} +} From d9b70087c484b1d24cc42a5f8fc2d9f90c369737 Mon Sep 17 00:00:00 2001 From: Emir Karabeg <78010029+emir-karabeg@users.noreply.github.com> Date: Mon, 6 Oct 2025 12:25:07 -0700 Subject: [PATCH 2/2] feat(blog): created first page (#1550) * feat(blog): created first page * feat(building): first draft blog complete --- apps/sim/app/(landing)/building/layout.tsx | 14 + .../openai-vs-n8n-vs-sim/openai-n8n-sim.tsx | 789 ++++++++++++++++++ .../building/openai-vs-n8n-vs-sim/page.tsx | 139 +++ apps/sim/app/(landing)/building/page.tsx | 8 + apps/sim/app/(landing)/components/nav/nav.tsx | 2 +- apps/sim/app/sitemap.ts | 12 +- .../building/openai-vs-n8n-vs-sim/copilot.png | Bin 0 -> 498356 bytes .../openai-vs-n8n-vs-sim/emir-karabeg.png | Bin 0 -> 2126322 bytes .../building/openai-vs-n8n-vs-sim/logs.png | Bin 0 -> 240020 bytes .../building/openai-vs-n8n-vs-sim/n8n.png | Bin 0 -> 672724 bytes .../building/openai-vs-n8n-vs-sim/openai.png | Bin 0 -> 151594 bytes .../building/openai-vs-n8n-vs-sim/sim.png | Bin 0 -> 308244 bytes .../openai-vs-n8n-vs-sim/templates.png | Bin 0 -> 345607 bytes .../building/openai-vs-n8n-vs-sim/widgets.png | Bin 0 -> 884024 bytes .../openai-vs-n8n-vs-sim/workflow.png | Bin 0 -> 332781 bytes 15 files changed, 962 insertions(+), 2 deletions(-) create mode 100644 apps/sim/app/(landing)/building/layout.tsx create mode 100644 apps/sim/app/(landing)/building/openai-vs-n8n-vs-sim/openai-n8n-sim.tsx create mode 100644 apps/sim/app/(landing)/building/openai-vs-n8n-vs-sim/page.tsx create mode 100644 apps/sim/app/(landing)/building/page.tsx create mode 100644 apps/sim/public/building/openai-vs-n8n-vs-sim/copilot.png create mode 100644 apps/sim/public/building/openai-vs-n8n-vs-sim/emir-karabeg.png create mode 100644 apps/sim/public/building/openai-vs-n8n-vs-sim/logs.png create mode 100644 apps/sim/public/building/openai-vs-n8n-vs-sim/n8n.png create mode 100644 apps/sim/public/building/openai-vs-n8n-vs-sim/openai.png create mode 100644 apps/sim/public/building/openai-vs-n8n-vs-sim/sim.png create mode 100644 apps/sim/public/building/openai-vs-n8n-vs-sim/templates.png create mode 100644 apps/sim/public/building/openai-vs-n8n-vs-sim/widgets.png create mode 100644 apps/sim/public/building/openai-vs-n8n-vs-sim/workflow.png diff --git a/apps/sim/app/(landing)/building/layout.tsx b/apps/sim/app/(landing)/building/layout.tsx new file mode 100644 index 0000000000..5ae50a1e9e --- /dev/null +++ b/apps/sim/app/(landing)/building/layout.tsx @@ -0,0 +1,14 @@ +import { Footer, Nav } from '@/app/(landing)/components' + +/** + * Layout for the building/blog section with navigation and footer + */ +export default function BuildingLayout({ children }: { children: React.ReactNode }) { + return ( + <> +