PostHog / posthog

🦔 PostHog provides open-source web & product analytics, session recording, feature flagging and A/B testing that you can self-host. Get started - free.
https://posthog.com
Other
21.87k stars 1.31k forks source link

Multiple, separate projects per installation #907

Closed shafy closed 4 years ago

shafy commented 4 years ago

Is your feature request related to a problem? Please describe. We use the events API with our mobile apps, and since there's only one API key per PostHog installation, we need to have separate installations for each app (and staging and prod versions thereof).

Describe the solution you'd like I'd like to add multiple apps/projects to one PostHog deployment that get assigned separate API keys (e.g., the way Mixpanel does it work well).

Describe alternatives you've considered Only alternative is having multiple deployments of PostHog.

timgl commented 4 years ago

Hey! This is already possible though not well documented as it's mostly something we use for our own multi-tenancy cloud offering

We have this concept of Teams that can have multiple users. Each team has its own API key.

To create teams, you can do something like:

python manage.py shell
from posthog.models import *
user = User.objects.create_user('email', 'password')
Team.objects.create_with_data(name='app name', users=[user])
shafy commented 4 years ago

Hey @timgl thanks for replying so quickly. Interesting, let me try this out. Is this more of a workaround, or will you graduate this to a full feature and make it accessible in the GUI, too?

timgl commented 4 years ago

We use this internally for our multi-tenancy stuff so it's well supported in that sense. It's likely that if we make this more accessible (in the GUI or whatever) for self-hosted instances it'd be an enterprise feature, given this is likely to appeal to larger orgs.

janbaykara commented 4 years ago

Would you accept PRs to surface this for the open source version?

shafy commented 4 years ago

Ok thanks... Although I think that this is something smaller teams also would want (even if it's only for staging and production).

I created at a second team and assigned the same user that is also in the default team, and now I get a 500 error (nothing more in my Heroku logs). Can one user be only in one team or is there another reason?

timgl commented 4 years ago

@shafy Enterprise might be the wrong word but certainly in our 'paid'/teams sphere, as it's not individual developers who would use this.

In terms of the error, users can only be assigned to a single team and that is pretty ingrained throughout. Does that still makes for your use case? An alternative might just be adding a property on every capture call with the app name, then being able to filter by that.

shafy commented 4 years ago

Thanks @timgl! Let me see and get back to this mid next week.

shafy commented 4 years ago

Hey @timgl had some time to test and think about it. Unfortunately, it doesn't really solve the issue. While it would allow to have only one deployment, we still need to have different user accounts to log in and they have to be created painfully through the console for each new user.

Therefore, it's easier to just have separate deployments. Although far from ideal.

The feature to switch between projects is there in every analytics tool I've ever used (Google Analytics, Mixpanel, Simple Analytics). And I disagree with you that it's not useful for smaller teams.

So, maybe you might want to reconsider adding it your roadmap? I didn't look into the code, but if it's possible to build such a feature with your current database and model architecture, I woud be happy to do it and create a PR if you're open to it?

pedybr commented 4 years ago

I would second @shafy . The functionality to have different products/projects in one analytics tool is a very basic requirement for us, since we are running many different services that are all part of the same product suite. To separate by team with excluding groups of users seems very awkward and not very transparent/useful. And even for stage/prod it would be super helpful. Adding a property on every capture sounds promising as well...

timgl commented 4 years ago

We now support this functionality in the enterprise tier.

windware-ono commented 3 years ago

Hello.

Can this feature be implemented in the community edition?

Enterprise edition seems quite pricey just for this and the workaround is to install an instance for every project, so it's doable except it'll take up on server resource and management burden.

Otherwise it's hard to think about using it on multiple projects.

jamesefhawkins commented 3 years ago

Hey!

We are about to release pure usage based pricing as a VPC deployment. This will mean you can get multiple projects from a starting price of $0.000225/event ingested (and getting much less expensive at higher volumes), with no minimum, rather than our previous $2k/month minimum. Hope that makes it a little easier to consider.