@@ -17521,7 +17521,7 @@ module.exports = (() => {
1752117521 this._product = product || null;
1752217522 this._contextKeys = contextKeys || [ ];
1752317523 this._validators = validators || { };
17524- this._transformers = transformers || {};
17524+ this._transformers = transformers || { };
1752517525 }
1752617526
1752717527 /**
@@ -18044,6 +18044,24 @@ module.exports = (() => {
1804418044 return marketplaceContractSigned;
1804518045 }
1804618046
18047+ // BARCHART EXCEL
18048+
18049+ static get BARCHART_EXCEL_LOGIN() {
18050+ return barchartExcelLogin;
18051+ }
18052+
18053+ static get BARCHART_EXCEL_QUOTES_OPENED() {
18054+ return barchartExcelQuotesOpened;
18055+ }
18056+
18057+ static get BARCHART_EXCEL_QUOTES_CLOSED() {
18058+ return barchartExcelQuotesClosed;
18059+ }
18060+
18061+ static get BARCHART_EXCEL_QUOTES_INSERTED() {
18062+ return barchartExcelQuotesInserted;
18063+ }
18064+
1804718065 /**
1804818066 * Get all context keys for productType.
1804918067 *
@@ -18222,6 +18240,14 @@ module.exports = (() => {
1822218240 const marketplaceOfferCreated = new EventType('OFFER-CREATED', 'Offer Created', ProductType.MARKETPLACE, ['userId', 'userType', 'companyId', 'companyName', 'entityId']);
1822318241 const marketplaceContractSigned = new EventType('CONTRACT-SIGNED', 'Contract Signed', ProductType.MARKETPLACE, ['userId', 'userType', 'companyId', 'companyName', 'entityId']);
1822418242
18243+ // Barchart Excel
18244+
18245+ const barchartExcelLogin = new EventType('BARCHART-EXCEL-LOGIN', 'User Logged In', ProductType.BARCHART_EXCEL, ['userId']);
18246+
18247+ const barchartExcelQuotesOpened = new EventType('BARCHART-EXCEL-QUOTES-OPENED', 'Quotes Opened', ProductType.BARCHART_EXCEL, ['userId']);
18248+ const barchartExcelQuotesClosed = new EventType('BARCHART-EXCEL-QUOTES-CLOSED', 'Quotes Closed', ProductType.BARCHART_EXCEL, ['userId']);
18249+ const barchartExcelQuotesInserted = new EventType('BARCHART-EXCEL-QUOTES-INSERTED', 'Quotes Inserted', ProductType.BARCHART_EXCEL, ['userId', 'symbolsCount', 'fieldsCount']);
18250+
1822518251 return EventType;
1822618252})();
1822718253
@@ -18322,6 +18348,17 @@ module.exports = (() => {
1832218348 return marketplace;
1832318349 }
1832418350
18351+ /**
18352+ * The Barchart Excel platform.
18353+ *
18354+ * @public
18355+ * @static
18356+ * @return {ProductType}
18357+ */
18358+ static get BARCHART_EXCEL() {
18359+ return barchartExcel;
18360+ }
18361+
1832518362 toString() {
1832618363 return `[ProductType (code=${this.code})]`;
1832718364 }
@@ -18333,6 +18370,7 @@ module.exports = (() => {
1833318370 const cmdtyView = new ProductType('CMDTYVIEW', 'CMDTYVIEW');
1833418371 const entitlements = new ProductType('ENTITLEMENTS', 'ENTITLEMENTS');
1833518372 const marketplace = new ProductType('MARKETPLACE', 'MARKETPLACE');
18373+ const barchartExcel = new ProductType('BARCHART-EXCEL', 'BARCHART-EXCEL');
1833618374
1833718375 return ProductType;
1833818376})();
@@ -19511,14 +19549,15 @@ module.exports = (() => {
1951119549 * to the remote service.
1951219550 *
1951319551 * @public
19552+ * @async
1951419553 */
19515- start() {
19554+ async start() {
1951619555 if (this._running) {
1951719556 return;
1951819557 }
1951919558 this._scheduler = new Scheduler();
1952019559 this._running = true;
19521- scheduleBuffer.call(this);
19560+ await scheduleBuffer.call(this);
1952219561 }
1952319562
1952419563 /**
@@ -19537,13 +19576,13 @@ module.exports = (() => {
1953719576 if (stop) {
1953819577 this.stop();
1953919578 }
19540- return processBuffer.call(this, batch);
19579+ await processBuffer.call(this, batch);
1954119580 }
1954219581
1954319582 /**
1954419583 * Stops the queue processing. Items in the buffer accumulate without being
1954519584 * transmitted to the remote service.
19546- *
19585+ *
1954719586 * @public
1954819587 */
1954919588 stop() {
@@ -19576,43 +19615,36 @@ module.exports = (() => {
1957619615 return '[EventBatcher]';
1957719616 }
1957819617 }
19579- function scheduleBuffer() {
19618+ async function scheduleBuffer() {
1958019619 if (!this._running) {
1958119620 return;
1958219621 }
1958319622 if (this._buffer.length === 0) {
19584- return this._scheduler.schedule(scheduleBuffer.bind(this), 5000, 'scheduleBuffer');
19623+ this._scheduler.schedule(scheduleBuffer.bind(this), 5000, 'scheduleBuffer');
19624+ return;
1958519625 }
1958619626 const batch = this._buffer;
1958719627 this._buffer = [];
19588- processBuffer.call(this, batch).then(() => {
19589- if (this._running) {
19590- this._scheduler.schedule(scheduleBuffer.bind(this), 5000, 'scheduleBuffer');
19591- }
19592- });
19628+ await processBuffer.call(this, batch);
19629+ if (this._running) {
19630+ this._scheduler.schedule(scheduleBuffer.bind(this), 5000, 'scheduleBuffer');
19631+ }
1959319632 }
1959419633 async function processBuffer(batch) {
1959519634 if (batch.length === 0) {
1959619635 return;
1959719636 }
19598- const events = batch.map(item => {
19599- let event;
19600- if (is.fn(item)) {
19601- event = item();
19602- } else {
19603- event = item;
19604- }
19605- return event;
19606- });
19607- return this._eventGateway.createEvents(events).then(response => {
19637+ const events = batch.map(item => is.fn(item) ? item() : item);
19638+ try {
19639+ const response = await this._eventGateway.createEvents(events);
1960819640 if (this._callback) {
1960919641 this._callback(response);
1961019642 }
1961119643 return response;
19612- }). catch(e => {
19644+ } catch (e) {
1961319645 console.error('Failed to transmit events to Barchart Usage Tracking Service', e);
1961419646 return null;
19615- });
19647+ }
1961619648 }
1961719649 return EventBatcher;
1961819650})();
@@ -19663,111 +19695,107 @@ module.exports = (() => {
1966319695 * @public
1966419696 * @returns {Promise<EventGateway>}
1966519697 */
19666- start() {
19667- return Promise.resolve().then(() => {
19668- if (this._startPromise === null) {
19669- this._startPromise = Promise.resolve().then( () => {
19698+ async start() {
19699+ if (this._startPromise === null) {
19700+ try {
19701+ this._startPromise = (async () => {
1967019702 this._started = true;
1967119703 return this;
19672- }).catch(e => {
19673- this._startPromise = null;
19674- throw e ;
19675- }) ;
19704+ })();
19705+ } catch (e) {
19706+ this._startPromise = null ;
19707+ throw e ;
1967619708 }
19677- return this._startPromise;
19678- }) ;
19709+ }
19710+ return this._startPromise ;
1967919711 }
1968019712
1968119713 /**
1968219714 * Saves one (or many) events.
1968319715 *
1968419716 * @public
19717+ * @async
1968519718 * @param {Schema.Event[]} events
1968619719 * @returns {Promise<Schema.Event[]>}
1968719720 */
19688- createEvents(events) {
19689- return Promise.resolve().then(() => {
19690- checkStart.call(this);
19691- assert.argumentIsArray(events, 'events');
19692- return Gateway.invoke(this._createEventEndpoint, {
19693- events: events.map(event => EventSchema.CLIENT.schema.format(event))
19694- });
19721+ async createEvents(events) {
19722+ checkStart.call(this);
19723+ assert.argumentIsArray(events, 'events');
19724+ return await Gateway.invoke(this._createEventEndpoint, {
19725+ events: events.map(event => EventSchema.CLIENT.schema.format(event))
1969519726 });
1969619727 }
1969719728
1969819729 /**
1969919730 * Creates and starts a new {@link EventGateway} for an environment.
1970019731 *
1970119732 * @public
19733+ * @static
19734+ * @async
1970219735 * @param {String} stage
19703- * @returns {Promise<EventGateway>|Promise< null>}
19736+ * @returns {Promise<EventGateway| null>}
1970419737 */
19705- static for(stage) {
19706- let gatewayPromise;
19738+ static async for(stage) {
1970719739 if (stage === 'staging') {
19708- gatewayPromise = EventGateway.forStaging();
19740+ return await EventGateway.forStaging();
1970919741 } else if (stage === 'production') {
19710- gatewayPromise = EventGateway.forProduction();
19742+ return await EventGateway.forProduction();
1971119743 } else {
19712- gatewayPromise = Promise.resolve( null) ;
19744+ return null;
1971319745 }
19714- return gatewayPromise;
1971519746 }
1971619747
1971719748 /**
1971819749 * Creates and starts a new {@link EventGateway} for the development environment.
1971919750 *
1972019751 * @public
1972119752 * @static
19753+ * @async
1972219754 * @returns {Promise<EventGateway>}
1972319755 */
19724- static forDevelopment() {
19725- return Promise.resolve().then(() => {
19726- return start(new EventGateway('https', Configuration.developmentHost, 443));
19727- });
19756+ static async forDevelopment() {
19757+ return await start(new EventGateway('https', Configuration.developmentHost, 443));
1972819758 }
1972919759
1973019760 /**
1973119761 * Creates and starts a new {@link EventGateway} for the staging environment.
1973219762 *
1973319763 * @public
1973419764 * @static
19765+ * @async
1973519766 * @returns {Promise<EventGateway>}
1973619767 */
19737- static forStaging() {
19738- return Promise.resolve().then(() => {
19739- return start(new EventGateway('https', Configuration.stagingHost, 443));
19740- });
19768+ static async forStaging() {
19769+ return await start(new EventGateway('https', Configuration.stagingHost, 443));
1974119770 }
1974219771
1974319772 /**
1974419773 * Creates and starts a new {@link EventGateway} for the production environment.
1974519774 *
1974619775 * @public
1974719776 * @static
19777+ * @async
1974819778 * @returns {Promise<EventGateway>}
1974919779 */
19750- static forProduction() {
19751- return Promise.resolve().then(() => {
19752- return start(new EventGateway('https', Configuration.productionHost, 443));
19753- });
19780+ static async forProduction() {
19781+ return await start(new EventGateway('https', Configuration.productionHost, 443));
1975419782 }
1975519783 toString() {
1975619784 return '[EventGateway]';
1975719785 }
1975819786 }
19759- function start(gateway) {
19760- return gateway.start().then(() => {
19761- return gateway;
19762- });
19787+ async function start(gateway) {
19788+ await gateway.start();
19789+ return gateway;
1976319790 }
19764- const createEventRequestInterceptor = request => {
19765- return Promise.all(request.data.events.map(event => FailureReason.validateSchema(EventSchema.CLIENT, event))).then(() => {
19766- return Promise.resolve(request);
19767- }).catch(e => {
19791+ const createEventRequestInterceptor = async request => {
19792+ try {
19793+ await Promise.all(request.data.events.map(event => FailureReason.validateSchema(EventSchema.CLIENT, event)));
19794+ return request;
19795+ } catch (e) {
1976819796 console.error('Error serializing data for event creation (using EventSchema.CLIENT schema)', e);
19769- return Promise.reject() ;
19770- });
19797+ throw e ;
19798+ }
1977119799 };
1977219800 const responseInterceptorForEventDeserialization = ResponseInterceptor.fromDelegate((response, ignored) => {
1977319801 return JSON.parse(response.data);
@@ -19788,7 +19816,7 @@ module.exports = (() => {
1978819816 'use strict';
1978919817
1979019818 return {
19791- version: '5.6.4 '
19819+ version: '5.7.0 '
1979219820 };
1979319821})();
1979419822
0 commit comments