Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

✨ Auto Flush for SDK extension #1824

Merged
merged 4 commits into from
Nov 18, 2022
Merged

✨ Auto Flush for SDK extension #1824

merged 4 commits into from
Nov 18, 2022

Conversation

liywjl
Copy link
Contributor

@liywjl liywjl commented Nov 17, 2022

Motivation

Add Auto Flush checkbox for SDK extensions

Screenshot 2022-11-17 at 14 50 26

Testing

  • Local
  • Staging
  • Unit
  • End to end

I have gone over the contributing documentation.

@liywjl liywjl requested a review from a team as a code owner November 17, 2022 14:51
@@ -6,6 +6,7 @@ export const store: Store = {
useDevBundles: false,
useRumSlim: false,
blockIntakeRequests: false,
autoFlush: true,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd like to move away from the background store: the state of the devtools panel should be local to the devtools instance/tab. Could you remove it here?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

isnt background store more about having defaults?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no, it's a centralized store I used at the beginning when the extension was an icon next to the URL bar. Now that it is a devtools extension, it makes more sense to not use a centralized store, but keep each tab / devtools instance separated.

developer-extension/src/panel/hooks/usePolling.ts Outdated Show resolved Hide resolved
Comment on lines 11 to 12
useEffect(flushEvents, [])
useInterval(flushEvents, 5000)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔨 warning: ‏disabling auto flush won't work, as we don't check for the autoFlush variable

🔨 warning: ‏usehooks-ts is not compatible with our nodejs version (kind of weird but well...)

💬 suggestion: ‏write a more well-suited hook ourselves:

function useAutoFlushEvents(enabled: boolean) {
  useEffect(() => {
    if (enabled) {
      flushEvents()
      const id = setInterval(flushEvents, FLUSH_EVENTS_INTERVAL)
      return () => clearInterval(id)
    }
  }, [enabled])
}


// then use it in the `ActionBar` component like that:
useAutoFlushEvents(autoFlush)

@liywjl liywjl merged commit f551178 into main Nov 18, 2022
@liywjl liywjl deleted the william/auto-flush-extensions branch November 18, 2022 15:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants