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

Add Devtools for useSubscription #374

Merged
merged 28 commits into from
Jan 17, 2024
Merged

Add Devtools for useSubscription #374

merged 28 commits into from
Jan 17, 2024

Conversation

collincchoy
Copy link
Contributor

@collincchoy collincchoy commented Jan 17, 2024

This PR adds a Vue Devtools plugin for debugging useSubscription.

Enable in-app with:

import { plugin as VueCompositionsDevtools } from '@prefecthq/vue-compositions'
...

const app = createApp(App)
if (APP_MODE() === 'development' || DEPLOYMENT_ENVIRONMENT() !== 'production') {
  app.use(VueCompositionsDevtools)
}

Custom inspector

image

Custom timeline layer and events

image

@collincchoy collincchoy requested a review from a team as a code owner January 17, 2024 17:51
import { plugin as VueCompositionsDevtools } from '@prefecthq/vue-compositions'

const app = createApp(App)
if (/*not in production*/) {
Copy link
Contributor Author

@collincchoy collincchoy Jan 17, 2024

Choose a reason for hiding this comment

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

I think this could be better, but I could use a hand getting this right...

I think ideally you'd just install this plugin onto your app and the plugin itself would no-op if in production and would also hint to a bundler to skip stuff for tree-shaking.

Here's the relevant docs - https://devtools.vuejs.org/plugin/plugins-guide.html#tree-shaking-for-production but I feel like those variables aren't the ones we want? 😕

I looked at a few other codebases - for example, vee-validate's plugin only checks __DEV__. Forgetting what exactly to do here...

obv, the debugtooling would have to be included in prod builds of this package so I don't want to do some check that will ultimately skip including the devtools in the package since an app would use the "production" build of this package.

Comment on lines +41 to +51
// timelineColor: {
// label: 'Timeline Color',
// type: 'choice',
// defaultValue: 0xFF69B4,
// options: [
// { value: 0x4fc08d, label: 'Vue Green' },
// { value: 0x175cd3, label: 'Prefect Blue' },
// { value: 0xFF69B4, label: 'Hot' }
// ],
// component: 'button-group'
// }
Copy link
Contributor Author

@collincchoy collincchoy Jan 17, 2024

Choose a reason for hiding this comment

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

We can add plugin settings like this https://devtools.vuejs.org/plugin/plugins-guide.html#plugin-settings

Here I was going to add a toggle to switch the color on the timeline but... changing the layer's color after having created it already isn't supported... 😢 . I thought i'd leave this scaffolding here tho incase some other setting comes to mind to add in.

1 thought I had was a giant list of all timeline events so you could filter down which ones get emitted/tracked. -- things got a lot noisier when I added in the channel update events (loading, error, etc.)


function getComponentName(vm: ComponentInternalInstance | null): string {
// @ts-ignore __name is not in the types but works.
return vm?.type.__name as string ?? vm?.type?.name ?? '🤷🏻‍♂️ Unknown component'
Copy link
Contributor Author

Choose a reason for hiding this comment

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

there are some cases where I haven't been able to get the actual component name... I think this might be due to some package linking issues... for example, components in ui-library are built into a prod dist and lose their debug info. or something else entirely i haven't been able to track down.

There is commented code further up which pulls the component names from the vue devtools plugin api - it also doesn't seem to capture all names. Not sure if it's better/worse than this but I'm imagining it'd be slower than just this.

Copy link
Collaborator

@pleek91 pleek91 left a comment

Choose a reason for hiding this comment

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

Do you mind linting these files? Otherwise ship it!

package.json Show resolved Hide resolved
src/devtools.ts Outdated Show resolved Hide resolved
src/useSubscription/models/channel.ts Outdated Show resolved Hide resolved
src/useSubscription/useSubscriptionDevtools.ts Outdated Show resolved Hide resolved
@@ -16,6 +16,16 @@
"editor.codeActionsOnSave": {
"source.fixAll.eslint": "explicit"
},
"eslint.options": {
Copy link
Contributor Author

@collincchoy collincchoy Jan 17, 2024

Choose a reason for hiding this comment

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

I guess I need these for my vs code to run eslint on save...
b/c by default it's just .js ?

but now i'm slightly confused b/c. ... how dis work before. 🤷

Copy link
Collaborator

Choose a reason for hiding this comment

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

huh that is weird 🤔 but that's what we have in ui-library 🤷

@collincchoy collincchoy merged commit 3f3eff4 into main Jan 17, 2024
3 checks passed
@collincchoy collincchoy deleted the devtools branch January 17, 2024 23:43
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