diff --git a/docs/onboarding/error-tracking/flutter.tsx b/docs/onboarding/error-tracking/flutter.tsx index e30d7c343c94..d7b833420ef3 100644 --- a/docs/onboarding/error-tracking/flutter.tsx +++ b/docs/onboarding/error-tracking/flutter.tsx @@ -3,12 +3,10 @@ import { OnboardingComponentsContext, createInstallation } from 'scenes/onboardi import { getFlutterSteps as getFlutterStepsPA } from '../product-analytics/flutter' import { StepDefinition } from '../steps' -const FLUTTER_ERROR_TRACKING_MIN_VERSION = '5.58.0' - export const getFlutterSteps = (ctx: OnboardingComponentsContext): StepDefinition[] => { const { CodeBlock, Markdown, CalloutBox, dedent } = ctx - const installSteps = getFlutterStepsPA(ctx, { minVersion: FLUTTER_ERROR_TRACKING_MIN_VERSION }) + const installSteps = getFlutterStepsPA(ctx) const exceptionAutocaptureStep: StepDefinition = { title: 'Set up exception autocapture', @@ -22,11 +20,6 @@ export const getFlutterSteps = (ctx: OnboardingComponentsContext): StepDefinitio `} - - {dedent` - Dart AOT symbolication and background isolate listeners require \`posthog_flutter\` ${FLUTTER_ERROR_TRACKING_MIN_VERSION} or later. If your project uses an earlier version, set \`posthog_flutter: ^${FLUTTER_ERROR_TRACKING_MIN_VERSION}\` in \`pubspec.yaml\` and run \`flutter pub get\`. - `} - {dedent` You can autocapture exceptions by configuring the \`errorTrackingConfig\` when setting up PostHog: diff --git a/docs/onboarding/product-analytics/flutter.tsx b/docs/onboarding/product-analytics/flutter.tsx index 95bc5ba6300a..4a1948a61f66 100644 --- a/docs/onboarding/product-analytics/flutter.tsx +++ b/docs/onboarding/product-analytics/flutter.tsx @@ -4,7 +4,7 @@ import { StepDefinition } from '../steps' import { DEFAULT_SNIPPET_METHODS, snippetFunctions } from './_snippets/js-snippet-builder' import { SDK_DEFAULTS_DATE } from './_snippets/sdkDefaults' -const DEFAULT_FLUTTER_SDK_VERSION = '5.24.0' +const DEFAULT_FLUTTER_SDK_VERSION = '6.0.0' export const getFlutterInstallSteps = ( ctx: OnboardingComponentsContext, @@ -31,6 +31,13 @@ export const getFlutterInstallSteps = ( }, ]} /> + posthog_flutter 6.0 requires Flutter 3.41 or later on every platform. + + If you embed Flutter in an iOS app as a module (`flutter create -t module`), use Flutter 3.50 or + later and build it with `flutter build swift-package`. Earlier Flutter versions install module + plugins with CocoaPods, and posthog_flutter 6.0 has no podspec, so stay on posthog_flutter 5.x + there. + ), }, @@ -62,7 +69,9 @@ export const getFlutterInstallSteps = ( ]} /> - Update the minimum Android SDK version to **21** in `android/app/build.gradle`: + posthog_flutter needs a minimum Android SDK version of **23** or higher. New Flutter + projects default to 24, so change `android/app/build.gradle` only if your app sets a + lower value: - Update the minimum platform version to iOS 13.0 in your `Podfile`: - + + {dedent` + iOS and macOS builds require Xcode 26 or later. Set the minimum deployment target to iOS 15.0, or macOS 11.0 for a macOS app, in Xcode (**Runner > General > Minimum Deployments**). PostHog installs through Swift Package Manager, which is on by default from Flutter 3.44. On Flutter 3.41 to 3.43, or if you turned it off, run \`flutter config --enable-swift-package-manager\`. If you keep a \`Podfile\` for other plugins, set \`platform :ios, '15.0'\` there too (\`platform :osx, '11.0'\` in \`macos/Podfile\`), then run \`flutter build ios --config-only\` (or \`flutter build macos --config-only\`). + `} + Add these values in `index.html`: diff --git a/docs/onboarding/session-replay/flutter.tsx b/docs/onboarding/session-replay/flutter.tsx index f4462d1bff0f..8f5a4f5683be 100644 --- a/docs/onboarding/session-replay/flutter.tsx +++ b/docs/onboarding/session-replay/flutter.tsx @@ -19,11 +19,18 @@ export const getFlutterSteps = (ctx: OnboardingComponentsContext): StepDefinitio language: 'yaml', file: 'pubspec.yaml', code: dedent` - posthog_flutter: ^5.24.0 + posthog_flutter: ^6.0.0 `, }, ]} /> + posthog_flutter 6.0 requires Flutter 3.41 or later on every platform. + + If you embed Flutter in an iOS app as a module (`flutter create -t module`), use Flutter 3.50 or + later and build it with `flutter build swift-package`. Earlier Flutter versions install module + plugins with CocoaPods, and posthog_flutter 6.0 has no podspec, so stay on posthog_flutter 5.x + there. + Session replay requires PostHog Flutter SDK version 4.7.0 or higher. We recommend always @@ -58,7 +65,10 @@ export const getFlutterSteps = (ctx: OnboardingComponentsContext): StepDefinitio }, ]} /> - Update the minimum Android SDK version to **21** in `android/app/build.gradle`: + + posthog_flutter needs a minimum Android SDK version of **23** or higher. New Flutter projects + default to 24, so change `android/app/build.gradle` only if your app sets a lower value: + - Update the minimum platform version to iOS 13.0 in your `Podfile`: - + + {dedent` + iOS and macOS builds require Xcode 26 or later. Set the minimum deployment target to iOS 15.0, or macOS 11.0 for a macOS app, in Xcode (**Runner > General > Minimum Deployments**). PostHog installs through Swift Package Manager, which is on by default from Flutter 3.44. On Flutter 3.41 to 3.43, or if you turned it off, run \`flutter config --enable-swift-package-manager\`. If you keep a \`Podfile\` for other plugins, set \`platform :ios, '15.0'\` there too (\`platform :osx, '11.0'\` in \`macos/Podfile\`), then run \`flutter build ios --config-only\` (or \`flutter build macos --config-only\`). + `} + ), }, diff --git a/frontend/src/scenes/onboarding/sdks/sdk-install-instructions/flutter.tsx b/frontend/src/scenes/onboarding/sdks/sdk-install-instructions/flutter.tsx deleted file mode 100644 index 1e889a155e55..000000000000 --- a/frontend/src/scenes/onboarding/sdks/sdk-install-instructions/flutter.tsx +++ /dev/null @@ -1,305 +0,0 @@ -import { useValues } from 'kea' - -import { Link } from '@posthog/lemon-ui' - -import { CodeSnippet, Language } from 'lib/components/CodeSnippet' -import { useJsSnippet } from 'lib/components/JSSnippet' -import { apiHostOrigin } from 'lib/utils/apiHost' -import { teamLogic } from 'scenes/teamLogic' - -export interface FlutterSetupProps { - includeReplay?: boolean - includeSurveys?: boolean - requiresManualInstall?: boolean -} - -export interface FlutterInstallProps { - apiToken?: string -} - -function FlutterInstallSnippet(): JSX.Element { - return posthog_flutter: ^5.24.0 -} - -function FlutterDartSetup(props: FlutterSetupProps & FlutterInstallProps): JSX.Element { - const configOptions = [ - props.includeReplay && - `// check https://posthog.com/docs/session-replay/installation?tab=Flutter - // for more config and to learn about how we capture sessions on mobile - // and what to expect - config.sessionReplay = true; - // choose whether to mask images or text - config.sessionReplayConfig.maskAllTexts = false; - config.sessionReplayConfig.maskAllImages = false;`, - props.includeSurveys && `config.surveys = true`, - ] - .filter(Boolean) - .join('\n') - - return ( - - {`import 'package:flutter/material.dart'; - -import 'package:posthog_flutter/posthog_flutter.dart'; - -Future main() async { - // init WidgetsFlutterBinding if not yet - WidgetsFlutterBinding.ensureInitialized(); - final config = PostHogConfig('${props.apiToken}'); - config.host = '${apiHostOrigin()}'; - config.debug = true; - config.captureApplicationLifecycleEvents = true; - ${configOptions} - // Setup PostHog with the given Context and Config - await Posthog().setup(config); - runApp(MyApp()); -}`} - - ) -} - -function InstallFlutterWidgetsAndObsserver(): JSX.Element { - return ( - - {`import 'package:flutter/material.dart'; - -import 'package:posthog_flutter/posthog_flutter.dart'; - -class MyApp extends StatefulWidget { - const MyApp({super.key}); - - @override - State createState() => _MyAppState(); -} - -class _MyAppState extends State { - @override - void initState() { - super.initState(); - } - - @override - Widget build(BuildContext context) { - // Wrap your App with PostHogWidget - return PostHogWidget( - child: MaterialApp( - // Add PosthogObserver to your navigatorObservers - navigatorObservers: [PosthogObserver()], - title: 'My App', - home: const HomeScreen(), - ), - ); - } -} -// If you're using go_router, check this page to learn how to set up the PosthogObserver -// https://posthog.com/docs/libraries/flutter#capturing-screen-views`} - - ) -} - -function InstallFlutterObserver(): JSX.Element { - return ( - - {`import 'package:flutter/material.dart'; - -import 'package:posthog_flutter/posthog_flutter.dart'; - -class MyApp extends StatefulWidget { - const MyApp({super.key}); - - @override - State createState() => _MyAppState(); -} - -class _MyAppState extends State { - @override - void initState() { - super.initState(); - } - - @override - Widget build(BuildContext context) { - return MaterialApp( - // Add PosthogObserver to your navigatorObservers - navigatorObservers: [PosthogObserver()], - title: 'My App', - home: const HomeScreen(), - ); -); - } -} -// If you're using go_router, check this page to learn how to set up the PosthogObserver -// https://posthog.com/docs/libraries/flutter#capturing-screen-views - -`} - - ) -} - -function FlutterAndroidSetupSnippet({ requiresManualInstall }: FlutterSetupProps): JSX.Element { - const { currentTeam } = useValues(teamLogic) - const url = apiHostOrigin() - - const minSdkVersionInstructions = ( - <> -

- Update the minimum Android SDK version to 23 in{' '} - android/app/build.gradle: -

- - {`defaultConfig { - minSdkVersion 23 - // rest of your config -}`} - - - ) - - if (requiresManualInstall) { - return ( - <> - - { - '\n\t\n\t\t[...]\n\t\n\t\n' - } - - {minSdkVersionInstructions} - - ) - } - return ( - <> - - {'\n\t\n\t\t[...]\n\t\n\t\n\t\n\t\n\t\n'} - - {minSdkVersionInstructions} - - ) -} - -function FlutterIOSSetupSnippet({ requiresManualInstall }: FlutterSetupProps): JSX.Element { - const { currentTeam } = useValues(teamLogic) - const url = apiHostOrigin() - - const minPlatformVersionInstructions = ( - <> -

- Update the minimum platform version to iOS 13.0 in your Podfile: -

- - {`platform :ios, '13.0' - # rest of your config`} - - - ) - - if (requiresManualInstall) { - return ( - <> - - {'\n\t[...]\n\tcom.posthog.posthog.AUTO_INIT\n\t\n\t[...]\n'} - - {minPlatformVersionInstructions} - - ) - } - return ( - <> - - {'\n\t[...]\n\tcom.posthog.posthog.PROJECT_TOKEN\n\t' + - currentTeam?.api_token + - '\n\tcom.posthog.posthog.POSTHOG_HOST\n\t' + - url + - '\n\tcom.posthog.posthog.CAPTURE_APPLICATION_LIFECYCLE_EVENTS\n\t\n\tcom.posthog.posthog.DEBUG\n\t\n'} - - {minPlatformVersionInstructions} - - ) -} - -function FlutterWebSetupSnippet(): JSX.Element { - const jsSnippet = useJsSnippet(4) - - return ( - - {` - - - ... -${jsSnippet} - -`} - - ) -} - -export function SDKInstallFlutterInstructions(props: FlutterSetupProps): JSX.Element { - const { currentTeam } = useValues(teamLogic) - - return ( - <> -

Install

- -

Android Setup

-

Add these values in AndroidManifest.xml

- -

iOS/macOS Setup

-

Add these values in Info.plist

- - {props.requiresManualInstall && ( - <> -

Dart Setup

-

Add these values in main.dart

- - {props.includeSurveys && ( - <> -

- Install the PosthogObserver to your app -

- - - )} - {props.includeReplay && ( - <> -

- Wrap your app with the PostHogWidget and install the{' '} - PosthogObserver -

- - - )} - - )} -

Web Setup

-

Add these values in index.html

- - - ) -} - -export function SDKInstallFlutterTrackScreenInstructions(): JSX.Element { - return ( - <> -

- With the PosthogObserver Observer, - PostHog will try to record all screen changes automatically. -

-

- If you want to manually send a new screen capture event, use the screen function. -

- {`import 'package:posthog_flutter/posthog_flutter.dart'; - -await Posthog().screen( - screenName: 'Dashboard', - properties: { - 'background': 'blue', - 'hero': 'superhog' - }); -`} - - ) -} diff --git a/frontend/src/scenes/onboarding/sdks/sdk-install-instructions/index.tsx b/frontend/src/scenes/onboarding/sdks/sdk-install-instructions/index.tsx index 45ffdf34a991..03edd81e2be6 100644 --- a/frontend/src/scenes/onboarding/sdks/sdk-install-instructions/index.tsx +++ b/frontend/src/scenes/onboarding/sdks/sdk-install-instructions/index.tsx @@ -4,7 +4,6 @@ export * from './astro' export * from './bubble' export * from './django' export * from './elixir' -export * from './flutter' export * from './framer' export * from './go' export * from './ios'