Socket
Socket
Sign inDemoInstall

@webex/internal-plugin-metrics

Package Overview
Dependencies
Maintainers
21
Versions
1205
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@webex/internal-plugin-metrics - npm Package Compare versions

Comparing version 1.59.0 to 1.60.1

8

dist/batcher.js

@@ -30,3 +30,3 @@ 'use strict';

/*!
* Copyright (c) 2015-2017 Cisco Systems, Inc. See LICENSE file.
* Copyright (c) 2015-2019 Cisco Systems, Inc. See LICENSE file.
*/

@@ -46,3 +46,3 @@

item.time = item.time || Date.now();
item.version = item.version || this.spark.version;
item.version = item.version || this.webex.version;

@@ -59,3 +59,3 @@ return _promise2.default.resolve(item);

submitHttpRequest: function submitHttpRequest(payload) {
return this.spark.request({
return this.webex.request({
method: 'POST',

@@ -79,3 +79,3 @@ service: 'metrics',

if (reason instanceof _webexCore.SparkHttpError.NetworkOrCORSError) {
if (reason instanceof _webexCore.WebexHttpError.NetworkOrCORSError) {
this.logger.warn('metrics-batcher: received network error submitting metrics, reenqueuing payload');

@@ -82,0 +82,0 @@

@@ -45,3 +45,3 @@ 'use strict';

submitHttpRequest: function submitHttpRequest(payload) {
return this.spark.request({
return this.webex.request({
method: 'POST',

@@ -56,3 +56,3 @@ service: 'metrics',

}); /*!
* Copyright (c) 2015-2017 Cisco Systems, Inc. See LICENSE file.
* Copyright (c) 2015-2019 Cisco Systems, Inc. See LICENSE file.
*/

@@ -59,0 +59,0 @@

@@ -28,3 +28,3 @@ 'use strict';

submitHttpRequest: function submitHttpRequest(payload) {
return this.spark.request({
return this.webex.request({
method: 'POST',

@@ -39,3 +39,3 @@ service: 'metrics',

}); /*!
* Copyright (c) 2015-2017 Cisco Systems, Inc. See LICENSE file.
* Copyright (c) 2015-2019 Cisco Systems, Inc. See LICENSE file.
*/

@@ -42,0 +42,0 @@

@@ -24,4 +24,4 @@ 'use strict';

}; /*!
* Copyright (c) 2015-2017 Cisco Systems, Inc. See LICENSE file.
* Copyright (c) 2015-2019 Cisco Systems, Inc. See LICENSE file.
*/
//# sourceMappingURL=config.js.map

@@ -30,3 +30,3 @@ 'use strict';

/*!
* Copyright (c) 2015-2017 Cisco Systems, Inc. See LICENSE file.
* Copyright (c) 2015-2019 Cisco Systems, Inc. See LICENSE file.
*/

@@ -33,0 +33,0 @@

@@ -16,3 +16,3 @@ 'use strict';

var _dec, _desc, _value, _obj; /*!
* Copyright (c) 2015-2017 Cisco Systems, Inc. See LICENSE file.
* Copyright (c) 2015-2019 Cisco Systems, Inc. See LICENSE file.
*/

@@ -67,3 +67,3 @@

var Metrics = _webexCore.SparkPlugin.extend((_dec = (0, _common.deprecated)('Metrics#sendUnstructured() is deprecated; please use Metrics#submit()'), (_obj = {
var Metrics = _webexCore.WebexPlugin.extend((_dec = (0, _common.deprecated)('Metrics#sendUnstructured() is deprecated; please use Metrics#submit()'), (_obj = {
children: {

@@ -147,3 +147,3 @@ batcher: _batcher2.default,

return this.spark.credentials.getClientToken().then(function (token) {
return this.webex.credentials.getClientToken().then(function (token) {
return _this.request({

@@ -169,3 +169,3 @@ method: 'POST',

},
version: '1.59.0'
version: '1.60.1'
}, (_applyDecoratedDescriptor(_obj, 'sendUnstructured', [_dec], (0, _getOwnPropertyDescriptor2.default)(_obj, 'sendUnstructured'), _obj)), _obj)));

@@ -172,0 +172,0 @@

{
"name": "@webex/internal-plugin-metrics",
"version": "1.59.0",
"version": "1.60.1",
"description": "",

@@ -9,3 +9,3 @@ "license": "MIT",

"devMain": "src/index.js",
"repository": "https://github.com/webex/spark-js-sdk/tree/master/packages/node_modules/@webex/internal-plugin-metrics",
"repository": "https://github.com/webex/webex-js-sdk/tree/master/packages/node_modules/@webex/internal-plugin-metrics",
"engines": {

@@ -21,8 +21,8 @@ "node": ">=4"

"babel-runtime": "^6.23.0",
"@webex/webex-core": "1.59.0",
"@webex/common": "1.59.0",
"@webex/common-timers": "1.58.5",
"@webex/internal-plugin-wdm": "1.59.0",
"@webex/webex-core": "1.60.1",
"@webex/common": "1.60.1",
"@webex/common-timers": "1.60.1",
"@webex/internal-plugin-wdm": "1.60.1",
"envify": "^4.1.0"
}
}

@@ -27,6 +27,6 @@ # @webex/internal-plugin-metrics

import SparkCore from '@webex/webex-core';
import WebexCore from '@webex/webex-core';
const spark = new SparkCore();
spark.internal.metrics.WHATEVER
const webex = new WebexCore();
webex.internal.metrics.WHATEVER

@@ -41,3 +41,3 @@ ```

Pull requests welcome. Please see [CONTRIBUTING.md](https://github.com/webex/spark-js-sdk/blob/master/CONTRIBUTING.md) for more details.
Pull requests welcome. Please see [CONTRIBUTING.md](https://github.com/webex/webex-js-sdk/blob/master/CONTRIBUTING.md) for more details.

@@ -44,0 +44,0 @@ ## License

/*!
* Copyright (c) 2015-2017 Cisco Systems, Inc. See LICENSE file.
* Copyright (c) 2015-2019 Cisco Systems, Inc. See LICENSE file.
*/
import {Batcher, SparkHttpError} from '@webex/webex-core';
import {Batcher, WebexHttpError} from '@webex/webex-core';
import {safeSetTimeout} from '@webex/common-timers';

@@ -20,3 +20,3 @@

item.time = item.time || Date.now();
item.version = item.version || this.spark.version;
item.version = item.version || this.webex.version;

@@ -35,3 +35,3 @@ return Promise.resolve(item);

submitHttpRequest(payload) {
return this.spark.request({
return this.webex.request({
method: 'POST',

@@ -51,3 +51,3 @@ service: 'metrics',

handleHttpError(reason) {
if (reason instanceof SparkHttpError.NetworkOrCORSError) {
if (reason instanceof WebexHttpError.NetworkOrCORSError) {
this.logger.warn('metrics-batcher: received network error submitting metrics, reenqueuing payload');

@@ -54,0 +54,0 @@

/*!
* Copyright (c) 2015-2017 Cisco Systems, Inc. See LICENSE file.
* Copyright (c) 2015-2019 Cisco Systems, Inc. See LICENSE file.
*/

@@ -33,3 +33,3 @@

submitHttpRequest(payload) {
return this.spark.request({
return this.webex.request({
method: 'POST',

@@ -36,0 +36,0 @@ service: 'metrics',

/*!
* Copyright (c) 2015-2017 Cisco Systems, Inc. See LICENSE file.
* Copyright (c) 2015-2019 Cisco Systems, Inc. See LICENSE file.
*/

@@ -20,3 +20,3 @@

submitHttpRequest(payload) {
return this.spark.request({
return this.webex.request({
method: 'POST',

@@ -23,0 +23,0 @@ service: 'metrics',

/*!
* Copyright (c) 2015-2017 Cisco Systems, Inc. See LICENSE file.
* Copyright (c) 2015-2019 Cisco Systems, Inc. See LICENSE file.
*/

@@ -4,0 +4,0 @@

/*!
* Copyright (c) 2015-2017 Cisco Systems, Inc. See LICENSE file.
* Copyright (c) 2015-2019 Cisco Systems, Inc. See LICENSE file.
*/

@@ -4,0 +4,0 @@

/*!
* Copyright (c) 2015-2017 Cisco Systems, Inc. See LICENSE file.
* Copyright (c) 2015-2019 Cisco Systems, Inc. See LICENSE file.
*/
import {SparkPlugin} from '@webex/webex-core';
import {WebexPlugin} from '@webex/webex-core';
import {deprecated} from '@webex/common';

@@ -12,3 +12,3 @@

const Metrics = SparkPlugin.extend({
const Metrics = WebexPlugin.extend({
children: {

@@ -91,3 +91,3 @@ batcher: Batcher,

postPreLoginMetric(payload, preLoginId) {
return this.spark.credentials.getClientToken().then((token) =>
return this.webex.credentials.getClientToken().then((token) =>
this.request({

@@ -94,0 +94,0 @@ method: 'POST',

/*!
* Copyright (c) 2015-2017 Cisco Systems, Inc. See LICENSE file.
* Copyright (c) 2015-2019 Cisco Systems, Inc. See LICENSE file.
*/

@@ -8,5 +8,5 @@

import Metrics, {config} from '@webex/internal-plugin-metrics';
import MockSpark from '@webex/test-helper-mock-webex';
import MockWebex from '@webex/test-helper-mock-webex';
import sinon from '@webex/test-helper-sinon';
import {SparkHttpError} from '@webex/webex-core';
import {WebexHttpError} from '@webex/webex-core';

@@ -26,6 +26,6 @@ function promiseTick(count) {

describe('MetricsBatcher', () => {
let spark;
let webex;
beforeEach(() => {
spark = new MockSpark({
webex = new MockWebex({
children: {

@@ -36,5 +36,5 @@ metrics: Metrics

spark.config.metrics = config.metrics;
webex.config.metrics = config.metrics;
spark.request = function (options) {
webex.request = function (options) {
return Promise.resolve({

@@ -46,3 +46,3 @@ statusCode: 204,

};
sinon.spy(spark, 'request');
sinon.spy(webex, 'request');
});

@@ -65,8 +65,8 @@

return spark.internal.metrics.batcher.request({
return webex.internal.metrics.batcher.request({
key: 'testMetric'
})
.then(() => {
assert.calledOnce(spark.request);
assert.lengthOf(spark.internal.metrics.batcher.queue, 0);
assert.calledOnce(webex.request);
assert.lengthOf(webex.internal.metrics.batcher.queue, 0);
});

@@ -81,3 +81,3 @@ });

// desire
spark.request = function () {
webex.request = function () {
// noop

@@ -87,3 +87,3 @@ };

sinon.stub(spark, 'request').callsFake((options) => {
sinon.stub(webex, 'request').callsFake((options) => {
options.headers = {

@@ -95,3 +95,3 @@ trackingid: count

if (count < 9) {
return Promise.reject(new SparkHttpError.NetworkOrCORSError({
return Promise.reject(new WebexHttpError.NetworkOrCORSError({
statusCode: 0,

@@ -109,3 +109,3 @@ options

const promise = spark.internal.metrics.batcher.request({
const promise = webex.internal.metrics.batcher.request({
key: 'testMetric'

@@ -115,5 +115,5 @@ });

return promiseTick(50)
.then(() => assert.lengthOf(spark.internal.metrics.batcher.queue, 1))
.then(() => assert.lengthOf(webex.internal.metrics.batcher.queue, 1))
.then(() => clock.tick(config.metrics.batcherWait))
.then(() => assert.calledOnce(spark.request))
.then(() => assert.calledOnce(webex.request))

@@ -124,3 +124,3 @@ .then(() => promiseTick(50))

.then(() => clock.tick(config.metrics.batcherWait))
.then(() => assert.calledTwice(spark.request))
.then(() => assert.calledTwice(webex.request))

@@ -131,3 +131,3 @@ .then(() => promiseTick(50))

.then(() => clock.tick(config.metrics.batcherWait))
.then(() => assert.calledThrice(spark.request))
.then(() => assert.calledThrice(webex.request))

@@ -138,3 +138,3 @@ .then(() => promiseTick(50))

.then(() => clock.tick(config.metrics.batcherWait))
.then(() => assert.callCount(spark.request, 4))
.then(() => assert.callCount(webex.request, 4))

@@ -145,3 +145,3 @@ .then(() => promiseTick(50))

.then(() => clock.tick(config.metrics.batcherWait))
.then(() => assert.callCount(spark.request, 5))
.then(() => assert.callCount(webex.request, 5))

@@ -152,3 +152,3 @@ .then(() => promiseTick(50))

.then(() => clock.tick(config.metrics.batcherWait))
.then(() => assert.callCount(spark.request, 6))
.then(() => assert.callCount(webex.request, 6))

@@ -159,3 +159,3 @@ .then(() => promiseTick(50))

.then(() => clock.tick(config.metrics.batcherWait))
.then(() => assert.callCount(spark.request, 7))
.then(() => assert.callCount(webex.request, 7))

@@ -166,3 +166,3 @@ .then(() => promiseTick(50))

.then(() => clock.tick(config.metrics.batcherWait))
.then(() => assert.callCount(spark.request, 8))
.then(() => assert.callCount(webex.request, 8))

@@ -173,11 +173,11 @@ .then(() => promiseTick(50))

.then(() => clock.tick(config.metrics.batcherWait))
.then(() => assert.callCount(spark.request, 9))
.then(() => assert.callCount(webex.request, 9))
.then(() => promiseTick(50))
.then(() => assert.lengthOf(spark.internal.metrics.batcher.queue, 0))
.then(() => assert.lengthOf(webex.internal.metrics.batcher.queue, 0))
.then(() => promise)
.then(() => {
assert.lengthOf(spark.request.args[1][0].body.metrics, 1, 'Reenqueuing the metric once did not increase the number of metrics to be submitted');
assert.lengthOf(spark.request.args[2][0].body.metrics, 1, 'Reenqueuing the metric twice did not increase the number of metrics to be submitted');
assert.lengthOf(spark.internal.metrics.batcher.queue, 0);
assert.lengthOf(webex.request.args[1][0].body.metrics, 1, 'Reenqueuing the metric once did not increase the number of metrics to be submitted');
assert.lengthOf(webex.request.args[2][0].body.metrics, 1, 'Reenqueuing the metric twice did not increase the number of metrics to be submitted');
assert.lengthOf(webex.internal.metrics.batcher.queue, 0);
});

@@ -184,0 +184,0 @@ });

/*!
* Copyright (c) 2015-2017 Cisco Systems, Inc. See LICENSE file.
* Copyright (c) 2015-2019 Cisco Systems, Inc. See LICENSE file.
*/

@@ -8,5 +8,5 @@

import Metrics, {config} from '@webex/internal-plugin-metrics';
import MockSpark from '@webex/test-helper-mock-webex';
import MockWebex from '@webex/test-helper-mock-webex';
import sinon from '@webex/test-helper-sinon';
import {SparkHttpError} from '@webex/webex-core';
import {WebexHttpError} from '@webex/webex-core';

@@ -26,6 +26,6 @@ function promiseTick(count) {

describe('callDiagnosticEventsBatcher', () => {
let spark;
let webex;
beforeEach(() => {
spark = new MockSpark({
webex = new MockWebex({
children: {

@@ -36,5 +36,5 @@ metrics: Metrics

spark.config.metrics = config.metrics;
webex.config.metrics = config.metrics;
spark.request = function (options) {
webex.request = function (options) {
return Promise.resolve({

@@ -46,3 +46,3 @@ statusCode: 204,

};
sinon.spy(spark, 'request');
sinon.spy(webex, 'request');
});

@@ -65,3 +65,3 @@

return spark.internal.metrics.callDiagnosticEventsBatcher.request({
return webex.internal.metrics.callDiagnosticEventsBatcher.request({
type: 'diagnostic-event',

@@ -75,4 +75,4 @@ eventPayload: {

.then(() => {
assert.calledOnce(spark.request);
assert.lengthOf(spark.internal.metrics.callDiagnosticEventsBatcher.queue, 0);
assert.calledOnce(webex.request);
assert.lengthOf(webex.internal.metrics.callDiagnosticEventsBatcher.queue, 0);
});

@@ -87,3 +87,3 @@ });

// desire
spark.request = function () {
webex.request = function () {
// noop

@@ -93,3 +93,3 @@ };

sinon.stub(spark, 'request').callsFake((options) => {
sinon.stub(webex, 'request').callsFake((options) => {
options.headers = {

@@ -101,3 +101,3 @@ trackingid: count

if (count < 9) {
return Promise.reject(new SparkHttpError.NetworkOrCORSError({
return Promise.reject(new WebexHttpError.NetworkOrCORSError({
statusCode: 0,

@@ -115,3 +115,3 @@ options

const promise = spark.internal.metrics.callDiagnosticEventsBatcher.request({
const promise = webex.internal.metrics.callDiagnosticEventsBatcher.request({
type: 'diagnostic-event',

@@ -126,5 +126,5 @@ eventPayload: {

return promiseTick(50)
.then(() => assert.lengthOf(spark.internal.metrics.callDiagnosticEventsBatcher.queue, 1))
.then(() => assert.lengthOf(webex.internal.metrics.callDiagnosticEventsBatcher.queue, 1))
.then(() => clock.tick(config.metrics.batcherWait))
.then(() => assert.calledOnce(spark.request))
.then(() => assert.calledOnce(webex.request))

@@ -135,3 +135,3 @@ .then(() => promiseTick(50))

.then(() => clock.tick(config.metrics.batcherWait))
.then(() => assert.calledTwice(spark.request))
.then(() => assert.calledTwice(webex.request))

@@ -142,3 +142,3 @@ .then(() => promiseTick(50))

.then(() => clock.tick(config.metrics.batcherWait))
.then(() => assert.calledThrice(spark.request))
.then(() => assert.calledThrice(webex.request))

@@ -149,3 +149,3 @@ .then(() => promiseTick(50))

.then(() => clock.tick(config.metrics.batcherWait))
.then(() => assert.callCount(spark.request, 4))
.then(() => assert.callCount(webex.request, 4))

@@ -156,3 +156,3 @@ .then(() => promiseTick(50))

.then(() => clock.tick(config.metrics.batcherWait))
.then(() => assert.callCount(spark.request, 5))
.then(() => assert.callCount(webex.request, 5))

@@ -163,3 +163,3 @@ .then(() => promiseTick(50))

.then(() => clock.tick(config.metrics.batcherWait))
.then(() => assert.callCount(spark.request, 6))
.then(() => assert.callCount(webex.request, 6))

@@ -170,3 +170,3 @@ .then(() => promiseTick(50))

.then(() => clock.tick(config.metrics.batcherWait))
.then(() => assert.callCount(spark.request, 7))
.then(() => assert.callCount(webex.request, 7))

@@ -177,3 +177,3 @@ .then(() => promiseTick(50))

.then(() => clock.tick(config.metrics.batcherWait))
.then(() => assert.callCount(spark.request, 8))
.then(() => assert.callCount(webex.request, 8))

@@ -184,11 +184,11 @@ .then(() => promiseTick(50))

.then(() => clock.tick(config.metrics.batcherWait))
.then(() => assert.callCount(spark.request, 9))
.then(() => assert.callCount(webex.request, 9))
.then(() => promiseTick(50))
.then(() => assert.lengthOf(spark.internal.metrics.callDiagnosticEventsBatcher.queue, 0))
.then(() => assert.lengthOf(webex.internal.metrics.callDiagnosticEventsBatcher.queue, 0))
.then(() => promise)
.then(() => {
assert.lengthOf(spark.request.args[1][0].body.metrics, 1, 'Reenqueuing the metric once did not increase the number of metrics to be submitted');
assert.lengthOf(spark.request.args[2][0].body.metrics, 1, 'Reenqueuing the metric twice did not increase the number of metrics to be submitted');
assert.lengthOf(spark.internal.metrics.callDiagnosticEventsBatcher.queue, 0);
assert.lengthOf(webex.request.args[1][0].body.metrics, 1, 'Reenqueuing the metric once did not increase the number of metrics to be submitted');
assert.lengthOf(webex.request.args[2][0].body.metrics, 1, 'Reenqueuing the metric twice did not increase the number of metrics to be submitted');
assert.lengthOf(webex.internal.metrics.callDiagnosticEventsBatcher.queue, 0);
});

@@ -195,0 +195,0 @@ });

/*!
* Copyright (c) 2015-2017 Cisco Systems, Inc. See LICENSE file.
* Copyright (c) 2015-2019 Cisco Systems, Inc. See LICENSE file.
*/

@@ -8,5 +8,5 @@

import Metrics, {config} from '@webex/internal-plugin-metrics';
import MockSpark from '@webex/test-helper-mock-webex';
import MockWebex from '@webex/test-helper-mock-webex';
import sinon from '@webex/test-helper-sinon';
import {SparkHttpError} from '@webex/webex-core';
import {WebexHttpError} from '@webex/webex-core';

@@ -26,6 +26,6 @@ function promiseTick(count) {

describe('ClientMetricsBatcher', () => {
let spark;
let webex;
beforeEach(() => {
spark = new MockSpark({
webex = new MockWebex({
children: {

@@ -36,5 +36,5 @@ metrics: Metrics

spark.config.metrics = config.metrics;
webex.config.metrics = config.metrics;
spark.request = function (options) {
webex.request = function (options) {
return Promise.resolve({

@@ -46,3 +46,3 @@ statusCode: 204,

};
sinon.spy(spark, 'request');
sinon.spy(webex, 'request');
});

@@ -65,8 +65,8 @@

return spark.internal.metrics.clientMetricsBatcher.request({
return webex.internal.metrics.clientMetricsBatcher.request({
key: 'testMetric'
})
.then(() => {
assert.calledOnce(spark.request);
assert.lengthOf(spark.internal.metrics.clientMetricsBatcher.queue, 0);
assert.calledOnce(webex.request);
assert.lengthOf(webex.internal.metrics.clientMetricsBatcher.queue, 0);
});

@@ -81,3 +81,3 @@ });

// desire
spark.request = function () {
webex.request = function () {
// noop

@@ -87,3 +87,3 @@ };

sinon.stub(spark, 'request').callsFake((options) => {
sinon.stub(webex, 'request').callsFake((options) => {
options.headers = {

@@ -95,3 +95,3 @@ trackingid: count

if (count < 9) {
return Promise.reject(new SparkHttpError.NetworkOrCORSError({
return Promise.reject(new WebexHttpError.NetworkOrCORSError({
statusCode: 0,

@@ -109,3 +109,3 @@ options

const promise = spark.internal.metrics.clientMetricsBatcher.request({
const promise = webex.internal.metrics.clientMetricsBatcher.request({
key: 'testMetric'

@@ -115,5 +115,5 @@ });

return promiseTick(50)
.then(() => assert.lengthOf(spark.internal.metrics.clientMetricsBatcher.queue, 1))
.then(() => assert.lengthOf(webex.internal.metrics.clientMetricsBatcher.queue, 1))
.then(() => clock.tick(config.metrics.batcherWait))
.then(() => assert.calledOnce(spark.request))
.then(() => assert.calledOnce(webex.request))

@@ -124,3 +124,3 @@ .then(() => promiseTick(50))

.then(() => clock.tick(config.metrics.batcherWait))
.then(() => assert.calledTwice(spark.request))
.then(() => assert.calledTwice(webex.request))

@@ -131,3 +131,3 @@ .then(() => promiseTick(50))

.then(() => clock.tick(config.metrics.batcherWait))
.then(() => assert.calledThrice(spark.request))
.then(() => assert.calledThrice(webex.request))

@@ -138,3 +138,3 @@ .then(() => promiseTick(50))

.then(() => clock.tick(config.metrics.batcherWait))
.then(() => assert.callCount(spark.request, 4))
.then(() => assert.callCount(webex.request, 4))

@@ -145,3 +145,3 @@ .then(() => promiseTick(50))

.then(() => clock.tick(config.metrics.batcherWait))
.then(() => assert.callCount(spark.request, 5))
.then(() => assert.callCount(webex.request, 5))

@@ -152,3 +152,3 @@ .then(() => promiseTick(50))

.then(() => clock.tick(config.metrics.batcherWait))
.then(() => assert.callCount(spark.request, 6))
.then(() => assert.callCount(webex.request, 6))

@@ -159,3 +159,3 @@ .then(() => promiseTick(50))

.then(() => clock.tick(config.metrics.batcherWait))
.then(() => assert.callCount(spark.request, 7))
.then(() => assert.callCount(webex.request, 7))

@@ -166,3 +166,3 @@ .then(() => promiseTick(50))

.then(() => clock.tick(config.metrics.batcherWait))
.then(() => assert.callCount(spark.request, 8))
.then(() => assert.callCount(webex.request, 8))

@@ -173,11 +173,11 @@ .then(() => promiseTick(50))

.then(() => clock.tick(config.metrics.batcherWait))
.then(() => assert.callCount(spark.request, 9))
.then(() => assert.callCount(webex.request, 9))
.then(() => promiseTick(50))
.then(() => assert.lengthOf(spark.internal.metrics.clientMetricsBatcher.queue, 0))
.then(() => assert.lengthOf(webex.internal.metrics.clientMetricsBatcher.queue, 0))
.then(() => promise)
.then(() => {
assert.lengthOf(spark.request.args[1][0].body.metrics, 1, 'Reenqueuing the metric once did not increase the number of metrics to be submitted');
assert.lengthOf(spark.request.args[2][0].body.metrics, 1, 'Reenqueuing the metric twice did not increase the number of metrics to be submitted');
assert.lengthOf(spark.internal.metrics.clientMetricsBatcher.queue, 0);
assert.lengthOf(webex.request.args[1][0].body.metrics, 1, 'Reenqueuing the metric once did not increase the number of metrics to be submitted');
assert.lengthOf(webex.request.args[2][0].body.metrics, 1, 'Reenqueuing the metric twice did not increase the number of metrics to be submitted');
assert.lengthOf(webex.internal.metrics.clientMetricsBatcher.queue, 0);
});

@@ -184,0 +184,0 @@ });

/*!
* Copyright (c) 2015-2017 Cisco Systems, Inc. See LICENSE file.
* Copyright (c) 2015-2019 Cisco Systems, Inc. See LICENSE file.
*/

@@ -7,3 +7,3 @@

import Metrics, {config} from '@webex/internal-plugin-metrics';
import MockSpark from '@webex/test-helper-mock-webex';
import MockWebex from '@webex/test-helper-mock-webex';
import lolex from 'lolex';

@@ -25,3 +25,3 @@ import sinon from '@webex/test-helper-sinon';

describe('Metrics', () => {
let spark;
let webex;
let metrics;

@@ -72,3 +72,3 @@ let clock;

beforeEach(() => {
spark = new MockSpark({
webex = new MockWebex({
children: {

@@ -79,6 +79,6 @@ metrics: Metrics

spark.config.metrics = config.metrics;
metrics = spark.internal.metrics;
webex.config.metrics = config.metrics;
metrics = webex.internal.metrics;
spark.request = function (options) {
webex.request = function (options) {
return Promise.resolve({

@@ -90,3 +90,3 @@ statusCode: 204,

};
sinon.spy(spark, 'request');
sinon.spy(webex, 'request');
sinon.spy(metrics, 'postPreLoginMetric');

@@ -105,4 +105,4 @@ sinon.spy(metrics, 'aliasUser');

.then(() => {
assert.calledOnce(spark.request);
const req = spark.request.args[0][0];
assert.calledOnce(webex.request);
const req = webex.request.args[0][0];
const metric = req.body.metrics[0];

@@ -118,3 +118,3 @@

assert.equal(metric.key, 'testMetric');
assert.equal(metric.version, spark.version);
assert.equal(metric.version, webex.version);
assert.equal(metric.env, 'TEST');

@@ -136,5 +136,5 @@ });

assert.called(metrics.postPreLoginMetric);
assert.calledOnce(spark.credentials.getClientToken);
assert.calledOnce(spark.request);
const req = spark.request.args[0][0];
assert.calledOnce(webex.credentials.getClientToken);
assert.calledOnce(webex.request);
const req = webex.request.args[0][0];
const metric = req.body.metrics[0];

@@ -170,4 +170,4 @@

.then(() => {
assert.calledOnce(spark.request);
const req = spark.request.args[0][0];
assert.calledOnce(webex.request);
const req = webex.request.args[0][0];
const metric = req.body.metrics[0];

@@ -198,4 +198,4 @@

.then(() => {
assert.calledOnce(spark.request);
const req = spark.request.args[0][0];
assert.calledOnce(webex.request);
const req = webex.request.args[0][0];
const metric = req.body.metrics[0];

@@ -221,4 +221,4 @@ const {headers} = req;

metrics.aliasUser(preLoginId).then(() => {
assert.calledOnce(spark.request);
const req = spark.request.args[0][0];
assert.calledOnce(webex.request);
const req = webex.request.args[0][0];
const params = req.qs;

@@ -238,4 +238,4 @@

.then(() => {
assert.calledOnce(spark.request);
const req = spark.request.args[0][0];
assert.calledOnce(webex.request);
const req = webex.request.args[0][0];
const metric = req.body.metrics[0];

@@ -242,0 +242,0 @@

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc