SDK output types
In your SDK feature, you can use an output type to define the outcome that is displayed on your site. Once created in the Developer Interface, a related Outcome decision node is available from the Outcomes segment title in the decision bar above the rules canvas.
Note: Each SDK feature can use only one output type.
You can create the following output types:
- Component
A Component output type uses HTML to define the outcome that is displayed on your site.
You can add multiple Component output types in the Developer Interface.
- Enum
An Enum output type uses a constant value to define the outcome that is displayed on your site.
You can add multiple Enum output types in the Developer Interface.
- String
A String output type uses a string that is displayed on your site.
You can add a single String output type in the Developer Interface.
When you add the String Output decision node to your rules canvas, the Output String dialog box displays, as illustrated below:
To define the string to display complete the following steps:
You can use the String decision node multiple times in your rule. Each time you add it to the rules canvas, you can define a different string as described above.
- Enter the string as you want it to display in the Output text box
- Select the Save button to save the string and return to the rules canvas. Selecting the Cancel button closes the Output String dialog box and returns you to the rules canvas; the String Output decision node is not included on the rules canvas
- Number
A Number output type uses a number that is displayed on your site.
You can add a single Number output type in the Developer Interface.
When you add the Number Output decision node to your rules canvas, the Output Number dialog box displays, as illustrated below:
To define the number to display complete the following steps:
You can use the Number Output decision node multiple times in your rule. Each time you add it to the rules canvas, you can define a different number as described above.
- Enter the number as you want it to display in the Output text box
- Select the Save button to save the number and return to the rules canvas. Selecting the Cancel button closes the Output Number dialog box and returns you to the rules canvas; the Number Output decision node is not included on the rules canvas
- JSON
A JSON output is defined by a JSON schema. It could contain different types of data, including string, number, enum, and component.
Technical users can create and add a JSON schema in the Developer Interface. Non-technical users can then create JSON outputs using a form that is dynamically generated from the JSON schema.
The JSON output options will be validated to ensure they are valid JSON and that they conform to the schema if specified.
Below is an example JSON Schema and the visual form generated for editing JSON output options:
Example JSON Schema |
Visual form for editing JSON outputs |
{ |
In addition to using the visual editor to create JSON outputs, you can also use the raw-text editor to do so.
Note: You can create JSON output options without adding a schema in advance. In this case, the JSON output editor will only validate if the input is a valid JSON.
You can use variables in the JSON output option to store user-specific data in the following format: blaize.user.<ua-slug> (with double curly brackets). For example, blaize.user.first-name (with double curly brackets).
After a JSON output option is saved, you can edit it by double-clicking it in the rules canvas.
When saving or publishing a feature version, validation is present to check that all the paths in the canvas lead to an output, it is not possible to save a rule with some of the decision paths leading to nothing.
Note the following limitations when using the JSON output type:
- Some newer JSON Schema features may not be supported by the Visual editor. If this is the case, the form won’t be shown.
- We only check if the JSON schema is a valid JSON, but not check if it is a schema that makes sense (e.g. it contains invalid references or unknown types). You should ensure the schema doesn't have such issues.
- Transformation
The Transformation output type allows you to use Zephr's highly customisable feature outcomes in your SDK rules.
After selecting Transformation as the output type, you can create outcomes with customised components, such as a payment or subscription change form, custom component block, or a template form that is defined in the Component Library. For detailed instructions on how to create outcomes and forms, see Feature Outcomes.
When an SDK feature rule is triggered, the following information about the returned components will be available in the response body:
- transformationType: Type of the component
- resourceId: Unique Id of the component
- contentPath: The URL of the component
Components can be accessed through the returned contentPath.
Below is an example of the returned transformations data:
\"transformations\":[
{
\"transformType\":\"CUSTOM_COMPONENT\",
\"resourceId\":\"7fb6c2d1-a894-4450-a791-34e6eab1ea13\",
\"contentPath\":\"/zephr/public/ui-components/v1/ui-components/7fb6c2d1-a894-4450-a791-34e6eab1ea13\"
},{
\"transformType\":\"FORM\",
\"resourceId\":\"M-2EZg3K\",
\"contentPath\":\"/zephr/public/ui-components/v1/ui-components/M-2EZg3K\"
},{
\"transformType\":\"FORM\",
\"resourceId\":\"F-lEWwDb\",
\"contentPath\":\"/zephr/public/ui-components/v1/ui-components/F-lEWwDb\"
}]
If you turn on the Content Enabled toggle, the following data will be returned in the response body:
\"transformations\":[
{
\"transformType\":\"ENABLE_CONTENT\",
\"resourceId\":null,
\"contentPath\":null
}
]
Output Type Comparison
The following table provides a summary of the application and limitations of each output type:
Component | Enum | String | Number | JSON | Transformation | |
---|---|---|---|---|---|---|
Pros |
|
|
|
|
|
|
Cons |
|
|
|
|
|
|
Example Use |
|
|
|
|