trackProductView method
Implementation
Future<RelevaResponse> trackProductView({
String? screenToken,
String? pageUrl,
required String productId,
Map<String, dynamic>? customFields,
List<String>? categories,
String? locale,
String? currency,
}) async {
if (!_config.enableTracking) {
return RelevaResponse(recommenders: [], banners: []);
}
final request = ScreenViewRequest(
screenToken: screenToken,
categories: categories,
);
if (pageUrl != null) request.pageUrl(pageUrl);
if (locale != null) request.locale(locale);
if (currency != null) request.currency(currency);
// Add product view
final viewedProduct = Viewedproduct(
productId,
customFields != null
? _convertToCustomFields(customFields)
: CustomFields.empty(),
);
request.productView(viewedProduct);
return await push(request);
}