Environment Element
Overview
The Spaaza Environment Element provides the context and user details to other Spaaza Elements included on a page. Every functional Element needs to be included within the Spaaza Environment tag in HTML.
To include the Environment Element on a webpage do the following:
- Add the following script tag at the top of the page
<script type="module" src="https://elements.spaaza.com/elem/spaaza-environment.js"></script>
- Add the Environment tag to the contents of the page (below the script tag). Add any other Elements you want to inlude on the page within the Environment tag:
<spaaza-environment config="config_goes_here">
<spaaza-member-card></spaaza-member-card>
<!-- other Spaaza Elements and HTML goes here -->
</spaaza-environment>
Properties
The Environment Element has a single config property, a stringified JSON object with the following fields:
| Field | Description |
|---|---|
| origin (mandatory) | The Spaaza API used - apistage0 for staging, api0 for production. |
| auth (mandatory) | A stringified JSON object with details used to authenticate the user. The JSON passed will depend on the authentication method used. Examples are shared below. |
The auth fields depend on the authentication method used.
| Field | Description |
|---|---|
| sessionKey (mandatory) | The session key of the user from the app |
| sessionUserHash (mandatory) | The hashed session string for the user. |
| externalIDHash | A secondary hashed string used for authenticating Shopify users. |
| sessionAuthPointID | The id of the user in the app. |
| userID | The id of the user in Spaaza. |
| myPriceAppHost (mandatory) | The hostname of the client in Spaaza. |
Below are two Environment Element HTML Tag examples using different authentication parameters and APIs.
<spaaza-environment config='{"origin":"https://api0.spaaza.com","auth":{"sessionUserHash":"123ghfghfghdsad4243245","externalIDHash":"7ukdsajkdjknjkdsanjk8886e","sessionAuthPointID":"1234567","myPriceAppHost":"acme.spaaza.com"}}'>
<spaaza-environment config='{"origin":"https://apistage0.spaaza.com","auth":{"sessionKey":"168r56bhjdasfdsfds78","userID":"6789","myPriceAppHost":"abc.test01.spaaza.com"}}'>