Expand my Community achievements bar.

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

Authored segments for custom ContextHub SessionStore

Avatar

Level 3

I am having difficulty creating a context hub segment that works off my custom session store.  

Here is my segment:

<?xml version="1.0" encoding="UTF-8"?> <jcr:root xmlns:sling="http://sling.apache.org/jcr/sling/1.0" xmlns:cq="http://www.day.com/jcr/cq/1.0" xmlns:jcr="http://www.jcp.org/jcr/1.0" xmlns:nt="http://www.jcp.org/jcr/nt/1.0" jcr:primaryType="cq:Page"> <jcr:content cq:lastModified="{Date}2015-01-08T11:13:48.123+01:00" cq:lastModifiedBy="admin" jcr:primaryType="cq:PageContent" jcr:title="Carrier PSI2659" sling:resourceType="cq/contexthub/components/segment-page" segmentName="cag-PSI2659B"> <traits jcr:primaryType="nt:unstructured" sling:resourceType="cq/contexthub/components/traits/logic/operator-and"> <andpar jcr:primaryType="nt:unstructured" sling:resourceType="foundation/components/parsys"> <rxClaimCarrierPSI2659 jcr:primaryType="nt:unstructured" sling:resourceType="cq/contexthub/components/traits/generic-comparison" dataType="string" operator="equal"> <left jcr:primaryType="nt:unstructured" sling:resourceType="cq/contexthub/components/traits/generic-comparison/type/property" property="member-profile-store/profileData/rxUserV2/carrierId"/> <right jcr:primaryType="nt:unstructured" sling:resourceType="cq/contexthub/components/traits/generic-comparison/type/value" value="abc"/> </rxClaimCarrierPSI2659> </andpar> </traits> </jcr:content> </jcr:root>

json model:

"profileData" : { "rxUserV2" : { "accountId":"ACTIVE", "carrierId":"PSI2659", "carrier":true, "demographics" : { "group6":"ACTIVE", "groupId":"ACTIVE" } }, "uuid":"a91e2f02-9d11-47a1-a910-02bd045c808d" }

My session store:

ContextHub.console.info(ContextHub.Shared.timestamp(), '[loading] customstore.member-profile-store'); (function($) { 'use strict'; /* default config */ var defaultConfig = { /* initial values to set in store's storage */ initialValues: {} }; /** * Store implementation. * * @extends ContextHub.Store.JSONPStore * @param {String} name - store name * @param {Object} config - config * @constructor */ var MemberProfileStore = function(name, config) { this.config = $.extend(true, {}, defaultConfig, config); this.init(name, this.config); }; /* inherit from ContextHub.Store.SessionStore */ ContextHub.Utils.inheritance.inherit(MemberProfileStore, ContextHub.Store.SessionStore); /** * Returns name. * * @return {String} */ MemberProfileStore.prototype.getClientName = function() { return this.getItem('profile').rxClaimCarrier || '[unknown]'; }; /** * Returns name. * * @return {Object} profile */ MemberProfileStore.prototype.getProfile = function() { return this.getItem('profileData') || '[unknown]'; }; /* register store candidate */ ContextHub.Utils.storeCandidates.registerStoreCandidate(MemberProfileStore, 'customstore.member-profile-store', 0); }(ContextHubJQ));
2 Replies

Avatar

Administrator

Hi, 

Can you please elaborate the issue? What is the error coming up ?

~kautuk



Kautuk Sahni