Skip to content

Commit 828bd68

Browse files
authored
fix(monitor): Astro Monitoring component props (#116)
- fix typo - Replaced individual props with MonitoringWithoutRouteProps type for better type safety. - Removed unused variables and imports to clean up the code. - Updated AstroMonitor component to spread props, enhancing flexibility and maintainability.
1 parent 374f15b commit 828bd68

File tree

2 files changed

+13
-14
lines changed

2 files changed

+13
-14
lines changed
Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,12 @@
11
---
2+
import type { MonitoringWithoutRouteProps } from '../..';
23
// @ts-ignore This file will not be packaged, so the file to be imported should be a .mjs file.
34
import { AstroMonitor } from './component.mjs';
45
5-
interface Props {
6-
url?: string;
7-
apiKey: string;
8-
}
9-
10-
const { apiKey, url } = Astro.props;
6+
type Props = MonitoringWithoutRouteProps;
117
128
const path = Astro.url.pathname;
139
const params = Astro.params;
1410
---
1511

16-
<AstroMonitor apiKey={apiKey} url={url} path={pathname} params={params} client:only="react" />
12+
<AstroMonitor path={path} params={params} {...Astro.props} client:only="react" />

packages/scan/src/core/monitor/params/astro/component.ts

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,16 @@
11
import { createElement } from 'react';
2-
import { Monitoring as BaseMonitoring, type MonitoringWithoutRouteProps } from '../..';
2+
import {
3+
Monitoring as BaseMonitoring,
4+
type MonitoringWithoutRouteProps,
5+
} from '../..';
36
import { computeRoute } from '../utils';
47

5-
export function AstroMonitor(props: {
6-
url?: string;
7-
apiKey: string;
8-
path: string;
9-
params: Record<string, string>;
10-
} & MonitoringWithoutRouteProps) {
8+
export function AstroMonitor(
9+
props: {
10+
path: string;
11+
params: Record<string, string | undefined>;
12+
} & MonitoringWithoutRouteProps,
13+
) {
1114
const path = props.path;
1215
const route = computeRoute(path, props.params);
1316

0 commit comments

Comments
 (0)