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 record event is throwing SqliteException #4838

Open
2 of 12 tasks
CarlosEspinozaMaruri opened this issue May 6, 2024 · 6 comments
Open
2 of 12 tasks

Analytics record event is throwing SqliteException #4838

CarlosEspinozaMaruri opened this issue May 6, 2024 · 6 comments
Assignees
Labels
analytics Issues related to the Amplify Analytics Category bug Something is not working; the issue has reproducible steps and has been reproduced Investigating Issues that are assigned and are being looked into pending-response Issue is pending response from the issue requestor

Comments

@CarlosEspinozaMaruri
Copy link

CarlosEspinozaMaruri commented May 6, 2024

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

  • 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
  • Windows
  • Linux

Flutter Version

3.10.0

Amplify Flutter Version

1.1.1

Deployment Method

Amplify CLI

Schema

No response

@khatruong2009 khatruong2009 added analytics Issues related to the Amplify Analytics Category pending-triage This issue is in the backlog of issues to triage labels May 7, 2024
@khatruong2009
Copy link
Contributor

Hi @CarlosEspinozaMaruri, thank you for submitting this issue. We will take a look at it and get back to you with any updates.

@khatruong2009 khatruong2009 self-assigned this May 9, 2024
@khatruong2009 khatruong2009 added the Investigating Issues that are assigned and are being looked into label May 9, 2024
@khatruong2009
Copy link
Contributor

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?

@khatruong2009 khatruong2009 removed the Investigating Issues that are assigned and are being looked into label May 9, 2024
@CarlosEspinozaMaruri
Copy link
Author

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.

@khatruong2009
Copy link
Contributor

Hi @CarlosEspinozaMaruri, you suspect this occurs in release mode on some Windows devices. Does this mean it works fine for iOS and Android platforms?

@CarlosEspinozaMaruri
Copy link
Author

@khatruong2009 yes

@NikaHsn
Copy link
Contributor

NikaHsn commented May 14, 2024

@CarlosEspinozaMaruri have you tried upgrading to Amplify Flutter 2.0.0 and does it resolve the issue?

@NikaHsn NikaHsn added Investigating Issues that are assigned and are being looked into bug Something is not working; the issue has reproducible steps and has been reproduced pending-response Issue is pending response from the issue requestor and removed pending-triage This issue is in the backlog of issues to triage labels May 14, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
analytics Issues related to the Amplify Analytics Category bug Something is not working; the issue has reproducible steps and has been reproduced Investigating Issues that are assigned and are being looked into pending-response Issue is pending response from the issue requestor
Projects
None yet
Development

No branches or pull requests

3 participants