paywallClickEvent method
Implementation
Future<void> paywallClickEvent(String clickAction) async {
pageViewDisposeEvent(0, 0);
await ConscentMethods().getOSVersion();
var anonId = await CoreDb.instance().getAnonId();
anonId ??= '${Uuid().v4()}';
DateFormat dateFormat = DateFormat("yyyy-MM-dd HH:mm:ss");
String createdAt = dateFormat.format(DateTime.now());
_messageBodyDataEvent.clientId = ConscentInitializer.mClientId;
_messageBodyDataEvent.contentId = ConscentInitializer.mContentId;
_messageBodyDataEvent.anonId = anonId;
_messageBodyDataEvent.userId = await CoreDb.instance().getUserId();
_messageBodyDataEvent.deviceType = "Mobile";
_messageBodyDataEvent.isCookieBlocked = 0;
_messageBodyDataEvent.paywallType = "Default";
_messageBodyDataEvent.paywallDisplayType = "INARTICLE";
_messageBodyDataEvent.numOfCta = Constants.numOfCta;
if (Constants.paywallConfig.data != null) {
_messageBodyDataEvent.paywallId = Constants.paywallConfig.data?.sId;
_messageBodyDataEvent.numOfCta = Constants
.paywallConfig.data?.configuration?.mobile?.templateId?.numberOfCta;
_messageBodyDataEvent.paywallType = Constants
.paywallConfig.data?.configuration?.mobile?.templateId?.paywallType;
_messageBodyDataEvent.paywallDisplayType = Constants
.paywallConfig.data?.configuration?.mobile?.templateId?.displayType;
}
_messageBodyDataEvent.osVersion = Constants.osVersion;
_messageBodyDataEvent.mobileModel = Constants.mobileModel;
_messageBodyDataEvent.osName = Constants.osName;
_messageBodyDataEvent.userAgent = Constants.userAgent;
_messageBodyDataEvent.clickAction = clickAction;
_messageBodyDataEvent.eventLocation = "PAYWALL";
_messageBodyDataEvent.eventType = "CLICK";
var paywallViewClickEvent =
PaywallClickEvent(messageBody: [_messageBodyDataEvent]);
paywallViewClickEvent.topic = "demoTopic";
final headers = {'Content-Type': 'application/json'};
Map<String, dynamic> body = paywallViewClickEvent.toJson();
String jsonBody = json.encode(body);
final encoding = Encoding.getByName('utf-8');
var response = await http.post(
Uri.parse('${APIMode.EVENT_BASE_URL}/collect/event'),
headers: headers,
body: jsonBody,
encoding: encoding,
);
}