posthog_api 0.1.0
posthog_api: ^0.1.0 copied to clipboard
Pure Dart server-side client for PostHog: event capture, identify, alias, groups, batching with retries, and remote feature flags. A port of posthog-node.
example/posthog_api_example.dart
import 'package:posthog_api/posthog_api.dart';
Future<void> main() async {
final posthog = PostHog(
'phc_your_project_api_key',
host: Uri.parse('https://eu.i.posthog.com'),
);
posthog.capture(
distinctId: 'user-123',
event: 'program_created',
properties: {
'exercises': 6,
r'$set': {'plan': 'pro'},
},
);
posthog.identify(
distinctId: 'user-123',
properties: {'email': 'ada@example.com'},
);
if (await posthog.isFeatureEnabled('new-editor', 'user-123') ?? false) {
print('new-editor is on');
}
await posthog.shutdown();
}