Repository navigation
Add collectConsentResyncRequired flag for collect-consent transitions - #116
Conversation
Release v3.0.2
…sync data when needed. Added Pending state to test app test screen for manual testing
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
| return ( | ||
| ConsentConstants.EventDataKey.YES.equals(newCollectVal) && | ||
| !ConsentConstants.EventDataKey.YES.equals(previousDefinitive) | ||
| ); |
There was a problem hiding this comment.
Hi @sagar-sharma-adobe ,
I see that, lastDefinitiveCollectConsent is nil on both a true first install and an SDK upgrade (key never written by the old SDK). The current code can't
distinguish between them, so the null → "y" path fires collectConsentResyncRequired = true on every fresh install where consent.default = "y" - even though there's nothing to resync.
Wouldn't it a better choice to check the persistedPreferences
`
// Before
return newCollectVal == ConsentConstants.EventDataKeys.YES
&& previousDefinitive != ConsentConstants.EventDataKeys.YES
// After
return newCollectVal == ConsentConstants.EventDataKeys.YES
&& (previousDefinitive != nil || persistedPreferences != nil)
&& previousDefinitive != ConsentConstants.EventDataKeys.YES
`
There was a problem hiding this comment.
This is a logically sound suggestion and a great observation. The only reason why we are not preloading the definitive state from sharedState/Config is to let a resync happen for every user once in app lifecyle during app update. This will resolve any previous update blocks. Though this also causes new installs to fire a resync as well but that seems to be a justifiable cost.
Description
Summary
When
consents.collect.valtransitions to"y"from a non-"y"value, theConsent extension now adds
collectConsentResyncRequired: trueto theCONSENT_PREFERENCES_UPDATEDevent. Downstream extensions (e.g. Messaging)listen for this flag to re-sync data that may have been silently dropped
by Edge while consent was previously
"n".Transition detection is centralized here so consumers don't each replicate
the state machine.
Behavior
null → "y"(fresh install / first definitive observation)"n" → "y"(classic recovery)"y" → "y""y" → "p" → "y""y")"n" → "p" → "y""n")collectdimension change"p"(pending) is treated as no-information — it neither advances thetracker nor can fire the flag. Tracked via a new persisted key
consent.lastDefinitiveCollect.Surface
CONSENT_PREFERENCES_UPDATEDcarries the flag.GET_CONSENTS_RESPONSE,EDGE_CONSENT_UPDATE, XDM shared state, andpersisted consents are unchanged.
API impact
No public/internal method signatures change.
mergeAndPersistandupdateDefaultConsentsare untouched; transition detection lives in anew sibling
evaluateCollectConsentTransition()onConsentManager,invoked internally by
shareCurrentConsents.Tests
ConsentManagerTest— 8 new unit tests covering the invariantsmatrix above, including cross-instance persistence and the
load-bearing
"y" → "p" → "y"case.ConsentExtensionTest— 7 new functional tests: flag presence onn → yvia each of the three dispatch sites(
handleConsentUpdate,handleEdgeConsentPreferenceHandle,handleConfigurationResponse); flag absence on repeated"y",GET_CONSENTS_RESPONSE, andEDGE_CONSENT_UPDATE; and an explicitassertion that the XDM shared state does NOT carry the flag.
on the appropriate dispatched-event assertions.
"pending"optionmapping to
"p"so they → p → yinvariant can be verified manually.Related Issue
Motivation and Context
How Has This Been Tested?
Screenshots (if appropriate):
Types of changes
Checklist: