| 1 | import type * as rum from "@distilled.cloud/aws/rum"; |
| 2 | import type * as Effect from "effect/Effect"; |
| 3 | import * as Binding from "../../Binding.ts"; |
| 4 | import type { AppMonitor } from "./AppMonitor.ts"; |
| 5 | |
| 6 | export interface GetAppMonitorDataRequest extends Omit< |
| 7 | rum.GetAppMonitorDataRequest, |
| 8 | "Name" |
| 9 | > {} |
| 10 | |
| 11 | /** |
| 12 | * Runtime binding for `rum:GetAppMonitorData` — retrieve the raw performance |
| 13 | * and error events that CloudWatch RUM collected from the bound |
| 14 | * {@link AppMonitor} for your own processing or analysis; the monitor name |
| 15 | * is injected automatically. |
| 16 | * |
| 17 | * Provide `RUM.GetAppMonitorDataHttp` on the hosting Lambda Function to |
| 18 | * satisfy the requirement. |
| 19 | * ### Reading RUM Telemetry |
| 20 | * **Example:** Read the Trailing Hour of Events |
| 21 | * ```typescript |
| 22 | * // init — grants rum:GetAppMonitorData on the monitor |
| 23 | * const getAppMonitorData = yield* AWS.RUM.GetAppMonitorData(monitor); |
| 24 | * |
| 25 | * // runtime — each event is a JSON string |
| 26 | * const now = Date.now(); |
| 27 | * const { Events } = yield* getAppMonitorData({ |
| 28 | * TimeRange: { After: now - 3_600_000, Before: now }, |
| 29 | * }); |
| 30 | * ``` |
| 31 | * |
| 32 | * @binding |
| 33 | */ |
| 34 | export interface GetAppMonitorData extends Binding.Service< |
| 35 | GetAppMonitorData, |
| 36 | "AWS.RUM.GetAppMonitorData", |
| 37 | ( |
| 38 | monitor: AppMonitor, |
| 39 | ) => Effect.Effect< |
| 40 | ( |
| 41 | request: GetAppMonitorDataRequest, |
| 42 | ) => Effect.Effect< |
| 43 | rum.GetAppMonitorDataResponse, |
| 44 | rum.GetAppMonitorDataError |
| 45 | > |
| 46 | > |
| 47 | > {} |
| 48 | |
| 49 | export const GetAppMonitorData = Binding.Service<GetAppMonitorData>( |
| 50 | "AWS.RUM.GetAppMonitorData", |
| 51 | ); |