Repository: PostHog/posthog
Pull request: Fix sessions indefinite loading users bug
## Changes

Closes #3985 

Going to **insights -> sessions -> graph data point** would load indefinitely
The API call was expecting entity values which weren't being set properly in the trends logic

https://user-images.githubusercontent.com/25164963/115620384-1637a500-a2c3-11eb-9dda-2aa645deb77d.mov

## Checklist

- [ ] All querysets/queries filter by Organization, by Team, and by User
- [ ] Django backend tests
- [ ] Jest frontend tests
- [ ] Cypress end-to-end tests
- [ ] Migrations are safe to run at scale (e.g. PostHog Cloud) – present proof if not obvious


Problem statement:
Clicking on session datapoint doesn't return people
## Bug description

*Please describe.*  
- For sessions in insights, clicking on a datapoint doesn't return people
*If this affects the front-end, screenshots would be of great help.*  

## Expected behavior
- the modal should return people



## How to reproduce

1. Go to sessions under insights
2. Click on a datapoint on the trend graph
3. Loading spinner forever

Hints from issue discussion:

Commit message: fix sessions loading users bug

Patch to review:
diff --git a/frontend/src/scenes/trends/trendsLogic.ts b/frontend/src/scenes/trends/trendsLogic.ts
index d31c38c478ac3..e89a84aaf9c99 100644
--- a/frontend/src/scenes/trends/trendsLogic.ts
+++ b/frontend/src/scenes/trends/trendsLogic.ts
@@ -100,8 +100,8 @@ function parsePeopleParams(peopleParams: PeopleParamType, filters: Partial<Filte
     const { action, date_from, date_to, breakdown_value, ...restParams } = peopleParams
     const params = filterClientSideParams({
         ...filters,
-        entity_id: action.id,
-        entity_type: action.type,
+        entity_id: action.id || filters?.events?.[0].id,
+        entity_type: action.type || filters?.events?.[0].type,
         entity_math: action.math || undefined,
         breakdown_value,
     })


Code review comments:
diff_hunk: @@ -100,8 +100,8 @@ function parsePeopleParams(peopleParams: PeopleParamType, filters: Partial<Filte
     const { action, date_from, date_to, breakdown_value, ...restParams } = peopleParams
     const params = filterClientSideParams({
         ...filters,
-        entity_id: action.id,
-        entity_type: action.type,
+        entity_id: action.id || filters?.events?.[0].id,
path: frontend/src/scenes/trends/trendsLogic.ts
text: @user1:
I think you can chain a third condition here for `filters?.actions?.[0].id`. Events work now but if an action is selected the datapoint still will fall over