-
Notifications
You must be signed in to change notification settings - Fork 37
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ref: relative imports and moved non exported files to src folder (#71)
- Loading branch information
1 parent
454c396
commit 1bf8e42
Showing
7 changed files
with
118 additions
and
107 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,4 @@ | ||
export 'package:posthog_flutter/src/posthog.dart'; | ||
export 'package:posthog_flutter/src/posthog_observer.dart'; | ||
library posthog_flutter; | ||
|
||
export 'src/posthog.dart'; | ||
export 'src/posthog_observer.dart'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
18 changes: 9 additions & 9 deletions
18
lib/posthog_flutter_platform_interface.dart → ...c/posthog_flutter_platform_interface.dart
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,94 @@ | ||
import 'dart:js'; | ||
|
||
import 'package:flutter/services.dart'; | ||
|
||
Future<dynamic> handleWebMethodCall(MethodCall call, JsObject context) async { | ||
final analytics = JsObject.fromBrowserObject(context['posthog']); | ||
switch (call.method) { | ||
case 'identify': | ||
final userProperties = call.arguments['userProperties']; | ||
final userPropertiesSetOnce = call.arguments['userPropertiesSetOnce']; | ||
analytics.callMethod('identify', [ | ||
call.arguments['userId'], | ||
JsObject.jsify(userProperties), | ||
JsObject.jsify(userPropertiesSetOnce), | ||
]); | ||
break; | ||
case 'capture': | ||
analytics.callMethod('capture', [ | ||
call.arguments['eventName'], | ||
JsObject.jsify(call.arguments['properties']), | ||
]); | ||
break; | ||
case 'screen': | ||
final properties = call.arguments['properties'] ?? {}; | ||
final screenName = call.arguments['screenName']; | ||
if (screenName != null) { | ||
properties['\$screen_name'] = screenName; | ||
} | ||
analytics.callMethod('capture', [ | ||
'\$screen', | ||
JsObject.jsify(properties), | ||
]); | ||
break; | ||
case 'alias': | ||
analytics.callMethod('alias', [ | ||
call.arguments['alias'], | ||
]); | ||
break; | ||
case 'distinctId': | ||
final distinctId = analytics.callMethod('get_distinct_id'); | ||
return distinctId; | ||
case 'reset': | ||
analytics.callMethod('reset'); | ||
break; | ||
case 'debug': | ||
analytics.callMethod('debug', [ | ||
call.arguments['debug'], | ||
]); | ||
break; | ||
case 'isFeatureEnabled': | ||
final isFeatureEnabled = analytics.callMethod('isFeatureEnabled', [ | ||
call.arguments['key'], | ||
]); | ||
return isFeatureEnabled; | ||
case 'group': | ||
analytics.callMethod('group', [ | ||
call.arguments['groupType'], | ||
call.arguments['groupKey'], | ||
JsObject.jsify(call.arguments['groupProperties']), | ||
]); | ||
break; | ||
case 'reloadFeatureFlags': | ||
analytics.callMethod('reloadFeatureFlags'); | ||
break; | ||
case 'enable': | ||
analytics.callMethod('opt_in_capturing'); | ||
break; | ||
case 'disable': | ||
analytics.callMethod('opt_out_capturing'); | ||
break; | ||
case 'getFeatureFlag': | ||
final featureFlag = analytics.callMethod('getFeatureFlag', [ | ||
call.arguments['key'], | ||
]); | ||
return featureFlag; | ||
case 'getFeatureFlagPayload': | ||
final featureFlag = analytics.callMethod('getFeatureFlagPayload', [ | ||
call.arguments['key'], | ||
]); | ||
return featureFlag; | ||
case 'register': | ||
final properties = {call.arguments['key']: call.arguments['value']}; | ||
analytics.callMethod('register', [ | ||
properties, | ||
]); | ||
break; | ||
default: | ||
throw PlatformException( | ||
code: 'Unimplemented', | ||
details: | ||
"The posthog plugin for web doesn't implement the method '${call.method}'", | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters