#Methods
#Audit
#noConflict
.noConflict(): this
If an Audit
object already exists in the global object of the current
page, the Audit.js
library will be renamed to PooolAudit
and the original
Audit
object will be restored.
Example
const pooolAudit = Audit.noConflict();
pooolAudit.init('<your app id>');
#init
.init(appId: String): this
Initializes Audit using your app ID.
Example
Audit.init('<your app id>');
#sendEvent
.sendEvent(eventName: String, data?: Object, options?: AuditOptions): Promise
Sends an audit event.
Example
Audit.sendEvent('page-view', { type: 'premium' });
#Available events
#page-view
Expected data
{
type: String('premium'|'free'|'page'),
}
Example
Audit.sendEvent('page-view', { type: 'premium' });
#Options
#beacon
- Type: Boolean
- Default: false
Sends the event using the Beacon API (navigator.sendBeacon
) to avoid loosing
requests sent right before a redirect (like a click over a button).
Example
audit.sendEvent('page-view', { type: 'premium' }, { beacon: true });
#config
.config(optionName: String, optionValue: Any, readOnly?: Boolean): this
.config(options: Object, readOnly?: Boolean): this
Allows to set some configuration options. See the
configuration options documentation.
Example
audit.config('debug', true);
.on(name: String, callback: Function): this
Allows to set a callback to be called when a specific event is triggered. See
the
events documentation.
Example
audit.on('identityAvailable', event) => {
console.log('User identity available:', event);
});
#once
.once(name: String, callback: Function): this
Same as .on()
but the callback will be called only once and removed afterwards.
Example
audit.once('identityAvailable', event) => {
console.log('User identity available:', event);
});
#off
.off(name: String, callback: Function): this
Allows to remove an event callback previously set with .on()
or .once()
.
Example
audit.off('identityAvailable', identityCallback);