vybekiit 0.7.34 → 0.7.35
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/bin.js +520 -9
- package/dist/global-skills/eas-app-stores/SKILL.md +2 -2
- package/dist/global-skills/eas-hosting/SKILL.md +2 -2
- package/dist/global-skills/eas-observe/SKILL.md +7 -15
- package/dist/global-skills/eas-observe/references/queries.md +51 -10
- package/dist/global-skills/eas-observe/references/setup.md +60 -7
- package/dist/global-skills/eas-simulator/SKILL.md +2 -2
- package/dist/global-skills/eas-simulator/references/run-your-app.md +2 -0
- package/dist/global-skills/eas-update/SKILL.md +2 -2
- package/dist/global-skills/eas-update-insights/SKILL.md +2 -2
- package/dist/global-skills/eas-workflows/SKILL.md +2 -2
- package/dist/global-skills/expo-animation/SKILL.md +2 -2
- package/dist/global-skills/expo-app-clip/SKILL.md +2 -2
- package/dist/global-skills/expo-brownfield/SKILL.md +2 -2
- package/dist/global-skills/expo-data-fetching/SKILL.md +2 -2
- package/dist/global-skills/expo-design-system/SKILL.md +2 -2
- package/dist/global-skills/expo-dev-client/SKILL.md +4 -2
- package/dist/global-skills/expo-dom/SKILL.md +2 -2
- package/dist/global-skills/expo-examples/SKILL.md +2 -2
- package/dist/global-skills/expo-migrate-module/SKILL.md +2 -2
- package/dist/global-skills/expo-module/SKILL.md +2 -2
- package/dist/global-skills/expo-native-ui/SKILL.md +2 -2
- package/dist/global-skills/expo-overview/SKILL.md +9 -4
- package/dist/global-skills/expo-overview/references/launch-without-dev-menu.md +24 -0
- package/dist/global-skills/expo-project-structure/SKILL.md +2 -2
- package/dist/global-skills/expo-router/SKILL.md +2 -2
- package/dist/global-skills/expo-ui/SKILL.md +2 -2
- package/dist/global-skills/expo-upgrade/SKILL.md +2 -2
- package/dist/global-skills/expo-web-to-native/SKILL.md +2 -2
- package/dist/global-skills/expo-web-to-native/references/verify-on-device.md +1 -1
- package/dist/global-skills/firebase-app-hosting-basics/SKILL.md +16 -3
- package/dist/global-skills/firebase-app-hosting-basics/references/cli_commands.md +10 -12
- package/dist/global-skills/firebase-app-hosting-basics/references/configuration.md +2 -1
- package/dist/global-skills/firebase-basics/SKILL.md +6 -4
- package/dist/global-skills/firebase-basics/references/web_setup.md +3 -3
- package/dist/global-skills/instrument-feature-flags/references/adding-feature-flag-code.md +81 -333
- package/dist/global-skills/instrument-feature-flags/references/android.md +19 -13
- package/dist/global-skills/instrument-feature-flags/references/api.md +17 -13
- package/dist/global-skills/instrument-feature-flags/references/best-practices.md +35 -35
- package/dist/global-skills/instrument-feature-flags/references/django.md +120 -72
- package/dist/global-skills/instrument-feature-flags/references/dotnet.md +48 -102
- package/dist/global-skills/instrument-feature-flags/references/elixir.md +4 -10
- package/dist/global-skills/instrument-feature-flags/references/flask.md +55 -39
- package/dist/global-skills/instrument-feature-flags/references/flutter.md +19 -13
- package/dist/global-skills/instrument-feature-flags/references/go.md +21 -13
- package/dist/global-skills/instrument-feature-flags/references/ios.md +19 -13
- package/dist/global-skills/instrument-feature-flags/references/java.md +4 -12
- package/dist/global-skills/instrument-feature-flags/references/laravel.md +18 -16
- package/dist/global-skills/instrument-feature-flags/references/next-js.md +44 -54
- package/dist/global-skills/instrument-feature-flags/references/nodejs.md +21 -13
- package/dist/global-skills/instrument-feature-flags/references/php.md +21 -13
- package/dist/global-skills/instrument-feature-flags/references/python.md +22 -14
- package/dist/global-skills/instrument-feature-flags/references/react-native.md +18 -13
- package/dist/global-skills/instrument-feature-flags/references/react.md +21 -14
- package/dist/global-skills/instrument-feature-flags/references/ruby-on-rails.md +31 -68
- package/dist/global-skills/instrument-feature-flags/references/ruby.md +21 -13
- package/dist/global-skills/instrument-feature-flags/references/rust.md +10 -34
- package/dist/global-skills/instrument-feature-flags/references/usage.md +94 -114
- package/dist/global-skills/instrument-feature-flags/references/web.md +21 -13
- package/dist/global-skills/instrument-product-analytics/references/EXAMPLE-android.md +7 -7
- package/dist/global-skills/instrument-product-analytics/references/EXAMPLE-expo.md +2 -2
- package/dist/global-skills/instrument-product-analytics/references/EXAMPLE-fastapi.md +1 -1
- package/dist/global-skills/instrument-product-analytics/references/EXAMPLE-flask.md +1 -1
- package/dist/global-skills/instrument-product-analytics/references/EXAMPLE-laravel.md +2 -2
- package/dist/global-skills/instrument-product-analytics/references/EXAMPLE-php.md +1 -1
- package/dist/global-skills/instrument-product-analytics/references/EXAMPLE-python.md +1 -1
- package/dist/global-skills/instrument-product-analytics/references/EXAMPLE-ruby.md +1 -1
- package/dist/global-skills/instrument-product-analytics/references/EXAMPLE-swift.md +4 -4
- package/dist/global-skills/instrument-product-analytics/references/android.md +64 -109
- package/dist/global-skills/instrument-product-analytics/references/angular.md +32 -28
- package/dist/global-skills/instrument-product-analytics/references/astro.md +29 -34
- package/dist/global-skills/instrument-product-analytics/references/configuration.md +27 -42
- package/dist/global-skills/instrument-product-analytics/references/django.md +120 -72
- package/dist/global-skills/instrument-product-analytics/references/dotnet.md +48 -102
- package/dist/global-skills/instrument-product-analytics/references/elixir.md +25 -50
- package/dist/global-skills/instrument-product-analytics/references/flask.md +55 -39
- package/dist/global-skills/instrument-product-analytics/references/flutter.md +94 -96
- package/dist/global-skills/instrument-product-analytics/references/go.md +39 -77
- package/dist/global-skills/instrument-product-analytics/references/identify-users.md +24 -26
- package/dist/global-skills/instrument-product-analytics/references/ios.md +22 -22
- package/dist/global-skills/instrument-product-analytics/references/laravel.md +18 -16
- package/dist/global-skills/instrument-product-analytics/references/next-js.md +44 -54
- package/dist/global-skills/instrument-product-analytics/references/nuxt-js-3-6.md +32 -34
- package/dist/global-skills/instrument-product-analytics/references/nuxt-js.md +36 -36
- package/dist/global-skills/instrument-product-analytics/references/php.md +42 -87
- package/dist/global-skills/instrument-product-analytics/references/posthog-python.md +15 -12
- package/dist/global-skills/instrument-product-analytics/references/python.md +106 -154
- package/dist/global-skills/instrument-product-analytics/references/react-native.md +97 -176
- package/dist/global-skills/instrument-product-analytics/references/react-router-v6.md +29 -40
- package/dist/global-skills/instrument-product-analytics/references/react-router-v7-data-mode.md +29 -38
- package/dist/global-skills/instrument-product-analytics/references/react-router-v7-declarative-mode.md +29 -40
- package/dist/global-skills/instrument-product-analytics/references/react-router-v7-framework-mode.md +32 -37
- package/dist/global-skills/instrument-product-analytics/references/ruby-on-rails.md +31 -68
- package/dist/global-skills/instrument-product-analytics/references/ruby.md +40 -96
- package/dist/global-skills/instrument-product-analytics/references/svelte.md +34 -34
- package/dist/global-skills/instrument-product-analytics/references/tanstack-start.md +19 -19
- package/dist/global-skills/instrument-product-analytics/references/usage.md +94 -114
- package/dist/global-skills/instrument-product-analytics/references/vue-js.md +33 -45
- package/dist/global-skills/mongodb-search-and-ai/SKILL.md +40 -22
- package/dist/global-skills/mongodb-search-and-ai/references/automated-embedding.md +8 -2
- package/dist/global-skills/mongodb-search-and-ai/references/quick-start.md +725 -0
- package/dist/global-skills/mongodb-search-and-ai/scripts/quickstart_complete.py +386 -0
- package/dist/global-skills/neon/references/claimable-neon.md +2 -0
- package/dist/global-skills/neon-realtime/references/queries.md +2 -2
- package/dist/global-skills/resend/SKILL.md +1 -1
- package/dist/global-skills/resend/references/inboxes.md +49 -21
- package/dist/global-skills/resend/references/webhooks.md +1 -1
- package/dist/global-skills/stripe-best-practices/SKILL.md +1 -1
- package/dist/global-skills/stripe-best-practices/references/connect.md +1 -1
- package/dist/global-skills/stripe-best-practices/references/security.md +9 -9
- package/dist/global-skills/vybekiitReferences/backend/AGENTS.md +1 -1
- package/dist/global-skills/vybekiitReferences/backend/agent/goal-routes.json +303 -18
- package/dist/global-skills/vybekiitReferences/extension/AGENTS.md +1 -1
- package/dist/global-skills/vybekiitReferences/extension/agent/goal-routes.json +352 -18
- package/dist/global-skills/vybekiitReferences/mobile/AGENTS.md +1 -1
- package/dist/global-skills/vybekiitReferences/mobile/agent/goal-routes.json +413 -22
- package/dist/global-skills/vybekiitReferences/spa/AGENTS.md +1 -1
- package/dist/global-skills/vybekiitReferences/spa/agent/goal-routes.json +391 -21
- package/dist/global-skills/vybekiitReferences/web/AGENTS.md +14 -2
- package/dist/global-skills/vybekiitReferences/web/agent/goal-routes.json +490 -32
- package/package.json +8 -8
|
@@ -2,6 +2,33 @@
|
|
|
2
2
|
|
|
3
3
|
# Flutter
|
|
4
4
|
|
|
5
|
+
Canonical URL: https://posthog.com/docs/libraries/flutter
|
|
6
|
+
|
|
7
|
+
> **Cloud region:** This page uses US Cloud hosts. For an EU Cloud project, use `https://eu.posthog.com` instead of `https://us.posthog.com` (app host for links).
|
|
8
|
+
|
|
9
|
+
## On this page
|
|
10
|
+
|
|
11
|
+
- [Installation](#installation)
|
|
12
|
+
- [Capturing events](#capturing-events)
|
|
13
|
+
- [Identifying users](#identifying-users)
|
|
14
|
+
- [Get the current user's distinct ID](#get-the-current-users-distinct-id)
|
|
15
|
+
- [Alias](#alias)
|
|
16
|
+
- [Anonymous vs identified events](#anonymous-vs-identified-events)
|
|
17
|
+
- [Super properties](#super-properties)
|
|
18
|
+
- [Group analytics](#group-analytics)
|
|
19
|
+
- [Feature flags](#feature-flags)
|
|
20
|
+
- [Experiments (A/B tests)](#experiments-ab-tests)
|
|
21
|
+
- [Error tracking](#error-tracking)
|
|
22
|
+
- [Logs](#logs)
|
|
23
|
+
- [Session replay](#session-replay)
|
|
24
|
+
- [Surveys](#surveys)
|
|
25
|
+
- [Push notifications](#push-notifications)
|
|
26
|
+
- [Flush](#flush)
|
|
27
|
+
- [Offline behavior](#offline-behavior)
|
|
28
|
+
- [Opt out of data capture](#opt-out-of-data-capture)
|
|
29
|
+
- [Amending or dropping events](#amending-or-dropping-events)
|
|
30
|
+
- [Debug mode](#debug-mode)
|
|
31
|
+
|
|
5
32
|
This is an optional library you can install if you're working with Flutter. It uses an internal queue to make calls fast and non-blocking. It also batches requests and flushes asynchronously, making it perfect to use in any part of your mobile app.
|
|
6
33
|
|
|
7
34
|
PostHog supports the iOS, macOS, Android, and Web platforms.
|
|
@@ -147,8 +174,6 @@ platform :ios, '13.0'
|
|
|
147
174
|
|
|
148
175
|
For Swift Package Manager projects without a `Podfile`, set the **Minimum Deployments** version to iOS 13.0 for the `Runner` target in Xcode (**Runner > General > Minimum Deployments**). After you change **Minimum Deployments**, regenerate the iOS project's configuration files:
|
|
149
176
|
|
|
150
|
-
Terminal
|
|
151
|
-
|
|
152
177
|
```bash
|
|
153
178
|
flutter build ios --config-only
|
|
154
179
|
```
|
|
@@ -159,8 +184,6 @@ If you followed the automatic SDK setup, then there's no more configuration need
|
|
|
159
184
|
|
|
160
185
|
If you followed the manual SDK setup:
|
|
161
186
|
|
|
162
|
-
Dart
|
|
163
|
-
|
|
164
187
|
```dart
|
|
165
188
|
import 'package:flutter/material.dart';
|
|
166
189
|
|
|
@@ -258,12 +281,47 @@ web/index.html
|
|
|
258
281
|
|
|
259
282
|
For more information please check: /docs/libraries/js
|
|
260
283
|
|
|
284
|
+
### Reproducible Android builds and Shorebird
|
|
285
|
+
|
|
286
|
+
The Flutter SDK uses the native PostHog Android SDK, which depends on the PostHog core library. The Flutter package permits a range of Android SDK versions, so Gradle can select a newer native version even when your `posthog_flutter` version hasn't changed. Your `pubspec.lock` doesn't lock these Gradle dependencies.
|
|
287
|
+
|
|
288
|
+
This matters for [Shorebird](https://docs.shorebird.dev/code-push/troubleshooting/) patches, which can't update native Android code. To keep PostHog's native dependencies consistent between a release and its patches, pin both native libraries before creating the release:
|
|
289
|
+
|
|
290
|
+
1. Inspect the versions selected for your release build. From your app's `android` directory, run:
|
|
291
|
+
|
|
292
|
+
```bash
|
|
293
|
+
./gradlew :app:dependencyInsight --dependency com.posthog --configuration releaseRuntimeClasspath
|
|
294
|
+
```
|
|
295
|
+
|
|
296
|
+
If you use product flavors, replace `releaseRuntimeClasspath` with your release variant's configuration, such as `productionReleaseRuntimeClasspath`. Record the selected versions of `com.posthog:posthog-android` and `com.posthog:posthog`; their version numbers differ.
|
|
297
|
+
|
|
298
|
+
2. Add strict constraints to your app's `android/app/build.gradle.kts`. Replace the placeholders with the versions selected together in the previous step:
|
|
299
|
+
|
|
300
|
+
```kotlin
|
|
301
|
+
dependencies {
|
|
302
|
+
constraints {
|
|
303
|
+
implementation("com.posthog:posthog-android") {
|
|
304
|
+
version { strictly("<android-sdk-version>") }
|
|
305
|
+
}
|
|
306
|
+
implementation("com.posthog:posthog") {
|
|
307
|
+
version { strictly("<core-version>") }
|
|
308
|
+
}
|
|
309
|
+
}
|
|
310
|
+
}
|
|
311
|
+
```
|
|
312
|
+
|
|
313
|
+
For a Groovy `build.gradle`, use the same dependency declarations with `version { strictly "<version>" }` inside each constraint. A plain version declaration can still be upgraded during Gradle conflict resolution; [strict constraints](https://docs.gradle.org/current/userguide/dependency_versions.html#sec:rich-version-constraints) enforce the selected versions.
|
|
314
|
+
|
|
315
|
+
3. Run the dependency report again, build your app, and verify that events arrive in PostHog. Commit the constraints and `pubspec.lock`, and use the same versions for the release and its patches.
|
|
316
|
+
|
|
317
|
+
For an existing Shorebird release, use the native versions recorded for that release, not versions resolved by a fresh build today. Pinning PostHog alone doesn't freeze other plugins or your build tools. For broader dependency control, see [Gradle dependency locking](https://docs.gradle.org/current/userguide/dependency_locking.html).
|
|
318
|
+
|
|
319
|
+
Pins also prevent automatic native bug fixes. When upgrading PostHog, review the pins, select compatible native versions together, and test event capture before shipping a new app-store release. Don't upgrade native dependencies in a Dart-only patch or force an old version below the Flutter package's required minimum.
|
|
320
|
+
|
|
261
321
|
## Capturing events
|
|
262
322
|
|
|
263
323
|
You can send custom events using `capture`:
|
|
264
324
|
|
|
265
|
-
Dart
|
|
266
|
-
|
|
267
325
|
```dart
|
|
268
326
|
await Posthog().capture(
|
|
269
327
|
eventName: 'user_signed_up',
|
|
@@ -274,9 +332,7 @@ await Posthog().capture(
|
|
|
274
332
|
|
|
275
333
|
### Setting event properties
|
|
276
334
|
|
|
277
|
-
Optionally, you can include additional information with the event by including a [properties](/docs/data/events.md#event-properties) object:
|
|
278
|
-
|
|
279
|
-
Dart
|
|
335
|
+
Optionally, you can include additional information with the event by including a [properties](https://posthog.com/docs/data/events.md#event-properties) object:
|
|
280
336
|
|
|
281
337
|
```dart
|
|
282
338
|
await Posthog().capture(
|
|
@@ -311,8 +367,6 @@ This works with any routing package, not just the plain `Navigator` API. Add the
|
|
|
311
367
|
|
|
312
368
|
Add the `PosthogObserver` to record screen views automatically:
|
|
313
369
|
|
|
314
|
-
Dart
|
|
315
|
-
|
|
316
370
|
```dart
|
|
317
371
|
import 'package:flutter/material.dart';
|
|
318
372
|
import 'package:posthog_flutter/posthog_flutter.dart';
|
|
@@ -336,8 +390,6 @@ class MyApp extends StatelessWidget {
|
|
|
336
390
|
|
|
337
391
|
Name your routes:
|
|
338
392
|
|
|
339
|
-
Dart
|
|
340
|
-
|
|
341
393
|
```dart
|
|
342
394
|
...
|
|
343
395
|
MaterialPageRoute(builder: (context) => const HomeScreenRoute(),
|
|
@@ -350,8 +402,6 @@ MaterialPageRoute(builder: (context) => const HomeScreenRoute(),
|
|
|
350
402
|
|
|
351
403
|
Add the `PosthogObserver` to record screen views automatically:
|
|
352
404
|
|
|
353
|
-
Dart
|
|
354
|
-
|
|
355
405
|
```dart
|
|
356
406
|
import 'package:flutter/material.dart';
|
|
357
407
|
import 'package:posthog_flutter/posthog_flutter.dart';
|
|
@@ -379,8 +429,6 @@ class MyApp extends StatelessWidget {
|
|
|
379
429
|
|
|
380
430
|
Name your routes:
|
|
381
431
|
|
|
382
|
-
Dart
|
|
383
|
-
|
|
384
432
|
```dart
|
|
385
433
|
...
|
|
386
434
|
GoRoute(
|
|
@@ -392,17 +440,15 @@ GoRoute(
|
|
|
392
440
|
|
|
393
441
|
## Identifying users
|
|
394
442
|
|
|
395
|
-
> We highly recommend reading our section on [Identifying users](/docs/integrate/identifying-users.md) to better understand how to correctly use this method.
|
|
443
|
+
> We highly recommend reading our section on [Identifying users](https://posthog.com/docs/integrate/identifying-users.md) to better understand how to correctly use this method.
|
|
396
444
|
|
|
397
445
|
Using `identify`, you can associate events with specific users. This enables you to gain full insights as to how they're using your product across different sessions, devices, and platforms.
|
|
398
446
|
|
|
399
447
|
An `identify` call has the following arguments:
|
|
400
448
|
|
|
401
449
|
- **userId:** Required. A unique identifier for your user. Typically either their email or database ID.
|
|
402
|
-
- **userProperties:** Optional. A dictionary with key:value pairs to set the [person properties](/docs/product-analytics/person-properties.md)
|
|
403
|
-
- **userPropertiesSetOnce:** Optional. Similar to `userProperties`. [See the difference between `userProperties` and `userPropertiesSetOnce`](/docs/product-analytics/person-properties.md#what-is-the-difference-between-set-and-set_once)
|
|
404
|
-
|
|
405
|
-
Dart
|
|
450
|
+
- **userProperties:** Optional. A dictionary with key:value pairs to set the [person properties](https://posthog.com/docs/product-analytics/person-properties.md)
|
|
451
|
+
- **userPropertiesSetOnce:** Optional. Similar to `userProperties`. [See the difference between `userProperties` and `userPropertiesSetOnce`](https://posthog.com/docs/product-analytics/person-properties.md#what-is-the-difference-between-set-and-set_once)
|
|
406
452
|
|
|
407
453
|
```dart
|
|
408
454
|
await Posthog().identify(
|
|
@@ -428,21 +474,19 @@ Sometimes, you want to assign multiple distinct IDs to a single user. This is he
|
|
|
428
474
|
|
|
429
475
|
In this case, you can use `alias` to assign another distinct ID to the same user.
|
|
430
476
|
|
|
431
|
-
Dart
|
|
432
|
-
|
|
433
477
|
```dart
|
|
434
478
|
await Posthog().alias(
|
|
435
479
|
alias: 'distinct_id',
|
|
436
480
|
);
|
|
437
481
|
```
|
|
438
482
|
|
|
439
|
-
We strongly recommend reading our docs on [alias](/docs/product-analytics/identify.md#alias-assigning-multiple-distinct-ids-to-the-same-user) to best understand how to correctly use this method.
|
|
483
|
+
We strongly recommend reading our docs on [alias](https://posthog.com/docs/product-analytics/identify.md#alias-assigning-multiple-distinct-ids-to-the-same-user) to best understand how to correctly use this method.
|
|
440
484
|
|
|
441
485
|
## Anonymous vs identified events
|
|
442
486
|
|
|
443
|
-
PostHog captures two types of events: [**anonymous** and **identified**](/docs/data/anonymous-vs-identified-events.md)
|
|
487
|
+
PostHog captures two types of events: [**anonymous** and **identified**](https://posthog.com/docs/data/anonymous-vs-identified-events.md)
|
|
444
488
|
|
|
445
|
-
**Identified events** enable you to attribute events to specific users, and attach [person properties](/docs/product-analytics/person-properties.md). They're best suited for logged-in users.
|
|
489
|
+
**Identified events** enable you to attribute events to specific users, and attach [person properties](https://posthog.com/docs/product-analytics/person-properties.md). They're best suited for logged-in users.
|
|
446
490
|
|
|
447
491
|
Scenarios where you want to capture identified events are:
|
|
448
492
|
|
|
@@ -450,7 +494,7 @@ Scenarios where you want to capture identified events are:
|
|
|
450
494
|
- Doing user segmented product analysis
|
|
451
495
|
- Growth and marketing teams wanting to analyze the *complete* conversion lifecycle
|
|
452
496
|
|
|
453
|
-
**Anonymous events** are events without individually identifiable data. They're best suited for [web analytics](/docs/web-analytics.md) or apps where users aren't logged in.
|
|
497
|
+
**Anonymous events** are events without individually identifiable data. They're best suited for [web analytics](https://posthog.com/docs/web-analytics.md) or apps where users aren't logged in.
|
|
454
498
|
|
|
455
499
|
Scenarios where you want to capture anonymous events are:
|
|
456
500
|
|
|
@@ -458,15 +502,15 @@ Scenarios where you want to capture anonymous events are:
|
|
|
458
502
|
- Content-focused sites
|
|
459
503
|
- B2C apps where users don't sign up or log in
|
|
460
504
|
|
|
461
|
-
Under the hood, the key difference between identified and anonymous events is that for identified events we create a [person profile](/docs/data/persons.md) for the user, whereas for anonymous events we do not.
|
|
505
|
+
Under the hood, the key difference between identified and anonymous events is that for identified events we create a [person profile](https://posthog.com/docs/data/persons.md) for the user, whereas for anonymous events we do not.
|
|
462
506
|
|
|
463
507
|
> **Important:** Due to the reduced cost of processing them, anonymous events can be up to 4x cheaper than identified ones, so we recommended you only capture identified events when needed.
|
|
464
508
|
|
|
465
509
|
### How to capture anonymous events
|
|
466
510
|
|
|
467
|
-
The Flutter SDK captures anonymous events by default. However, this may change depending on your `personProfiles` [config](/docs/libraries/flutter.md#person-profiles-anonymous-vs-identified-persons) when initializing PostHog:
|
|
511
|
+
The Flutter SDK captures anonymous events by default. However, this may change depending on your `personProfiles` [config](https://posthog.com/docs/libraries/flutter.md#person-profiles-anonymous-vs-identified-persons) when initializing PostHog:
|
|
468
512
|
|
|
469
|
-
1. `personProfiles: PostHogPersonProfiles.identifiedOnly` *(recommended)* *(default)* - Anonymous events are captured by default. PostHog only captures identified events for users where [person profiles](/docs/data/persons.md) have already been created.
|
|
513
|
+
1. `personProfiles: PostHogPersonProfiles.identifiedOnly` *(recommended)* *(default)* - Anonymous events are captured by default. PostHog only captures identified events for users where [person profiles](https://posthog.com/docs/data/persons.md) have already been created.
|
|
470
514
|
|
|
471
515
|
2. `personProfiles: PostHogPersonProfiles.always` - Capture identified events for all events.
|
|
472
516
|
|
|
@@ -474,8 +518,6 @@ The Flutter SDK captures anonymous events by default. However, this may change d
|
|
|
474
518
|
|
|
475
519
|
For example:
|
|
476
520
|
|
|
477
|
-
Dart
|
|
478
|
-
|
|
479
521
|
```dart
|
|
480
522
|
final config = PostHogConfig('<ph_project_token>');
|
|
481
523
|
config.host = 'https://us.i.posthog.com';
|
|
@@ -484,13 +526,13 @@ config.personProfiles = PostHogPersonProfiles.identifiedOnly;
|
|
|
484
526
|
|
|
485
527
|
### How to capture identified events
|
|
486
528
|
|
|
487
|
-
If you've set the [`personProfiles` config](/docs/libraries/flutter.md#person-profiles-anonymous-vs-identified-persons) to `PostHogPersonProfiles.identifiedOnly` (the default option), anonymous events are captured by default. Then, to capture identified events, call any of the following functions:
|
|
529
|
+
If you've set the [`personProfiles` config](https://posthog.com/docs/libraries/flutter.md#person-profiles-anonymous-vs-identified-persons) to `PostHogPersonProfiles.identifiedOnly` (the default option), anonymous events are captured by default. Then, to capture identified events, call any of the following functions:
|
|
488
530
|
|
|
489
|
-
- [`identify()`](/docs/product-analytics/identify.md)
|
|
490
|
-
- [`alias()`](/docs/product-analytics/identify.md#alias-assigning-multiple-distinct-ids-to-the-same-user)
|
|
491
|
-
- [`group()`](/docs/product-analytics/group-analytics.md)
|
|
531
|
+
- [`identify()`](https://posthog.com/docs/product-analytics/identify.md)
|
|
532
|
+
- [`alias()`](https://posthog.com/docs/product-analytics/identify.md#alias-assigning-multiple-distinct-ids-to-the-same-user)
|
|
533
|
+
- [`group()`](https://posthog.com/docs/product-analytics/group-analytics.md)
|
|
492
534
|
|
|
493
|
-
When you call any of these functions, it creates a [person profile](/docs/data/persons.md) for the user. Once this profile is created, all subsequent events for this user will be captured as identified events.
|
|
535
|
+
When you call any of these functions, it creates a [person profile](https://posthog.com/docs/data/persons.md) for the user. Once this profile is created, all subsequent events for this user will be captured as identified events.
|
|
494
536
|
|
|
495
537
|
Alternatively, you can set `personProfiles` to `PostHogPersonProfiles.always` to capture identified events by default.
|
|
496
538
|
|
|
@@ -502,8 +544,6 @@ They are set using `Posthog().register`, which takes a key and value, and they p
|
|
|
502
544
|
|
|
503
545
|
For example, take a look at the following call:
|
|
504
546
|
|
|
505
|
-
Dart
|
|
506
|
-
|
|
507
547
|
```dart
|
|
508
548
|
import 'package:posthog_flutter/posthog_flutter.dart';
|
|
509
549
|
|
|
@@ -518,8 +558,6 @@ However, please note that this does not store properties against the User, only
|
|
|
518
558
|
|
|
519
559
|
Super properties are persisted across sessions so you have to explicitly remove them if they are no longer relevant. In order to stop sending a super property with events, you can use `Posthog().unregister`, like so:
|
|
520
560
|
|
|
521
|
-
Dart
|
|
522
|
-
|
|
523
561
|
```dart
|
|
524
562
|
import 'package:posthog_flutter/posthog_flutter.dart';
|
|
525
563
|
|
|
@@ -532,18 +570,16 @@ If you are doing this as part of a user logging out you can instead simply use `
|
|
|
532
570
|
|
|
533
571
|
## Group analytics
|
|
534
572
|
|
|
535
|
-
Group analytics allows you to associate the events for that person's session with a group (e.g. teams, organizations, etc.). See [Group Analytics](/docs/product-analytics/group-analytics.md) for Flutter examples and implementation details.
|
|
573
|
+
Group analytics allows you to associate the events for that person's session with a group (e.g. teams, organizations, etc.). See [Group Analytics](https://posthog.com/docs/product-analytics/group-analytics.md) for Flutter examples and implementation details.
|
|
536
574
|
|
|
537
|
-
> **Note:** This is a paid feature and is not available on the open-source or free cloud plan. Learn more on the [pricing page](/pricing.md).
|
|
575
|
+
> **Note:** This is a paid feature and is not available on the open-source or free cloud plan. Learn more on the [pricing page](https://posthog.com/pricing.md).
|
|
538
576
|
|
|
539
577
|
## Feature flags
|
|
540
578
|
|
|
541
|
-
PostHog's [feature flags](/docs/feature-flags.md) enable you to safely deploy and roll back new features as well as target specific users and groups with them.
|
|
579
|
+
PostHog's [feature flags](https://posthog.com/docs/feature-flags.md) enable you to safely deploy and roll back new features as well as target specific users and groups with them.
|
|
542
580
|
|
|
543
581
|
### Boolean feature flags
|
|
544
582
|
|
|
545
|
-
Dart
|
|
546
|
-
|
|
547
583
|
```dart
|
|
548
584
|
final result = await Posthog().getFeatureFlagResult('flag-key');
|
|
549
585
|
if (result != null && result.enabled) {
|
|
@@ -556,8 +592,6 @@ if (result != null && result.enabled) {
|
|
|
556
592
|
|
|
557
593
|
### Multivariate feature flags
|
|
558
594
|
|
|
559
|
-
Dart
|
|
560
|
-
|
|
561
595
|
```dart
|
|
562
596
|
final result = await Posthog().getFeatureFlagResult('flag-key');
|
|
563
597
|
if (result != null && result.variant == 'variant-key') { // replace 'variant-key' with the key of your variant
|
|
@@ -578,8 +612,6 @@ This means that for most screens, the feature flags are available immediately
|
|
|
578
612
|
|
|
579
613
|
To handle this, you can use the `onFeatureFlags` callback in your config to be notified when flags are loaded:
|
|
580
614
|
|
|
581
|
-
Dart
|
|
582
|
-
|
|
583
615
|
```dart
|
|
584
616
|
final config = PostHogConfig('<ph_project_token>');
|
|
585
617
|
config.host = 'https://us.i.posthog.com';
|
|
@@ -595,8 +627,6 @@ await Posthog().setup(config);
|
|
|
595
627
|
|
|
596
628
|
Feature flag values are cached. If something has changed with your user and you'd like to refetch their flag values, call:
|
|
597
629
|
|
|
598
|
-
Dart
|
|
599
|
-
|
|
600
630
|
```dart
|
|
601
631
|
await Posthog().reloadFeatureFlags();
|
|
602
632
|
```
|
|
@@ -609,8 +639,6 @@ To have your feature flags available immediately, you can initialize PostHog wit
|
|
|
609
639
|
|
|
610
640
|
Set `config.bootstrap` before calling `setup()` to seed identity and flag values before the first `/flags` response (requires the Flutter SDK `5.31.0`+):
|
|
611
641
|
|
|
612
|
-
Dart
|
|
613
|
-
|
|
614
642
|
```dart
|
|
615
643
|
final config = PostHogConfig('<ph_project_token>');
|
|
616
644
|
config.host = 'https://us.i.posthog.com';
|
|
@@ -634,14 +662,12 @@ The values are forwarded to the native iOS and Android SDKs:
|
|
|
634
662
|
|
|
635
663
|
The feature-flags-loaded signal fires as soon as bootstrapped flags are applied, so startup logic can read them immediately. These SDKs don't support the `sessionID` bootstrap option. When person profiles are set to `never`, the SDK preserves a different anonymous identity instead of merging it into an identified bootstrap.
|
|
636
664
|
|
|
637
|
-
On Flutter web, `bootstrap` is not applied, so configure it in your `posthog.init({...})` snippet instead. See the [SDK bootstrapping guide](/docs/libraries/bootstrapping.md) for the cross-SDK overview.
|
|
665
|
+
On Flutter web, `bootstrap` is not applied, so configure it in your `posthog.init({...})` snippet instead. See the [SDK bootstrapping guide](https://posthog.com/docs/libraries/bootstrapping.md) for the cross-SDK overview.
|
|
638
666
|
|
|
639
667
|
### Setting properties for flag evaluation
|
|
640
668
|
|
|
641
669
|
If a flag targets person or group properties, you can send those properties inline with the next flag evaluation request instead of waiting for a `$set` event to be ingested. This avoids the race where a flag returns a stale value right after you set a property.
|
|
642
670
|
|
|
643
|
-
Dart
|
|
644
|
-
|
|
645
671
|
```dart
|
|
646
672
|
// Person properties — included in the next flag evaluation request
|
|
647
673
|
await Posthog().setPersonPropertiesForFlags({
|
|
@@ -653,41 +679,41 @@ await Posthog().setPersonPropertiesForFlags({
|
|
|
653
679
|
await Posthog().setGroupPropertiesForFlags('company', {'plan': 'enterprise'});
|
|
654
680
|
```
|
|
655
681
|
|
|
656
|
-
By default these reload feature flags, and the returned `Future` completes once the reload finishes, so the next `getFeatureFlag` reflects the new properties. Pass `reloadFeatureFlags: false` to set several properties before reloading. Use `resetPersonPropertiesForFlags()` and `resetGroupPropertiesForFlags()` to clear them. See [property overrides for flag evaluation](/docs/feature-flags/property-overrides.md) for details.
|
|
682
|
+
By default these reload feature flags, and the returned `Future` completes once the reload finishes, so the next `getFeatureFlag` reflects the new properties. Pass `reloadFeatureFlags: false` to set several properties before reloading. Use `resetPersonPropertiesForFlags()` and `resetGroupPropertiesForFlags()` to clear them. See [property overrides for flag evaluation](https://posthog.com/docs/feature-flags/property-overrides.md) for details.
|
|
657
683
|
|
|
658
684
|
## Experiments (A/B tests)
|
|
659
685
|
|
|
660
|
-
Since [experiments](/docs/experiments/start-here.md) use feature flags, the code for running an experiment is very similar to the feature flags code. See [feature flag code examples](/docs/feature-flags/adding-feature-flag-code?tab=Flutter.md) for Flutter implementation details.
|
|
686
|
+
Since [experiments](https://posthog.com/docs/experiments/start-here.md) use feature flags, the code for running an experiment is very similar to the feature flags code. See [feature flag code examples](https://posthog.com/docs/feature-flags/adding-feature-flag-code?tab=Flutter.md) for Flutter implementation details.
|
|
661
687
|
|
|
662
|
-
It's also possible to [run experiments without using feature flags](/docs/experiments/running-experiments-without-feature-flags.md).
|
|
688
|
+
It's also possible to [run experiments without using feature flags](https://posthog.com/docs/experiments/running-experiments-without-feature-flags.md).
|
|
663
689
|
|
|
664
690
|
## Error tracking
|
|
665
691
|
|
|
666
|
-
To set up error tracking in your project, see the [error tracking docs](/docs/error-tracking.md).
|
|
692
|
+
To set up error tracking in your project, see the [error tracking docs](https://posthog.com/docs/error-tracking.md).
|
|
667
693
|
|
|
668
694
|
## Logs
|
|
669
695
|
|
|
670
|
-
To set up [logs](/docs/logs.md) in your Flutter app, follow the [Flutter logs installation guide](/docs/logs/installation/flutter.md). The SDK exposes `Posthog().logger.{trace,debug,info,warn,error,fatal}` (and `Posthog().captureLog` for full control) for sending structured records to PostHog Logs, with batching, offline persistence, and a rate cap built in.
|
|
696
|
+
To set up [logs](https://posthog.com/docs/logs.md) in your Flutter app, follow the [Flutter logs installation guide](https://posthog.com/docs/logs/installation/flutter.md). The SDK exposes `Posthog().logger.{trace,debug,info,warn,error,fatal}` (and `Posthog().captureLog` for full control) for sending structured records to PostHog Logs, with batching, offline persistence, and a rate cap built in.
|
|
671
697
|
|
|
672
698
|
## Session replay
|
|
673
699
|
|
|
674
700
|
> **Note:** Session replay is supported on Flutter Web, Android, and iOS.
|
|
675
701
|
|
|
676
|
-
To set up [session replay web](/docs/session-replay.md) or [mobile session replay](/docs/session-replay/mobile.md) in your project, all you need to do is install the Flutter SDK, follow the [additional installation instructions](/docs/session-replay/installation/flutter.md), and enable "Record user sessions" in [your project settings](https://us.posthog.com/settings/project-replay) and enable the `sessionReplay` option.
|
|
702
|
+
To set up [session replay web](https://posthog.com/docs/session-replay.md) or [mobile session replay](https://posthog.com/docs/session-replay/mobile.md) in your project, all you need to do is install the Flutter SDK, follow the [additional installation instructions](https://posthog.com/docs/session-replay/installation/flutter.md), and enable "Record user sessions" in [your project settings](https://us.posthog.com/settings/project-replay) and enable the `sessionReplay` option.
|
|
677
703
|
|
|
678
|
-
If you're using Flutter Web, also enable the [Canvas capture](/docs/session-replay/canvas-recording.md) in [your project settings](https://us.posthog.com/settings/project-replay). This is needed as Flutter renders your app using a browser canvas element.
|
|
704
|
+
If you're using Flutter Web, also enable the [Canvas capture](https://posthog.com/docs/session-replay/canvas-recording.md) in [your project settings](https://us.posthog.com/settings/project-replay). This is needed as Flutter renders your app using a browser canvas element.
|
|
679
705
|
|
|
680
|
-
On Flutter Web, masking (`maskAllTexts`, `maskAllImages`, `PostHogMaskWidget`) applies inside that canvas too — declare `session_recording.canvasCapture.maskRegionsFn` in the `posthog.init` call in your `web/index.html` to enable it (requires PostHog Flutter SDK 5.34.0+ and posthog-js 1.408.0+). See [masking on Flutter Web](/docs/session-replay/privacy.md) under the Flutter tab.
|
|
706
|
+
On Flutter Web, masking (`maskAllTexts`, `maskAllImages`, `PostHogMaskWidget`) applies inside that canvas too — declare `session_recording.canvasCapture.maskRegionsFn` in the `posthog.init` call in your `web/index.html` to enable it (requires PostHog Flutter SDK 5.34.0+ and posthog-js 1.408.0+). See [masking on Flutter Web](https://posthog.com/docs/session-replay/privacy.md) under the Flutter tab.
|
|
681
707
|
|
|
682
708
|
## Surveys
|
|
683
709
|
|
|
684
710
|
> **Note:** Surveys are supported in Flutter for **Web**, **iOS**, and **Android** platforms.
|
|
685
711
|
|
|
686
|
-
[Surveys](/docs/surveys.md) launched with [popover presentation](/docs/surveys/creating-surveys.md#presentation) are automatically shown to users matching the [display conditions](/docs/surveys/creating-surveys.md#display-conditions) you set up.
|
|
712
|
+
[Surveys](https://posthog.com/docs/surveys.md) launched with [popover presentation](https://posthog.com/docs/surveys/creating-surveys.md#presentation) are automatically shown to users matching the [display conditions](https://posthog.com/docs/surveys/creating-surveys.md#display-conditions) you set up.
|
|
687
713
|
|
|
688
714
|
## Push notifications
|
|
689
715
|
|
|
690
|
-
The Flutter SDK can register a device for [Workflows](/docs/workflows.md) push notifications and capture when a user opens one. For setup, including automatic and manual registration, capturing opens, opting out, and identity verification, see [Push notifications](/docs/workflows/push-notifications.md).
|
|
716
|
+
The Flutter SDK can register a device for [Workflows](https://posthog.com/docs/workflows.md) push notifications and capture when a user opens one. For setup, including automatic and manual registration, capturing opens, opting out, and identity verification, see [Push notifications](https://posthog.com/docs/workflows/push-notifications.md).
|
|
691
717
|
|
|
692
718
|
## Flush
|
|
693
719
|
|
|
@@ -695,8 +721,6 @@ You can configure how many events queue before flushing with `flushAt`. Setting
|
|
|
695
721
|
|
|
696
722
|
You can also configure the flush interval with `flushInterval` (default 30 seconds), after which queued events are sent regardless of how many have been gathered:
|
|
697
723
|
|
|
698
|
-
Dart
|
|
699
|
-
|
|
700
724
|
```dart
|
|
701
725
|
final config = PostHogConfig('<ph_project_token>');
|
|
702
726
|
config.flushAt = 20;
|
|
@@ -705,8 +729,6 @@ config.flushInterval = const Duration(seconds: 30);
|
|
|
705
729
|
|
|
706
730
|
You can also manually flush the queue to start sending events immediately instead of waiting for the next batch:
|
|
707
731
|
|
|
708
|
-
Dart
|
|
709
|
-
|
|
710
732
|
```dart
|
|
711
733
|
await Posthog().flush();
|
|
712
734
|
```
|
|
@@ -725,24 +747,18 @@ The PostHog Flutter SDK will continue to capture events when the device is offli
|
|
|
725
747
|
|
|
726
748
|
You can disable data collection for a user at any time using the `disable()` method:
|
|
727
749
|
|
|
728
|
-
Dart
|
|
729
|
-
|
|
730
750
|
```dart
|
|
731
751
|
await Posthog().disable();
|
|
732
752
|
```
|
|
733
753
|
|
|
734
754
|
This prevents any future events from being sent. It doesn't remove events already captured for the user. To opt the user back in:
|
|
735
755
|
|
|
736
|
-
Dart
|
|
737
|
-
|
|
738
756
|
```dart
|
|
739
757
|
await Posthog().enable();
|
|
740
758
|
```
|
|
741
759
|
|
|
742
760
|
To check if a user is opted out:
|
|
743
761
|
|
|
744
|
-
Dart
|
|
745
|
-
|
|
746
762
|
```dart
|
|
747
763
|
await Posthog().isOptOut();
|
|
748
764
|
```
|
|
@@ -755,8 +771,6 @@ Since version 5.13.0, you can provide `beforeSend` callbacks when initializing t
|
|
|
755
771
|
|
|
756
772
|
`beforeSend` gives you one place to edit or redact information before it is sent to PostHog. For example:
|
|
757
773
|
|
|
758
|
-
Dart
|
|
759
|
-
|
|
760
774
|
```dart
|
|
761
775
|
final config = PostHogConfig('<ph_project_token>');
|
|
762
776
|
config.host = 'https://us.i.posthog.com';
|
|
@@ -778,8 +792,6 @@ await Posthog().setup(config);
|
|
|
778
792
|
|
|
779
793
|
Return `null` from the callback to drop the event:
|
|
780
794
|
|
|
781
|
-
Dart
|
|
782
|
-
|
|
783
795
|
```dart
|
|
784
796
|
config.beforeSend = [
|
|
785
797
|
(event) {
|
|
@@ -798,8 +810,6 @@ You can stop specific screens from being autocaptured by filtering them in your
|
|
|
798
810
|
|
|
799
811
|
Because it's just a function, you can filter however you like – an **ignorelist** (drop the screens you name), an **allowlist** (invert the check to capture only the screens you name), or any custom rule such as a name prefix, a regex, or a check against the event's properties.
|
|
800
812
|
|
|
801
|
-
Dart
|
|
802
|
-
|
|
803
813
|
```dart
|
|
804
814
|
const ignoredScreens = {'Splash', 'Debug'};
|
|
805
815
|
|
|
@@ -835,8 +845,6 @@ If you're not seeing the expected events being captured, the feature flags being
|
|
|
835
845
|
|
|
836
846
|
You can enable debug mode during initialization by setting the `debug` option to `true` in the `PostHogConfig` object. A common pattern is to set this to `true` in development environments only using environment variables.
|
|
837
847
|
|
|
838
|
-
Dart
|
|
839
|
-
|
|
840
848
|
```dart
|
|
841
849
|
final config = PostHogConfig('<ph_project_token>');
|
|
842
850
|
config.host = 'https://us.i.posthog.com';
|
|
@@ -848,17 +856,7 @@ This will enable verbose logs about the inner workings of the SDK.
|
|
|
848
856
|
|
|
849
857
|
You can also enable debug by calling the `Posthog().debug()` method in your code.
|
|
850
858
|
|
|
851
|
-
Dart
|
|
852
|
-
|
|
853
859
|
```dart
|
|
854
860
|
await Posthog().debug(true);
|
|
855
861
|
await Posthog().debug(false);
|
|
856
862
|
```
|
|
857
|
-
|
|
858
|
-
### Still have questions?
|
|
859
|
-
|
|
860
|
-
Ask PostHog AI
|
|
861
|
-
|
|
862
|
-
### Was this page useful?
|
|
863
|
-
|
|
864
|
-
HelpfulCould be better
|