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

Implements Amplitude with flutter_segment package #66

Open
RicharC293 opened this issue Sep 20, 2021 · 3 comments
Open

Implements Amplitude with flutter_segment package #66

RicharC293 opened this issue Sep 20, 2021 · 3 comments

Comments

@RicharC293
Copy link

We are trying to implement this package for segment and amplitude integration all at the flutter level.
https://pub.dev/packages/flutter_segment
https://pub.dev/packages/flutter_segment#setting-the-options-globally

The flutter_segment package to identify the user asks me for a session_id but when trying to get this session_id with the amplitude package it always returns -1.

My question is, what would be the best practice to integrate these two packages, maybe there is any suggestion?

As far as I understand I need to identify the user to get a session Id, maybe it works in a similar way with the anonimus id that segment provides?

@yuhao900914
Copy link
Contributor

Hi @RicharC293. Does the issue is when you trying to get session id from amplitude_flutter the session id always be -1? Without the implementation details, we cannot find the real cause is. May I know which version of amplitude_flutter you are using and how you get the session id?

@RicharC293
Copy link
Author

Sometimes when i call getSessionId() return session id but in other cases return -1
Flutter doctor -v
[√] Flutter (Channel stable, 2.5.0, on Microsoft Windows [Versión 10.0.19042.1237], locale es-EC)
• Flutter version 2.5.0 at C:\src\flutter
• Upstream repository https://github.com/flutter/flutter.git
• Framework revision 4cc385b4b8 (13 days ago), 2021-09-07 23:01:49 -0700
• Engine revision f0826da7ef
• Dart version 2.14.0

[√] Android toolchain - develop for Android devices (Android SDK version 30.0.3)
• Android SDK at C:\Users\tipti\AppData\Local\Android\Sdk
• Platform android-30, build-tools 30.0.3
• ANDROID_HOME = C:\Users\tipti\AppData\Local\Android\Sdk
• Java binary at: C:\Program Files\Android\Android Studio\jre\bin\java
• Java version OpenJDK Runtime Environment (build 11.0.10+0-b96-7249189)
• All Android licenses accepted.

[√] Chrome - develop for the web
• Chrome at C:\Program Files\Google\Chrome\Application\chrome.exe

[√] Android Studio (version 2020.3)
• Android Studio at C:\Program Files\Android\Android Studio
• Flutter plugin can be installed from:
https://plugins.jetbrains.com/plugin/9212-flutter
• Dart plugin can be installed from:
https://plugins.jetbrains.com/plugin/6351-dart
• Java version OpenJDK Runtime Environment (build 11.0.10+0-b96-7249189)

[√] VS Code (version 1.60.1)
• VS Code at C:\Users\tipti\AppData\Local\Programs\Microsoft VS Code
• Flutter extension can be installed from:
https://marketplace.visualstudio.com/items?itemName=Dart-Code.flutter

[√] Connected device (3 available)
• LM X525 (mobile) • LMX525USUKZP5D9PE6 • android-arm • Android 10 (API 29)
• Chrome (web) • chrome • web-javascript • Google Chrome 93.0.4577.82
• Edge (web) • edge • web-javascript • Microsoft Edge 93.0.961.52

• No issues found!

Amplitude Version amplitude_flutter 3.3.0
Flutter Segment flutter_segment 3.1.2

Code to call session_id implemented

static Future<int> _getAmplitudeSessionId(User user) async {
    try {
      final Amplitude analytics =
          Amplitude.getInstance(instanceName: "client_mobile");
      analytics.setUseDynamicConfig(true);
      analytics.setServerUrl("https://api2.amplitude.com");
      analytics.init(Flavor.amplitude, userId: "${user.userId}");
      analytics.trackingSessionEvents(true);
      print(await analytics.getSessionId());
      return await analytics.getSessionId();
    } catch (err) {
      debugPrint("INITIALIZE_AMPLITUDE: $err");
      return null;
    }
  }

@this-alias
Copy link

Did you ever find the solution to this problem? We see the same thing where the session ID defaults to -1 in Amplitude because intergrations.Actions Amplitude.session_id is blank in Segment for the event integrations parameter.

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

3 participants