]> git.ipfire.org Git - thirdparty/vuejs/pinia.git/commitdiff
feat(devtools): add more data to actions
authorEduardo San Martin Morote <posva13@gmail.com>
Wed, 12 May 2021 15:33:25 +0000 (17:33 +0200)
committerEduardo San Martin Morote <posva13@gmail.com>
Wed, 12 May 2021 15:33:25 +0000 (17:33 +0200)
src/devtools/plugin.ts

index d1c8dabdb1158aa6ec7880d57a505afdc8f166ed..5e14011cfccf8733decf6a628da0c4e35addf8e5 100644 (file)
@@ -9,6 +9,7 @@ import {
   ActionsTree,
 } from '../types'
 import {
+  formatDisplay,
   formatEventData,
   formatMutationType,
   formatStoreForInspectorState,
@@ -165,18 +166,27 @@ export function addDevtools(app: App, store: Store) {
           event: {
             time: Date.now(),
             title: '🛫 ' + name,
-            data: args,
+            subtitle: 'start',
+            data: {
+              action: formatDisplay(name),
+              args,
+            },
             groupId,
           },
         })
 
-        after(() => {
+        after((result) => {
           api.addTimelineEvent({
             layerId: MUTATIONS_LAYER_ID,
             event: {
               time: Date.now(),
               title: '🛬 ' + name,
-              data: args,
+              subtitle: 'end',
+              data: {
+                action: formatDisplay(name),
+                args,
+                result,
+              },
               groupId,
             },
           })
@@ -188,8 +198,10 @@ export function addDevtools(app: App, store: Store) {
             event: {
               time: Date.now(),
               logType: 'error',
-              title: '❌ ' + name,
+              title: '💥 ' + name,
+              subtitle: 'end',
               data: {
+                action: formatDisplay(name),
                 args,
                 error,
               },
@@ -295,8 +307,11 @@ export function devtoolsPlugin<
     }
   }
 
-  // FIXME: can this be fixed?
-  addDevtools(app, store as unknown as Store)
+  addDevtools(
+    app,
+    // @ts-expect-error: FIXME: if possible...
+    store
+  )
 
   return { ...wrappedActions }
 }