-
Notifications
You must be signed in to change notification settings - Fork 249
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change | ||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|
@@ -0,0 +1,43 @@ | ||||||||||||
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. | ||||||||||||
// SPDX-License-Identifier: Apache-2.0 | ||||||||||||
|
||||||||||||
import 'package:amplify_core/amplify_core.dart'; | ||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||||||
|
||||||||||||
/// {@template amplify_datastore.datastore_plugin_options} | ||||||||||||
/// The plugin options for the Amplify DataStore plugin. | ||||||||||||
/// {@endtemplate} | ||||||||||||
class DataStorePluginOptions { | ||||||||||||
/// {@macro amplify_datastore.datastore_plugin_options} | ||||||||||||
const DataStorePluginOptions({ | ||||||||||||
this.errorHandler, | ||||||||||||
this.conflictHandler, | ||||||||||||
this.syncExpressions = const [], | ||||||||||||
this.syncInterval, | ||||||||||||
this.syncMaxRecords, | ||||||||||||
this.syncPageSize, | ||||||||||||
this.authModeStrategy = AuthModeStrategy.defaultStrategy, | ||||||||||||
}); | ||||||||||||
|
||||||||||||
/// The custom error handler function that receives an [AmplifyException] | ||||||||||||
/// object when DataStore encounters an unhandled error. | ||||||||||||
final Function(AmplifyException)? errorHandler; | ||||||||||||
|
||||||||||||
/// The custom conflict handler function that receives an [ConflictData] | ||||||||||||
/// object when DataStore encounters a data conflict. | ||||||||||||
final DataStoreConflictHandler? conflictHandler; | ||||||||||||
|
||||||||||||
/// The list of sync expressions to filter datastore sync. | ||||||||||||
final List<DataStoreSyncExpression> syncExpressions; | ||||||||||||
|
||||||||||||
/// The syncing interval in seconds. | ||||||||||||
final int? syncInterval; | ||||||||||||
|
||||||||||||
/// The max number of records to sync. | ||||||||||||
final int? syncMaxRecords; | ||||||||||||
|
||||||||||||
/// The page size to sync. | ||||||||||||
final int? syncPageSize; | ||||||||||||
|
||||||||||||
/// The strategy for authorizing an API call. | ||||||||||||
final AuthModeStrategy authModeStrategy; | ||||||||||||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -54,6 +54,9 @@ class _MyAppState extends State<MyApp> { | |
AmplifyAnalyticsPinpoint( | ||
// ignore: invalid_use_of_visible_for_testing_member | ||
secureStorageFactory: storageFactory, | ||
options: const AnalyticsPinpointPluginOptions( | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. note: We should call this change out in the migration guide |
||
autoFlushEventsInterval: Duration(seconds: 10), | ||
), | ||
), | ||
]); | ||
|
||
|
Original file line number | Diff line number | Diff line change | ||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|
@@ -0,0 +1,15 @@ | ||||||||||||
// 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} | ||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||||||
/// The plugin options for the Amplify Analytics Pinpoint plugin | ||||||||||||
/// {@endtemplate} | ||||||||||||
class AnalyticsPinpointPluginOptions { | ||||||||||||
/// {@macro amplify_analytics_pinpoint_dart.analytics_pinpoint_plugin_options} | ||||||||||||
const AnalyticsPinpointPluginOptions({ | ||||||||||||
this.autoFlushEventsInterval = const Duration(seconds: 30), | ||||||||||||
}); | ||||||||||||
|
||||||||||||
/// The duration in seconds between flushing analytics events to Pinpoint. | ||||||||||||
final Duration autoFlushEventsInterval; | ||||||||||||
} |
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.
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.
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.
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