Skip to content

optInTracking and optOutTracking return void, causing a race condition for hasOptedOutTracking #146

Open
@DaVaMa1

Description

@DaVaMa1

When using the methods optInTracking and optOutTracking they return fairly instantly as they have return type void. This means that checking the status of tracking later on with hasOptedOutTracking might return a ''wrong'' value if called too soon. This could be prevented by just returning the future from the method channel call. (Assuming they handle everything properly and only return after completing.

Essentially what I'm asking for is if:

/// Use this method to n
  /// opt-in an already opted-out user from tracking. People updates and track
  /// calls will be sent to Mixpanel after using this method.
  /// This method will internally track an opt-in event to your project.
  void optInTracking() {
    _channel.invokeMethod<void>('optInTracking');
  }

  /// Use this method to opt-out a user from tracking. Events and people updates that haven't been
  /// flushed yet will be deleted. Use flush() before calling this method if you want
  /// to send all the queues to Mixpanel before.
  ///
  /// This method will also remove any user-related information from the device.
  void optOutTracking() {
    _channel.invokeMethod<void>('optOutTracking');
  }

Can be changed to

/// Use this method to n
  /// opt-in an already opted-out user from tracking. People updates and track
  /// calls will be sent to Mixpanel after using this method.
  /// This method will internally track an opt-in event to your project.
  Future<void> optInTracking()  async {
    return _channel.invokeMethod<void>('optInTracking');
  }

  /// Use this method to opt-out a user from tracking. Events and people updates that haven't been
  /// flushed yet will be deleted. Use flush() before calling this method if you want
  /// to send all the queues to Mixpanel before.
  ///
  /// This method will also remove any user-related information from the device.
 Future<void> optOutTracking() async {
     return _channel.invokeMethod<void>('optOutTracking');
  }

Maybe there are certain considerations I'm unaware off, please let me know what you think.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions