Skip to content

Commit

Permalink
feat: frontend and backend counting
Browse files Browse the repository at this point in the history
  • Loading branch information
kwasniew committed Jan 29, 2025
1 parent 72906dd commit e9d66ae
Showing 1 changed file with 13 additions and 7 deletions.
20 changes: 13 additions & 7 deletions src/lib/middleware/response-time-metrics.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,15 +67,21 @@ export function responseTimeMetrics(
}

if (flagResolver.isEnabled('uniqueSdkTracking')) {
// if some SDK doesn't provide any
const connectionId =
req.headers['x-unleash-connection-id'] ||
`${req.headers['unleash-instanceid']}${req.ip}`;
// todo: exclude short lived APIs like PHP and Next
eventBus.emit(SDK_CONNECTION_ID_RECEIVED, {
connectionId,
type: req.url.includes('/frontend') ? 'frontend' : 'backend',
});
req.headers['unleash-instanceid'];
if (req.url.includes('/api/client') && connectionId) {
eventBus.emit(SDK_CONNECTION_ID_RECEIVED, {
connectionId,
type: 'backend',
});
}
if (req.url.includes('/api/frontend') && connectionId) {
eventBus.emit(SDK_CONNECTION_ID_RECEIVED, {
connectionId,
type: 'frontend',
});
}
}

const timingInfo = {
Expand Down

0 comments on commit e9d66ae

Please sign in to comment.