import{datadogRum}from'@datadog/browser-rum';datadogRum.init({...,beforeSend:(event,context)=>{// RUM リソースの応答ヘッダーを収集します
if(event.type==='resource'&&event.resource.type==='fetch'){event.context.responseHeaders=Object.fromEntries(context.response.headers)}returntrue},...});
次の beforeSend コンフィギュレーションでメッセージに “profile is not defined” (プロファイルが定義されていません) が含まれている場合は、フロントエンドエラーを破棄します。
import{datadogRum}from'@datadog/browser-rum';datadogRum.init({...,beforeSend:(event,context)=>{// メッセージに 'profile is not defined' が含まれている場合は、RUM エラーを破棄します
if(event.type==='error'&&event.error.message.includes('profile is not defined')){returnfalse}},...});
{"application":{"id":"75d50c62-8b66-403c-a453-aaa1c44d64bd"},"date":1623941859639,"service":"shopist-web-ui","session":{"type":"user","id":"4203a142-1e3c-41b0-822d-316705d98f19","has_replay":true},"view":{"id":"0a771c95-9bc4-4640-978e-ad28da64da45","referrer":"http://localhost:3000/profile","url":"http://localhost:3000/profile-edit"},"action":{"id":"7b30e681-ce5c-47a8-ac22-6aff8be59744"},"error":{"id":"3c0295b1-da48-4827-93c9-ea06be4aafd9","message":"profile is not defined","source":"source","stack":"ReferenceError: profile is not defined\n at VueComponent.discardEdit @ http://localhost:3000/_nuxt/pages/profile-edit.js:911:41\n at invokeWithErrorHandling @ http://localhost:3000/_nuxt/commons.app.js:12167:26\n at VueComponent.invoker @ http://localhost:3000/_nuxt/commons.app.js:12492:14\n at invokeWithErrorHandling @ http://localhost:3000/_nuxt/commons.app.js:12167:26\n at VueComponent.Vue.$emit @ http://localhost:3000/_nuxt/commons.app.js:14196:9\n at VueComponent.cancelDraft @ http://localhost:3000/_nuxt/pages/profile-edit.js:828:12\n at invokeWithErrorHandling @ http://localhost:3000/_nuxt/commons.app.js:12167:26\n at HTMLButtonElement.invoker @ http://localhost:3000/_nuxt/commons.app.js:12492:14\n at HTMLButtonElement.original._wrapper @ http://localhost:3000/_nuxt/commons.app.js:17221:25","type":"ReferenceError","handling":"unhandled"},"type":"error","context":{"browser_test":false,"usr.email":"jane@doe.com","usr.id":"f57eg30cc9"}}
{"error":{"message":"profile is not defined","stack":"ReferenceError: profile is not defined\n at VueComponent.discardEdit @ http://localhost:3000/_nuxt/pages/profile-edit.js:911:41\n at invokeWithErrorHandling @ http://localhost:3000/_nuxt/commons.app.js:12167:26\n at VueComponent.invoker @ http://localhost:3000/_nuxt/commons.app.js:12492:14\n at invokeWithErrorHandling @ http://localhost:3000/_nuxt/commons.app.js:12167:26\n at VueComponent.Vue.$emit @ http://localhost:3000/_nuxt/commons.app.js:14196:9\n at VueComponent.cancelDraft @ http://localhost:3000/_nuxt/pages/profile-edit.js:828:12\n at invokeWithErrorHandling @ http://localhost:3000/_nuxt/commons.app.js:12167:26\n at HTMLButtonElement.invoker @ http://localhost:3000/_nuxt/commons.app.js:12492:14\n at HTMLButtonElement.original._wrapper @ http://localhost:3000/_nuxt/commons.app.js:17221:25"}}