Skip to content

Commit

Permalink
Add sender and calldata to props
Browse files Browse the repository at this point in the history
  • Loading branch information
makoto committed Jan 24, 2024
1 parent b904c67 commit 34816f5
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 5 deletions.
10 changes: 7 additions & 3 deletions arb-gateway/src/tracker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,9 +69,13 @@ export class Tracker {
if (requestInfo.get('Referrer')) {
body.referrer = requestInfo.get('Referrer') || '';
}

if (props) {
body.props = props;
body.props = props || {}
const trackingData = (body.url).match(/\/0x[a-fA-F0-9]{40}\/0x[a-fA-F0-9]{1,}\.json/)
if (trackingData) {
body.props = Object.assign(body.props, {
sender:trackingData[0].slice(1,42),
calldata:trackingData[0].slice(44).replace(".json","")
})
}

if (data) {
Expand Down
6 changes: 4 additions & 2 deletions arb-gateway/src/worker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ const logResult = async (
const [streamForLog, streamForResult] = result.body.tee();
const logResult = await new Response(streamForLog).json();
const logResultData = logResult.data.substring(0, 200);
console.log('***TrackingEvent', logResultData)
await tracker.trackEvent(
'result',
request,
Expand Down Expand Up @@ -64,7 +63,10 @@ async function fetch(request: CFWRequest, env: Env) {
gateway.add(server);
app = server.makeApp('/');
}
// return app.handle(request);
await tracker.trackEvent(
'request', request,{},true
);

return app.handle(request).then(logResult.bind(null, request));
}

Expand Down

0 comments on commit 34816f5

Please sign in to comment.