From 6f4edf883f639c2da00fb1eb3ac1062fce211439 Mon Sep 17 00:00:00 2001 From: Alex Van Liew Date: Mon, 20 Nov 2023 01:16:01 -0800 Subject: [PATCH] feat(vue): Support Vue 3 lifecycle hooks in mixin options (#9578) Adds support for the `unmount` hook added in Vue 3. The `destroy` hook no longer works in Vue 2. See PR and issue for more details. --- packages/vue/src/tracing.ts | 3 +++ packages/vue/src/types.ts | 4 +++- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/packages/vue/src/tracing.ts b/packages/vue/src/tracing.ts index 100ff4aeb126..312ee076ba25 100644 --- a/packages/vue/src/tracing.ts +++ b/packages/vue/src/tracing.ts @@ -23,6 +23,9 @@ interface VueSentry extends ViewModel { const HOOKS: { [key in Operation]: Hook[] } = { activate: ['activated', 'deactivated'], create: ['beforeCreate', 'created'], + // Vue 3 + unmount: ['beforeUnmount', 'unmounted'], + // Vue 2 destroy: ['beforeDestroy', 'destroyed'], mount: ['beforeMount', 'mounted'], update: ['beforeUpdate', 'updated'], diff --git a/packages/vue/src/types.ts b/packages/vue/src/types.ts index 2a1ee6d89046..164878449ed9 100644 --- a/packages/vue/src/types.ts +++ b/packages/vue/src/types.ts @@ -76,12 +76,14 @@ export type Hook = | 'activated' | 'beforeCreate' | 'beforeDestroy' + | 'beforeUnmount' | 'beforeMount' | 'beforeUpdate' | 'created' | 'deactivated' | 'destroyed' + | 'unmounted' | 'mounted' | 'updated'; -export type Operation = 'activate' | 'create' | 'destroy' | 'mount' | 'update'; +export type Operation = 'activate' | 'create' | 'destroy' | 'mount' | 'update' | 'unmount';