function getEventData()

in sse_uploader/src/dataUtils.js [71:104]


function getEventData(row: any): SSEvent {
  const data = {}, userData = {}, customData = {};

  // Event parameters
  for (const p of SERVER_EVENT_PARAMS) {
    if (row[p])
      data[p] = row[p];
  }

  // Custom parameters
  for (const p of CUSTOM_PARAMS) {
    if (row[`custom.${p}`])
      customData[p] = row[`custom.${p}`];
  }

  // User data parameters
  for (const p of Object.keys(USER_PARAMS_MAPPINGS)) {
    if (row[`user.${p}`]) {
      if (NON_HASHABLE.includes(p)) {
        userData[USER_PARAMS_MAPPINGS[p]] = row[`user.${p}`];
      }
      else {
        const hash = crypto.createHash('sha256');
        const pii = row[`user.${p}`].toLowerCase().trim();
        hash.update(pii);
        userData[USER_PARAMS_MAPPINGS[p]] = hash.digest('hex');
      }
    }
  }

  data.user_data = userData;
  data.custom_data = customData;
  return data;
}