diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md new file mode 100644 index 0000000..23b0d74 --- /dev/null +++ b/CONTRIBUTING.md @@ -0,0 +1,3 @@ +## Contributing + +If you wish to contribute a change to this repo, please send a [pull request](https://github.com/posthog/posthog-flutter/pulls). diff --git a/README.md b/README.md index 434951c..21c574e 100644 --- a/README.md +++ b/README.md @@ -1,217 +1,10 @@ -# PostHog plugin - [![Package on pub.dev][pubdev_badge]][pubdev_link] -Flutter plugin to support iOS/macOS, Android and Web sources at https://posthog.com. - -## Usage - -To use this plugin, add `posthog_flutter` as a [dependency in your pubspec.yaml file](https://pub.dev/packages/posthog_flutter/install). - -### Supported methods - -| Method | Android | iOS/macOS | Web | -| ------------------------- | ------- | --------- | --- | -| `setup` | X | X | | -| `identify` | X | X | X | -| `capture` | X | X | X | -| `screen` | X | X | X | -| `alias` | X | X | X | -| `getDistinctId` | X | X | X | -| `reset` | X | X | X | -| `disable` | X | X | X | -| `enable` | X | X | X | -| `debug` | X | X | X | -| `register` | X | X | X | -| `unregister` | X | X | X | -| `flush` | X | X | | -| `isFeatureEnabled` | X | X | X | -| `reloadFeatureFlags` | X | X | X | -| `getFeatureFlag` | X | X | X | -| `getFeatureFlagPayload` | X | X | X | -| `group` | X | X | X | -| `close` | X | X | | - -### Example - -```dart -import 'package:flutter/material.dart'; -import 'package:posthog_flutter/posthog_flutter.dart'; - -void main() => runApp(MyApp()); - -class MyApp extends StatelessWidget { - @override - Widget build(BuildContext context) { - return MaterialApp( - navigatorObservers: [ - // The PosthogObserver records screen views automatically - PosthogObserver(), - ], - home: Scaffold( - appBar: AppBar( - title: Text('Posthog example app'), - ), - body: Center( - child: FlatButton( - child: Text('TRACK ACTION WITH POSTHOG'), - onPressed: () { - Posthog().capture( - eventName: 'ButtonClicked', - properties: { - 'foo': 'bar', - 'number': 1337, - 'clicked': true, - }, - ); - }, - ), - ), - ) - ); - } -} -``` - -## Installation - -Setup your Android, iOS/macOS and/or web sources as described at Posthog.com and generate your api keys. - -Set your Posthog api key and change the automatic event tracking (only for Android and iOS) on if you wish the library to take care of it for you. -Remember that the application lifecycle events won't have any special context set for you by the time it is initialized. If you are using a self hosted instance of Posthog you will need to have the public hostname or ip for your instance as well. - -### Android - -Automatically: - -```xml file=AndroidManifest.xml - - - - [...] - - - - - - - - -``` - -Or manually, disable the auto init: - -```xml file=AndroidManifest.xml - - - - [...] - - - - -``` - -And setup the SDK manually: - -```dart -Future 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()); -} -``` - -### iOS/macOS - -Automatically: - -```xml file=Info.plist - - - - - [...] - com.posthog.posthog.API_KEY - YOUR_API_KEY_GOES_HERE - com.posthog.posthog.POSTHOG_HOST - - https://us.i.posthog.com - com.posthog.posthog.CAPTURE_APPLICATION_LIFECYCLE_EVENTS - - com.posthog.posthog.DEBUG - - [...] - - -``` - -Or manually, disable the auto init: - -```xml file=Info.plist - - - - - [...] - com.posthog.posthog.AUTO_INIT - - [...] - - -``` - -And setup the SDK manually: - -```dart -Future 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()); -} -``` - -### Web - -```html file=index.html - - - - ... - - - - - ... - - -``` - -For more informations please check the [docs](https://posthog.com/docs/libraries/js). - -## Issues - -Please file any issues, bugs, or feature requests in the [GitHub repo](https://github.com/posthog/posthog-flutter/issues/new). +# PostHog Flutter -## Contributing +Please see the main [PostHog docs](https://posthog.com/docs). -If you wish to contribute a change to this repo, please send a [pull request](https://github.com/posthog/posthog-flutter/pulls). +Specifically, the [Flutter docs](https://posthog.com/docs/libraries/flutter) details. ## Questions?