@webex/internal-plugin-metrics 3.12.0-next.45 → 3.12.0-next.47
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +239 -1
- package/dist/call-diagnostic/call-diagnostic-metrics.js +21 -2
- package/dist/call-diagnostic/call-diagnostic-metrics.js.map +1 -1
- package/dist/config.js +4 -0
- package/dist/config.js.map +1 -1
- package/dist/index.js +10 -1
- package/dist/index.js.map +1 -1
- package/dist/metrics.js +118 -5
- package/dist/metrics.js.map +1 -1
- package/dist/network-telemetry.js +610 -0
- package/dist/network-telemetry.js.map +1 -0
- package/dist/types/call-diagnostic/call-diagnostic-metrics.d.ts +6 -0
- package/dist/types/config.d.ts +5 -0
- package/dist/types/network-telemetry.d.ts +108 -0
- package/package.json +2 -2
- package/src/call-diagnostic/call-diagnostic-metrics.ts +18 -1
- package/src/config.js +4 -0
- package/src/index.ts +9 -0
- package/src/metrics.js +123 -5
- package/src/network-telemetry.ts +757 -0
- package/test/unit/spec/call-diagnostic/call-diagnostic-metrics.ts +54 -0
- package/test/unit/spec/metrics.js +14 -5
- package/test/unit/spec/network-telemetry.ts +610 -0
|
@@ -841,6 +841,60 @@ describe('internal-plugin-metrics', () => {
|
|
|
841
841
|
userId: 'preLoginId',
|
|
842
842
|
});
|
|
843
843
|
});
|
|
844
|
+
|
|
845
|
+
it('should use the userId from credentials when no device userId is available', () => {
|
|
846
|
+
cd.device.userId = undefined;
|
|
847
|
+
webex.credentials.getUserId = sinon.stub().returns('credentials-user-id');
|
|
848
|
+
|
|
849
|
+
const res = cd.getIdentifiers({
|
|
850
|
+
correlationId: 'correlationId',
|
|
851
|
+
});
|
|
852
|
+
|
|
853
|
+
assert.deepEqual(res, {
|
|
854
|
+
correlationId: 'correlationId',
|
|
855
|
+
locusUrl: 'locus-url',
|
|
856
|
+
deviceId: 'deviceUrl',
|
|
857
|
+
orgId: 'orgId',
|
|
858
|
+
userId: 'credentials-user-id',
|
|
859
|
+
});
|
|
860
|
+
});
|
|
861
|
+
|
|
862
|
+
it('should prefer the device userId over the credentials userId', () => {
|
|
863
|
+
webex.credentials.getUserId = sinon.stub().returns('credentials-user-id');
|
|
864
|
+
|
|
865
|
+
const res = cd.getIdentifiers({
|
|
866
|
+
correlationId: 'correlationId',
|
|
867
|
+
});
|
|
868
|
+
|
|
869
|
+
assert.equal(res.userId, 'userId');
|
|
870
|
+
assert.notCalled(webex.credentials.getUserId);
|
|
871
|
+
});
|
|
872
|
+
|
|
873
|
+
it('should fall back to preLoginId when neither the device nor credentials provide a userId', () => {
|
|
874
|
+
cd.device.userId = undefined;
|
|
875
|
+
webex.credentials.getUserId = sinon.stub().throws(new Error('no user token available'));
|
|
876
|
+
|
|
877
|
+
const res = cd.getIdentifiers({
|
|
878
|
+
correlationId: 'correlationId',
|
|
879
|
+
preLoginId: 'preLoginId',
|
|
880
|
+
});
|
|
881
|
+
|
|
882
|
+
assert.equal(res.userId, 'preLoginId');
|
|
883
|
+
});
|
|
884
|
+
});
|
|
885
|
+
|
|
886
|
+
describe('#getUserIdFromCredentials', () => {
|
|
887
|
+
it('should return the userId from credentials', () => {
|
|
888
|
+
webex.credentials.getUserId = sinon.stub().returns('credentials-user-id');
|
|
889
|
+
|
|
890
|
+
assert.equal(cd.getUserIdFromCredentials(), 'credentials-user-id');
|
|
891
|
+
});
|
|
892
|
+
|
|
893
|
+
it('should return undefined when credentials cannot provide a userId', () => {
|
|
894
|
+
webex.credentials.getUserId = sinon.stub().throws(new Error('no user token available'));
|
|
895
|
+
|
|
896
|
+
assert.isUndefined(cd.getUserIdFromCredentials());
|
|
897
|
+
});
|
|
844
898
|
});
|
|
845
899
|
|
|
846
900
|
it('should prepare diagnostic event successfully', () => {
|
|
@@ -13,7 +13,7 @@ import {BrowserDetection} from '@webex/common';
|
|
|
13
13
|
const {getOSVersion} = BrowserDetection();
|
|
14
14
|
|
|
15
15
|
//@ts-ignore
|
|
16
|
-
global.window = {location: {hostname: 'whatever'}};
|
|
16
|
+
global.window = {location: {hostname: 'whatever', origin: 'https://whatever'}};
|
|
17
17
|
function promiseTick(count) {
|
|
18
18
|
let promise = Promise.resolve();
|
|
19
19
|
|
|
@@ -30,6 +30,7 @@ describe('plugin-metrics', () => {
|
|
|
30
30
|
let webex;
|
|
31
31
|
let metrics;
|
|
32
32
|
let clock;
|
|
33
|
+
let previousWindow;
|
|
33
34
|
|
|
34
35
|
const eventName = 'test_event';
|
|
35
36
|
const mockPayload = {
|
|
@@ -67,10 +68,15 @@ describe('plugin-metrics', () => {
|
|
|
67
68
|
|
|
68
69
|
beforeEach(() => {
|
|
69
70
|
clock = FakeTimers.install({now: 0});
|
|
71
|
+
previousWindow = global.window;
|
|
72
|
+
// Other test files also replace the shared browser mock. Restore the
|
|
73
|
+
// location needed to verify that app_url prefers the browser origin.
|
|
74
|
+
global.window = {location: {hostname: 'whatever', origin: 'https://whatever'}};
|
|
70
75
|
});
|
|
71
76
|
|
|
72
77
|
afterEach(() => {
|
|
73
78
|
clock.uninstall();
|
|
79
|
+
global.window = previousWindow;
|
|
74
80
|
});
|
|
75
81
|
|
|
76
82
|
beforeEach(() => {
|
|
@@ -107,10 +113,10 @@ describe('plugin-metrics', () => {
|
|
|
107
113
|
webex.meetings = {
|
|
108
114
|
config: {
|
|
109
115
|
metrics: {
|
|
110
|
-
clientVersion: '43.0.105'
|
|
111
|
-
}
|
|
112
|
-
}
|
|
113
|
-
}
|
|
116
|
+
clientVersion: '43.0.105',
|
|
117
|
+
},
|
|
118
|
+
},
|
|
119
|
+
};
|
|
114
120
|
|
|
115
121
|
sinon.spy(webex, 'request');
|
|
116
122
|
sinon.spy(metrics, 'aliasUser');
|
|
@@ -186,6 +192,9 @@ describe('plugin-metrics', () => {
|
|
|
186
192
|
},
|
|
187
193
|
metricName: 'test',
|
|
188
194
|
tags: {
|
|
195
|
+
app_name: 'appName',
|
|
196
|
+
app_url: 'https://whatever',
|
|
197
|
+
app_version: 'appVersion',
|
|
189
198
|
appVersion: '43.0.105',
|
|
190
199
|
browser: '',
|
|
191
200
|
domain: 'whatever',
|