Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(AP-2173): Add persistence to context #147

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

Conversation

tfoster
Copy link
Contributor

@tfoster tfoster commented Dec 22, 2022

This change allows an implementer to designate context keys to persist in either local or session storage.

@sonarcloud
Copy link

sonarcloud bot commented Dec 22, 2022

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

No Coverage information No Coverage information
0.0% 0.0% Duplication

@mattstrom
Copy link
Contributor

Unit tests would be good too if you can add some.

@mattstrom
Copy link
Contributor

There's an argument to be made that these changes belong in asset-manager since they are browser-specific. Though, I understand it was probably more straightforward to implement here. However, there might be some privacy and compliance considerations we need to observe.

asset-manager has a class named EvolvStorageManager which is responsible for allowing persistence only after consent has been granted. We probably need to observe consent here too.

See evolv-ai/asset-manager#186

Copy link
Contributor

@robertsevernsentient robertsevernsentient left a comment

Choose a reason for hiding this comment

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

Placing our whole context onto session and local storage concerns me as it dramatically increases the information that we store on a cookie like area -- that customers ask for information on when we go through security reviews -- so it should at least be optional

We also make this information available to chrome plugins

The other concern is that this makes the functionality specific to the client -- could be argued that is ok, given a true sdk implementation, the dev controls the lifecycle, and this code will be ignored in npm. But we've previously managed to browser specific implementations to asset manager

Also -- tests

}

function mergeAllPersistedStorage(contextKey, context) {
if (window === undefined || !window.localStorage) {
Copy link
Contributor

Choose a reason for hiding this comment

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

javascript-sdk currently has no references to session or local storage. Is this check to prevent errors if we're running on node?

A warning here that persisting is doing nothing would be good -- but should this capability live in asset-manager?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah, I'll add a warning.

src/context.js Show resolved Hide resolved
@tfoster
Copy link
Contributor Author

tfoster commented Mar 20, 2023

Placing our whole context onto session and local storage concerns me as it dramatically increases the information that we store on a cookie like area -- that customers ask for information on when we go through security reviews -- so it should at least be optional

We also make this information available to chrome plugins

The other concern is that this makes the functionality specific to the client -- could be argued that is ok, given a true sdk implementation, the dev controls the lifecycle, and this code will be ignored in npm. But we've previously managed to browser specific implementations to asset manager

Also -- tests

@robertsevernsentient I agree that we shouldn't persist the full context. This functionality allows the consumer to specify one or more keys to persist, not the full context.

I can add a warning about not persisting when executing in NodeJS. I could also make the storage pluggable, but the usecases for this would be limited server-side.

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.

3 participants