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

AppsFlyer Destination not initializing properly #98

Open
ClaireDavis opened this issue Aug 22, 2024 · 7 comments
Open

AppsFlyer Destination not initializing properly #98

ClaireDavis opened this issue Aug 22, 2024 · 7 comments

Comments

@ClaireDavis
Copy link

Hello - I'm attempting to migrate my app to use the latest analytics_flutter package, but when I try to add the appsflyer plugin, it doesn't initialize properly.

This is how I'm setting up my analytics client:

    analyticsClient = createClient(
      Configuration(
        _segmentWriteKey ?? '',
      ),
    )
      ..addPlugin(AppsFlyerDestination())
      ..addPlugin(PluginAdvertisingId());

Then when update is called in AppsFlyerDestination, the settings map is null so it returns early on line 24 of plugin_appsflyer.dart. Later when identify is called, there is a userId, but then line 61 throws an error because it's force unwrapping appsFlyer which was never set in update because of the early return.

How can I get this to work properly?

@ClaireDavis
Copy link
Author

Here's an example project that shows the issue

https://github.com/ClaireDavis/segment_analytics_test

@edsonjab
Copy link
Contributor

Hi @ClaireDavis thank you for your report, we start looking into this.

@edsonjab
Copy link
Contributor

edsonjab commented Sep 3, 2024

Hi @ClaireDavis sorry to answer late, I can't replicate the issue, could you help me to show us the logs with the error please?

@ClaireDavis
Copy link
Author

@edsonjab

In order to repro the error, I had to add a write key to the configuration. I then get this error on running the app and letting it load:

Launching lib/main.dart on iPhone 15 in debug mode...
Xcode build done.                                           18.9s
Connecting to VM Service at ws://127.0.0.1:52481/PzlgjxLpe4Q=/ws
Connected to the VM Service.
[ERROR:flutter/runtime/dart_vm_initializer.cc(41)] Unhandled Exception: Null check operator used on a null value
#0      AppsFlyerDestination.track (package:segment_analytics_plugin_appsflyer/plugin_appsflyer.dart:110:22)
plugin_appsflyer.dart:110
#1      EventPlugin.execute (package:segment_analytics/plugin.dart:54:16)
plugin.dart:54
#2      DestinationPlugin.process (package:segment_analytics/plugin.dart:163:17)
plugin.dart:163
<asynchronous suspension>
this is the output of my flutter doctor:
[✓] Flutter (Channel stable, 3.24.0, on macOS 14.6.1 23G93 darwin-arm64, locale en-US)
    • Flutter version 3.24.0 on channel stable at /Users/clairedavis/fvm/versions/3.24.0
    • Upstream repository https://github.com/flutter/flutter.git
    • Framework revision 80c2e84975 (5 weeks ago), 2024-07-30 23:06:49 +0700
    • Engine revision b8800d88be
    • Dart version 3.5.0
    • DevTools version 2.37.2

[✓] Android toolchain - develop for Android devices (Android SDK version 34.0.0)
    • Android SDK at /Users/clairedavis/Library/Android/sdk
    • Platform android-34, build-tools 34.0.0
    • ANDROID_SDK_ROOT = /Users/clairedavis/Library/Android/sdk
    • Java binary at: /Applications/Android Studio.app/Contents/jbr/Contents/Home/bin/java
    • Java version OpenJDK Runtime Environment (build 17.0.11+0-17.0.11b1207.24-11852314)
    • All Android licenses accepted.

[✓] Xcode - develop for iOS and macOS (Xcode 15.4)
    • Xcode at /Applications/Xcode.app/Contents/Developer
    • Build 15F31d
    • CocoaPods version 1.15.2

[✓] Chrome - develop for the web
    • Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome

[✓] Android Studio (version 2024.1)
    • Android Studio at /Applications/Android Studio.app/Contents
    • 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 17.0.11+0-17.0.11b1207.24-11852314)

[✓] VS Code (version 1.92.2)
    • VS Code at /Applications/Visual Studio Code.app/Contents
    • Flutter extension version 3.94.0

[✓] Connected device (5 available)
    • sdk gphone64 arm64 (mobile)     • emulator-5554                        • android-arm64  • Android 14 (API 34) (emulator)
    • iPhone 15 (mobile)              • 9ED72432-71DD-4404-8BCA-8D601A3A5F12 • ios            • com.apple.CoreSimulator.SimRuntime.iOS-17-4 (simulator)
    • macOS (desktop)                 • macos                                • darwin-arm64   • macOS 14.6.1 23G93 darwin-arm64
    • Mac Designed for iPad (desktop) • mac-designed-for-ipad                • darwin         • macOS 14.6.1 23G93 darwin-arm64
    • Chrome (web)                    • chrome                               • web-javascript • Google Chrome 128.0.6613.114
    ! Error: Browsing on the local area network for Claire’s iPhone. Ensure the device is unlocked and attached with a cable or associated with the same local
      area network as this Mac.
      The device must be opted into Developer Mode to connect wirelessly. (code -27)

[✓] Network resources
    • All expected network resources are available.

I've attached a zip showing the issue. You'll notice that settings is null at first which triggers an early return but then tracking events force unwrap appsFlyer even though it was never initialized.

segment_error_screen_recording.mov.zip

@edsonjab
Copy link
Contributor

Hi @ClaireDavis sorry to answer late, this is an example to use the AppsFlyerDestination plugin:
image

@cerealexx
Copy link

cerealexx commented Oct 3, 2024

hey @edsonjab, I've followed your example to initialize Segment with AppsFlyer the following way:

Future<void> config(Configuration configuration) async {
    final appsFlyerSettings = {
      'AppsFlyer': {
        if (defaultTargetPlatform == TargetPlatform.iOS)
          'appleAppID': _dotEnv.env['APPSFLYER_IOS_APP_ID'],
        'appsFlyerDevKey': _dotEnv.env['APPSFLYER_DEV_KEY'],
        'httpFallback': false,
        'trackAttributionData': true,
        'type': 'mobile',
        'versionSettings': {'foo': []}
      }
    };
    _appsFlyerDestination = AppsFlyerDestination();
    _segment = createClient(configuration)
      ..addPlugin(PluginAdvertisingId())
      ..addPlugin(_appsFlyerDestination);
    await _segment.init();
    _appsFlyerDestination.update(appsFlyerSettings, ContextUpdateType.initial);
  }

But I'm not seeing anything under the integration property inside the Segment debugger when I track an event.
Also, what are the httpFallbackand versionSettings properties for? I've searched inside the update method and they don't seem to be used for anything. Is there any documentation on how to use this plugin that you cant point me to besides that screenshot you posted?

@awaisjamil-mp
Copy link

any update??

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

4 participants