-
Notifications
You must be signed in to change notification settings - Fork 1.9k
PostHog demo environment #7824
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
PostHog demo environment #7824
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Found some things to nit about, but looks good.
The only question I have is if we actually want to enable this? Probably, but then we must make sure it's always up to date with some playable data. Enabling the "make some noise" plugin might be enough even?
posthog/api/signup.py
Outdated
is_instance_first_user: bool = not User.objects.exists() | ||
already_existing_demo_user = ( | ||
None if not settings.DEMO else User.objects.filter(email=validated_data["email"]).first() | ||
) | ||
|
||
organization_name = validated_data.pop("organization_name", validated_data["first_name"]) | ||
if not already_existing_demo_user: | ||
# Normal signup flow | ||
is_instance_first_user: bool = not User.objects.exists() | ||
|
||
organization_name = validated_data.pop("organization_name", validated_data["first_name"]) | ||
if settings.DEMO: | ||
validated_data["password"] = None | ||
|
||
self._organization, self._team, self._user = User.objects.bootstrap( | ||
organization_name=organization_name, | ||
create_team=self.create_team, | ||
**validated_data, | ||
is_staff=is_instance_first_user, | ||
) | ||
else: | ||
# If there's an email collision in signup in the demo environment, we treat it as a login | ||
is_instance_first_user = False | ||
|
||
self._user = already_existing_demo_user | ||
self._organization = already_existing_demo_user.organization | ||
self._team = already_existing_demo_user.team |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A nit perhaps, but could this be refactored to:
if settings.DEMO:
# override everything
else:
# normal flow
It's kind of hard to follow along, and such critical code as the signup flow should be made as mistake-proof as possible. Maybe already just flipping the if if not already_existing_demo_user:
to if already_existing_demo_user:
will make this cleaner?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Agreed, refactored the demo handling to method enter_demo()
.
posthog/utils.py
Outdated
""" | ||
if settings.MULTI_TENANCY: | ||
return "cloud" | ||
if settings.DEMO: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nittiest of nits, but if
-> elif
to keep tactical formation.
I've left some comments on why I think we can't make this somewhere users go yet |
This PR hasn't seen activity in a week! Should it be merged, closed, or further worked on? If you want to keep it open, post a comment or remove the |
Overall LGTM but I'll appreciate also another pair of 👀 from someone of my team. Also, what's the long term plan for this? Do we have a plan to make sure:
Thank you! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm
<a href="https://posthog.com/signup/self-host">easily deploy PostHog yourself</a> or{' '} | ||
<a href="https://app.posthog.com/signup">sign up for a free PostHog Cloud account</a>. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: https://posthog.com/signup covers both self-hosting and cloud and we should likely just redirect them there, and that page can evolve and give all the guidance. "easily deploy" might mislead folks to thinking it's easier to self-host compared to cloud, which isn't true. Related Q: do we want that page to highlight the option to check out the demo too?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good point, simplified to a single link to that "Get started" page with copy "deploy your own PostHog instance or sign up for PostHog Cloud". I think if we go forward with the demo env, it should be somewhere on the website, but the homepage seems like the clearest place to expose it, so I'll stay with that for now (PostHog/posthog.com#2661).
Good questions @guidoiaquinti I don't have a great story for deployment yet (the current MVP at demo.posthog.com rans with the hobby script), but it can be just a self-hosted PostHog instance (probably AWS or DO) pinned to |
yes it's simple for the deployment side. I'd suggest following latest the same as cloud (which likely means you'll want to have the workflow in this repo). I'd pick DO since it's the easiest to manage, the values file should likely live in the vpc repo (so we can define stuff we don't want public, e.g sentry, google sign on). Reach out in the platform channel if we can help with anything. |
Changes
This adds a new mode of operation to the app: PostHog Demo™.
Enabled with env var
DEMO
, it merges the normal signup and login flows into a "demo signin", i.e. you create an account without a password (when you first enter the demo environment with that email) and log in also without a password (if entering with an already used email). On account creation, you're plopped into a fresh demo project. The announcement bar at the top shows a special demo mode message. As for analytics, demo mode is a newrealm
(to track it while distinguishing it from production instances):demo
.Demo of the demo:

How did you test this code?
Spun up a PostHog Demo™ instance with the hobby script, available at https://demo.posthog.com (just as a proof of concept, will need to move away from my personal DigitalOcean account later on).