Skip to content

Commit

Permalink
working version
Browse files Browse the repository at this point in the history
  • Loading branch information
jasonLaster committed Sep 23, 2024
1 parent 9609b0c commit bfb1e60
Show file tree
Hide file tree
Showing 5 changed files with 38 additions and 17 deletions.
8 changes: 5 additions & 3 deletions packages/replay-next/src/suspense/NetworkRequestsCache.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,12 @@ import {
ResponseBodyData,
TimeStampedPoint,
} from "@replayio/protocol";
import { transformSupplementalId } from "protocol/utils"
import { StreamingCacheLoadOptions, createStreamingCache } from "suspense";

import { comparePoints } from "protocol/execution-point-utils";
import { assert } from "protocol/utils";
import { ReplayClientInterface } from "shared/client/types";
import { ReplayClientInterface, TargetPoint } from "shared/client/types";

export type NetworkEventWithTime<EventType> = EventType & {
time: number;
Expand All @@ -41,7 +42,7 @@ export type NetworkRequestsData = {
};
timeStampedPoint: TimeStampedPoint;
triggerPoint: TimeStampedPoint | null;
serverPoint: TimeStampedPoint | null;
targetPoint: TargetPoint | null;
};

export type NetworkRequestsCacheData = {
Expand Down Expand Up @@ -81,6 +82,7 @@ export const networkRequestsCache = createStreamingCache<
ids.push(id);

const targetPoint = replayClient.getTargetPoint(point, 0);
console.log(`TARGET`, transformSupplementalId(targetPoint?.point?.point ?? "", targetPoint?.supplementalIndex ?? 0))

records[id] = {
id,
Expand All @@ -95,13 +97,13 @@ export const networkRequestsCache = createStreamingCache<
responseEvent: null,
responseRawHeaderEvent: null,
},
serverPoint: targetPoint?.point ?? null,
requestBodyData: null,
responseBodyData: null,
timeStampedPoint: {
point,
time,
},
targetPoint: targetPoint ?? null,
triggerPoint: triggerPoint ?? null,
} as NetworkRequestsData;
});
Expand Down
6 changes: 2 additions & 4 deletions packages/shared/client/ReplayClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@ import {
SupplementalSession,
SupplementalRecordingConnection,
TimeStampedPointWithPaintHash,
TargetPoint,
} from "./types";

export const MAX_POINTS_TO_FIND = 10_000;
Expand Down Expand Up @@ -611,9 +612,7 @@ export class ReplayClient implements ReplayClientInterface {
});
}

getTargetPoint(point: ExecutionPoint, pointSupplementalIndex: number): {
point: TimeStampedPoint, supplementalIndex: number
} | null {
getTargetPoint(point: ExecutionPoint, pointSupplementalIndex: number): TargetPoint | null {
const recordingId = this.getSupplementalIndexRecordingId(pointSupplementalIndex);

let targetPoint: TimeStampedPoint | undefined;
Expand Down Expand Up @@ -642,7 +641,6 @@ export class ReplayClient implements ReplayClientInterface {
}

private async maybeGetConnectionStepTarget(point: ExecutionPoint, pointSupplementalIndex: number): Promise<PauseDescription | null> {

const targetPoint = this.getTargetPoint(point, pointSupplementalIndex);
if (!targetPoint) {
return null;
Expand Down
7 changes: 6 additions & 1 deletion packages/shared/client/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,11 @@ export interface SupplementalSession extends SupplementalRecording {
sessionId: string;
}

export interface TargetPoint {
point: TimeStampedPoint;
supplementalIndex: number
}

export interface ReplayClientInterface {
get loadedRegions(): LoadedRegions | null;
addEventListener(type: ReplayClientEvents, handler: Function): void;
Expand Down Expand Up @@ -207,7 +212,7 @@ export interface ReplayClientInterface {
events: RequestEventInfo[];
requests: RequestInfo[];
}>;
getTargetPoint(point: ExecutionPoint, pointSupplementalIndex: number): { point: TimeStampedPoint | undefined, supplementalIndex: number } | null;
getTargetPoint(point: ExecutionPoint, pointSupplementalIndex: number): TargetPoint | null;
findPaints(): Promise<TimeStampedPointWithPaintHash[]>;
findPoints(selector: PointSelector, limits?: PointLimits): Promise<PointDescription[]>;

Expand Down
29 changes: 22 additions & 7 deletions src/ui/components/NetworkMonitor/NetworkMonitorListRow.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,10 @@ import {
URLEncodedToPlaintext,
} from "./content";
import styles from "./NetworkMonitorListRow.module.css";
import { transformSupplementalId } from "protocol/utils"

import { useAppDispatch } from "ui/setup/hooks";
import { seek } from "ui/actions/timeline";

export const LIST_ROW_HEIGHT = 26;

Expand Down Expand Up @@ -117,13 +121,13 @@ function RequestRow({
start: startTime,
status,
triggerPoint,
serverPoint,
targetPoint,
url,
} = request;


if (serverPoint) {
console.log("serverPoint!!", serverPoint);
if (targetPoint) {
console.log("targetPoint!!", targetPoint);
}


Expand Down Expand Up @@ -151,6 +155,9 @@ function RequestRow({
}
}


const dispatch = useAppDispatch();

const [, dismissJumpToNetworkRequestNag] = useNag(Nag.JUMP_TO_NETWORK_REQUEST);

useEffect(() => {
Expand Down Expand Up @@ -233,7 +240,7 @@ function RequestRow({
)}
{columns.name && (
<div className={styles.Column} data-name="name">
{serverPoint && (
{targetPoint && (
<span style={{ color: "red" }}>Server</span>
)}
{name} {graphqlOperationName && `(${graphqlOperationName})`}
Expand Down Expand Up @@ -265,11 +272,19 @@ function RequestRow({
</div>
)}

{serverPoint && (
{targetPoint && (
<button
className={styles.ServerSeekButton}
data-test-name="Network-RequestRow-SeekButton"
onClick={() => seekToRequestWrapper({point: serverPoint, id: id})}
onClick={() => {
dispatch(
seek({
executionPoint: transformSupplementalId(targetPoint.point.point, targetPoint.supplementalIndex),
openSource: true,
time: targetPoint.point.time,
})
);
}}
tabIndex={0}
style={{
backgroundColor: "red !important",
Expand All @@ -285,7 +300,7 @@ function RequestRow({
</button>
)}

{!serverPoint && triggerPoint && triggerPoint.time !== currentTime && (
{!targetPoint && triggerPoint && triggerPoint.time !== currentTime && (
<button
className={styles.SeekButton}
data-test-name="Network-RequestRow-SeekButton"
Expand Down
5 changes: 3 additions & 2 deletions src/ui/components/NetworkMonitor/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import keyBy from "lodash/keyBy";

import { assert, compareExecutionPoints } from "protocol/utils";
import { NetworkRequestsCacheData } from "replay-next/src/suspense/NetworkRequestsCache";
import { TargetPoint } from "shared/client/types";

export enum CanonicalRequestType {
CSS,
Expand Down Expand Up @@ -47,7 +48,7 @@ export type RequestSummary = {
requestHeaders: Header[];
responseHeaders: Header[];
start: number;
serverPoint: TimeStampedPoint | null;
targetPoint: TargetPoint | null;
status: number | undefined;
type: CanonicalRequestType;
url: string;
Expand Down Expand Up @@ -170,7 +171,7 @@ export const partialRequestsToCompleteSummaries = (
start: record.timeStampedPoint.time,
status: responseEvent?.responseStatus,
triggerPoint: record.triggerPoint,
serverPoint: record.serverPoint,
targetPoint: record.targetPoint,
type: REQUEST_TYPES[openEvent.requestCause || ""] ?? CanonicalRequestType.OTHER,
url: openEvent.requestUrl,
};
Expand Down

0 comments on commit bfb1e60

Please sign in to comment.