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;
}
}
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:
This is my initialization code: