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

Plugin editor types #4468

Merged
merged 8 commits into from
Jun 1, 2021
Merged

Plugin editor types #4468

merged 8 commits into from
Jun 1, 2021

Conversation

mariusandra
Copy link
Collaborator

Changes

  • Adds @posthog/plugin-scaffold types into the plugin source editor for sweet TypeScript support
  • Changes the default plugin to one that encourages discovery (loosely based on @Twixes 's advanced plugin kit)
  • This is just the first step though. We should add types for all other exported packages (e.g. aws sdk, plugin contrib, ...) as well.

2021-05-25 12 43 45

Checklist

  • All querysets/queries filter by Organization, by Team, and by User
  • Django backend tests
  • Jest frontend tests
  • Cypress end-to-end tests
  • Migrations are safe to run at scale (e.g. PostHog Cloud) – present proof if not obvious

@mariusandra mariusandra requested a review from Twixes May 25, 2021 10:47
@timgl timgl temporarily deployed to posthog-pr-4468 May 25, 2021 10:50 Inactive
@mariusandra mariusandra mentioned this pull request May 26, 2021
Copy link
Member

@Twixes Twixes left a comment

Choose a reason for hiding this comment

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

There is a problem in that this doesn't build

import { Plugin } from '@posthog/plugin-scaffold'

type MyPluginType = Plugin<{
config: {},
Copy link
Member

Choose a reason for hiding this comment

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

This should match defaultConfig.

@mariusandra
Copy link
Collaborator Author

So, feedback addressed and it builds now. Still some issues with this PR. Not sure if they are blockers or not:

  • We only have types for anything imported from @posthog/plugin-scaffold. No types for fetch or any of the other packages like aws-sdk here.
  • As an improvement, I'd suggest adding two things to plugin-scaffold: 1) all pinned versions of all packages that plugin authors can import from into devDependencies, a build script that copies the types of all those packages into the plugin scaffold package for exporting. The posthog would just take these types from inside scaffold, instead of requiring us to install aws-sdk and other large things that slow down builds.
  • We need to make sure to keep posthog, plugin-server and plugin-scaffold versions in sync. Automatic github actions could help.

@Twixes Twixes temporarily deployed to posthog-pr-4468 June 1, 2021 10:14 Inactive
@Twixes Twixes temporarily deployed to posthog-pr-4468 June 1, 2021 11:06 Inactive
Copy link
Member

@Twixes Twixes left a comment

Choose a reason for hiding this comment

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

Nice.
As for improvements, I'd say nothing blocking. May be worth creating issue for some e.g. ensuring plugin-scaffold is up to date.

@Twixes Twixes merged commit f7a4202 into master Jun 1, 2021
@Twixes Twixes deleted the plugin-editor-types branch June 1, 2021 11:19
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.

3 participants