in src/service.ts [159:259]
constructor(hpmFactory: IHpmFactory, wpmpFactory: IWpmpFactory, routerFactory: IRouterFactory, config: IServiceConfiguration = {}) {
this.wpmp = wpmpFactory(config.wpmpName, config.logMessages);
this.hpm = hpmFactory(this.wpmp, null, config.version, config.type);
this.router = routerFactory(this.wpmp);
this.uniqueSessionId = utils.generateUUID();
/**
* Adds handler for report events.
*/
this.router.post(`/reports/:uniqueId/events/:eventName`, (req, _res) => {
const event: IEvent<any> = {
type: 'report',
id: req.params.uniqueId as string,
name: req.params.eventName as string,
value: req.body
};
this.handleEvent(event);
});
this.router.post(`/reports/:uniqueId/pages/:pageName/events/:eventName`, (req, _res) => {
const event: IEvent<any> = {
type: 'report',
id: req.params.uniqueId as string,
name: req.params.eventName as string,
value: req.body
};
this.handleEvent(event);
});
this.router.post(`/reports/:uniqueId/pages/:pageName/visuals/:visualName/events/:eventName`, (req, _res) => {
const event: IEvent<any> = {
type: 'report',
id: req.params.uniqueId as string,
name: req.params.eventName as string,
value: req.body
};
this.handleEvent(event);
});
this.router.post(`/dashboards/:uniqueId/events/:eventName`, (req, _res) => {
const event: IEvent<any> = {
type: 'dashboard',
id: req.params.uniqueId as string,
name: req.params.eventName as string,
value: req.body
};
this.handleEvent(event);
});
this.router.post(`/tile/:uniqueId/events/:eventName`, (req, _res) => {
const event: IEvent<any> = {
type: 'tile',
id: req.params.uniqueId as string,
name: req.params.eventName as string,
value: req.body
};
this.handleEvent(event);
});
/**
* Adds handler for Q&A events.
*/
this.router.post(`/qna/:uniqueId/events/:eventName`, (req, _res) => {
const event: IEvent<any> = {
type: 'qna',
id: req.params.uniqueId as string,
name: req.params.eventName as string,
value: req.body
};
this.handleEvent(event);
});
/**
* Adds handler for front load 'ready' message.
*/
this.router.post(`/ready/:uniqueId`, (req, _res) => {
const event: IEvent<any> = {
type: 'report',
id: req.params.uniqueId as string,
name: 'ready',
value: req.body
};
this.handleEvent(event);
});
this.embeds = [];
// TODO: Change when Object.assign is available.
this.config = utils.assign({}, Service.defaultConfig, config);
if (this.config.autoEmbedOnContentLoaded) {
this.enableAutoEmbed();
}
}