Skip to content

Commit

Permalink
getIdTimeByType validation was fixed
Browse files Browse the repository at this point in the history
  • Loading branch information
Gonzalo Lopez authored and Pablo Damian Berdun committed Nov 11, 2024
1 parent 8829f93 commit 8ae8088
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 3 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased]

### Fixed

- Fixed getIdTimeByType method.

## [1.2.0] - 2024-11-08

### Added
Expand Down
5 changes: 3 additions & 2 deletions lib/event-tracker.js
Original file line number Diff line number Diff line change
Expand Up @@ -434,10 +434,11 @@ class EventTracker{

const lastIndex = filteredEvents.length - 1;
const event = filteredEvents[lastIndex];
const parsedEvent = Event.parseEventFromDB(event);

if(!Helpers.isObject(event) || !Object.keys(event).includes('time')) return null;
if(!Helpers.isObject(parsedEvent) || !parsedEvent["time"]) return null;

return event.time;
return parsedEvent["time"];

} catch (error) {
return Promise.reject(error);
Expand Down
2 changes: 1 addition & 1 deletion lib/event.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ class Event {
}

static parseEventForDB(event) {
const {id, type, time, payload} = event;
const {id, type, time, payload} = event || {};
let parsedPayload;

try {
Expand Down

0 comments on commit 8ae8088

Please sign in to comment.