Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add more portions of the path to r11s request errors #22943

Merged
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 24 additions & 8 deletions packages/drivers/routerlicious-driver/src/errorUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -194,16 +194,32 @@ export function getUrlForTelemetry(hostName: string, path?: string): string | un
}
const strippedHostName = hostNameMatch[1];

let extractedPath: string | undefined;
let extractedPath = "";
if (path !== undefined) {
// Extract the first portion of the path and explicitly match it to known path names
const pathMatch = path.match(/^\/?([^/]+)/);
if (pathMatch && [socketIoPath, "repos", "deltas", "documents"].includes(pathMatch[1])) {
extractedPath = pathMatch[1];
// Extract portions of the path and explicitly match them to known path names
const portionArray: string[] = [];
for (const portion of path.split("/")) {
if (portion !== "") {
if (
[
socketIoPath,
"repos",
"deltas",
"documents",
"session",
"git",
"summaries",
"latest",
].includes(portion)
) {
portionArray.push(portion);
} else {
portionArray.push("REDACTED");
}
}
}
extractedPath = portionArray.join("/");
}

return extractedPath !== undefined
? `${strippedHostName}/${extractedPath}`
: strippedHostName;
return extractedPath !== "" ? `${strippedHostName}/${extractedPath}` : strippedHostName;
}
Original file line number Diff line number Diff line change
Expand Up @@ -304,13 +304,18 @@ describe("ErrorUtils", () => {
["https://some.url.com/", "", "some.url.com"],
["something://some.url.com/", "", "something:"],
["some.url.com/path", undefined, "some.url.com"],
["some.url.com/", "randomPath", "some.url.com"],
["some.url.com/", "randomPath", "some.url.com/REDACTED"],
["some.url.com/", socketIoPath, `some.url.com/${socketIoPath}`],
["http://some.url.com/", "repos", "some.url.com/repos"],
["some.url.com/", "deltas", "some.url.com/deltas"],
["https://some.url.com", "documents", "some.url.com/documents"],
["https://some.url.com/", "/documents/", "some.url.com/documents"],
["https://some.url.com/", "documents/morePath", "some.url.com/documents"],
["https://some.url.com/", "documents/morePath", "some.url.com/documents/REDACTED"],
[
"https://some.url.com",
"documents/morePath/documents/latest/abc-123/",
"some.url.com/documents/REDACTED/documents/latest/REDACTED",
],
];

testCases.forEach((testCase) => {
Expand Down
Loading