Skip to content

Commit

Permalink
chore: update main branch
Browse files Browse the repository at this point in the history
  • Loading branch information
thisames committed Oct 8, 2024
2 parents 1970021 + 61d8f41 commit cea3bad
Show file tree
Hide file tree
Showing 31 changed files with 760 additions and 520 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
## Next

- chore: change host to new address ([#106](https://github.com/PostHog/posthog-flutter/pull/106))
- chore: allow manual initialization of the SDK ([#117](https://github.com/PostHog/posthog-flutter/pull/117))

## 4.5.0

Expand Down
16 changes: 16 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
.PHONY: formatKotlin formatSwift formatDart

# brew install ktlint
# TODO: add ktlint steps in CI
formatKotlin:
ktlint --format

# brew install swiftlint
# TODO: add swiftlint steps in CI
formatSwift:
swiftformat ios/Classes --swiftversion 5.3
swiftlint ios/Classes --fix

formatDart:
dart format .
dart analyze .
72 changes: 67 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ To use this plugin, add `posthog_flutter` as a [dependency in your pubspec.yaml

| Method | Android | iOS/macOS | Web |
| ------------------------- | ------- | --------- | --- |
| `setup` | X | X | |
| `identify` | X | X | X |
| `capture` | X | X | X |
| `screen` | X | X | X |
Expand All @@ -29,6 +30,7 @@ To use this plugin, add `posthog_flutter` as a [dependency in your pubspec.yaml
| `getFeatureFlag` | X | X | X |
| `getFeatureFlagPayload` | X | X | X |
| `group` | X | X | X |
| `close` | X | X | |

### Example

Expand Down Expand Up @@ -80,9 +82,9 @@ Remember that the application lifecycle events won't have any special context se

### Android

#### AndroidManifest.xml
Automatically:

```xml
```xml file=AndroidManifest.xml
<manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.example.posthog_flutter_example">
<application>
<activity>
Expand All @@ -97,11 +99,40 @@ Remember that the application lifecycle events won't have any special context se
</manifest>
```

Or manually, disable the auto init:

```xml file=AndroidManifest.xml
<manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.example.posthog_flutter_example">
<application>
<activity>
[...]
</activity>
<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());
}
```

### iOS/macOS

#### Info.plist
Automatically:

```xml
```xml file=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">
Expand All @@ -121,9 +152,40 @@ Remember that the application lifecycle events won't have any special context se
</plist>
```

Or manually, disable the auto init:

```xml file=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>
[...]
<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());
}
```

### Web

```html
```html file=index.html
<!DOCTYPE html>
<html>
<head>
Expand Down
Loading

0 comments on commit cea3bad

Please sign in to comment.