src/services/analyticsService.js
/**
 * @description Update/upsert analytics document
 * @memberof analyticsService
 * @function updateSection
 * @returns updated mongo document
 */
@description Update/upsert analytics document
@memberof analyticsService
@function updateSection
@returns updated mongo document
@description Update / upsert analytics document @memberof analyticsService @function updateSection @returns updated mongo document
async function updateAnalyticsRecord(req) {
  try {
    LOGGER.info(`Entering into updateAnalyticsRecord() of :: ${FILE_NAME}`);
    const { body } = req;
    const currentTime = new Date();
    const query = {
      browserName: body.browserName,
      browserLanguage: body.browserLanguage,
      browserPlatform: body.browserPlatform,
      country: body.country,
      region: body.region,
      sessionDuration: 0,
      createdTime: currentTime,
    };
    const upsertFlag = true;
    const result = await analyticsDAO.update(query, upsertFlag);
    LOGGER.info(`Success in updateAnalyticsRecord() of :: ${FILE_NAME}`);
    return result;
  } catch (error) {
    LOGGER.error(`Error in updateAnalyticsRecord() of :: ${FILE_NAME} :: ${error}`);
    throw new Error(error);
  }
}
async function updateAnalyticsRecord ( req ) { try { LOGGER . info ( ` ${ FILE_NAME } ` ) ; const { body } = req ; const currentTime = new Date ( ) ; const query = { browserName : body . browserName , browserLanguage : body . browserLanguage , browserPlatform : body . browserPlatform , country : body . country , region : body . region , sessionDuration : 0 , createdTime : currentTime , } ; const upsertFlag = true ; const result = await analyticsDAO . update ( query , upsertFlag ) ; LOGGER . info ( ` ${ FILE_NAME } ` ) ; return result ; } catch ( error ) { LOGGER . error ( ` ${ FILE_NAME } ${ error } ` ) ; throw new Error ( error ) ; } }
@description Update/upsert analytics document
 @memberof analyticsService
 @function updateSection
 @returns updated mongo document
@description Update / upsert analytics document @memberof analyticsService @function updateSection @returns updated mongo document