feat(frontend): implement project-based routing
Problem
Alternative to https://github.com/PostHog/posthog/pull/13453
Changes

I'm off for a week, and if anyone feels like picking this up, here's Santa's list:
- [x] Update all frontend routes to use
/p/:idin front of the URL - [x] Make sure they all old routes keep working
- [ ] Fix the tests that are failing because
getCurrentTeamId()is not mocked - [ ] Create a short ID to use instead of the real ID to prevent increment-based attacks. --> Should we?
- [ ] Make a backend middleware that switches the project if needed
- [ ] Create a frontend middleware (e.g. in sceneLogic), that does a full reload if you load an URL with the wrong project in it, by e.g. clicking on a link
(/p/:other/events) that we accidentally route you to in the frontend? - [ ] Add tests
How did you test this code?
@benjackwhite I added the changes into kea-router, and a todo list to the top of the PR.
@benjackwhite I added the changes into kea-router, and a todo list to the top of the PR.
Super cool. If you haven't done it by the new year I will be happy to take on that TODO list when I'm back 😉
I rebased from master and tweaked it somewhat:

Still expecting a lot of test failures.
📸 UI snapshots have been updated
1 snapshot changes in total. 0 added, 1 modified, 0 deleted:
chromium: 0 added, 1 modified, 0 deleted (diff for shard 2)webkit: 0 added, 0 modified, 0 deletedfirefox: 0 added, 0 modified, 0 deleted
Triggered by this commit.
📸 UI snapshots have been updated
2 snapshot changes in total. 0 added, 2 modified, 0 deleted:
chromium: 0 added, 1 modified, 0 deleted (diff for shard 2)webkit: 0 added, 1 modified, 0 deleted (diff for shard 2)firefox: 0 added, 0 modified, 0 deleted
Triggered by this commit.
📸 UI snapshots have been updated
1 snapshot changes in total. 0 added, 1 modified, 0 deleted:
chromium: 0 added, 0 modified, 0 deletedwebkit: 0 added, 1 modified, 0 deleted (diff for shard 2)firefox: 0 added, 0 modified, 0 deleted
Triggered by this commit.
📸 UI snapshots have been updated
1 snapshot changes in total. 0 added, 1 modified, 0 deleted:
chromium: 0 added, 0 modified, 0 deletedwebkit: 0 added, 1 modified, 0 deleted (diff for shard 2)firefox: 0 added, 0 modified, 0 deleted
Triggered by this commit.
📸 UI snapshots have been updated
1 snapshot changes in total. 0 added, 1 modified, 0 deleted:
chromium: 0 added, 0 modified, 0 deletedwebkit: 0 added, 1 modified, 0 deleted (diff for shard 2)firefox: 0 added, 0 modified, 0 deleted
Triggered by this commit.
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 stale label – otherwise this will be closed in another week.
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 stale label – otherwise this will be closed in another week.
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 stale label – otherwise this will be closed in another week.
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 stale label – otherwise this will be closed in another week.
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 stale label – otherwise this will be closed in another week.
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 stale label – otherwise this will be closed in another week.
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 stale label – otherwise this will be closed in another week.
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 stale label – otherwise this will be closed in another week.
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 stale label – otherwise this will be closed in another week.
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 stale label – otherwise this will be closed in another week.
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 stale label – otherwise this will be closed in another week.
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 stale label – otherwise this will be closed in another week.
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 stale label – otherwise this will be closed in another week.
This PR was closed due to lack of activity. Feel free to reopen if it's still relevant.
📸 UI snapshots have been updated
2 snapshot changes in total. 0 added, 2 modified, 0 deleted:
chromium: 0 added, 2 modified, 0 deleted (diff for shard 2)webkit: 0 added, 0 modified, 0 deleted
Triggered by this commit.
📸 UI snapshots have been updated
1 snapshot changes in total. 0 added, 1 modified, 0 deleted:
chromium: 0 added, 1 modified, 0 deleted (diff for shard 2)webkit: 0 added, 0 modified, 0 deleted
Triggered by this commit.
This is ready for a review @Twixes @benjackwhite
The code adds /project/:id in front of the URLs that need it, and changes current_team in middleware.py if the team changes.
Everything seems to work. Is there anything I'm missing? I still see some @current-s in the frontend. Should we fully remove them as well? Should we stick to /project/:id or find some other URL structure?
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 stale label – otherwise this will be closed in another week.
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 stale label – otherwise this will be closed in another week.
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 stale label – otherwise this will be closed in another week.
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 stale label – otherwise this will be closed in another week.
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 stale label – otherwise this will be closed in another week.