Expand my Community achievements bar.

Guidelines for the Responsible Use of Generative AI in the Experience Cloud Community.

ContextHub APIs vs localStorage API for manipulation

Avatar

Level 4

I observed a behavior while manipulating the data for ContextHubPersistence. As this is stored in browser localStorage, I was thinking of manipulating the data using localStorage APIs for a chrome extension (as I am not able to access the ContextHub API inside chrome extension's execution environment, yet. I am trying for options)

  1. I am able to set the value to localStorage ContextHubPersistence key, value is shown, but its getting removed after I reload the page.
  2. When I use ContextHub JavaScript API to set value  ContextHub.getStore('profile').setItem('myItem', 'ContextHub'); , the value is retained even after reloading the page.

Is there more to ContextHub data than just a storage in localStorage?

Thanks,

Sandeep

3 Replies

Avatar

Level 4

There are listeners which are attached to Client Context or Context Hub APIs which are triggered when we use these APIs.  This will not happen in case of localStorage APIs.

Avatar

Level 10

Hi @sandeep.

AEM 6.3 + We Retail

I don't see value for this retained even if you use API

" ContextHub.getStore('profile').setItem('myItem', 'ContextHub');

Thanks

Avatar

Level 4

Yes edubey

It doesn't seems to be working for 6.3 We Retail. I just double checked in 6.1, 6.2 Geomatrixx outdoors website, its working there.

Thanks,
Sandeep