pageViewEvent method
Implementation
Future<void> pageViewEvent(double heights, double onScollDepth) async {
await ConscentMethods().getOSVersion();
_timer = Timer.periodic(const Duration(seconds: 1), (timer) {
Constants.totalTime = Constants.totalTime + 1;
Constants.idleTimeSpent = Constants.totalTime;
});
var uuid = '${Uuid().v4()}';
var anonId = await CoreDb.instance().getAnonId();
var userType = await CoreDb.instance().getUserType();
userType ??= "NEW";
anonId ??= '${Uuid().v4()}';
DateFormat dateFormat = DateFormat("yyyy-MM-dd HH:mm:ss");
String createdAt = dateFormat.format(DateTime.now());
_messageBodyPageView.anonId = anonId;
_messageBodyPageView.userId = await CoreDb.instance().getUserId();
_messageBodyPageView.userType = userType;
_messageBodyPageView.deviceType = 'Mobile';
_messageBodyPageView.browser = "";
_messageBodyPageView.userAgent = Constants.userAgent;
_messageBodyPageView.eventType = "VIEW";
_messageBodyPageView.eventLocation = "PAGE";
_messageBodyPageView.clientId = '${ConscentInitializer.mClientId}';
_messageBodyPageView.osName = Constants.osName;
_messageBodyPageView.userAgent = Constants.userAgent;
_messageBodyPageView.contentId = '${ConscentInitializer.mContentId}';
if (_messageBodyPageView.pageLength == 0 ||
_messageBodyPageView.pageLength == null) {
_messageBodyPageView.pageLength = heights.toInt();
}
if (_messageBodyPageView.scrollDepth == 0 ||
_messageBodyPageView.scrollDepth == null) {
_messageBodyPageView.scrollDepth = onScollDepth.toInt();
}
if (Constants.freeAccess == true) {
_messageBodyPageView.premiumContent = false;
} else {
_messageBodyPageView.premiumContent = true;
}
_messageBodyPageView.pageType = "APP";
_messageBodyPageView.osVersion = Constants.osVersion;
_messageBodyPageView.mobileModel = Constants.mobileModel;
await CoreDb.instance().setUserType("REPEAT");
}