Skip to content

Commit c1871ad

Browse files
Merge pull request #155 from decentraland/feat/add-sentry-to-wp
feat: Add Sentry to WP
2 parents f5b4949 + cd72f06 commit c1871ad

19 files changed

Lines changed: 257 additions & 35 deletions

File tree

.github/workflows/build-release.yaml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,3 +47,14 @@ jobs:
4747
gitlab-pipeline-url: ${{ secrets.GITLAB_CDN_DEPLOYER_URL }}
4848
env:
4949
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
50+
- name: Create Sentry release
51+
if: github.event_name == 'release' && github.event.action == 'created'
52+
uses: getsentry/action-release@v1
53+
env:
54+
SENTRY_AUTH_TOKEN: ${{ secrets.SENTRY_AUTH_TOKEN }}
55+
SENTRY_ORG: ${{ vars.SENTRY_ORG }}
56+
SENTRY_PROJECT: ${{ vars.SENTRY_PROJECT }}
57+
with:
58+
sourcemaps: ${{ github.workspace }}/dist
59+
version: '${{ vars.SENTRY_RELEASE_PREFIX }}@${{ github.event.release.tag_name }}'
60+
url_prefix: '~'

package-lock.json

Lines changed: 150 additions & 31 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
"@babylonjs/materials": "^4.2.2",
1212
"@dcl/schemas": "^20.3.3",
1313
"@dcl/ui-env": "^1.5.1",
14+
"@sentry/browser": "^10.42.0",
1415
"classnames": "^2.3.1",
1516
"decentraland-ui": "^6.17.1",
1617
"fast-deep-equal": "^3.1.3",
@@ -76,4 +77,4 @@
7677
"typescript": "^5.2.2",
7778
"vite": "^6.3.5"
7879
}
79-
}
80+
}

src/components/Preview/Preview.tsx

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ import { useController } from '../../hooks/useController'
1515
import { render } from '../../lib/babylon/render'
1616
import { handleEmoteEvents } from '../../lib/emote-events'
1717
import { getParent } from '../../lib/parent'
18+
import { captureException } from '../../lib/sentry'
1819
import './Preview.css'
1920

2021
const Preview: React.FC = () => {
@@ -67,7 +68,10 @@ const Preview: React.FC = () => {
6768
// handle emote events and forward them as messages
6869
removeEmoteEvents = handleEmoteEvents(controller.current)
6970
})
70-
.catch((error) => setPreviewError(error.message))
71+
.catch((error) => {
72+
captureException(error, { component: 'Preview', phase: 'render' })
73+
setPreviewError(error.message)
74+
})
7175
.finally(() => {
7276
setIsLoadingModel(false)
7377
setIsLoaded(true)
@@ -90,6 +94,7 @@ const Preview: React.FC = () => {
9094
controller.current?.emote.play()
9195
}
9296
} else if (error) {
97+
captureException(new Error(error), { component: 'Preview', phase: 'sendErrorToParent' })
9398
sendMessage(getParent(), PreviewMessageType.ERROR, { message: error })
9499
setIsMessageSent(true)
95100
}

src/components/UnityPreview/UnityPreview.tsx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import { PreviewType, PreviewMessageType, sendMessage, PreviewRenderer } from '@
44

55
import { sendIndividualOverrideMessages, sendUnityMessage, UnityMethod } from '../../lib/unity/messages'
66
import { getParent } from '../../lib/parent'
7+
import { captureException } from '../../lib/sentry'
78
import { render } from '../../lib/unity/render'
89
import { getRandomDefaultProfile } from '../../lib/profile'
910
import { useWindowSize } from '../../hooks/useWindowSize'
@@ -86,6 +87,7 @@ const useUnityRenderer = (
8687
} else if (type === UnityMessageType.ELEMENT_BOUNDS) {
8788
sendMessage(getParent(), ELEMENT_BOUNDS_RESPONSE as any, payload)
8889
} else if (type === UnityMessageType.ERROR) {
90+
captureException(new Error(payload), { component: 'UnityPreview', phase: 'unityMessage' })
8991
setRenderingState((prev) => ({ ...prev, error: payload }))
9092
sendMessage(getParent(), PreviewMessageType.ERROR, { message: 'Error loading the wearable. Please try again.' })
9193
}
@@ -116,6 +118,7 @@ const useUnityRenderer = (
116118
} catch (err) {
117119
const errorMessage = err instanceof Error ? err.message : DEFAULT_ERROR_MESSAGE
118120
console.error('Unity init failed:', err)
121+
captureException(err, { component: 'UnityPreview', phase: 'initializeUnity' })
119122
setRenderingState((prev) => ({ ...prev, error: errorMessage }))
120123
sendMessage(getParent(), PreviewMessageType.ERROR, { message: errorMessage })
121124
} finally {

src/config/env/dev.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
{
22
"MARKETPLACE_SERVER_URL": "https://marketplace-api.decentraland.zone",
3+
"SENTRY_DSN": "https://fc6203205a7c4a0e1408cc9e7fdad2be@o4504361728212992.ingest.us.sentry.io/4510982059130880",
34
"PEER_URL": "https://peer-ap1.decentraland.zone",
45
"NETWORK": "amoy"
56
}

src/config/env/prod.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
{
22
"MARKETPLACE_SERVER_URL": "https://marketplace-api.decentraland.org",
3+
"SENTRY_DSN": "https://fc6203205a7c4a0e1408cc9e7fdad2be@o4504361728212992.ingest.us.sentry.io/4510982059130880",
34
"PEER_URL": "https://peer.decentraland.org",
45
"NETWORK": "matic"
56
}

src/config/env/stg.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
{
22
"MARKETPLACE_SERVER_URL": "https://marketplace-api.decentraland.org",
3+
"SENTRY_DSN": "https://fc6203205a7c4a0e1408cc9e7fdad2be@o4504361728212992.ingest.us.sentry.io/4510982059130880",
34
"PEER_URL": "https://peer.decentraland.org",
45
"NETWORK": "matic"
56
}

src/hooks/useAsync.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import { useEffect, useState } from 'react'
2+
import { captureException } from '../lib/sentry'
23

34
/*
45
ids and nonces are used to identity the order on which async functions are called,
@@ -32,6 +33,7 @@ export function useAsync<T>(id: string, asyncFunction: (...args: any[]) => Promi
3233
}
3334
})
3435
.catch((error) => {
36+
captureException(error, { phase: 'useAsync', id })
3537
if (isValid(id, nonce)) {
3638
setError(error.message)
3739
}

src/hooks/useController.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import { useRef } from 'react'
22
import { IPreviewController, PreviewMessagePayload, PreviewMessageType, sendMessage } from '@dcl/schemas'
33
import { useMessage } from './useMessage'
44
import { getParent } from '../lib/parent'
5+
import { captureException } from '../lib/sentry'
56

67
function sendResult(id: string, result: any) {
78
sendMessage(getParent(), PreviewMessageType.CONTROLLER_RESPONSE, { id, ok: true, result })
@@ -36,6 +37,7 @@ export const useController = () => {
3637
const result = await fn.apply(null, params)
3738
sendResult(id, result)
3839
} catch (error: any) {
40+
captureException(error, { phase: 'controller', namespace, method })
3941
sendError(id, error.message)
4042
}
4143
} else {

0 commit comments

Comments
 (0)