Skip to content

Commit 1d4cd81

Browse files
Merge pull request #6807 from Shopify/fix-unknown-user-id-in-observe
Avoid sending 'unknown' to Observe as the user ID
2 parents c8829ea + 419e465 commit 1d4cd81

2 files changed

Lines changed: 6 additions & 2 deletions

File tree

packages/cli-kit/src/public/node/error-handler.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -263,7 +263,7 @@ describe('sends errors to Bugsnag', () => {
263263
expect(capturedEventHandler).toHaveBeenCalled()
264264

265265
const mockEvent = capturedEventHandler.mock.calls[0]![0]
266-
expect(mockEvent.setUser).toHaveBeenCalledWith('unknown')
266+
expect(mockEvent.setUser).toHaveBeenCalledWith(undefined)
267267
})
268268

269269
test('attaches custom metadata with allowed slice_name when startCommand is present', async () => {

packages/cli-kit/src/public/node/error-handler.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,11 @@ export async function sendErrorToBugsnag(
126126

127127
if (report) {
128128
initializeBugsnag()
129-
const userId = await getLastSeenUserIdAfterAuth()
129+
let userId: string | undefined = await getLastSeenUserIdAfterAuth()
130+
if (userId === 'unknown') {
131+
// Observe will use the IP when undefined
132+
userId = undefined
133+
}
130134
await new Promise((resolve, reject) => {
131135
outputDebug(`Reporting ${unhandled ? 'unhandled' : 'handled'} error to Bugsnag: ${reportableError.message}`)
132136
const eventHandler = (event: Event) => {

0 commit comments

Comments
 (0)