-
Notifications
You must be signed in to change notification settings - Fork 260
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Analytics - Update Methods , Clean Code #21
Conversation
...d/src/main/kotlin/com/amazonaws/amplify/amplify_analytics_pinpoint/AmplifyAnalyticsBridge.kt
Show resolved
Hide resolved
AmplifyAnalyticsPinpointPlugin analyticsPlugin = new AmplifyAnalyticsPinpointPlugin(); | ||
amplifyInstance.addPlugin(analyticsPlugins: [analyticsPlugin]); | ||
|
||
var isConfigured = await amplifyInstance.configure(amplifyconfig); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not adding the plugins anymore? Also - while you don't need to assign the result of configure to a var, since it's void, you could still catch an error.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks yeah should be adding those plugins :) Sure, I'll catch it then
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
See comments. Also, please resolve conflicts.
33fdce1
to
1e96e03
Compare
# Conflicts: # packages/amplify_analytics_pinpoint/android/src/main/kotlin/com/amazonaws/amplify/amplify_analytics_pinpoint/AmplifyAnalyticsBridge.kt
Include suggestions from Michael for Readme file.
1e96e03
to
4060176
Compare
Merge requests resolved, also added Mlab's readme file changes |
Amplify.Analytics.flushEvents(); | ||
result.success(true); | ||
Amplify.Analytics.flushEvents() | ||
result.success(true) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do you have some lint tooling available that can enforce this as part of the build/PR process?
|
||
for (name in propertyNames) { | ||
Amplify.Analytics.unregisterGlobalProperties(name); | ||
if(propertyNames.size == 0){ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if (
try { | ||
Amplify.Analytics.unregisterGlobalProperties() | ||
result.success(true); | ||
else{ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
else {
_amplifyConfigured = true; | ||
}); | ||
} catch (e) { | ||
print(e); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If the configuration fails, that probably means you won't be able to use Analytics, right? So, log-n-gobble may not be the best strategy here. Should you not have the exception bubble back up to the user, so they know not to proceed? (Or, can make the decision themselves, as to whether or not they want to, at least. Right now, you make that choice for them.)
public static func unregisterAllGlobalProperties(result: @escaping FlutterResult){ | ||
Amplify.Analytics.unregisterGlobalProperties() | ||
|
||
if(propertyNames.count == 0){ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Meh, yea -- these are driving me nuts though. I don't know any language where whitespace isn't used around control flow keywords. The Dart style guide does not contain any examples of this. https://dart.dev/guides/language/effective-dart/style
Future<void> registerGlobalProperties( | ||
{@required AnalyticsProperties globalProperties}) async { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Join back to one line? Why break? What is the line wrap strategy that is being used in this code base? Has your team come to an agreement?
Running this opinionated and langauge-idiomatic formatting tool would probably be a good step in your build process.
https://dart.dev/guides/language/effective-dart/style#do-format-your-code-using-dartfmt
https://github.com/dart-lang/dart_style/wiki/Formatting-Rules
Quick PR to update methods to combine unregisterGlobalProperties with unregisterAllGlobalProperties
Minor other changes related to style and spacing
Removed optional ; in kotlin to be consistent
Issue #, if available:
Description of changes:
By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.