Skip to content

Commit b5ce403

Browse files
committed
feat: add timestamps to client events
1 parent 21119c0 commit b5ce403

File tree

4 files changed

+47
-2
lines changed

4 files changed

+47
-2
lines changed

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
"@dcl/catalyst-contracts": "^4.4.2",
2121
"@dcl/crypto": "^3.4.5",
2222
"@dcl/platform-server-commons": "^0.0.4",
23-
"@dcl/schemas": "^14.0.0",
23+
"@dcl/schemas": "https://sdk-team-cdn.decentraland.org/@dcl/schemas/branch/feat/multiple-timestamps-on-client-events/dcl-schemas-16.0.1-13812753145.commit-5cf4966.tgz",
2424
"@well-known-components/env-config-provider": "^1.2.0",
2525
"@well-known-components/http-server": "^2.1.0",
2626
"@well-known-components/interfaces": "^1.4.3",

src/adapters/event-parser.ts

+20
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,10 @@ export function createEventParserComponent({ logs }: Pick<AppComponents, 'logs'>
5050
userAddress: event.context.dcl_eth_address,
5151
sessionId: event.context.session_id,
5252
timestamp: event.sentAt,
53+
timestamps: {
54+
receivedAt: new Date(event.receivedAt).getTime(),
55+
reportedAt: new Date(event.timestamp).getTime()
56+
},
5357
realm: event.context.realm,
5458
parcel: {
5559
isEmptyParcel: event.properties.is_empty_parcel,
@@ -72,6 +76,10 @@ export function createEventParserComponent({ logs }: Pick<AppComponents, 'logs'>
7276
userAddress: event.context.dcl_eth_address,
7377
sessionId: event.context.session_id,
7478
timestamp: event.sentAt,
79+
timestamps: {
80+
receivedAt: new Date(event.receivedAt).getTime(),
81+
reportedAt: new Date(event.timestamp).getTime()
82+
},
7583
realm: event.context.realm,
7684
emote: {
7785
emoteIndex: event.properties.emote_index,
@@ -94,6 +102,10 @@ export function createEventParserComponent({ logs }: Pick<AppComponents, 'logs'>
94102
userAddress: event.context.dcl_eth_address,
95103
sessionId: event.context.session_id,
96104
timestamp: event.sentAt,
105+
timestamps: {
106+
receivedAt: new Date(event.receivedAt).getTime(),
107+
reportedAt: new Date(event.timestamp).getTime()
108+
},
97109
realm: event.context.realm,
98110
passport: {
99111
receiver: event.properties.receiver_id
@@ -113,6 +125,10 @@ export function createEventParserComponent({ logs }: Pick<AppComponents, 'logs'>
113125
userAddress: event.context.dcl_eth_address,
114126
sessionId: event.context.session_id,
115127
timestamp: event.sentAt,
128+
timestamps: {
129+
receivedAt: new Date(event.receivedAt).getTime(),
130+
reportedAt: new Date(event.timestamp).getTime()
131+
},
116132
realm: event.context.realm,
117133
distance: event.properties.distance,
118134
stepCount: event.properties.step_count
@@ -131,6 +147,10 @@ export function createEventParserComponent({ logs }: Pick<AppComponents, 'logs'>
131147
userAddress: event.context.dcl_eth_address,
132148
sessionId: event.context.session_id,
133149
timestamp: event.sentAt,
150+
timestamps: {
151+
receivedAt: new Date(event.receivedAt).getTime(),
152+
reportedAt: new Date(event.timestamp).getTime()
153+
},
134154
realm: event.context.realm,
135155
height: event.properties.height
136156
}

src/metrics.ts

+17-1
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,28 @@ import { validateMetricsDeclaration } from '@well-known-components/metrics'
33
import { metricDeclarations as pgMetricDeclarations } from '@well-known-components/pg-component'
44
import { metricDeclarations as theGraphMetricDeclarations } from '@well-known-components/thegraph-component'
55
import { getDefaultHttpMetrics } from '@well-known-components/http-server'
6+
import { IMetricsComponent } from '@well-known-components/interfaces'
67

78
export const metricDeclarations = {
89
...getDefaultHttpMetrics(),
910
...logMetricDeclarations,
1011
...pgMetricDeclarations,
11-
...theGraphMetricDeclarations
12+
...theGraphMetricDeclarations,
13+
explorer_segment_event_delay_in_seconds: {
14+
type: IMetricsComponent.GaugeType,
15+
help: 'Delay between segment event and explorer event',
16+
labelNames: ['event_type']
17+
},
18+
segment_webhook_event_delay_in_seconds: {
19+
type: IMetricsComponent.GaugeType,
20+
help: 'Delay between segment webhook event and explorer event',
21+
labelNames: ['event_type']
22+
},
23+
handled_explorer_events_count: {
24+
type: IMetricsComponent.CounterType,
25+
help: 'Number of explorer events',
26+
labelNames: ['event_type']
27+
}
1228
}
1329

1430
// type assertions

yarn.lock

+9
Original file line numberDiff line numberDiff line change
@@ -802,6 +802,15 @@
802802
ajv-errors "^3.0.0"
803803
ajv-keywords "^5.1.0"
804804

805+
"@dcl/schemas@https://sdk-team-cdn.decentraland.org/@dcl/schemas/branch/feat/multiple-timestamps-on-client-events/dcl-schemas-16.0.1-13812753145.commit-5cf4966.tgz":
806+
version "16.0.1-13812753145.commit-5cf4966"
807+
resolved "https://sdk-team-cdn.decentraland.org/@dcl/schemas/branch/feat/multiple-timestamps-on-client-events/dcl-schemas-16.0.1-13812753145.commit-5cf4966.tgz#1b8b50f9d741f921294370342ce25809e5ef202a"
808+
dependencies:
809+
ajv "^8.11.0"
810+
ajv-errors "^3.0.0"
811+
ajv-keywords "^5.1.0"
812+
mitt "^3.0.1"
813+
805814
"@eslint-community/eslint-utils@^4.2.0", "@eslint-community/eslint-utils@^4.4.0":
806815
version "4.4.0"
807816
resolved "https://registry.yarnpkg.com/@eslint-community/eslint-utils/-/eslint-utils-4.4.0.tgz#a23514e8fb9af1269d5f7788aa556798d61c6b59"

0 commit comments

Comments
 (0)