Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: update flutter docs #9531

Merged
merged 1 commit into from
Oct 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
79 changes: 75 additions & 4 deletions contents/docs/integrate/_snippets/install-flutter.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,11 @@ Then complete the set up for each platform:

#### Android setup

For Android, add your PostHog configuration to your `AndroidManifest.xml` file located in the `android/app/src/main`:
There are 2 ways of initializing the SDK, automatically and manually.

Automatically:

Add your PostHog configuration to your `AndroidManifest.xml` file located in the `android/app/src/main`:

```xml file=android/app/src/main/AndroidManifest.xml
<manifest xmlns:android="http://schemas.android.com/apk/res/android" package="your.package.name">
Expand All @@ -37,7 +41,36 @@ For Android, add your PostHog configuration to your `AndroidManifest.xml` file l
</manifest>
```

You'll also need to update the minimum Android SDK version to `21` in `android/app/build.gradle`:
Or manually (more control and more configurations available):

Add your PostHog configuration to your `AndroidManifest.xml` file located in the `android/app/src/main`:

```xml file=android/app/src/main/AndroidManifest.xml
<manifest xmlns:android="http://schemas.android.com/apk/res/android" package="your.package.name">
<application>
<!-- ... other configuration ... -->
<meta-data android:name="com.posthog.posthog.AUTO_INIT" android:value="false" />
</application>
</manifest>
```

And setup the SDK manually:

```dart
Future<void> main() async {
// init WidgetsFlutterBinding if not yet
WidgetsFlutterBinding.ensureInitialized();
final config = PostHogConfig('YOUR_API_KEY_GOES_HERE');
config.debug = true;
config.captureApplicationLifecycleEvents = true;
// or EU Host: 'https://eu.i.posthog.com'
config.host = 'https://us.i.posthog.com';
await Posthog().setup(config);
runApp(MyApp());
}
```

In both cases, you'll also need to update the minimum Android SDK version to `21` in `android/app/build.gradle`:

```gradle_kotlin file=android/app/build.gradle
// rest of your config
Expand All @@ -52,7 +85,13 @@ You'll also need to update the minimum Android SDK version to `21` in `android/a

#### iOS setup

For iOS, you'll need to have [Cocoapods](https://guides.cocoapods.org/using/getting-started.html) installed. Then add your PostHog configuration to the `Info.plist` file located in the `ios/Runner` directory:
There are 2 ways of initializing the SDK, automatically and manually.

You'll need to have [Cocoapods](https://guides.cocoapods.org/using/getting-started.html) installed.

Automatically:

Add your PostHog configuration to the `Info.plist` file located in the `ios/Runner` directory:

```xml file=ios/Runner/Info.plist
<?xml version="1.0" encoding="UTF-8"?>
Expand All @@ -72,7 +111,39 @@ For iOS, you'll need to have [Cocoapods](https://guides.cocoapods.org/using/gett
</plist>
```

Then you need to set the minimum platform version to iOS 13.0 in your Podfile:
Or manually (more control and more configurations available):

Add your PostHog configuration to the `Info.plist` file located in the `ios/Runner` directory:

```xml file=ios/Runner/Info.plist
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<!-- rest of your configuration -->
<key>com.posthog.posthog.AUTO_INIT</key>
<false/>
</dict>
</plist>
```

And setup the SDK manually:

```dart
Future<void> main() async {
// init WidgetsFlutterBinding if not yet
WidgetsFlutterBinding.ensureInitialized();
final config = PostHogConfig('YOUR_API_KEY_GOES_HERE');
config.debug = true;
config.captureApplicationLifecycleEvents = true;
// or EU Host: 'https://eu.i.posthog.com'
config.host = 'https://us.i.posthog.com';
await Posthog().setup(config);
runApp(MyApp());
}
```

In both cases, you'll need to set the minimum platform version to iOS 13.0 in your Podfile:

```yaml file=ios/Podfile
platform :ios, '13.0'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ if (PostHog.getFeatureFlag("flag-key") == "variant-key") { // replace 'variant-k

### Ensuring flags are loaded before usage

Every time a user loads a screen, we send a request in the background to fetch the feature flags that apply to that user. We store those flags in the storage.
Every time a user opens the app, we send a request in the background to fetch the feature flags that apply to that user. We store those flags in the storage.

This means that for most screens, the feature flags are available immediately – **except for the first time a user visits**.

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ if (await Posthog().getFeatureFlag('flag-key') == 'variant-key') { // replace 'v

### Ensuring flags are loaded before usage

Every time a user loads a screen, we send a request in the background to fetch the feature flags that apply to that user. We store those flags in the storage.
Every time a user opens the app, we send a request in the background to fetch the feature flags that apply to that user. We store those flags in the storage.

This means that for most screens, the feature flags are available immediately – **except for the first time a user visits**.

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ if (PostHogSDK.shared.getFeatureFlag("flag-key") as? String == "variant-key") {

### Ensuring flags are loaded before usage

Every time a user loads a screen, we send a request in the background to fetch the feature flags that apply to that user. We store those flags in the storage.
Every time a user opens the app, we send a request in the background to fetch the feature flags that apply to that user. We store those flags in the storage.

This means that for most screens, the feature flags are available immediately – **except for the first time a user visits**.

Expand Down
2 changes: 1 addition & 1 deletion contents/docs/libraries/android/index.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ PostHog.capture(

## Super Properties

Super Properties are properties associated with events that are set once and then sent with every `capture` call, be it a $screen, or anything else.
Super Properties are properties associated with events that are set once and then sent with every `capture` call, be it a `$screen`, or anything else.

They are set using `PostHog.register`, which takes a key and value, and they persist across sessions.

Expand Down
20 changes: 19 additions & 1 deletion contents/docs/libraries/flutter/index.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -96,9 +96,23 @@ await Posthog().alias(

We strongly recommend reading our docs on [alias](/docs/data/identify#alias-assigning-multiple-distinct-ids-to-the-same-user) to best understand how to correctly use this method.

## Person Profiles ("anonymous" vs "identified" persons)

The default behavior for this SDK is to use the `identifiedOnly` mode of person processing, but this can be changed in the config. The options are:
- `PostHogPersonProfiles.identifiedOnly`
- `PostHogPersonProfiles.never`
- `PostHogPersonProfiles.always`

To change the person profiles behaviour, you'll have to setup the SDK manually and set the desired person profiles:

```dart
final config = PostHogConfig('YOUR_API_KEY_GOES_HERE');
config.personProfiles = PostHogPersonProfiles.always
```

## Super Properties

Super Properties are properties associated with events that are set once and then sent with every `capture` call, be it a $screen, or anything else.
Super Properties are properties associated with events that are set once and then sent with every `capture` call, be it a `$screen`, or anything else.

They are set using `Posthog().register`, which takes a key and value, and they persist across sessions.

Expand Down Expand Up @@ -167,8 +181,12 @@ import FlutterFeatureFlagsCode from '../../integrate/feature-flags-code/_snippet

> **Note: ** Session replay is only supported on the [Flutter Web](https://flutter.dev/multi-platform/web) environment.

> We're currently working on Session replay for Android and iOS, subscribe to the [issue](https://github.com/PostHog/posthog-flutter/issues/69) and stay tuned.

To set up [session replay](/docs/session-replay) in your project, all you need to do is install the Flutter SDK and enable "Record user sessions" in [your project settings](https://us.posthog.com/settings/project-replay).

If you're using the `canvaskit` renderer, also enable the "Canvas capture" in [your project settings](https://us.posthog.com/settings/project-replay).

## Issues

Please file any issues, bugs, or feature requests in our [GitHub repository](https://github.com/posthog/posthog-flutter/issues/new).
Expand Down
2 changes: 1 addition & 1 deletion contents/docs/libraries/ios/index.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ PostHogSDK.shared.capture("signed_up", properties: ["plan": "Pro++"], userProper

## Super Properties

Super Properties are properties associated with events that are set once and then sent with every `capture` call, be it a $screen, or anything else.
Super Properties are properties associated with events that are set once and then sent with every `capture` call, be it a `$screen`, or anything else.

They are set using `PostHogSDK.shared.register`, which takes a properties object as a parameter, and they persist across sessions.

Expand Down
2 changes: 1 addition & 1 deletion contents/docs/libraries/react-native/index.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ posthog.capture('some_event', { $set_once: { userProperty: 'value' } })

## Super properties

Super properties are properties associated with events that are set once and then sent with every `capture` call, be it a $screen, an autocaptured touch, or anything else.
Super properties are properties associated with events that are set once and then sent with every `capture` call, be it a `$screen`, an autocaptured touch, or anything else.

They are set using `posthog.register`, which takes a properties object as a parameter, and they persist across sessions.

Expand Down
Loading