Explorar el Código

feat: send error to team

Ahmad Kholid hace 2 años
padre
commit
c3c2233017

+ 2 - 2
src/assets/css/tailwind.css

@@ -33,8 +33,8 @@
 }
 }
 
 
 body, :host {
 body, :host {
-  font-family: 'Inter var';
-  font-size: 16px;
+  font-family: 'Inter var' !important;
+  font-size: 16px !important;
   font-feature-settings: 'cv02', 'cv03', 'cv04', 'cv11';
   font-feature-settings: 'cv02', 'cv03', 'cv04', 'cv11';
   @apply bg-gray-50 dark:bg-gray-900 leading-normal;
   @apply bg-gray-50 dark:bg-gray-900 leading-normal;
 }
 }

+ 10 - 9
src/background/index.js

@@ -111,21 +111,21 @@ const workflow = {
     engine.init();
     engine.init();
     engine.on(
     engine.on(
       'destroyed',
       'destroyed',
-      ({ id, status, history, startedTimestamp, endedTimestamp }) => {
+      ({
+        id,
+        status,
+        history,
+        startedTimestamp,
+        endedTimestamp,
+        blockDetail,
+      }) => {
         if (
         if (
           workflowData.id.startsWith('team_') &&
           workflowData.id.startsWith('team_') &&
           workflowData.teamId &&
           workflowData.teamId &&
           status === 'error'
           status === 'error'
         ) {
         ) {
-          let message = '';
-
-          const historyItem = history.at(-1);
-          if (historyItem && historyItem.type === 'error') {
-            message = getBlockMessage(historyItem);
-          }
-
+          const message = getBlockMessage(blockDetail);
           const workflowHistory = history.map((item) => {
           const workflowHistory = history.map((item) => {
-            delete item.blockId;
             delete item.logId;
             delete item.logId;
             delete item.prevBlockData;
             delete item.prevBlockData;
             delete item.workerId;
             delete item.workerId;
@@ -140,6 +140,7 @@ const workflow = {
             endedTimestamp,
             endedTimestamp,
             startedTimestamp,
             startedTimestamp,
             history: workflowHistory,
             history: workflowHistory,
+            blockId: blockDetail.blockId,
           };
           };
 
 
           fetchApi(`/teams/${workflowData.teamId}/workflows/logs`, {
           fetchApi(`/teams/${workflowData.teamId}/workflows/logs`, {

+ 2 - 1
src/background/workflowEngine/engine.js

@@ -293,7 +293,7 @@ class WorkflowEngine {
     }
     }
   }
   }
 
 
-  async destroy(status, message) {
+  async destroy(status, message, blockDetail) {
     try {
     try {
       if (this.isDestroyed) return;
       if (this.isDestroyed) return;
       if (this.isUsingProxy) browser.proxy.settings.clear({});
       if (this.isUsingProxy) browser.proxy.settings.clear({});
@@ -352,6 +352,7 @@ class WorkflowEngine {
       this.dispatchEvent('destroyed', {
       this.dispatchEvent('destroyed', {
         status,
         status,
         message,
         message,
+        blockDetail,
         id: this.id,
         id: this.id,
         endedTimestamp,
         endedTimestamp,
         history: this.history,
         history: this.history,

+ 3 - 1
src/background/workflowEngine/injectContentScript.js

@@ -17,7 +17,7 @@ async function contentScriptExist(tabId, frameId = 0) {
 export default function (tabId, frameId = 0) {
 export default function (tabId, frameId = 0) {
   return new Promise((resolve) => {
   return new Promise((resolve) => {
     const currentFrameId = typeof frameId !== 'number' ? 0 : frameId;
     const currentFrameId = typeof frameId !== 'number' ? 0 : frameId;
-    const tryCount = 0;
+    let tryCount = 0;
 
 
     (async function tryExecute() {
     (async function tryExecute() {
       try {
       try {
@@ -26,6 +26,8 @@ export default function (tabId, frameId = 0) {
           return;
           return;
         }
         }
 
 
+        tryCount += 1;
+
         await browser.tabs.executeScript(tabId, {
         await browser.tabs.executeScript(tabId, {
           allFrames: true,
           allFrames: true,
           runAt: 'document_end',
           runAt: 'document_end',

+ 6 - 6
src/background/workflowEngine/worker.js

@@ -227,10 +227,10 @@ class Worker {
         }
         }
       }
       }
 
 
-      addBlockLog('error', {
-        message: error.message,
-        ...(error.data || {}),
-      });
+      const errorLogItem = { message: error.message, ...(error.data || {}) };
+      addBlockLog('error', errorLogItem);
+
+      errorLogItem.blockId = block.id;
 
 
       const { onError } = this.settings;
       const { onError } = this.settings;
       const nodeConnections = this.getBlockConnections(block.id);
       const nodeConnections = this.getBlockConnections(block.id);
@@ -246,7 +246,7 @@ class Worker {
 
 
         if (restartCount >= maxRestart) {
         if (restartCount >= maxRestart) {
           localStorage.removeItem(restartKey);
           localStorage.removeItem(restartKey);
-          this.engine.destroy('error');
+          this.engine.destroy('error', error.message, errorLogItem);
           return;
           return;
         }
         }
 
 
@@ -257,7 +257,7 @@ class Worker {
 
 
         localStorage.setItem(restartKey, restartCount + 1);
         localStorage.setItem(restartKey, restartCount + 1);
       } else {
       } else {
-        this.engine.destroy('error', error.message);
+        this.engine.destroy('error', error.message, errorLogItem);
       }
       }
     }
     }
   }
   }

+ 4 - 4
src/content/commandPalette/App.vue

@@ -248,10 +248,10 @@ function onKeydown(event) {
     return;
     return;
   }
   }
 
 
-  if ((!(ctrlKey || metaKey) && !shiftKey) || key.toLowerCase() !== 'a') return;
-
-  event.preventDefault();
-  state.active = true;
+  if ((ctrlKey || metaKey) && shiftKey && key.toLowerCase() === 'a') {
+    event.preventDefault();
+    state.active = true;
+  }
 }
 }
 function onInputKeydown(event) {
 function onInputKeydown(event) {
   const { key } = event;
   const { key } = event;

+ 12 - 0
src/utils/getBlockMessage.js

@@ -0,0 +1,12 @@
+import locale from '../locales/en/newtab.json';
+
+export default function ({ message, ...data }) {
+  const normalize = (value) => value.join('');
+  const interpolate = (key) => data[key];
+  const named = (key) => key;
+
+  const localeMessage = locale.log.messages[message];
+  if (localeMessage) return localeMessage({ normalize, interpolate, named });
+
+  return message;
+}