Skip to content

Commit

Permalink
tracking rentals
Browse files Browse the repository at this point in the history
  • Loading branch information
blytheaw committed Aug 12, 2023
1 parent e0e5b73 commit 333e11f
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion src/handlers/api/rentals.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ import {
CreateRentalSchema,
UpdateRentalSchema,
} from "../../schemas/rental.js";
import { metrics } from "../../common/utils.js";
import { MetricUnits } from "@aws-lambda-powertools/metrics";

const rentalIdPathSchema = z.object({
id: z.string().uuid(),
Expand Down Expand Up @@ -36,7 +38,12 @@ export const update = ApiHandler(
body: UpdateRentalSchema,
}),
async (request) => {
return await Rental.update(request.pathParameters.id, request.body);
await Rental.update(request.pathParameters.id, request.body);

// Use CloudWatch custom metrics for tracking key indicators
if (request.body.status === "rented") {
metrics.addMetric("RentalCount", MetricUnits.Count, 1);
}
}
);

Expand Down

0 comments on commit 333e11f

Please sign in to comment.