Skip to content

Commit

Permalink
fix(monitor): Astro Monitoring component props (aidenybai#116)
Browse files Browse the repository at this point in the history
- 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.
  • Loading branch information
xinyao27 authored Dec 14, 2024
1 parent 374f15b commit 828bd68
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 14 deletions.
10 changes: 3 additions & 7 deletions packages/scan/src/core/monitor/params/astro/Monitoring.astro
Original file line number Diff line number Diff line change
@@ -1,16 +1,12 @@
---
import type { MonitoringWithoutRouteProps } from '../..';
// @ts-ignore This file will not be packaged, so the file to be imported should be a .mjs file.
import { AstroMonitor } from './component.mjs';
interface Props {
url?: string;
apiKey: string;
}
const { apiKey, url } = Astro.props;
type Props = MonitoringWithoutRouteProps;
const path = Astro.url.pathname;
const params = Astro.params;
---

<AstroMonitor apiKey={apiKey} url={url} path={pathname} params={params} client:only="react" />
<AstroMonitor path={path} params={params} {...Astro.props} client:only="react" />
17 changes: 10 additions & 7 deletions packages/scan/src/core/monitor/params/astro/component.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,16 @@
import { createElement } from 'react';
import { Monitoring as BaseMonitoring, type MonitoringWithoutRouteProps } from '../..';
import {
Monitoring as BaseMonitoring,
type MonitoringWithoutRouteProps,
} from '../..';
import { computeRoute } from '../utils';

export function AstroMonitor(props: {
url?: string;
apiKey: string;
path: string;
params: Record<string, string>;
} & MonitoringWithoutRouteProps) {
export function AstroMonitor(
props: {
path: string;
params: Record<string, string | undefined>;
} & MonitoringWithoutRouteProps,
) {
const path = props.path;
const route = computeRoute(path, props.params);

Expand Down

0 comments on commit 828bd68

Please sign in to comment.