radarlabs / flutter-radar

Flutter package for Radar, the leading geofencing and location tracking platform
https://radar.io
Apache License 2.0
22 stars 13 forks source link

Radar SDK isn't consistent with updating values and does not support offline or batch sync #11

Open Yczar opened 3 years ago

Yczar commented 3 years ago

We are currently on the Team Plan and our project name is TD God-View. We integrated the flutter plugin for our product which is a Logistics App.

We have observed some inconsistency in the behaviour of the plugin which we would like to clarify for trips.

1) When we started a trip we noticed the trip did not have the userId field set even though we could see from the logs that we were setting this value 2) Trip was not updated even after calling start trip, we could not see the trip on the radar dashboard.  3) At some point, after recalling the start trip function pertaining to our use case, we would get the results on radar sometimes in a perfect manner and sometimes we get it inconsistently.

Our implementation We initialised the plugin on the main method, which was verified because the plugin logged the radar initialise method on the console. await Radar.initialize(environment['RADAR_PUBLISHABLE_KEY']!);

The plugin logged this: 

I/RadarLogger(21315): :round_pushpin:️ Radar initialized

After initialising the plugin we set the user ID and the user description immediately after the user logged in following the documentation procedure which states that the function is meant to be called only once. And we also verified the plugin stored the data by calling the getUserId function on the plugin.

static Future<void> initRadar(BuildContext context) async{

 /// [TdUser] details
 String userId = context.read<LoginProvider>().currentUser!.id!;
 String displayName = context.read<LoginProvider>().currentUser!.displayName;

 /// [logger]
 log('');
 log('---------------- RADAR INITIALIZED ----------------');
 log('::::: UserId: $userId :::::');
 log('::::: Display Name: $displayName :::::');
 log('');

 /// Setting user's Description
 await Radar.setUserId(userId);
 await Radar.setDescription(displayName);
 await Radar.startTracking('continuous');
 log('Radar tracking');
}

This was logged immediately this method was called:

[log] ---------------- RADAR INITIALIZED ----------------
[log] ::::: UserId: Eds4G5HD2AypMeBPD :::::
[log] ::::: Display Name: Babalola Gbogo :::::

This was logged after a little while [log] Radar tracking

Then we proceeded to starting a trip in which sometimes it won’t start and sometimes it will.

static Future<void> startTrip({
 required BuildContext context,
}) async {
 final Stop _firstStop = context
   .read<TripProvider>()
   .stops!
   .where((_stop) => _stop.position == 1)
   .toList()
   .first;
 final String externalId =
   '${_firstStop.deliveryTripId}_${_firstStop.stopId}';
 final outlet = await _getRetailOutlet(
  context,
  _firstStop,
 );

 /// [logger]
 log('');
 log('---------------- START TRIP ----------------');
 log('::::: First Stop: ${_firstStop.retailOutletName} :::::');
 log('::::: Outlet Type: ${outletMapper(
  outlet: outlet!.outletType,
 )} :::::');
 log('');

 /// Starting trip with radar
 await _startRadarTrip(
  externalId: externalId,
  outletType: outletMapper(
   outlet: outlet.outletType,
  ),
  outletId: outlet.retailOutletId!,
 );
  log('Trip Started');
}

We verified that it called these methods using the log output

[log] ---------------- START TRIP ----------------
[log] ::::: First Stop: Liquid metal :::::
[log] ::::: Outlet Type: large-super-market :::::

And then after a little delay this got logged [log] Trip Started

nickpatrick commented 3 years ago

Hey @Yczar, thanks for the note.

In this version of the Flutter package and native iOS and Android SDKs, trip options "ride along" with location updates. So you won't see users or trips in the Radar dashboard until a location update is successfully sent to the server (i.e., after you call startTrip(tripOptions) and then subsequently call trackOnce() or startTracking('continuous') and a location update is sent to the server successfully).

We don't support offline replay or batching today, although we're thinking about adding it in the future. If the device is offline, you should see users and trips in the Radar dashboard on the next location update after the device comes back online.

Let me know if that answers your questions.