Add SHA-256 hashing and retained fields to DataLayer#367
Merged
Conversation
…to sha-256-datalayer
fernanDOTdo
approved these changes
Nov 19, 2025
fernanDOTdo
marked this pull request as ready for review
November 19, 2025 19:15
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
From: https://app.productive.io/2650-4site-interactive-studios-inc/tasks/14613708
This implements a new
retainedFieldsset to work along sidehashedFieldsandexcludedFields.Any field within
retainedFieldswill have it's value hashed with the SHA-256 method, and saved in LocalStorage. On init, it checks all fields inretainedFieldsif the values are present in LocalStorage and appends them to the page json.This can be tested here: https://act.amnestyusa.org/page/181587/subscribe/1?mode=DEMO&assets=enhanced-data-layer
EN_RETAINED_FIELD_SUPPORTER.EMAILADDRESSwindow.dataLayercontainsEN_FORM_VALUE_UPDATEDwith a sha-256 hashed value, should be in the last index. The value should match what is in LocalStorage.window.dataLayerfor thepageJsonVariablesReadyevent, with a valueEN_RETAINED_FIELD_SUPPORTER.EMAILADDRESSthat matches the same value in LocalStorage. NOTE: There may be more than onepageJsonVariablesReadyevents, refer to the higher index.This was built with compatibility in mind, the hash method remains for use on
hashedFields, however in a later build during a less busy season ideally theshaHashwill take over that method. In addition to that, the function for checking if a field should be retained should remove the specific implementation to use theshaHashmethod and instead rely upon thehashedFieldscheck's value.