updateExternalAttribution method

Future<void> updateExternalAttribution(
  1. Map attribution, {
  2. required AdaptyExternalAttributionProvider provider,
})

Sends external attribution data for the current profile.

The method returns after the backend accepts the data for asynchronous processing. A successful return does not mean that the data has already been processed or that the profile has already been updated.

Read more in the Adapty documentation.

Parameters:

  • attribution: a map containing attribution (conversion) data.
  • provider: the external attribution provider.

Implementation

Future<void> updateExternalAttribution(
  Map attribution, {
  required AdaptyExternalAttributionProvider provider,
}) async {
  late final String encodedAttribution;
  try {
    encodedAttribution = json.encode(attribution);
  } catch (error) {
    throw AdaptyError(
      'Failed to encode external attribution data',
      AdaptyErrorCode.wrongParam,
      error.toString(),
    );
  }

  return _invokeMethod<void>(
    Method.updateExternalAttribution,
    (data) => null,
    {
      Argument.attribution: encodedAttribution,
      Argument.provider: provider.rawValue,
    },
  );
}