@EPAuditLog
@NoArgsConstructor
public class WebAnalyticsExtAppController extends EPRestrictedRESTfulBaseController {
+ public static final String FEED_ML = "feed.ml";
private WidgetMService widgetMService;
private AppsCacheService appCacheService;
private static final String MACHINE_LEARNING_SERVICE_CTX = "/ml_api";
private static final String REGISTER_ACTION = MACHINE_LEARNING_SERVICE_CTX + "/" + "registerAction";
- private static final String CONSUL_ML_SERVICE_ID = "machine-learning";
private static final String APP_KEY = "uebkey";
+ private static final String ERROR_MSG = " Error retrieving Application to capture app name for analytics; Proceeding with empty app name";
private final EELFLoggerDelegate logger = EELFLoggerDelegate.getLogger(WebAnalyticsExtAppController.class);
private final AsyncRestTemplate restTemplate = new AsyncRestTemplate();
private final SuccessCallback<ResponseEntity<String>> successCallback = arg -> logger.info(EELFLoggerDelegate.debugLogger, arg.getBody());
try {
app = getApp(request);
} catch (Exception e) {
- logger.error(EELFLoggerDelegate.errorLogger,
- " Error retrieving Application to capture app name for analytics; Proceeding with empty app name");
+ logger.error(EELFLoggerDelegate.errorLogger,
+ ERROR_MSG, e);
}
if (app != null) {
String restEndPoint = app.getAppRestEndpoint();
appName = getAppName(request, appName);
} catch (Exception e) {
logger.error(EELFLoggerDelegate.errorLogger,
- " Error retrieving Application to capture app name for analytics; Proceeding with empty app name");
+ ERROR_MSG, e);
}
try {
- storeAuxAnalytics(analyticsMap, appName);
+ if(SystemProperties.containsProperty(FEED_ML) &&
+ SystemProperties.getProperty(FEED_ML).equals("true")) {
+ storeAuxAnalytics(analyticsMap, appName);
+ }
+
} catch (Exception e) {
logger.error(EELFLoggerDelegate.errorLogger,
- " Error retrieving Application to capture app name for analytics; Proceeding with empty app name");
+ ERROR_MSG, e);
}
MDC.put(EPCommonSystemProperties.AUDITLOG_END_TIMESTAMP, EPEELFLoggerAdvice.getCurrentDateTimeUTC());
return appRecord;
}
- private void storeAuxAnalytics(Analytics analyticsMap, String appName) {
+ protected void storeAuxAnalytics(Analytics analyticsMap, String appName) {
logger.info(EELFLoggerDelegate.debugLogger,
" Registering an action for recommendation: AppName/Function/UserId " + appName + "/"
+ analyticsMap.getFunction() + "/" + analyticsMap.getUserid());
+
Map<String, String> requestMapping = new HashMap<>();
requestMapping.put("id", analyticsMap.getUserid());
requestMapping.put("action", appName + "|" + analyticsMap.getFunction());
-
+
HttpHeaders headers = new HttpHeaders();
headers.setContentType(MediaType.APPLICATION_JSON);
// send it!
ListenableFuture<ResponseEntity<String>> out = restTemplate.exchange(
- EcompPortalUtils.widgetMsProtocol() + "://"
- + widgetMService.getServiceLocation(CONSUL_ML_SERVICE_ID,
- SystemProperties.getProperty("microservices.m-learn.local.port"))
+ EcompPortalUtils.widgetMLProtocol() + "://"
+ + widgetMService.getMLServiceLocation()
+ REGISTER_ACTION,
HttpMethod.POST, entity, String.class);
out.addCallback(successCallback, failureCallback);
}
-}
+}
\ No newline at end of file