Skip to content
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

Merged
merged 2 commits into from Aug 13, 2020

Conversation

fjnoyp
Copy link
Contributor

@fjnoyp fjnoyp commented Aug 11, 2020

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.

AmplifyAnalyticsPinpointPlugin analyticsPlugin = new AmplifyAnalyticsPinpointPlugin();
amplifyInstance.addPlugin(analyticsPlugins: [analyticsPlugin]);

var isConfigured = await amplifyInstance.configure(amplifyconfig);
Copy link
Contributor

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.

Copy link
Contributor Author

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

Copy link
Contributor

@haverchuck haverchuck left a 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.

@fjnoyp fjnoyp force-pushed the amplify_analytics_combineMethod branch from 33fdce1 to 1e96e03 Compare August 11, 2020 16:21
@fjnoyp fjnoyp requested a review from haverchuck August 11, 2020 16:21
# Conflicts:
#	packages/amplify_analytics_pinpoint/android/src/main/kotlin/com/amazonaws/amplify/amplify_analytics_pinpoint/AmplifyAnalyticsBridge.kt
Include suggestions from Michael for Readme file.
@fjnoyp fjnoyp force-pushed the amplify_analytics_combineMethod branch from 1e96e03 to 4060176 Compare August 13, 2020 00:24
@fjnoyp
Copy link
Contributor Author

fjnoyp commented Aug 13, 2020

Merge requests resolved, also added Mlab's readme file changes

@fjnoyp fjnoyp merged commit 4b04d1f into master Aug 13, 2020
@fjnoyp fjnoyp deleted the amplify_analytics_combineMethod branch August 13, 2020 00:28
Amplify.Analytics.flushEvents();
result.success(true);
Amplify.Analytics.flushEvents()
result.success(true)
Copy link
Contributor

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){
Copy link
Contributor

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{
Copy link
Contributor

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);
Copy link
Contributor

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){
Copy link
Contributor

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

Comment on lines +41 to +42
Future<void> registerGlobalProperties(
{@required AnalyticsProperties globalProperties}) async {
Copy link
Contributor

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants