SIGN IN SIGN UP

Don't jitter developer-initiated subscriber attribute posts in foreground (#4041)

Posting subscriber attributes always waited out a random 0-5s jitter
before the request left the device. That jitter exists to spread out
syncs that many apps perform at the same lifecycle moment, but it was
hardcoded in the poster, so it also applied to syncs a developer
explicitly asked for while the app is foregrounded.

This PR fixes that so we know only add the jittering if the app is
foregrounded.

<!-- CURSOR_SUMMARY -->
---

> [!NOTE]
> **Low Risk**
> Timing-only change for network enqueue; foreground attribute syncs
become faster without altering auth or purchase logic.
> 
> **Overview**
> Subscriber attribute POSTs no longer always wait on the fixed **0–5s**
dispatcher jitter. **`Delay.jitterOnlyIfInBackground`** centralizes the
rule: **background** → `DEFAULT` jitter, **foreground** → `Delay.NONE`.
> 
> **`synchronizeSubscriberAttributesForAllUsers`** and
**`SubscriberAttributesPoster`** now take an explicit **`delay`** and
pass it to the backend instead of hardcoding jitter in the poster. Call
sites pick delay from app state: e.g.
**`syncAttributesAndOfferingsIfNeeded`** and login/logout in
**`IdentityManager`** use background-aware jitter; lifecycle sync uses
**`NONE`** on background and **`DEFAULT`** on foreground.
> 
> **`Backend`** callback enqueue paths that previously inlined the same
if/else now call **`jitterOnlyIfInBackground`** for consistency.
> 
> <sup>Reviewed by [Cursor Bugbot](https://cursor.com/bugbot) for commit
47f9d89b1a6e8751b313ed1a6f8db027b341fa1b. Bugbot is set up for automated
code reviews on this repo. Configure
[here](https://www.cursor.com/dashboard/bugbot).</sup>
<!-- /CURSOR_SUMMARY -->

---------

Co-authored-by: Claude Opus 5 (1M context) <noreply@anthropic.com>
T
Toni Rico committed
735e672eaba5bc3f682df8b15b0eb07d81499cfc
Parent: fd95247
Committed by GitHub <noreply@github.com> on 8/20/2026, 11:01:22 AM