-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Set Sentry user id to hashed identifier
We calculate the ID of the user by hashing the address. This way we won't store any sensitive information in Sentry.
- Loading branch information
Showing
3 changed files
with
62 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
import { describe, expect, it, vi } from "vitest" | ||
import * as Sentry from "@sentry/react" | ||
import sentry from "./sentry" | ||
|
||
describe("sentry", () => { | ||
describe("setUser", () => { | ||
vi.mock("@sentry/react") | ||
|
||
const testCases = [ | ||
{ bitcoinAddress: undefined, expectedResult: null }, | ||
{ bitcoinAddress: "", expectedResult: null }, | ||
{ bitcoinAddress: " ", expectedResult: null }, | ||
{ | ||
bitcoinAddress: "17VZNX1SN5NtKa8UQFxwQbFeFc3iqRYhem", | ||
expectedResult: { id: "1f520a9757" }, | ||
}, | ||
{ | ||
bitcoinAddress: "bc1qw508d6qejxtdg4y5r3zarvary0c5xw7kv8f3t4", | ||
expectedResult: { id: "6cd42dab02" }, | ||
}, | ||
{ | ||
bitcoinAddress: "BC1QW508D6QEJXTDG4Y5R3ZARVARY0C5XW7KV8F3T4", | ||
expectedResult: { id: "6cd42dab02" }, | ||
}, | ||
] | ||
|
||
describe.each(testCases)( | ||
"when address is $bitcoinAddress", | ||
({ bitcoinAddress, expectedResult }) => { | ||
it("should set expected user in Sentry", () => { | ||
sentry.setUser(bitcoinAddress) | ||
|
||
expect(Sentry.setUser).toHaveBeenCalledWith(expectedResult) | ||
}) | ||
}, | ||
) | ||
}) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters