amplify-flutter
amplify-flutter copied to clipboard
Analytics record event is throwing SqliteException
Description
When I try to record an event in amplify Analytics the app throw this exception:
SqliteException(5): while executing statement, database is locked, database is locked (code 5)
Causing statement: INSERT INTO "drift_queued_items" ("value") VALUES (?), parameters: ["Event","EventType","Invoice printed","Timestamp","2024-05-06T20:17:12.885202Z","AppPackageName","--","AppTitle","--","AppVersionCode","1.17.3","Attributes",["Account ID","--","Location ID","--","Point of sale ID","--","Environment","live","From","Review invoice"],"ClientSdkVersion","0.3.0","Metrics",[],"SdkName","amplify-flutter","Session",["Duration",0,"Id","--","StartTimestamp","2024-05-06T11:41:51.455797Z"]]
StackTrace: #0 DriftCommunication.request (package:drift/src/remote/communication.dart:113)
#1 _BaseExecutor._runRequest (package:drift/src/remote/client_impl.dart:97)
#2 _BaseExecutor.runInsert (package:drift/src/remote/client_impl.dart:124)
#3 LazyDatabase.runInsert (package:drift/src/utils/lazy_database.dart:78)
#4 InsertStatement.insert.<anonymous closure> (package:drift/src/runtime/query_builder/statements/insert.dart:74)
#5 DatabaseConnectionUser.doWhenOpened.<anonymous closure> (package:drift/src/runtime/api/connection_user.dart:162)
#6 _rootRunUnary (dart:async/zone.dart:1407)
<asynchronous suspension>
#7 InsertStatement.insert (package:drift/src/runtime/query_builder/statements/insert.dart:73)
<asynchronous suspension>
#8 DriftQueuedItemStore.addItem (package:amplify_analytics_pinpoint_dart/src/impl/analytics_client/event_client/queued_item_store/drift/drift_queued_item_store.dart:57)
<asynchronous suspension>
#9 EventStorageAdapter.saveEvent (package:amplify_analytics_pinpoint_dart/src/impl/analytics_client/event_client/event_storage_adapter.dart:51)
<asynchronous suspension>
#10 EventClient.recordEvent (package:amplify_analytics_pinpoint_dart/src/impl/analytics_client/event_client/event_client.dart:86)
<asynchronous suspension>
#11 AmplifyAnalyticsPinpointDart.recordEvent (package:amplify_analytics_pinpoint_dart/src/analytics_plugin_impl.dart:218)
<asynchronous suspension>
#12 recordEvent (package:--/analytics/api.dart:80)
<asynchronous suspension>
}
Categories
- [X] Analytics
- [ ] API (REST)
- [ ] API (GraphQL)
- [ ] Auth
- [ ] Authenticator
- [ ] DataStore
- [ ] Notifications (Push)
- [ ] Storage
Steps to Reproduce
Call Amplify.Analytics.recordEvent(event: event)
Screenshots
No response
Platforms
- [] iOS
- [] Android
- [ ] Web
- [ ] macOS
- [X] Windows
- [ ] Linux
Flutter Version
3.10.0
Amplify Flutter Version
1.1.1
Deployment Method
Amplify CLI
Schema
No response
Hi @CarlosEspinozaMaruri, thank you for submitting this issue. We will take a look at it and get back to you with any updates.
Hi @CarlosEspinozaMaruri, could you provide more detailed reproduction steps (pubspec.yaml, longer code snippets, more context)? Have you tried using a more recent version of amplify-flutter
?
Hi @khatruong2009! The application is currently compatible with Windows, iOS, and Android platforms. I haven't had the chance to experiment with the latest version of Amplify Flutter yet.
Here's the pubspec.yaml file:
dependencies:
flutter:
sdk: flutter
flutter_localizations:
sdk: flutter
uuid: ^3.0.7
cupertino_icons: ^1.0.2
amplify_flutter: ^1.1.1
amplify_auth_cognito: ^1.1.1
amplify_analytics_pinpoint: ^1.0.0
workmanager: ^0.5.1
http: ^1.0.0
sqflite: ^2.2.8+4
path_provider: ^2.0.15
intercom_flutter: ^8.0.3
nanoid: ^1.0.0
get:
get_it:
stacked: ^3.4.0
shared_preferences: ^2.1.2
big_dart: ^1.0.1
currency_text_input_formatter: ^2.1.10
collection: ^1.16.0
intl: ^0.18.0
cached_network_image: ^3.2.0
searchfield: ^0.8.7
provider: ^6.0.5
package_info_plus: ^4.0.2
infinite_scroll_pagination: ^3.2.0
msgpack_dart: ^1.0.1
permission_handler: ^10.3.0
app_settings: ^4.2.0
crypto: ^3.0.3
flutter_markdown: ^0.6.18
sqflite_common_ffi: ^2.1.1+1
windows_usb_printer: ^0.0.2+4
window_manager: ^0.3.7
url_launcher: ^6.1.0
flutter_svg: ^2.0.9
aws_cloudwatch: ^1.0.0
talker_flutter:
Here's a code snippet for recording events:
recordEvent(eventName, {customProperties = const {}}) async {
final event = amplify_flutter.AnalyticsEvent(eventName);
customProperties.forEach(
(key, value) {
if (value is String)
event.customProperties.addStringProperty(key, value);
else if (value is int)
event.customProperties.addIntProperty(key, value);
else if (value is double)
event.customProperties.addDoubleProperty(key, value);
else if (value is bool)
event.customProperties.addBoolProperty(key, value);
},
);
if (!kDebugMode) {
await amplify_flutter.Amplify.Analytics.recordEvent(event: event);
}
}
To record an event when a user performs an action, I use:
recordEvent('firstInstall');
I'm not sure, but I suspect it occurs in release mode on some Windows devices.
Hi @CarlosEspinozaMaruri, you suspect this occurs in release mode on some Windows devices. Does this mean it works fine for iOS and Android platforms?
@khatruong2009 yes
@CarlosEspinozaMaruri have you tried upgrading to Amplify Flutter 2.0.0 and does it resolve the issue?
@NikaHsn I haven't had the chance to test it yet. I will try to update the package and let you know if the issue persists.
@CarlosEspinozaMaruri please let us know if you updated to Amplify Flutter ^2.0.0 and facing the issue.
@CarlosEspinozaMaruri let us know if you are still facing this issue. Thanks.
Hi @CarlosEspinozaMaruri, I'm going to close this issue now due to lack of activity. If this issue resurfaces or you encounter another issue, please feel free to submit another issue or reopen this one. Thanks