Skip to content
This repository has been archived by the owner on May 15, 2020. It is now read-only.

Pending events are never sent #67

Open
cesarferreira opened this issue Mar 25, 2020 · 7 comments
Open

Pending events are never sent #67

cesarferreira opened this issue Mar 25, 2020 · 7 comments

Comments

@cesarferreira
Copy link

cesarferreira commented Mar 25, 2020

every time I trigger an event / wait for a period of time I get the same logs:

flutter: [{event_id: 27, event_type: swipe_right, session_id: 1584271557097, timestamp: 1584271593805, uuid: 1426235e-6f6f-4a44-a729-7e6d0e28424fR, library: {name: amplitude-flutter, version: 1.2.0}, api_properties: {}, os_name: iOS, os_version: 13.3, device_brand: null, device_manufacturer: Apple, device_model: iPhone, device_id: 3635f525-d251-47f4-aa49-b8b3744c2632R, platform: iOS, version_name: 1.0, language: en-US, user_id: jQ613NLFnHU75jLQwSnNuaKjQno1}, {event_id: 28, event_type: delete_saved_item, session_id: 1584271557097, timestamp: 1584271598526, uuid: 06137627-c249-4e05-a4c9-8b7b07679941R, library: {name: amplitude-flutter, version: 1.2.0}, properties: [{id: 174}], api_properties: {}, os_name: iOS, os_version: 13.3, device_brand: null, device_manufacturer: Apple, device_model: iPhone, device_id: 3635f525-d251-47f4-aa49-b8b3744c2632R, platform: iOS, version_name: 1.0, language: en-US, user_id: jQ613NLFnHU75jLQwSnNuaKjQno1}, {event_id: 29, event_type: $identify, session_id: 158427155709<…>

checking the timestamp of event_id: 27:

image (4)

It looks like it gets a list of pending events to send but it never sends them.. all of our data is inaccurate .

It's like when a fresh install occurs it can send events until some limit then it just stops and keeps logging this list.

this is my analytics class:

class Analytics {
  Analytics({@required this.amplitude});

  final AmplitudeFlutter amplitude;

  log(
      {@required String event,
      Map<String, dynamic> properties = const <String, String>{}}) async {
    amplitude.logEvent(name: event, properties: properties);
  }

  identify(FirebaseUser firebaseUser) {
    amplitude.setUserId(firebaseUser.uid);

    // identify a user
    final Identify identify = Identify()
      ..set('email', firebaseUser.email)
      ..set('name', firebaseUser.displayName)
      ..set('provider', firebaseUser.providerId);

    amplitude.identify(identify);
  }

  flush() {
    amplitude
        .flushEvents()
        .then((value) => {debugPrint("Flushed all the events")})
        .catchError((e) => print(e));
  }
}

and the tracking:

Provider.of<Analytics>(context, listen: false)
  .log(event: 'add_to_basket', properties: {
    'properties': [
       {'id': piece.id}
     ]
});
@haoliu-amp
Copy link
Contributor

@cesarferreira Happy to help. I believe this happens in your dev environment, right? I have problem to get this reproduced. Do you mind sharing the repo steps?

@cesarferreira
Copy link
Author

Hi! Thanks for the quick reply. This happens in production. Is there a way to set this to Dev environment and I'm not aware of it? What repo steps? I create a singleton of the analytics class on main.dart and then use it everywhere. It looks like it's gathering an array of events and it never manages to deliver them. I don't know how can I give you more information. Is there a possibility it's failing to upload and retaining them?

Best Regards. César

@haoliu-amp
Copy link
Contributor

What I mean is, does this log happen while you're doing development? Or this is some log getting reported to something like Splunk?

I wonder if it happens on your device or it's from your customers'.

@cesarferreira
Copy link
Author

happens to both me developing and to customers as well.
I saw that log on my iOS phone both in debug as release builds

@haoliu-amp
Copy link
Contributor

Cool, would mind share what are the steps to get this reproduced? Or you're also not sure?

@cesarferreira
Copy link
Author

After a few events it just stops sending them to the server and I see events with old timestamps on the logs. Also tried flushing them, still doesnt work

@cesarferreira
Copy link
Author

cesarferreira commented Mar 27, 2020

Forked the library and noticed all responses were coming as 400, yet only 200 and 413 are being handled, everything else is swallowed without any warning.

flutter: status: 400
flutter: response: invalid_event_field. Invalid fields [properties].

I was sending the properties in a bad way. Still, I think the library should print a warning and at least dispose those items, the way it is now, once it gets a bad event it wont get out of the 400 error loop.

Thanks for you time!

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

No branches or pull requests

2 participants