Skip to content

Commit

Permalink
fix: issue with route and path
Browse files Browse the repository at this point in the history
  • Loading branch information
NisargIO committed Dec 12, 2024
1 parent b1facc2 commit 49e5698
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 7 deletions.
3 changes: 1 addition & 2 deletions packages/scan/src/core/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -131,9 +131,8 @@ interface Monitor {
interactions: Array<InternalInteraction>;
session: ReturnType<typeof getSession>;
url: string | null;
apiKey: string | null;
route: string | null;
path: string | null;
apiKey: string | null;
commit: string | null;
branch: string | null;
}
Expand Down
9 changes: 4 additions & 5 deletions packages/scan/src/core/monitor/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,8 @@ export interface MonitoringWithoutRouteProps
export const Monitoring = ({
url,
apiKey,
path = null, // path passed down would be reactive
params,
path = null, // path passed down would be reactive
route = null,
commit = null,
branch = null,
Expand All @@ -59,19 +59,18 @@ export const Monitoring = ({
url,
apiKey,
route,
path,
commit,
branch,
};

// When using Monitoring without framework, we need to compute the route from the path and params
if (!route && path && params) {
Store.monitor.value.route = computeRoute(path, params);
} else {
Store.monitor.value.route = route ?? new URL(window.location.toString()).pathname;
Store.monitor.value.route =
route ?? path ?? new URL(window.location.toString()).pathname; // this is inaccurate on vanilla react if the path is not provided but used for session route
}

Store.monitor.value.path = path ?? new URL(window.location.toString()).pathname;

// eslint-disable-next-line import/no-named-as-default-member
React.useEffect(() => {
scanMonitoring({ enabled: true });
Expand Down

0 comments on commit 49e5698

Please sign in to comment.