-
Notifications
You must be signed in to change notification settings - Fork 25
DEVPROD-4509: Exclude "secret fields" in Sentry Breadcrumbs #2284
Conversation
// if there is data in response then server responded with 200; therefore, is authenticated. | ||
dispatchAuthenticated(); | ||
} | ||
leaveBreadcrumb( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I made a separate Apollo Link for leaveBreadcrumb
1 flaky test on run #16229 ↗︎
Details:
Review all test suite changes for PR #2284 ↗︎ |
dispatchAuthenticated?: () => void; | ||
} | ||
|
||
const cache = new InMemoryCache({ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Moved cache definition to a separate file
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Awesome!
}, | ||
}); | ||
|
||
const authLink = (logout: () => void): ApolloLink => |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I moved all Apollo Links to a new file
}, | ||
}); | ||
|
||
const getGQLClient = ({ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I converted this into a hook.
|
||
describe("post", () => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I didn't update the test logic and only nested it
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great work here it works really well! I just had a few suggestions
@@ -14,7 +14,7 @@ describe("Viewing a patch", () => { | |||
); | |||
}); | |||
it("Clicking the 'My Patches' breadcrumb goes to the logged in user's Patches Page when the current patch belongs to the logged in user", () => { | |||
cy.contains("My Patches").click(); | |||
cy.dataCy("bc-my-patches").click(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this the fix for the flaky test? 😍
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think so
dispatchAuthenticated?: () => void; | ||
} | ||
|
||
const cache = new InMemoryCache({ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Awesome!
* @param keyToDelete The name of the key to be removed. | ||
* @returns The object with the key removed. | ||
*/ | ||
export function deleteNestedKey<T extends object>( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How do you feel about using a similar redaction pattern as we use in the backend? Instead of deleting the key we instead replace the value with the word REDACTED
or something similar. This still allows us to debug and see that we sent a value while also accomplishing the same affect.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great tests!
Co-authored-by: Mohamed Khelif <[email protected]>
Co-authored-by: Mohamed Khelif <[email protected]>
Co-authored-by: Mohamed Khelif <[email protected]>
This reverts commit 2f15e3d.
This reverts commit 6213cdb.
src/utils/object/omit.ts
Outdated
export const omit = <T extends object, K extends [...(keyof T)[]]>( | ||
obj: T, | ||
params: K, | ||
) => { | ||
const newObj = { ...obj }; | ||
params.forEach((param) => delete newObj[param]); | ||
deleteNestedKey(newObj, params as string[]); | ||
return newObj as Omit<T, K[number]>; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The typing here is no longer valid it does not handle nested keys.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it might makes sense to keep these utility functions separate since one handles simple key value maps and the other handles deeply nested objects. What do you think?
src/utils/object/deleteNestedKey.ts
Outdated
keyToUpdate: string | string[], | ||
redactedString?: string, | ||
): Partial<T> { | ||
const deleteKey = (currentObject: any) => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
const deleteKey = (currentObject: any) => { | |
const deleteKey = (currentObject: { [key:string]: any}) => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks great! sorry I realized theres one more spot where we need to redact variables.
spruce/src/gql/client/link/index.ts
Line 39 in 21ff1bb
variables: operation.variables, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great work on this! 🚀
Closing this PR since it has already been moved to the UI repo |
DEVPROD-4509
Description
These code changes query SecretFields and use them to clean up GQL variables that are sent to Sentry. Since Sentry breadcrumbs are sent within an Apollo Link which is set during Apollo Client initialization, these code changes block Apollo Client initialization until SecretFields are fetched.
These code changes also update
Login.tsx
to utilizefetch
instead of the Apollo client. If Apollo cannot be initialized because of failure to fetch Secret Fields, then the user is redirected to the Login page where Apollo cannot be initialized. The login page is used in the dev environment only.