Skip to content

Commit

Permalink
feat: forward UsedEmote explorer event (#23)
Browse files Browse the repository at this point in the history
* feat: forward UsedEmote explorer event

* chore: bump schemas
  • Loading branch information
aleortega authored Sep 5, 2024
1 parent b0409da commit 9035973
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 9 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
33 changes: 29 additions & 4 deletions src/adapters/event-parser.ts
Original file line number Diff line number Diff line change
@@ -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),
Expand All @@ -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
}

Expand Down
8 changes: 4 additions & 4 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down

0 comments on commit 9035973

Please sign in to comment.