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

BUG : anonymousId is not defaulting to deviceId #143

Closed
1 of 3 tasks
Filmaluco opened this issue Dec 11, 2023 · 1 comment
Closed
1 of 3 tasks

BUG : anonymousId is not defaulting to deviceId #143

Filmaluco opened this issue Dec 11, 2023 · 1 comment
Assignees

Comments

@Filmaluco
Copy link

Describe the bug
Please provide the following information:

According to the documentation AnonymousId should be device id putAnonymousId is called.
However using the code provided bellow, the anonymousId is different from the deviceId.

Which platform is the issue occurring on
Is the error occurring on:

  • Android
  • iOS
  • Both Android and iOS

Expected behavior
anonymousId is a 16 number digit and the same as deviceId

To Reproduce
Use the following class and init on the start of the app.

class RudderStackAnalyticsProvider extends IAnalyticsProvider {
  RudderStackAnalyticsProvider(this._environmentType, this._writeKey);

  final String _writeKey;
  final EnvironmentType _environmentType;
  final RudderController _client = RudderController.instance;
  String _userId = 'user';

  @override
  Future<void> init() async {
    RudderLogger.init(
      _environmentType == EnvironmentType.development
          ? RudderLogger.DEBUG
          : RudderLogger.VERBOSE,
    );
    final builder = RudderConfigBuilder()
      ..withDataPlaneUrl('https://mindmanukih.dataplane.rudderstack.com')
      // https://github.com/rudderlabs/rudder-sdk-flutter/issues/37#issuecomment-999316787
      ..withMobileConfig(
        MobileConfig(
          autoCollectAdvertId: true,
        ),
      )
      ..withDebug(false); // Set to true for verbose logs from RudderStack

    _client.initialize(
      _writeKey,
      config: builder.build(),
    );
  }

  @override
  Future<void> logEvent({
    required String eventName,
    Map<String, dynamic>? parameters,
  }) async {
    final properties = RudderProperty();
    parameters?.forEach(properties.put);

    _client.track(eventName, properties: properties);
  }

  @override
  Future<void> flush() async {}

  @override
  Future<void> reset() async {
    _client.reset();
  }

  @override
  Future<void> updateUserId(String? userId) async {
    if (_userId == userId) {
      return;
    } else if (userId != null) {
      _userId = userId;
      _client.identify(userId);
    } else {
      _userId = 'user';
      _client
        ..identify('user')
        ..reset();
    }
  }

  @override
  Future<void> addTraits(Map<String, Object?> traits) async {
    final rudderTraits = RudderTraits();
    traits.forEach(rudderTraits.put);
    _client.identify(_userId, traits: rudderTraits);
  }
}

Version of the Flutter SDK
Please provide the following information:

rudder_sdk_flutter: ^2.6.0

SDK initialisation snippet
provided above

Framework version of the SDK
Flutter 3.13.3
Dart 3.1.1

@Filmaluco Filmaluco added the bug Something isn't working label Dec 11, 2023
@desusai7
Copy link
Contributor

Hi @Filmaluco,

Starting from version 2.5.0 of the Rudderstack Flutter SDK, we are not using the device ID as anonymousId. We had also documented it here.

@desusai7 desusai7 removed the bug Something isn't working label Dec 12, 2023
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

2 participants