Skip to content

Add collectConsentResyncRequired flag for collect-consent transitions - #116

Merged
sagar-sharma-adobe merged 6 commits into
adobe:stagingfrom
sagar-sharma-adobe:dev
Jun 4, 2026
Merged

sagar-sharma-adobe merged 6 commits into
adobe:stagingfrom
sagar-sharma-adobe:dev

Conversation

@sagar-sharma-adobe

Copy link
Copy Markdown
Contributor

Description

Summary

When consents.collect.val transitions to "y" from a non-"y" value, the
Consent extension now adds collectConsentResyncRequired: true to the
CONSENT_PREFERENCES_UPDATED event. 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

Sequence Flag
null → "y" (fresh install / first definitive observation) ✅
"n" → "y" (classic recovery) ✅
"y" → "y" ❌
"y" → "p" → "y" ❌ (pending does not overwrite prior "y")
"n" → "p" → "y" ✅ (pending preserves prior "n")
Non-collect dimension change ❌

"p" (pending) is treated as no-information — it neither advances the
tracker nor can fire the flag. Tracked via a new persisted key
consent.lastDefinitiveCollect.

Surface

  • Only CONSENT_PREFERENCES_UPDATED carries the flag.
  • GET_CONSENTS_RESPONSE, EDGE_CONSENT_UPDATE, XDM shared state, and
    persisted consents are unchanged.

API impact

No public/internal method signatures change. mergeAndPersist and
updateDefaultConsents are untouched; transition detection lives in a
new sibling evaluateCollectConsentTransition() on ConsentManager,
invoked internally by shareCurrentConsents.

Tests

  • ConsentManagerTest — 8 new unit tests covering the invariants
    matrix above, including cross-instance persistence and the
    load-bearing "y" → "p" → "y" case.
  • ConsentExtensionTest — 7 new functional tests: flag presence on
    n → y via each of the three dispatch sites
    (handleConsentUpdate, handleEdgeConsentPreferenceHandle,
    handleConfigurationResponse); flag absence on repeated "y",
    GET_CONSENTS_RESPONSE, and EDGE_CONSENT_UPDATE; and an explicit
    assertion that the XDM shared state does NOT carry the flag.
  • Instrumented tests — 3 existing tests updated to expect the flag
    on the appropriate dispatched-event assertions.
  • Test app — collect-consent dropdown gains a "pending" option
    mapping to "p" so the y → p → y invariant can be verified manually.

Related Issue

Motivation and Context

How Has This Been Tested?

Screenshots (if appropriate):

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)

Checklist:

  • I have signed the Adobe Open Source CLA.
  • My code follows the code style of this project.
  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.
  • I have read the CONTRIBUTING document.
  • I have added tests to cover my changes.
  • All new and existing tests passed.

kevinlind and others added 2 commits August 14, 2025 13:28
…sync data when needed.

Added Pending state to test app test screen for manual testing
@codecov

codecov Bot commented Jun 3, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@sagar-sharma-adobe
sagar-sharma-adobe changed the base branch from main to staging June 3, 2026 09:18
Comment on lines +139 to +142
return (
ConsentConstants.EventDataKey.YES.equals(newCollectVal) &&
!ConsentConstants.EventDataKey.YES.equals(previousDefinitive)
);

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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
`

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@sagar-sharma-adobe
sagar-sharma-adobe merged commit f6c8bba into adobe:staging Jun 4, 2026
11 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants