initSdk method
Implementation
@override
Future<String?> initSdk(CXExporterOptions options) async {
var arguments = options.toMap();
// Remove beforeSend from arguments as it cannot be serialized
arguments.remove('beforeSend');
arguments['pluginVersion'] = PluginInfo.version;
arguments['hasBeforeSend'] = options.beforeSend != null;
final version =
await methodChannel.invokeMethod<String>('initSdk', arguments);
// beforeSend is optional: only set up listener when provided; otherwise native SDK sends events directly.
if (options.beforeSend != null) {
_beforeSendCallback = options.beforeSend;
_startListening();
} else {
_beforeSendCallback = null;
stopListening();
}
// traces exporter: listen to the second EventChannel when a callback is provided.
if (options.tracesExporter != null) {
_tracesExporterCallback = options.tracesExporter;
_startTracesExporterListening();
} else {
_tracesExporterCallback = null;
_stopTracesExporterListening();
}
return version;
}