diff --git a/package.json b/package.json index a5e7761..9aaf4a6 100644 --- a/package.json +++ b/package.json @@ -19,7 +19,7 @@ "@aws-sdk/client-sns": "^3.609.0", "@dcl/catalyst-contracts": "^4.4.1", "@dcl/platform-server-commons": "^0.0.4", - "@dcl/schemas": "^13.8.6", + "@dcl/schemas": "^13.9.0", "@well-known-components/env-config-provider": "^1.2.0", "@well-known-components/http-server": "^2.1.0", "@well-known-components/interfaces": "^1.4.3", diff --git a/src/adapters/event-parser.ts b/src/adapters/event-parser.ts index d80f5ea..39e4ae6 100644 --- a/src/adapters/event-parser.ts +++ b/src/adapters/event-parser.ts @@ -1,15 +1,18 @@ -import { Event, Events, MoveToParcelEvent } from '@dcl/schemas' +import { Event, Events, MoveToParcelEvent, UsedEmoteEvent } from '@dcl/schemas' enum ExplorerEventIds { - MOVE_TO_PARCEL = 'move_to_parcel' + MOVE_TO_PARCEL = 'move_to_parcel', + USED_EMOTE = 'used_emote' } function parseExplorerClientEvent(event: any): Event | undefined { - if (event && (event.event as string).toLocaleLowerCase() === ExplorerEventIds.MOVE_TO_PARCEL) { + if (!event || !event.event) return undefined + + if ((event.event as string).toLocaleLowerCase() === ExplorerEventIds.MOVE_TO_PARCEL) { return { type: Events.Type.CLIENT, subType: Events.SubType.Client.MOVE_TO_PARCEL, - timestamp: event.timestamp, + timestamp: new Date(event.timestamp).getTime(), key: event.messageId, metadata: { authChain: JSON.parse(event.context.auth_chain), @@ -27,6 +30,28 @@ function parseExplorerClientEvent(event: any): Event | undefined { } as MoveToParcelEvent } + if ((event.event as string).toLocaleLowerCase() === ExplorerEventIds.USED_EMOTE) { + return { + type: Events.Type.CLIENT, + subType: Events.SubType.Client.USED_EMOTE, + timestamp: new Date(event.timestamp).getTime(), + key: event.messageId, + metadata: { + authChain: JSON.parse(event.context.auth_chain), + userAddress: event.context.dcl_eth_address, + sessionId: event.context.session_id, + timestamp: event.sentAt, + realm: event.context.realm, + emote: { + emoteIndex: event.properties.emote_index, + isBase: event.properties.is_base, + itemId: event.properties.item_id, + source: event.properties.source + } + } + } as UsedEmoteEvent + } + return undefined } diff --git a/yarn.lock b/yarn.lock index f99792b..ba5f4c2 100644 --- a/yarn.lock +++ b/yarn.lock @@ -774,10 +774,10 @@ "@well-known-components/interfaces" "^1.4.2" node-fetch "^2.7.0" -"@dcl/schemas@^13.8.6": - version "13.8.6" - resolved "https://registry.yarnpkg.com/@dcl/schemas/-/schemas-13.8.6.tgz#ada9cf0c55544a622d2a2f0f76d206fceeaa5a43" - integrity sha512-n79qq6vT+95CY+o3wDroQ97q2vFuIRDKPcJI9S+RVOg9PyVYs8Z4bsHp6kqP2FhhscNLc85xEnIdD2/3SIh56A== +"@dcl/schemas@^13.9.0": + version "13.9.0" + resolved "https://registry.yarnpkg.com/@dcl/schemas/-/schemas-13.9.0.tgz#191645a43f9ef03f0e4515218fae3a11a2b4d501" + integrity sha512-t8t043TfxIpXqzR1mNehD4d6YFfbauq5ICoLL2Y72emSiu8q0bCI3pNCoaN0Ea6s7n+6AVv39Q8TvzWUneRBpQ== dependencies: ajv "^8.11.0" ajv-errors "^3.0.0"