Skip to content

PluginError #184

Description

@giovanna-afarelli

I am using the latest version (1.1.9) with the AppsFlyer plugin. It works and we are receiving the events in Segment and Appsflyer. But we are getting a PluginError exception:

I/flutter (15244): ┌───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
I/flutter (15244): │ #0 SystemLogger.parseLog (package:segment_analytics/logger.dart:80:16)
I/flutter (15244): │ #1 log (package:segment_analytics/logger.dart:106:23)
I/flutter (15244): ├┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄
I/flutter (15244): │ ⛔ Segment: An internal error occurred: Instance of 'PluginError'
I/flutter (15244): └───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
I/flutter (15244): ┌───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
I/flutter (15244): │ #0 SystemLogger.parseLog (package:segment_analytics/logger.dart:77:16)
I/flutter (15244): │ #1 log (package:segment_analytics/logger.dart:106:23)
I/flutter (15244): ├┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄
I/flutter (15244): │ ⚠️ Segment: Destination AppsFlyer failed to execute: Null check operator used on a null value

This is my initialization code:

    final configuration = Configuration(
    writeKey,
    trackApplicationLifecycleEvents: true,
    collectDeviceId: true,
    debug: kDebugMode,
    defaultIntegrationSettings: {
      'AppsFlyer': {
        'enabled': true,
        'appsFlyerId': appsFlyerId,
      },
    },
    errorHandler: (exception) {
      _logger.error(
        'Analytics initialization error: ${exception.toString()}',
        data: exception,
      );
    },
  );

  final appsFlyerDestination = _getAppsflyerDestination(
    appsFlyerId,
    appsFlyerDevKey,
    appsFlyerIosAppId,
  );

  final segment = createClient(configuration);
  if (appsFlyerDestination != null) {
    segment.addPlugin(appsFlyerDestination);
  }

  await segment.init();
  instance = Analytics();
  instance.analytics = segment;

  setContext(
    {
      "externalIds": [
        {
          "id": appsFlyerId,
          "type": "appsflyerId",
        }
      ],
    },
  );

 static AppsFlyerDestination? _getAppsflyerDestination(
  String? appsflyerId, String appsFlyerDevKey, String? appsFlyerIosAppId) {
try {
  final appsFlyerDestination = AppsFlyerDestination();
  final appleAppId = Platform.isIOS ? appsFlyerIosAppId : null;
  final appsFlyerDestinationSettings = {
    'appleAppID': appleAppId,
    'appsFlyerDevKey': appsFlyerDevKey,
    'httpFallback': false,
    'trackAttributionData': true,
    'type': 'mobile',
    'versionSettings': {
      '': [''],
    },
  };
  appsFlyerDestination.update(
      appsFlyerDestinationSettings, ContextUpdateType.initial);

  return appsFlyerDestination;
} catch (e) {
  AppInitErrorsService().addError(
    Exception('Appsflyer initialization error: ${e.toString()}'),
  );
  return null;
 }
}

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