viewContent method
Sends only the fixed ViewContent event and an allowlisted content ID/type.
Implementation
Future<bool> viewContent({
required String contentId,
required String contentType,
}) async {
final config = _config;
if (config == null ||
!config.enabled ||
!config.viewContentEnabled ||
(contentType == 'profile' &&
!(config.profileViewEnabled ?? config.viewContentEnabled)) ||
(contentType == 'event' &&
!(config.eventViewEnabled ?? config.viewContentEnabled)) ||
contentId.trim().isEmpty ||
!const {'profile', 'event'}.contains(contentType)) {
return false;
}
final qualifiedContentId = [
'tenant',
Uri.encodeComponent(config.tenantId.trim()),
contentType,
Uri.encodeComponent(contentId.trim()),
].join('/');
return await _channel.invokeMethod<bool>('logEvent', {
'event': 'ViewContent',
'parameters': {
'content_id': qualifiedContentId,
'content_type': contentType,
},
}) ??
false;
}