fillPayload method

Future<void> fillPayload(
  1. String cookie,
  2. RequestOptions options
)

Implementation

Future<void> fillPayload(String cookie, RequestOptions options) async {
  deviceInfos = await EventTracker().initPlatformState();
  deviceInfos["ua"] = options.headers["User-Agent"];
  deviceInfos["ddk"] = dataDomeKey;//client key
  deviceInfos["cid"] = DataDomeDio.parseCookieValue(cookie);
  deviceInfos["request"] = options.uri;

  if(context != null) {
    // complete device infos of payload that requires context
    MediaQueryData? media = MediaQuery.maybeOf(context!);
    if(media != null) {
      // The context does have a MediaQuery
      deviceInfos["screen_x"] = media.size.width.toStringAsFixed(3);
      deviceInfos["screen_y"] = media.size.height.toStringAsFixed(3);
      deviceInfos["screen_d"] = media.devicePixelRatio;
    }
  }
}