Show Menu
TOPICS×

Sample ContextHub Store Candidates

ContextHub provides several sample store candidates that you can use in your solutions. The following information is provided for each sample:
  • Where to find the source code so that you can open it for learning purposes.
  • How to configure the stores that you create from the store candidates.
  • How the store data is structured so that you can access it.
The sample store candidates are provided as reference configurations to help you build your own dedicated configuration for your project and as such should not be used directly.

aem.segmentation Sample Store Candidate

Store for resolved and unresolved ContextHub segments. Automatically retrieves segments from the ContextHub SegmentManager.

Source Location

/libs/settings/cloudsettings/legacy/contexthub/segmentation

Base Implementation

The aem.segmentation store candidate extends ContextHub.Store.PersistedJSONPStore .

Configuration

When you create an aem.segmentation store, you do not need to provide a detailed configuration. The default configuration specifies the location of the ContextHub segment definitions.
{
   "service":{
      "jsonp":false,
      "timeout":1000,
      "path":"/etc/segmentation/contexthub.segment.js"
   }
}

contexthub.geolocation Sample Store Candidate

The contexthub.geolocation sample store candidate uses Google Maps to obtain and store information about the client location.

Source Location

/libs/settings/cloudsettings/legacy/contexthub/geolocation

Base Implementation

The contexthub.geolocation store candidate extends ContextHub.Store.PersistedJSONPStore .

Configuration

The default configuration specifies information about the Google service and the initial latitude and longitude coordinates.
{
        "service": {
            "jsonp": false,
            "timeout": 1000,
            "ttl": 1800000,
            "secure": false,
            "host": "maps.googleapis.com",
            "port": 80,
            "path": "/maps/api/geocode/json"
        },

        "eventDeferring": 16,

        "html5coordinatesDiscoveryAPI": {
            "timeout": 30000,
            "ttl": 900000,
            "highAccuracy": false
        },

        "initialValues": {
            "latitude": 37.331375,
            "longitude": -121.893992
        }
    }

Data Items

The store uses a data tree that is similar to the following example:
{
   "latitude":"37.331375",
   "longitude":"-121.893992"
}

A security policy introduced in Chrome 50.x requires that that all geolocation related calls are made over a secured connection. Therefore AEM forces https usage for geolocation API calls if AEM is running over https as well. Otherwise http is used in order to comply with the policy of same origin.
See this Google blog post for more details on the change in Chrome.

contexthub.surferinfo Sample Store Candidate

Stores information about the current client environment such as the device, window, browser, date and time.

Source Location

/libs/settings/cloudsettings/legacy/contexthub/surferinfo

Base Implementation

The contexthub.surferinfo store candidate extends ContextHub.Store.PersistedStore .

Configuration

The default configuration is inherited from ContextHub.Store.PersistedStore .

Data Items

Stores that use this store candidate have a data tree that is similar to the following example:
{
   "display":{
      "resolution":{
         "width":1440,
         "height":900
      },
      "devicePixelRatio":1,
      "colorDepth":24,
      "nrOfColors":16777216,
      "pixelsPerInch":96,
      "orientation":{
         "mode":"landscape",
         "direction":"normal"
      }
   },
   "window":{
      "dimension":{
         "width":1395,
         "height":652
      },
      "percentageUsage":0.7
   },
   "browser":{
      "version":"39.0",
      "family":"Firefox",
      "userAgent":"Mozilla/5.0 (Macintosh; Intel Mac OS X 10.9; rv:39.0) Gecko/20100101 Firefox/39.0"
   },
   "device":{
      "category":"Desktop",
      "type":"Desktop",
      "model":"PC",
      "version":""
   },
   "isMobile":true,
   "os":{
      "name":"Mac OS X",
      "version":"10"
   },
   "year":2015,
   "month":7,
   "day":22,
   "hour":14,
   "minutes":1
}

granite.emulators Sample Store Candidate

The granite.emulators sample store candidate stores information about client devices.

Source Location

/libs/settings/cloudsettings/legacy/contexthub/emulators

Base Implementation

The granite.emulators store candidate extends ContextHub.Store.PersistedStore .

Configuration

The default configuration includes an array named defaultEmulators that contains information about different devices. When you create a store, provide different device profiles in the Detail Configuration property as required, using the format illustrated in the following example:
{
   "defaultEmulators":[
        {
            "id": "iphone-6",
            "title": "iPhone 6",
            "type": "mobile",
            "platform": "iOS",
            "platformVersion": "8.1.3",
            "width": 750,
            "height": 1334,
            "canRotate": true,
            "orientation": "Portrait",
            "device-pixel-ratio": 2
        },
        {
            "id": "iphone-6-plus",
            "title": "iPhone 6 Plus",
            "type": "mobile",
            "platform": "iOS",
            "platformVersion": "8.1.3",
            "width": 1080,
            "height": 1920,
            "canRotate": true,
            "orientation": "Portrait",
            "device-pixel-ratio": 3
        },
        {
            "id": "galaxy-s4",
            "title": "Samsung Galaxy S4",
            "type": "mobile",
            "platform": "Android",
            "platformVersion": "4.4.2 KitKat",
            "width": 1080,
            "height": 1920,
            "canRotate": true,
            "orientation": "Portrait",
            "device-pixel-ratio": 3
        }
    ]
}

Data Items

The store data tree is similar to the following example:
{
   "devices":[
      {"id":"native",
      "title":"Native",
      "type":"screen",
      "width":1395,
      "height":374,
      "orientation":"Landscape",
      "platform":"Mac OS X",
      "platformVersion":"10",
      "canRotate":false
      },
      {"id":"ipad-3",
      "title":"iPad 3 / 4 / Air",
      "type":"tablet",
      "platform":"iOS",
      "platformVersion":"8.1.3",
      "width":1536,
      "height":2048,
      "canRotate":true,
      "orientation":"Portrait",
      "device-pixel-ratio":2
      },
      {"id":"iphone-6",
      "title":"iPhone 6",
      "type":"mobile",
      "platform":"iOS",
      "platformVersion":"8.1.3",
      "width":750,
      "height":1334,
      "canRotate":true,
      "orientation":"Portrait",
      "device-pixel-ratio":2
      },
      {"id":"galaxy-s4",
      "title":"Samsung Galaxy S4",
      "type":"mobile",
      "platform":"Android",
      "platformVersion":"4.4.2 KitKat",
      "width":1080,
      "height":1920,
      "canRotate":true,
      "orientation":"Portrait",
      "device-pixel-ratio":3
      }
   ],
   "currentDeviceId":"native",
   "orientations":[
      {"id":"landscape",
      "title":"Landscape"
      },
      {"id":"portrait",
       "title":"Portrait"
      }
   ],
   "currentDevice":{
      "id":"native",
      "title":"Native",
      "type":"screen",
      "width":1395,
      "height":374,
      "orientation":"Landscape",
      "platform":"Mac OS X",
      "platformVersion":"10",
      "canRotate":false
   }
}


granite.profile Sample Store Candidate

Stores information about the current user.

Source Location

/libs/settings/cloudsettings/legacy/contexthub/profile

Base Implementation

The granite.profile store candidate extends ContextHub.Store.PersistedJSONPStore .

Configuration

The following default configuration is used. You should not change this configuration.
{
   "service":{
      "jsonp":false,
      "timeout":1000,
      "path":"${contexthub:/store/profile/path}.infinity.json"
   },
   "initialValues":{"path":"/home/users/a/anonymous"}
}

Data Items

Stores that use this store candidate have a data tree that is similar to the following example:
{
   "displayName":"anonymous",
   "path":"/home/users/6/6zavE_DGre6Ad9Y5E0Ba",
   "avatar":"/etc/designs/default/images/social/avatar.png",
   "authorizableId":"anonymous"
}