Skip to content

Commit 0d09e63

Browse files
committed
refactor: extract telemetryAttrs into a single line
1 parent 35a0531 commit 0d09e63

1 file changed

Lines changed: 10 additions & 5 deletions

File tree

src/cli/primitives/GatewayTargetPrimitive.ts

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -330,6 +330,11 @@ export class GatewayTargetPrimitive extends BasePrimitive<AddGatewayTargetOption
330330
(cliOptions.outboundAuthType ?? 'none').replaceAll('_', '-')
331331
);
332332
const telemetryHost = standardize(GatewayTargetHost, cliOptions.host ?? 'lambda');
333+
const telemetryAttrs = {
334+
target_type: telemetryTargetType,
335+
host: telemetryHost,
336+
outbound_auth: telemetryOutboundAuth,
337+
};
333338

334339
// Handle API Gateway targets (no code generation)
335340
if (cliOptions.type === 'apiGateway') {
@@ -367,7 +372,7 @@ export class GatewayTargetPrimitive extends BasePrimitive<AddGatewayTargetOption
367372
} else {
368373
console.log(`Added gateway target '${result.toolName}'`);
369374
}
370-
return { target_type: telemetryTargetType, host: telemetryHost, outbound_auth: telemetryOutboundAuth };
375+
return telemetryAttrs;
371376
}
372377

373378
// Handle schema-based targets (OpenAPI / Smithy)
@@ -403,7 +408,7 @@ export class GatewayTargetPrimitive extends BasePrimitive<AddGatewayTargetOption
403408
} else {
404409
console.log(`Added gateway target '${result.toolName}'`);
405410
}
406-
return { target_type: telemetryTargetType, host: telemetryHost, outbound_auth: telemetryOutboundAuth };
411+
return telemetryAttrs;
407412
}
408413

409414
// Handle Lambda Function ARN targets (no code generation)
@@ -422,7 +427,7 @@ export class GatewayTargetPrimitive extends BasePrimitive<AddGatewayTargetOption
422427
} else {
423428
console.log(`Added gateway target '${result.toolName}'`);
424429
}
425-
return { target_type: telemetryTargetType, host: 'lambda', outbound_auth: telemetryOutboundAuth };
430+
return { ...telemetryAttrs, host: 'lambda' };
426431
}
427432

428433
// Handle MCP server targets (existing endpoint, no code generation)
@@ -458,7 +463,7 @@ export class GatewayTargetPrimitive extends BasePrimitive<AddGatewayTargetOption
458463
} else {
459464
console.log(`Added gateway target '${result.toolName}'`);
460465
}
461-
return { target_type: telemetryTargetType, host: telemetryHost, outbound_auth: telemetryOutboundAuth };
466+
return telemetryAttrs;
462467
}
463468

464469
const result = await this.add({
@@ -482,7 +487,7 @@ export class GatewayTargetPrimitive extends BasePrimitive<AddGatewayTargetOption
482487
}
483488
}
484489

485-
return { target_type: telemetryTargetType, host: telemetryHost, outbound_auth: telemetryOutboundAuth };
490+
return telemetryAttrs;
486491
});
487492
});
488493

0 commit comments

Comments
 (0)