iachat/app/javascript
Shivam Mishra 9761214860
feat: Add debounce for meta query (#11195)
This PR combines the approaches in
https://github.com/chatwoot/chatwoot/pull/11190 and
https://github.com/chatwoot/chatwoot/pull/11187 to debounce the meta
request with a max wait time of 2.5 seconds With 500 concurrent users,
the theoretical limit with this is 720K requests per minute, if all of
them continuously receive websocket events.

The max wait of 2.5 seconds is still very generous, and we can easily
make it 2 seconds for smaller accounts and 5 seconds for larger
accounts.

```js
const debouncedFetchMetaData = debounce(fetchMetaData, 500, false, 200);
const longDebouncedFetchMetaData = debounce(fetchMetaData, 500, false, 5000);

export const actions = {
  get: async ({ commit, state: $state }, params) => {
    if ($state.allCount > 100) {
      longDebouncedFetchMetaData(commit, params);
    } else {
      debouncedFetchMetaData(commit, params);
    }
  },
  set({ commit }, meta) {
    commit(types.SET_CONV_TAB_META, meta);
  },
};

```

Related Utils PR: https://github.com/chatwoot/utils/pull/49
Here's the debounce in action

<img width="934" alt="image"
src="https://github.com/user-attachments/assets/5265a108-9c64-4488-9b4c-2e0d06aadc50"
/>

---------

Co-authored-by: Pranav <pranavrajs@gmail.com>
2025-03-27 19:41:02 -07:00
..
dashboard feat: Add debounce for meta query (#11195) 2025-03-27 19:41:02 -07:00
design-system feat: Add histoire for component playground (#10256) 2024-10-09 22:10:53 -07:00
entrypoints feat: update notification settings (#10529) 2024-12-05 19:05:04 +05:30
portal feat: Add RTL Support to Widget (#11022) 2025-03-21 09:39:03 -07:00
sdk feat: Support card message postback event as widget event (#11133) 2025-03-20 12:00:24 -07:00
shared chore: Add cache to improve widget performance (#11163) 2025-03-24 16:04:49 -07:00
superadmin_pages chore: fix circleci on vite build (#10214) 2024-10-07 15:27:41 +05:30
survey feat: Add RTL Support to Widget (#11022) 2025-03-21 09:39:03 -07:00
v3 feat: Update auth screens (#11108) 2025-03-19 15:19:32 +05:30
widget fix: Update throttle for /meta endpoints, will call every 2s for small account, 10s for large accounts (#11190) 2025-03-26 14:59:39 -07:00
histoire.setup.ts feat: Add compose conversation components (#10457) 2024-12-05 16:31:47 -08:00