Skip to content
Open
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
68 changes: 67 additions & 1 deletion contents/docs/feature-flags/property-overrides.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,20 @@ PostHog.identify(
val showFeature = PostHog.isFeatureEnabled("enterprise-feature")
```

```dart
// Properties are automatically available for flag evaluation
await Posthog().identify(
userId: 'user-123',
userProperties: {
'email': 'user@company.com',
'plan': 'enterprise',
},
)

// This flag check can use 'plan' immediately
final showFeature = await Posthog().isFeatureEnabled('enterprise-feature')
```

</MultiLanguage>

#### From group calls
Expand Down Expand Up @@ -135,6 +149,20 @@ PostHog.group(
val showFeature = PostHog.isFeatureEnabled("enterprise-companies-feature")
```

```dart
await Posthog().group(
groupType: 'company',
groupKey: 'company-123',
groupProperties: {
'name': 'Acme Inc',
'plan': 'enterprise',
},
)

// Group properties are available for flag evaluation
final showFeature = await Posthog().isFeatureEnabled('enterprise-companies-feature')
```

</MultiLanguage>

### Default properties in the web SDK
Expand Down Expand Up @@ -203,7 +231,7 @@ This adds the following properties to flag requests:

### Default properties in mobile SDKs

Mobile SDKs (React Native, iOS, and Android) include common device and app properties in every feature flag evaluation request. The `setDefaultPersonProperties` configuration option controls this behavior and defaults to `true`.
Mobile SDKs (React Native, iOS, Android, and Flutter) include common device and app properties in every feature flag evaluation request. The `setDefaultPersonProperties` configuration option controls this behavior and defaults to `true`.

| Property | Description |
|----------|-------------|
Expand Down Expand Up @@ -268,6 +296,17 @@ PostHog.setPersonPropertiesForFlags(
val showFeature = PostHog.isFeatureEnabled("enterprise-feature")
```

```dart
// Set properties for flag evaluation
await Posthog().setPersonPropertiesForFlags({
'plan': 'enterprise',
'company_size': 'large',
})

// Properties persist across flag evaluations
final showFeature = await Posthog().isFeatureEnabled('enterprise-feature')
```

</MultiLanguage>

> **Note:** Properties set with `setPersonPropertiesForFlags()` are additive. Each call merges new properties with existing ones rather than replacing them.
Expand Down Expand Up @@ -314,6 +353,15 @@ PostHog.setPersonPropertiesForFlags(mapOf("company_size" to "large"), reloadFeat
PostHog.reloadFeatureFlags()
```

```dart
// Set properties without reloading
await Posthog().setPersonPropertiesForFlags({'plan': 'enterprise'}, reloadFeatureFlags: false)
await Posthog().setPersonPropertiesForFlags({'company_size': 'large'}, reloadFeatureFlags: false)
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Meant group here?


// Manually reload when ready
await Posthog().reloadFeatureFlags()
```

</MultiLanguage>

### Resetting property overrides
Expand All @@ -338,6 +386,10 @@ PostHogSDK.shared.resetPersonPropertiesForFlags()
PostHog.resetPersonPropertiesForFlags()
```

```dart
await Posthog().resetPersonPropertiesForFlags()
```

</MultiLanguage>

On mobile SDKs, this automatically triggers a feature flag reload. Pass `false` to reset without reloading. On web, flags are not automatically reloaded. Call `reloadFeatureFlags()` manually if needed.
Expand Down Expand Up @@ -408,6 +460,20 @@ PostHog.resetGroupPropertiesForFlags("company")
PostHog.resetGroupPropertiesForFlags()
```

```dart
// Set group properties for flag evaluation
await Posthog().setGroupPropertiesForFlags('company', {
'plan': 'enterprise',
'employee_count': 500,
})

// Reset group properties for a specific type
await Posthog().resetGroupPropertiesForFlags(groupType: 'company')

// Reset all group properties
await Posthog().resetGroupPropertiesForFlags()
```

</MultiLanguage>

### Use case: Targeting by browser or device
Expand Down
17 changes: 17 additions & 0 deletions contents/docs/libraries/flutter/index.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,23 @@ import FlutterFeatureFlagsCode from '../../integrate/feature-flags-code/_snippet

<FlutterFeatureFlagsCode />

### Setting properties for flag evaluation

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.

```dart
// Person properties — included in the next flag evaluation request
await Posthog().setPersonPropertiesForFlags({
'storefront_country': 'US',
'plan': 'enterprise',
})

// Group properties
await Posthog().setGroupPropertiesForFlags('company', {'plan': 'enterprise'})
```

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) for details.

## Experiments (A/B tests)

Since [experiments](/docs/experiments/start-here) use feature flags, the code for running an experiment is very similar to the feature flags code:
Expand Down
Loading