Refactor model emit, and recent conn dropdown

This commit is contained in:
Gregory Schier
2024-02-05 10:39:47 -08:00
parent bf90f84d16
commit a7f2a86d71
29 changed files with 691 additions and 458 deletions

View File

@@ -9,6 +9,8 @@ export function trackEvent(
| 'Workspace'
| 'Environment'
| 'Folder'
| 'GrpcMessage'
| 'GrpcConnection'
| 'GrpcRequest'
| 'HttpRequest'
| 'HttpResponse'

View File

@@ -14,12 +14,17 @@ export function fallbackRequestName(r: HttpRequest | GrpcRequest | null): string
const fixedUrl = r.url.match(/^https?:\/\//) ? r.url : 'http://' + r.url;
try {
const url = new URL(fixedUrl);
const pathname = url.pathname === '/' ? '' : url.pathname;
return `${url.host}${pathname}`;
} catch (_) {
// Nothing
if (r.model === 'grpc_request' && r.service != null && r.method != null) {
const shortService = r.service.split('.').pop();
return `${shortService}/${r.method}`;
} else {
try {
const url = new URL(fixedUrl);
const pathname = url.pathname === '/' ? '' : url.pathname;
return `${url.host}${pathname}`;
} catch (_) {
// Nothing
}
}
return r.url;

View File

@@ -132,6 +132,7 @@ export interface GrpcConnection extends BaseModel {
readonly model: 'grpc_connection';
service: string;
method: string;
elapsed: number;
}
export interface HttpRequest extends BaseModel {