ClientIdAccessor Lightning component
ClientIdAccessor Lightning component
The Coveo ClientIdAccessor
Lightning component reads and writes the client ID in the CoveoV2
namespace localStorage.
Due to Lightning Locker restrictions, a Lightning component that belongs to a different namespace can’t directly access the client ID in the CoveoV2
namespace localStorage.
The Coveo ClientIdAccessor
Lightning component offers methods to access and manipulate the client ID in the CoveoV2
namespace so it can be retrieved and reused across sites during a
visit (see Integrate a Coveo ClientIdAccessor Lightning component).
Usage
Reference it in a custom Aura component (for example, LightningComponent.cmp
).
<!-- LightningComponent.cmp -->
<aura:component implements="forceCommunity:availableForAllPageTypes">
<aura:handler name="init" value="{!this}" action="{!c.doInit}"/>
<CoveoV2:ClientIdAccessor aura:id="clientIdAccessor"/>
</aura:component>
Access and set the client ID in the CoveoV2
namespace localStorage as follows:
// LightningComponentController.js
({
doInit: function(component) {
const clientIdCmp = component.find("clientIdAccessor");
// Access the ClientID value from the CoveoV2 namespace.
const clientId = clientIdCmp.getClientId();
// Set the Client ID value in the CoveoV2 namespace.
clientIdCmp.setClientId('123e4567-e89b-12d3-a456-426614174000');
}
})
Resources included with this component
This component doesn’t include any resources.
Aura methods
This component supports the Aura methods referenced in this section.
getClientId
Reads the client ID in the CoveoV2
namespace localStorage.
const clientId = clientIdCmp.getClientId();
setClientId
Writes the client ID in the CoveoV2
namespace localStorage.
Warning
This method will override any existing client ID already in the |
This function requires a parameter:
-
the client ID (String): The client ID value to set in the
CoveoV2
namespace localStorage.
clientIdCmp.setClientId('123e4567-e89b-12d3-a456-426614174000');
Aura events
This component doesn’t include any Aura events.
Options
This component doesn’t include any options.