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

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

Open
DaVaMa1 opened this issue May 3, 2024 · 0 comments

Comments

@DaVaMa1
Copy link

DaVaMa1 commented May 3, 2024

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.

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

No branches or pull requests

1 participant