From 2b1d71658a1db46b813ae64f543bcec8e0fbe28b Mon Sep 17 00:00:00 2001 From: James Greenhill Date: Thu, 25 Jun 2020 15:52:21 -0700 Subject: [PATCH] further cleanups with capture method --- .../posthog_flutter/PosthogFlutterPlugin.java | 14 +++++------ example/lib/main.dart | 8 +++---- example/web/index.html | 2 +- ios/Classes/PosthogFlutterPlugin.m | 6 ++--- lib/src/posthog.dart | 20 ++++------------ lib/src/posthog_method_channel.dart | 24 ++++--------------- lib/src/posthog_platform_interface.dart | 14 +++-------- lib/src/posthog_web.dart | 2 +- 8 files changed, 27 insertions(+), 63 deletions(-) diff --git a/android/src/main/java/com/posthog/posthog_flutter/PosthogFlutterPlugin.java b/android/src/main/java/com/posthog/posthog_flutter/PosthogFlutterPlugin.java index cc6938d..90ba5ff 100644 --- a/android/src/main/java/com/posthog/posthog_flutter/PosthogFlutterPlugin.java +++ b/android/src/main/java/com/posthog/posthog_flutter/PosthogFlutterPlugin.java @@ -59,11 +59,11 @@ private void setupChannels(Context applicationContext, BinaryMessenger messenger String writeKey = bundle.getString("com.posthog.posthog.API_KEY"); String posthogHost = bundle.getString("com.posthog.posthog.POSTHOG_HOST"); - Boolean trackApplicationLifecycleEvents = bundle.getBoolean("com.posthog.posthog.TRACK_APPLICATION_LIFECYCLE_EVENTS"); + Boolean captureApplicationLifecycleEvents = bundle.getBoolean("com.posthog.posthog.TRACK_APPLICATION_LIFECYCLE_EVENTS"); Boolean debug = bundle.getBoolean("com.posthog.posthog.DEBUG", false); PostHog.Builder analyticsBuilder = new PostHog.Builder(applicationContext, writeKey, posthogHost); - if (trackApplicationLifecycleEvents) { + if (captureApplicationLifecycleEvents) { // Enable this to record certain application events automatically analyticsBuilder.captureApplicationLifecycleEvents(); } @@ -121,8 +121,8 @@ public void onDetachedFromEngine(FlutterPluginBinding binding) { } public void onMethodCall(MethodCall call, Result result) { if(call.method.equals("identify")) { this.identify(call, result); - } else if (call.method.equals("track")) { - this.track(call, result); + } else if (call.method.equals("capture")) { + this.capture(call, result); } else if (call.method.equals("screen")) { this.screen(call, result); } else if (call.method.equals("alias")) { @@ -171,19 +171,19 @@ private void callIdentify( PostHog.with(this.applicationContext).identify(userId, properties, options); } - private void track(MethodCall call, Result result) { + private void capture(MethodCall call, Result result) { try { String eventName = call.argument("eventName"); HashMap propertiesData = call.argument("properties"); HashMap options = call.argument("options"); - this.callTrack(eventName, propertiesData, options); + this.callCapture(eventName, propertiesData, options); result.success(true); } catch (Exception e) { result.error("PosthogFlutterException", e.getLocalizedMessage(), null); } } - private void callTrack( + private void callCapture( String eventName, HashMap propertiesData, HashMap optionsData diff --git a/example/lib/main.dart b/example/lib/main.dart index 1792567..d48b20b 100644 --- a/example/lib/main.dart +++ b/example/lib/main.dart @@ -46,9 +46,9 @@ class MyApp extends StatelessWidget { Spacer(), Center( child: FlatButton( - child: Text('TRACK ACTION WITH POSTHOG'), + child: Text('CAPTURE ACTION WITH POSTHOG'), onPressed: () { - Posthog.track( + Posthog.capture( eventName: 'ButtonClicked', properties: { 'foo': 'bar', @@ -83,7 +83,7 @@ class MyApp extends StatelessWidget { child: Text('Disable'), onPressed: () async { await Posthog.disable(); - Posthog.track(eventName: 'This event will not be logged'); + Posthog.capture(eventName: 'This event will not be logged'); }, ), ), @@ -93,7 +93,7 @@ class MyApp extends StatelessWidget { child: Text('Enable'), onPressed: () async { await Posthog.enable(); - Posthog.track(eventName: 'Enabled tracking events!'); + Posthog.capture(eventName: 'Enabled capturing events!'); }, ), ), diff --git a/example/web/index.html b/example/web/index.html index 983fddb..dc6c217 100644 --- a/example/web/index.html +++ b/example/web/index.html @@ -10,7 +10,7 @@