Cannot set user id and user property at the same time
- Dominant language
- TypeScript
- Stars
- 7.8k
- Forks
- 2.2k
- Avg merge
- 22h 28m
- Merged PRs (30d)
- 6
Description
### Version info
**Angular:** 12.2.0
**Firebase:** 9.6.6
**AngularFire:** 7.2.1
### Expected behavior
I need to set user id and a user property after a user has logged in. User property is product_amount, and the user belongs to different audiences based on the product_amount.
### Actual behavior
Every user is counted to belong to two audiences. After user has logged in, I set `this.analytics.setUserId(id);`, which causes product_amount to be zero. After user id is set, I set user properties with
```
this.analytics.setUserProperties(
{ product_amount: this.product_amount },
{ global: true }
);
```
which logs the real product amount.
It is not possible to set user id and user properties at the same time. That means initial user property is always the wrong one.
Contributor guide
Research direction
Start by reproducing the issue with Angular 12.2.0, Firebase 9.6.6, and AngularFire 7.2.1 using setUserId and setUserProperties with the product_amount property. Inspect the AngularFire analytics entry points and Firebase Analytics behavior to determine why setting the ID resets the property; done means both values remain correct and audience assignment is accurate.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- firebase, typescript
- Domain
- analytics
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 30/100