:hedgehog: PostHog is the leading platform for building self-driving products. Our developer tools – AI observability, analytics, session replay, flags, experiments, error tracking, logs, and more – capture all the context agents need to diagnose problems, uncover opportunities, and ship fixes. Steer it all from Slack, web, desktop, or the MCP.
Python ab-testingai-analyticsanalyticscdpdata-warehouseexperimentsfeature-flagsjavascriptproduct-analyticspythonreactsession-replaysurveystypescriptweb-analytics
feat(logs): add ios and react native to logs onboarding (#59216)
Anna Garcia1090f489f68f
diff --git a/docs/onboarding/logs/index.ts b/docs/onboarding/logs/index.tsindex 33aea8b64867..5ad1a14964d3 100644--- a/docs/onboarding/logs/index.ts+++ b/docs/onboarding/logs/index.ts@@ -1,6 +1,8 @@export { GoInstallation } from './go'+export { IOSInstallation } from './ios'export { JavaInstallation } from './java'export { NextJSInstallation } from './nextjs'export { NodeJSInstallation } from './nodejs'export { OpenTelemetryInstallation } from './opentelemetry'export { PythonInstallation } from './python'+export { ReactNativeInstallation } from './react-native'diff --git a/docs/onboarding/logs/ios.tsx b/docs/onboarding/logs/ios.tsxnew file mode 100644index 000000000000..c4d216c65e86--- /dev/null+++ b/docs/onboarding/logs/ios.tsx@@ -0,0 +1,52 @@+import { OnboardingComponentsContext, createInstallation } from 'scenes/onboarding/OnboardingDocsContentWrapper'++import { getIOSSteps as getIOSStepsPA } from '../product-analytics/ios'+import { StepDefinition } from '../steps'++export const getIOSSteps = (ctx: OnboardingComponentsContext): StepDefinition[] => {+ const { CodeBlock, Markdown, dedent } = ctx++ const installSteps = getIOSStepsPA(ctx, {+ minVersionPod: '3.58',+ minVersionSPM: '3.58.0',+ })++ const sendLogStep: StepDefinition = {+ title: 'Send a log',+ badge: 'required',+ content: (+ <>+ <Markdown>+ Capture a structured log record with `captureLog`. Records are batched and shipped to PostHog's logs+ product.+ </Markdown>+ <CodeBlock+ blocks={[+ {+ language: 'swift',+ file: 'Swift',+ code: dedent`+ import PostHog++ PostHogSDK.shared.captureLog("Server started", level: .info, attributes: [+ "server.port": 3000,+ "server.env": "production"+ ])+ `,+ },+ ]}+ />+ <Markdown>+ {dedent`+ Logs appear in PostHog within a few seconds. Use the [Logs page](https://app.posthog.com/logs) to search and filter+ by service name, severity, or any attribute you attach.+ `}+ </Markdown>+ </>+ ),+ }++ return [...installSteps, sendLogStep]+}++export const IOSInstallation = createInstallation(getIOSSteps)diff --git a/docs/onboarding/logs/react-native.tsx b/docs/onboarding/logs/react-native.tsxnew file mode 100644index 000000000000..924047c3b060--- /dev/null+++ b/docs/onboarding/logs/react-native.tsx@@ -0,0 +1,56 @@+import { OnboardingComponentsContext, createInstallation } from 'scenes/onboarding/OnboardingDocsContentWrapper'++import { getReactNativeSteps as getReactNativeStepsPA } from '../product-analytics/react-native'+import { StepDefinition } from '../steps'++export const getReactNativeSteps = (ctx: OnboardingComponentsContext): StepDefinition[] => {+ const { CodeBlock, Markdown, dedent } = ctx++ const installSteps = getReactNativeStepsPA(ctx, { minVersion: '4.44.0' })++ const sendLogStep: StepDefinition = {+ title: 'Send a log',+ badge: 'required',+ content: (+ <>+ <Markdown>+ Capture a structured log record using the logger facade. Requires `posthog-react-native` 4.44.0 or+ later. Records are batched and shipped to PostHog's logs product.+ </Markdown>+ <CodeBlock+ blocks={[+ {+ language: 'tsx',+ file: 'Component.tsx',+ code: dedent`+ import { usePostHog } from 'posthog-react-native'++ function MyComponent() {+ const posthog = usePostHog()++ const handlePress = () => {+ posthog.logger.info('checkout completed', {+ order_id: 'ord_789'+ })+ }++ return <Button onPress={handlePress} title="Check out" />+ }+ `,+ },+ ]}+ />+ <Markdown>+ {dedent`+ Logs appear in PostHog within a few seconds. Use the [Logs page](https://app.posthog.com/logs) to search and filter+ by service name, severity, or any attribute you attach.+ `}+ </Markdown>+ </>+ ),+ }++ return [...installSteps, sendLogStep]+}++export const ReactNativeInstallation = createInstallation(getReactNativeSteps)diff --git a/docs/onboarding/product-analytics/react-native.tsx b/docs/onboarding/product-analytics/react-native.tsxindex 68a9f8e68bb7..e8448c1e9a28 100644--- a/docs/onboarding/product-analytics/react-native.tsx+++ b/docs/onboarding/product-analytics/react-native.tsx@@ -2,9 +2,16 @@ import { OnboardingComponentsContext, createInstallation } from 'scenes/onboardiimport { StepDefinition } from '../steps'-export const getReactNativeSteps = (ctx: OnboardingComponentsContext): StepDefinition[] => {+export const getReactNativeSteps = (+ ctx: OnboardingComponentsContext,+ options?: {+ minVersion?: string+ }+): StepDefinition[] => {const { CodeBlock, Markdown, dedent } = ctx+ const pkg = options?.minVersion ? `posthog-react-native@^${options.minVersion}` : 'posthog-react-native'+return [{title: 'Install the package',@@ -18,14 +25,14 @@ export const getReactNativeSteps = (ctx: OnboardingComponentsContext): StepDefinlanguage: 'bash',file: 'Expo',code: dedent`- npx expo install posthog-react-native expo-file-system expo-application expo-device expo-localization+ npx expo install ${pkg} expo-file-system expo-application expo-device expo-localization`,},{language: 'bash',file: 'yarn',code: dedent`- yarn add posthog-react-native @react-native-async-storage/async-storage react-native-device-info react-native-localize+ yarn add ${pkg} @react-native-async-storage/async-storage react-native-device-info react-native-localize# for iOScd ios && pod install@@ -35,7 +42,7 @@ export const getReactNativeSteps = (ctx: OnboardingComponentsContext): StepDefinlanguage: 'bash',file: 'npm',code: dedent`- npm i -s posthog-react-native @react-native-async-storage/async-storage react-native-device-info react-native-localize+ npm i -s ${pkg} @react-native-async-storage/async-storage react-native-device-info react-native-localize# for iOScd ios && pod installdiff --git a/frontend/src/scenes/onboarding/sdks/logs/LogsSDKInstructions.tsx b/frontend/src/scenes/onboarding/sdks/logs/LogsSDKInstructions.tsxindex bd3eed183446..5262478c3a7c 100644--- a/frontend/src/scenes/onboarding/sdks/logs/LogsSDKInstructions.tsx+++ b/frontend/src/scenes/onboarding/sdks/logs/LogsSDKInstructions.tsx@@ -1,10 +1,12 @@import {GoInstallation,+ IOSInstallation,JavaInstallation,NextJSInstallation,NodeJSInstallation,OpenTelemetryInstallation,PythonInstallation,+ ReactNativeInstallation,} from '@posthog/shared-onboarding/logs'import { SDKInstructionsMap, SDKKey } from '~/types'@@ -38,6 +40,14 @@ const LogsOpenTelemetryInstructionsWrapper = withOnboardingDocsWrapper({Installation: OpenTelemetryInstallation,})+const LogsIOSInstructionsWrapper = withOnboardingDocsWrapper({+ Installation: IOSInstallation,+})++const LogsReactNativeInstructionsWrapper = withOnboardingDocsWrapper({+ Installation: ReactNativeInstallation,+})+export const LogsSDKInstructions: SDKInstructionsMap = {[SDKKey.NODE_JS]: LogsNodeJSInstructionsWrapper,[SDKKey.NEXT_JS]: LogsNextJSInstructionsWrapper,@@ -45,4 +55,6 @@ export const LogsSDKInstructions: SDKInstructionsMap = {[SDKKey.GO]: LogsGoInstructionsWrapper,[SDKKey.JAVA]: LogsJavaInstructionsWrapper,[SDKKey.OPENTELEMETRY]: LogsOpenTelemetryInstructionsWrapper,+ [SDKKey.IOS]: LogsIOSInstructionsWrapper,+ [SDKKey.REACT_NATIVE]: LogsReactNativeInstructionsWrapper,}