Skip to content
This repository has been archived by the owner on Nov 4, 2021. It is now read-only.

Better starter kit #17

Closed
mariusandra opened this issue Nov 18, 2020 · 8 comments
Closed

Better starter kit #17

mariusandra opened this issue Nov 18, 2020 · 8 comments
Assignees

Comments

@mariusandra
Copy link
Collaborator

Currently the helloworldplugin is our "blank plugin starter kit".

This should be extended with:

@Twixes
Copy link
Member

Twixes commented Jan 20, 2021

@Twixes Twixes closed this as completed Jan 20, 2021
@mariusandra
Copy link
Collaborator Author

Well, not yet done since those starter kits don't work with the current version of posthog nor plugin server

@mariusandra mariusandra reopened this Jan 20, 2021
@Twixes
Copy link
Member

Twixes commented Jan 20, 2021

Ah right, though I think they are only missing plugin.json

@mariusandra
Copy link
Collaborator Author

Well, I could come up with a list of (subjective?) things to improve... but these are not something to spend time on now.

  • The entire plugin.json situation.
  • The naming is still confusing to me. What's "advanced"? For me the only legit difference is JS vs TS, so the name should just reflect that.
  • I'd still prefer yarn.lock over package-json.lock, just to be consistent with every other posthog repository. If you are using npm and run npm install, nothing bad will happen. NPM 7 even supports yarn.lock out of the box (even though it'll still make a package-lock.json).
  • There are probably too many files in the simple starter kit. .editorconfig and .gitattributes can probably go. jest.config.js can be moved into package.json.
  • The maxmind plugin required rollup to mash all imported ts files into one. As it is now, you can't move your shared functions into another folder and just import them. That begs the question: what's the use of a src folder if it can only contain one file?
  • The TS starter doesn't contain guides to help you with typing your global, config and attachments like in the maxmind plugin.
  • I still think the TS plugin structure in the starter as it is now, while providing better typing support, is less friendly to the developers. Having just a bunch of predefined functions and adding : Meta to the arguments is not that much work and makes everything look so much cleaner and simpler. But I understand we will not reach consensus here.

Again, let's not work on this now. There are bigger fish to fry.

@Twixes
Copy link
Member

Twixes commented Jan 20, 2021

Generally agree (plugin.json-wise let's solve this by going with vox populi). As for naming, not set on it all (though just typescript it's a bit limiting, that's just a part of it).
And definitely +1 on using Rollup.
That tiny additional bit of typing makes too nice of a difference to just give up though!

@mariusandra
Copy link
Collaborator Author

mariusandra commented Jun 1, 2021

With plugins becoming more and more mainstream, people tend to take whatever random starting point they can find and code a plugin on top of this.

To remove confusion and help adoption of plugins, I propose it's finally time to clean up this starter kit situation (together with world class docs)... and consolidate on just one and simplified posthog-plugin-starter-kit that we promote everywhere.

My wishes for this kit:

  • As friendly and approachable as possible.
  • No or just very few lines of code to delete when starting the project
  • TypeScript and thus no compilation step with rollup or anything
  • Yarn and yarn create posthog-plugin
  • Remove all unnecessary yet nice to have files like .editorconfig.
  • Keep all the code under src, keep simple jest tests under tests. No dist needed.
  • Investigate the option of even moving plugin.json under src, and adding src/index.ts as another search path for the code in an archive.

@neilkakkar
Copy link
Contributor

neilkakkar commented Jun 16, 2021

So, I just tried writing a new plugin, and this template still feels annoying.

I followed the instructions in the tutorial ( PostHog/posthog.com#1467 ), and once I used the template, I ended up deleting lots of files that felt useless ( https://github.com/neilkakkar/posthog-github-followers-plugin/commits/main )

This included: the test file, package.json, yarn.lock. I didn't really need these to finish my plugin, since I'm testing it using "Install from URL" (everything is happening in the browser).

I think the crux here is that: the template shouldn't be a plugin in itself, but just a starting point.

This implies getting rid of everything extra in the plugin - tests, package.json, lockfiles, etc.

I think we should split things out into:

(1) Exemplary plugins to serve as reference. This would include a list of plugins and their specialty, showing how tests and package.json work.
(2) Template - the starter kit, which quickly lets you get up and running with a plugin.

I'm planning to include a link to (1) from (2), so everything is easily available, and then all our technique improvements / upgrades actually go into existing plugins, instead of the template. Something like:

image

And the template has instructions like:

image

@Twixes
Copy link
Member

Twixes commented Jun 16, 2021

I think this can be closed now after PostHog/posthog-plugin-starter-kit#7

@Twixes Twixes closed this as completed Jun 16, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants