We have updated the SDK to read off Ceroscontext. In particular:
The SDK Developer portal can be found here.
We have made this change to provide a more stable way for customers to interact with these variables without the risk that we might change them. This will also allow for additional customers to access this data through their own SDK implementation.
How It Works
CerosContext is an object that contains context values related to the Ceros ecosystem. Names of the current context variables are stored in the CerosSDK.CONTEXT structure:
CONTEXT: {
appSlug
issue.projectId
issue.id
issue.lastPublishedDate
previewMode
issue.firstPublishedDate
issue.creationDate
issue.lastModifiedDate
}
The SDK provides a method to enumerate the names of all the available context variables CerosSDK.enumerateContextVariables and a method to retrieve a specific context value by name CerosSDK.getContextValue although the usage is slightly different between embedded and standalone versions.
Retrieving a context value in standalone mode
When using the Standalone SDK, the context values are returned synchronously through a call to CerosSDK.getContextValue
var appSlug = CerosSDK.getContextValue("appSlug");
var lastModifiedDate = CerosSDK.getContextValue("issue.lastModifiedDate");
Retrieving a context value in embedded mode
In embedded mode, the context is not available in the hosting page, thus it will need to be retrieved from an embedded Ceros experience using a callback. Additional parameters are required when calling CerosSDK.getContextValue
var appSlug;
CerosSDK.getContextValue(myExperience, "appSlug", function(data) {
// `data` is an object that contains the following fields
// {variableName: "appSlug", variableValue: <appSlugValue>}
appSlug = data.variableValue;
});
var lastModifiedDate;
CerosSDK.getContextValue(myExperience, "issue.lastModifiedDate", function(data) {
lastModifiedDate = data.variableValue;
});