-
-
Notifications
You must be signed in to change notification settings - Fork 342
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Co-authored-by: GitHub <noreply@github.com>
- Loading branch information
1 parent
7406fdc
commit a71ab71
Showing
14 changed files
with
285 additions
and
7 deletions.
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
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
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
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
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,54 @@ | ||
import type { Event, EventHint, EventProcessor, Integration } from '@sentry/types'; | ||
import { logger } from '@sentry/utils'; | ||
|
||
import { NATIVE } from '../wrapper'; | ||
|
||
/** Adds ViewHierarchy to error events */ | ||
export class ViewHierarchy implements Integration { | ||
/** | ||
* @inheritDoc | ||
*/ | ||
public static id: string = 'ViewHierarchy'; | ||
|
||
private static _fileName: string = 'view-hierarchy.json'; | ||
private static _contentType: string = 'application/json'; | ||
private static _attachmentType: string = 'event.view_hierarchy'; | ||
|
||
/** | ||
* @inheritDoc | ||
*/ | ||
public name: string = ViewHierarchy.id; | ||
|
||
/** | ||
* @inheritDoc | ||
*/ | ||
public setupOnce(addGlobalEventProcessor: (e: EventProcessor) => void): void { | ||
addGlobalEventProcessor(async (event: Event, hint: EventHint) => { | ||
const hasException = event.exception && event.exception.values && event.exception.values.length > 0; | ||
if (!hasException) { | ||
return event; | ||
} | ||
|
||
let viewHierarchy: Uint8Array | null = null; | ||
try { | ||
viewHierarchy = await NATIVE.fetchViewHierarchy() | ||
} catch (e) { | ||
logger.error('Failed to get view hierarchy from native.', e); | ||
} | ||
|
||
if (viewHierarchy) { | ||
hint.attachments = [ | ||
{ | ||
filename: ViewHierarchy._fileName, | ||
contentType: ViewHierarchy._contentType, | ||
attachmentType: ViewHierarchy._attachmentType, | ||
data: viewHierarchy, | ||
}, | ||
...(hint?.attachments || []), | ||
]; | ||
} | ||
|
||
return event; | ||
}); | ||
} | ||
} |
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
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
Oops, something went wrong.