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 autofill for posthog props in plugin config #2838

Merged
merged 10 commits into from
Jan 25, 2021

Conversation

yakkomajuri
Copy link
Contributor

@yakkomajuri yakkomajuri commented Dec 24, 2020

Changes

This autofills two PostHog-related config values for plugins:

  • posthogHost
  • posthogApiKey

Ideally in the future we would expand the plugin server with more PostHog functionality beyond events. However, at the moment there are things that can be done by hitting the PostHog API. For example, the release tracking plugins hit the annotations endpoint to generate annotations for each new release in your repo.

To do that, they need a host and a key. So this PR grabs the host from the window and creates an API key so that you don't have to.

Checklist

  • All querysets/queries filter by Organization, by Team, and by User
  • Django backend tests
  • Jest frontend tests
  • Cypress end-to-end tests

@timgl timgl temporarily deployed to posthog-plugin-config-a-3yndtd December 24, 2020 13:31 Inactive
Copy link
Collaborator

@mariusandra mariusandra left a comment

Choose a reason for hiding this comment

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

Hey, some thoughts below regarding this implementation.

I understand this is needed for some plugins that want to talk to the API (e.g. the github annotations plugin). This will work, though a nicer solution would be to autogenerate and pre-fill this stuff in the plugin-server... and then expose some api object that can be called that has the right authentication already pre-filled. That's obviously more work though... :)

frontend/src/scenes/plugins/pluginsLogic.ts Outdated Show resolved Hide resolved
frontend/src/types.ts Outdated Show resolved Hide resolved
frontend/src/scenes/plugins/PluginDrawer.tsx Outdated Show resolved Hide resolved
@Twixes Twixes self-requested a review January 15, 2021 11:53
@yakkomajuri
Copy link
Contributor Author

Finally had a little time to come back to this - all addressed @mariusandra

Also completely agree it is far from the best solution. I'd love to have access to more if not all of the PostHog API directly in the plugin, but while that's not the case this will just make things easier for people looking to use the GitHub and GitLab plugins (which work on Cloud!)

@Twixes Twixes temporarily deployed to posthog-plugin-config-a-ptsdgq January 21, 2021 13:14 Inactive
@mariusandra mariusandra temporarily deployed to posthog-plugin-config-a-ptsdgq January 25, 2021 22:15 Inactive
@mariusandra mariusandra temporarily deployed to posthog-plugin-config-a-ptsdgq January 25, 2021 22:28 Inactive
@mariusandra
Copy link
Collaborator

Hey! Finally had the time to review it. I made quite some changes and cleanup though.

Playing with this now, I think we need some "secret" or "write-only" field type for plugins, so that this key wouldn't be shown all the time. As in, someone could go into "plugins" and read their boss's personal API key and do something with it. I had a need for it with the github star sync plugin for example.

@mariusandra mariusandra merged commit 35c987f into master Jan 25, 2021
@mariusandra mariusandra deleted the plugin-config-autofill branch January 25, 2021 22:36
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.

None yet

4 participants