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

feat!: use plugin options for optional plugin parameters #4762

Merged
merged 3 commits into from
Apr 25, 2024

Conversation

NikaHsn
Copy link
Member

@NikaHsn NikaHsn commented Apr 22, 2024

Issue #, if available:

Description of changes:

  • update analytics to use plugin options and remove autoflush interval from analytics config
  • update api plugin to use plugin options
  • update datastore to use plugin options

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

@NikaHsn NikaHsn force-pushed the feat/plugin_options branch 4 times, most recently from 0208571 to fdd2423 Compare April 23, 2024 17:32
@NikaHsn NikaHsn marked this pull request as ready for review April 23, 2024 18:40
@NikaHsn NikaHsn requested a review from a team as a code owner April 23, 2024 18:40
/// {@template amplify_datastore.datastore_plugin_options}
/// The plugin options for the Amplify DataStore plugin.
/// {@endtemplate}
class DataStorePluginOptions {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the plugin option definitions should live in core

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we should maintain category-specific types within the core and keep types exclusive to plugins within their respective package.

@@ -39,8 +39,7 @@ const _v4analytics = '''
},
"pinpointTargeting": {
"region": "$REGION"
},
"autoFlushEventsInterval": $ANALYTICS_FLUSH_INTERVAL
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't have the full context on these tests, but I believe the intention is to test against the output from various versions of the Amplify CLI. These files are generated using an npm script, which I think depends on different versions of the Amplify CLI. If we regenerate these files these changes will be removed.

The approach I took in the auth PR was to remove certain keys from the JSON in the test assertions. You can see that here: https://github.com/aws-amplify/amplify-flutter/pull/4764/files#diff-10ab98843576a1782a1c3212f13233440a0474bf716ee5f2b70eb2264356d8ebR37

Long term I am not sure how useful these tests are. They are testing against versions of the CLI that are pretty outdated now. I think they should be updated or removed. I think it will be easier to do that as a follow up after we get the breaking changes in though.

Copy link
Member Author

@NikaHsn NikaHsn Apr 23, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the file is auto generated by running the generate script. CLI does not generate this feild, based on our docs this field must be manually added to the configuration. https://docs.amplify.aws/flutter/build-a-backend/more-features/analytics/record-events/#flush-events

@@ -54,6 +54,9 @@ class _MyAppState extends State<MyApp> {
AmplifyAnalyticsPinpoint(
// ignore: invalid_use_of_visible_for_testing_member
secureStorageFactory: storageFactory,
options: const AnalyticsPinpointPluginOptions(
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

note: We should call this change out in the migration guide

/// {@template amplify_datastore.datastore_plugin_options}
/// The plugin options for the Amplify DataStore plugin.
/// {@endtemplate}
class DataStorePluginOptions {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

suggestion: This should probably be in a separate file

/// {@template amplify_api_dart.api_plugin_options}
/// The plugin options for the Amplify API plugin.
/// {@endtemplate}
class APIPluginOptions {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

suggestion: new file

@@ -21,18 +21,15 @@ import 'package:meta/meta.dart';
class AmplifyAPIDart extends APIPluginInterface with AWSDebuggable {
/// {@macro amplify_api_dart.amplify_api_dart}
AmplifyAPIDart({
List<APIAuthProvider> authProviders = const [],
APIPluginOptions options = const APIPluginOptions(),
ConnectivityPlatform connectivity = const ConnectivityPlatform(),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Q: Was this missed?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is intended for the API flutter package to provide platform-specific implementations for ConnectivityPlatform, and it is not related to plugin options.

@NikaHsn NikaHsn force-pushed the feat/plugin_options branch from fdd2423 to ff38d1d Compare April 23, 2024 22:06
@@ -0,0 +1,40 @@
import 'package:amplify_core/amplify_core.dart';
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
import 'package:amplify_core/amplify_core.dart';
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
// SPDX-License-Identifier: Apache-2.0
import 'package:amplify_core/amplify_core.dart';

@@ -0,0 +1,12 @@
/// {@template amplify_analytics_pinpoint_dart.analytics_pinpoint_plugin_options}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
/// {@template amplify_analytics_pinpoint_dart.analytics_pinpoint_plugin_options}
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
// SPDX-License-Identifier: Apache-2.0
/// {@template amplify_analytics_pinpoint_dart.analytics_pinpoint_plugin_options}

@@ -0,0 +1,26 @@
import 'package:amplify_core/amplify_core.dart';
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
import 'package:amplify_core/amplify_core.dart';
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
// SPDX-License-Identifier: Apache-2.0
import 'package:amplify_core/amplify_core.dart';

Copy link
Contributor

@Equartey Equartey left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great, nice work!

@NikaHsn NikaHsn merged commit 71fa108 into main Apr 25, 2024
155 checks passed
@Equartey Equartey deleted the feat/plugin_options branch April 25, 2024 17:39
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.

3 participants