@webex/internal-plugin-metrics 3.12.0-next.52 → 3.12.0-next.53

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.
@@ -3784,7 +3784,7 @@ describe('internal-plugin-metrics', () => {
3784
3784
  serviceErrorCode: undefined,
3785
3785
  errorCode: 1026,
3786
3786
  rawErrorMessage: '{}\nundefined https://example.com\nWEBEX_TRACKING_ID: undefined\n',
3787
- httpStatusCode: 0,
3787
+ httpCode: 0,
3788
3788
  });
3789
3789
  });
3790
3790
 
@@ -3901,7 +3901,7 @@ describe('internal-plugin-metrics', () => {
3901
3901
  serviceErrorCode: undefined,
3902
3902
  errorCode: 1026,
3903
3903
  rawErrorMessage: '{}\nundefined https://example.com\nWEBEX_TRACKING_ID: undefined\n',
3904
- httpStatusCode: 0,
3904
+ httpCode: 0,
3905
3905
  });
3906
3906
  });
3907
3907
 
@@ -3923,7 +3923,7 @@ describe('internal-plugin-metrics', () => {
3923
3923
  serviceErrorCode: undefined,
3924
3924
  errorCode: 1010,
3925
3925
  rawErrorMessage: '{}\nundefined https://example.com\nWEBEX_TRACKING_ID: undefined\n',
3926
- httpStatusCode: 0,
3926
+ httpCode: 0,
3927
3927
  });
3928
3928
  });
3929
3929
 
@@ -3949,7 +3949,7 @@ describe('internal-plugin-metrics', () => {
3949
3949
  serviceErrorCode: undefined,
3950
3950
  errorCode: 1010,
3951
3951
  rawErrorMessage: '{}\nundefined https://example.com\nWEBEX_TRACKING_ID: undefined\n',
3952
- httpStatusCode: 0,
3952
+ httpCode: 0,
3953
3953
  });
3954
3954
  });
3955
3955
 
@@ -4054,8 +4054,144 @@ describe('internal-plugin-metrics', () => {
4054
4054
  });
4055
4055
  });
4056
4056
 
4057
- describe('httpStatusCode', () => {
4058
- it('should include httpStatusCode for browser media errors', () => {
4057
+ describe('httpCode', () => {
4058
+ it('should identify an outgoing Locus 429', () => {
4059
+ const rawErrorMessage =
4060
+ 'partition 371 on PARALLEL_EXECUTOR_PARTITION_KEY_QUEUE_FULL state';
4061
+ const [res] = cd.generateClientEventErrorPayload({
4062
+ message: rawErrorMessage,
4063
+ statusCode: 429,
4064
+ options: {uri: 'https://locus.example.com/locus/api/v1/loci/call'},
4065
+ });
4066
+
4067
+ assert.deepEqual(res, {
4068
+ category: 'signaling',
4069
+ errorCode: 1002,
4070
+ errorDescription: 'LocusRateLimitedOutgoing',
4071
+ fatal: true,
4072
+ name: 'locus.response',
4073
+ rawErrorMessage,
4074
+ serviceErrorCode: undefined,
4075
+ shownToUser: false,
4076
+ httpCode: 429,
4077
+ });
4078
+ });
4079
+
4080
+ [
4081
+ ['media', 'https://example.com/locus/api/v1/loci/123/media'],
4082
+ ['hashtree', 'https://example.com/locus/api/v1/loci/123/hashtree'],
4083
+ ['host-only Locus URL', 'https://locus.example.com/api/v1/resource'],
4084
+ ['query-only Locus URL', 'https://example.com/api/v1/resource?service=locus'],
4085
+ ].forEach(([operation, uri]) => {
4086
+ it(`should identify a Locus 429 for ${operation}`, () => {
4087
+ const [res] = cd.generateClientEventErrorPayload({
4088
+ message: 'Locus rate limited',
4089
+ statusCode: 429,
4090
+ options: {uri},
4091
+ });
4092
+
4093
+ assert.equal(res.errorCode, 1002);
4094
+ assert.equal(res.errorDescription, 'LocusRateLimitedOutgoing');
4095
+ assert.equal(res.httpCode, 429);
4096
+ });
4097
+ });
4098
+
4099
+ it('should identify an unavailable Locus 503', () => {
4100
+ const rawErrorMessage = 'Service unavailable';
4101
+ const [res] = cd.generateClientEventErrorPayload({
4102
+ message: rawErrorMessage,
4103
+ statusCode: 503,
4104
+ options: {uri: 'https://locus.example.com/locus/api/v1/loci/call'},
4105
+ });
4106
+
4107
+ assert.deepEqual(res, {
4108
+ category: 'signaling',
4109
+ errorCode: 1003,
4110
+ errorDescription: 'LocusUnavailable',
4111
+ fatal: true,
4112
+ name: 'locus.response',
4113
+ rawErrorMessage,
4114
+ serviceErrorCode: undefined,
4115
+ shownToUser: false,
4116
+ httpCode: 503,
4117
+ });
4118
+ });
4119
+
4120
+ it('should prefer a specific service error mapping over the Locus HTTP status', () => {
4121
+ const rawErrorMessage = 'Fraud detected';
4122
+ const [res] = cd.generateClientEventErrorPayload({
4123
+ body: {errorCode: 2423012},
4124
+ message: rawErrorMessage,
4125
+ statusCode: 429,
4126
+ options: {uri: 'https://locus.example.com/locus/api/v1/loci/call'},
4127
+ });
4128
+
4129
+ assert.deepEqual(res, {
4130
+ category: 'expected',
4131
+ errorCode: 12000,
4132
+ errorDescription: 'FraudDetection',
4133
+ fatal: true,
4134
+ name: 'locus.response',
4135
+ rawErrorMessage,
4136
+ serviceErrorCode: 2423012,
4137
+ shownToUser: true,
4138
+ httpCode: 429,
4139
+ });
4140
+ });
4141
+
4142
+ it('should retain an unmapped service error code on the Locus HTTP status payload', () => {
4143
+ const rawErrorMessage = 'Locus rate limited';
4144
+ const [res] = cd.generateClientEventErrorPayload({
4145
+ body: {errorCode: 2429999},
4146
+ message: rawErrorMessage,
4147
+ statusCode: 429,
4148
+ options: {uri: 'https://locus.example.com/locus/api/v1/loci/call'},
4149
+ });
4150
+
4151
+ assert.deepEqual(res, {
4152
+ category: 'signaling',
4153
+ errorCode: 1002,
4154
+ errorDescription: 'LocusRateLimitedOutgoing',
4155
+ fatal: true,
4156
+ name: 'locus.response',
4157
+ rawErrorMessage,
4158
+ serviceErrorCode: 2429999,
4159
+ shownToUser: false,
4160
+ httpCode: 429,
4161
+ });
4162
+ });
4163
+
4164
+ it('should not identify a non-Locus 429 as a Locus rate limit', () => {
4165
+ const [res] = cd.generateClientEventErrorPayload({
4166
+ message: 'Too many requests',
4167
+ statusCode: 429,
4168
+ options: {uri: 'https://example.com/api/v1/resource'},
4169
+ });
4170
+
4171
+ assert.deepEqual(res, {
4172
+ category: 'other',
4173
+ errorCode: 9999,
4174
+ errorDescription: 'UnknownError',
4175
+ fatal: true,
4176
+ name: 'other',
4177
+ rawErrorMessage: 'Too many requests',
4178
+ serviceErrorCode: 9999,
4179
+ shownToUser: false,
4180
+ httpCode: 429,
4181
+ });
4182
+ });
4183
+
4184
+ it('should keep the fallback classification when a 429 has no request URL', () => {
4185
+ const [res] = cd.generateClientEventErrorPayload({
4186
+ message: 'Too many requests',
4187
+ statusCode: 429,
4188
+ });
4189
+
4190
+ assert.equal(res.errorCode, 9999);
4191
+ assert.equal(res.httpCode, 429);
4192
+ });
4193
+
4194
+ it('should include httpCode for browser media errors', () => {
4059
4195
  const [res, cached] = cd.generateClientEventErrorPayload({
4060
4196
  name: 'PermissionDeniedError',
4061
4197
  message: 'bad times',
@@ -4073,11 +4209,11 @@ describe('internal-plugin-metrics', () => {
4073
4209
  rawErrorMessage: 'bad times',
4074
4210
  serviceErrorCode: undefined,
4075
4211
  shownToUser: false,
4076
- httpStatusCode: 401,
4212
+ httpCode: 401,
4077
4213
  });
4078
4214
  });
4079
4215
 
4080
- it('should include httpStatusCode for SdpOfferCreationErrors', () => {
4216
+ it('should include httpCode for SdpOfferCreationErrors', () => {
4081
4217
  const [res, cached] = cd.generateClientEventErrorPayload({
4082
4218
  name: 'SdpOfferCreationError',
4083
4219
  message: 'bad times',
@@ -4095,11 +4231,11 @@ describe('internal-plugin-metrics', () => {
4095
4231
  rawErrorMessage: 'bad times',
4096
4232
  serviceErrorCode: undefined,
4097
4233
  shownToUser: true,
4098
- httpStatusCode: 404,
4234
+ httpCode: 404,
4099
4235
  });
4100
4236
  });
4101
4237
 
4102
- it('should include httpStatusCode for service error codes', () => {
4238
+ it('should include httpCode for service error codes', () => {
4103
4239
  const [res, cached] = cd.generateClientEventErrorPayload({
4104
4240
  body: {errorCode: 58400},
4105
4241
  message: 'bad times',
@@ -4114,11 +4250,11 @@ describe('internal-plugin-metrics', () => {
4114
4250
  rawErrorMessage: 'bad times',
4115
4251
  serviceErrorCode: 58400,
4116
4252
  shownToUser: false,
4117
- httpStatusCode: 400,
4253
+ httpCode: 400,
4118
4254
  });
4119
4255
  });
4120
4256
 
4121
- it('should include httpStatusCode for locus service error codes', () => {
4257
+ it('should include httpCode for locus service error codes', () => {
4122
4258
  const [res, cached] = cd.generateClientEventErrorPayload({
4123
4259
  body: {errorCode: 2403001},
4124
4260
  message: 'bad times',
@@ -4133,11 +4269,11 @@ describe('internal-plugin-metrics', () => {
4133
4269
  rawErrorMessage: 'bad times',
4134
4270
  serviceErrorCode: 2403001,
4135
4271
  shownToUser: false,
4136
- httpStatusCode: 400,
4272
+ httpCode: 400,
4137
4273
  });
4138
4274
  });
4139
4275
 
4140
- it('should include httpStatusCode for meetingInfo service error codes', () => {
4276
+ it('should include httpCode for meetingInfo service error codes', () => {
4141
4277
  const [res, cached] = cd.generateClientEventErrorPayload({
4142
4278
  body: {data: {meetingInfo: {}}},
4143
4279
  message: 'bad times',
@@ -4152,11 +4288,11 @@ describe('internal-plugin-metrics', () => {
4152
4288
  rawErrorMessage: 'bad times',
4153
4289
  serviceErrorCode: undefined,
4154
4290
  shownToUser: false,
4155
- httpStatusCode: 400,
4291
+ httpCode: 400,
4156
4292
  });
4157
4293
  });
4158
4294
 
4159
- it('should include httpStatusCode for network errors', () => {
4295
+ it('should include httpCode for network errors', () => {
4160
4296
  const error = new WebexHttpError.NetworkOrCORSError({
4161
4297
  statusCode: 400,
4162
4298
  options: {service: '', headers: {}},
@@ -4171,11 +4307,11 @@ describe('internal-plugin-metrics', () => {
4171
4307
  rawErrorMessage: 'undefined\nundefined /undefined\nWEBEX_TRACKING_ID: undefined\n',
4172
4308
  serviceErrorCode: undefined,
4173
4309
  shownToUser: false,
4174
- httpStatusCode: 400,
4310
+ httpCode: 400,
4175
4311
  });
4176
4312
  });
4177
4313
 
4178
- it('should include httpStatusCode for unauthorized errors', () => {
4314
+ it('should include httpCode for unauthorized errors', () => {
4179
4315
  const error = new WebexHttpError.Unauthorized({
4180
4316
  statusCode: 401,
4181
4317
  options: {service: '', headers: {}},
@@ -4190,11 +4326,11 @@ describe('internal-plugin-metrics', () => {
4190
4326
  rawErrorMessage: 'undefined\nundefined /undefined\nWEBEX_TRACKING_ID: undefined\n',
4191
4327
  serviceErrorCode: undefined,
4192
4328
  shownToUser: false,
4193
- httpStatusCode: 401,
4329
+ httpCode: 401,
4194
4330
  });
4195
4331
  });
4196
4332
 
4197
- it('should include httpStatusCode for unknown errors', () => {
4333
+ it('should include httpCode for unknown errors', () => {
4198
4334
  const [res, cached] = cd.generateClientEventErrorPayload({
4199
4335
  message: 'bad times',
4200
4336
  statusCode: 404,
@@ -4208,7 +4344,7 @@ describe('internal-plugin-metrics', () => {
4208
4344
  serviceErrorCode: 9999,
4209
4345
  errorDescription: 'UnknownError',
4210
4346
  rawErrorMessage: 'bad times',
4211
- httpStatusCode: 404,
4347
+ httpCode: 404,
4212
4348
  });
4213
4349
  });
4214
4350
  });