o11y 242.3.3 → 242.8.1
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/dist/modules/o11y/client/client.js +210 -170
- package/dist/modules/o11y/client/client.js.map +1 -1
- package/dist/modules/o11y/client/interfaces/InstrumentationContext.d.ts +1 -0
- package/dist/modules/o11y/client/library/AppInstrumentationImpl.d.ts +1 -1
- package/dist/modules/o11y/client/library/AutomaticClickTracker.d.ts +7 -7
- package/dist/modules/o11y/client/library/IdleDetectorImpl.d.ts +8 -8
- package/dist/modules/o11y/client/library/InstrumentationImpl.d.ts +1 -1
- package/dist/modules/o11y/client/library/LogValidator.d.ts +5 -5
- package/dist/modules/o11y/client/library/MockObj.d.ts +3 -0
- package/dist/modules/o11y/client/library/NextgenImpl.d.ts +3 -3
- package/dist/modules/o11y/client/library/Tracing.d.ts +2 -2
- package/dist/modules/o11y/client/shared/SchemaUtil.d.ts +1 -1
- package/dist/modules/o11y/client/shared/Utility.d.ts +1 -1
- package/dist/modules/o11y/client/test/MockMouseEvent.d.ts +47 -0
- package/dist/modules/o11y/client/test/TestEnvironment.d.ts +7 -0
- package/dist/modules/o11y/client/version.d.ts +1 -1
- package/dist/modules/o11y/collectors/collectors.js +4 -1
- package/dist/modules/o11y/collectors/collectors.js.map +1 -1
- package/dist/modules/o11y/collectors/interfaces/InstrumentationContext.d.ts +1 -0
- package/dist/modules/o11y/collectors/library/AppInstrumentationImpl.d.ts +1 -1
- package/dist/modules/o11y/collectors/library/AutomaticClickTracker.d.ts +7 -7
- package/dist/modules/o11y/collectors/library/IdleDetectorImpl.d.ts +8 -8
- package/dist/modules/o11y/collectors/library/InstrumentationImpl.d.ts +1 -1
- package/dist/modules/o11y/collectors/library/LogValidator.d.ts +5 -5
- package/dist/modules/o11y/collectors/library/MockObj.d.ts +3 -0
- package/dist/modules/o11y/collectors/library/NextgenImpl.d.ts +3 -3
- package/dist/modules/o11y/collectors/library/Tracing.d.ts +2 -2
- package/dist/modules/o11y/collectors/shared/SchemaUtil.d.ts +1 -1
- package/dist/modules/o11y/collectors/shared/Utility.d.ts +1 -1
- package/dist/modules/o11y/collectors/test/MockMouseEvent.d.ts +47 -0
- package/dist/modules/o11y/collectors/test/TestEnvironment.d.ts +7 -0
- package/dist/modules/o11y/collectors/version.d.ts +1 -1
- package/dist/modules/o11y/core_envelope/core_envelope.js +1 -1
- package/dist/modules/o11y/core_envelope/core_envelope.js.map +1 -1
- package/dist/modules/o11y/core_envelope/interfaces/InstrumentationContext.d.ts +1 -0
- package/dist/modules/o11y/core_envelope/library/AppInstrumentationImpl.d.ts +1 -1
- package/dist/modules/o11y/core_envelope/library/AutomaticClickTracker.d.ts +7 -7
- package/dist/modules/o11y/core_envelope/library/IdleDetectorImpl.d.ts +8 -8
- package/dist/modules/o11y/core_envelope/library/InstrumentationImpl.d.ts +1 -1
- package/dist/modules/o11y/core_envelope/library/LogValidator.d.ts +5 -5
- package/dist/modules/o11y/core_envelope/library/MockObj.d.ts +3 -0
- package/dist/modules/o11y/core_envelope/library/NextgenImpl.d.ts +3 -3
- package/dist/modules/o11y/core_envelope/library/Tracing.d.ts +2 -2
- package/dist/modules/o11y/core_envelope/shared/SchemaUtil.d.ts +1 -1
- package/dist/modules/o11y/core_envelope/shared/Utility.d.ts +1 -1
- package/dist/modules/o11y/core_envelope/test/MockMouseEvent.d.ts +47 -0
- package/dist/modules/o11y/core_envelope/test/TestEnvironment.d.ts +7 -0
- package/dist/modules/o11y/core_envelope/version.d.ts +1 -1
- package/dist/modules/o11y/shared/interfaces/InstrumentationContext.d.ts +1 -0
- package/dist/modules/o11y/shared/library/AppInstrumentationImpl.d.ts +1 -1
- package/dist/modules/o11y/shared/library/AutomaticClickTracker.d.ts +7 -7
- package/dist/modules/o11y/shared/library/IdleDetectorImpl.d.ts +8 -8
- package/dist/modules/o11y/shared/library/InstrumentationImpl.d.ts +1 -1
- package/dist/modules/o11y/shared/library/LogValidator.d.ts +5 -5
- package/dist/modules/o11y/shared/library/MockObj.d.ts +3 -0
- package/dist/modules/o11y/shared/library/NextgenImpl.d.ts +3 -3
- package/dist/modules/o11y/shared/library/Tracing.d.ts +2 -2
- package/dist/modules/o11y/shared/shared/SchemaUtil.d.ts +1 -1
- package/dist/modules/o11y/shared/shared/Utility.d.ts +1 -1
- package/dist/modules/o11y/shared/shared.js +11 -15
- package/dist/modules/o11y/shared/shared.js.map +1 -1
- package/dist/modules/o11y/shared/test/MockMouseEvent.d.ts +47 -0
- package/dist/modules/o11y/shared/test/TestEnvironment.d.ts +7 -0
- package/dist/modules/o11y/shared/version.d.ts +1 -1
- package/dist/modules/o11y/simple_collector/interfaces/InstrumentationContext.d.ts +1 -0
- package/dist/modules/o11y/simple_collector/library/AppInstrumentationImpl.d.ts +1 -1
- package/dist/modules/o11y/simple_collector/library/AutomaticClickTracker.d.ts +7 -7
- package/dist/modules/o11y/simple_collector/library/IdleDetectorImpl.d.ts +8 -8
- package/dist/modules/o11y/simple_collector/library/InstrumentationImpl.d.ts +1 -1
- package/dist/modules/o11y/simple_collector/library/LogValidator.d.ts +5 -5
- package/dist/modules/o11y/simple_collector/library/MockObj.d.ts +3 -0
- package/dist/modules/o11y/simple_collector/library/NextgenImpl.d.ts +3 -3
- package/dist/modules/o11y/simple_collector/library/Tracing.d.ts +2 -2
- package/dist/modules/o11y/simple_collector/shared/SchemaUtil.d.ts +1 -1
- package/dist/modules/o11y/simple_collector/shared/Utility.d.ts +1 -1
- package/dist/modules/o11y/simple_collector/simple_collector.js +2 -1
- package/dist/modules/o11y/simple_collector/simple_collector.js.map +1 -1
- package/dist/modules/o11y/simple_collector/test/MockMouseEvent.d.ts +47 -0
- package/dist/modules/o11y/simple_collector/test/TestEnvironment.d.ts +7 -0
- package/dist/modules/o11y/simple_collector/version.d.ts +1 -1
- package/dist/modules/o11y/web_vitals/interfaces/InstrumentationContext.d.ts +1 -0
- package/dist/modules/o11y/web_vitals/library/AppInstrumentationImpl.d.ts +1 -1
- package/dist/modules/o11y/web_vitals/library/AutomaticClickTracker.d.ts +7 -7
- package/dist/modules/o11y/web_vitals/library/IdleDetectorImpl.d.ts +8 -8
- package/dist/modules/o11y/web_vitals/library/InstrumentationImpl.d.ts +1 -1
- package/dist/modules/o11y/web_vitals/library/LogValidator.d.ts +5 -5
- package/dist/modules/o11y/web_vitals/library/MockObj.d.ts +3 -0
- package/dist/modules/o11y/web_vitals/library/NextgenImpl.d.ts +3 -3
- package/dist/modules/o11y/web_vitals/library/Tracing.d.ts +2 -2
- package/dist/modules/o11y/web_vitals/shared/SchemaUtil.d.ts +1 -1
- package/dist/modules/o11y/web_vitals/shared/Utility.d.ts +1 -1
- package/dist/modules/o11y/web_vitals/test/MockMouseEvent.d.ts +47 -0
- package/dist/modules/o11y/web_vitals/test/TestEnvironment.d.ts +7 -0
- package/dist/modules/o11y/web_vitals/version.d.ts +1 -1
- package/package.json +2 -2
- package/dist/modules/o11y/client/library/MockEvent.d.ts +0 -7
- package/dist/modules/o11y/collectors/library/MockEvent.d.ts +0 -7
- package/dist/modules/o11y/core_envelope/library/MockEvent.d.ts +0 -7
- package/dist/modules/o11y/shared/library/MockEvent.d.ts +0 -7
- package/dist/modules/o11y/simple_collector/library/MockEvent.d.ts +0 -7
- package/dist/modules/o11y/web_vitals/library/MockEvent.d.ts +0 -7
|
@@ -12,9 +12,9 @@ const headerParentSpanId = 'X-B3-ParentSpanId';
|
|
|
12
12
|
const defaultActivityNameForFetch = 'fetch';
|
|
13
13
|
const defaultActivityNameForXhrSend = 'xhr_send';
|
|
14
14
|
class Tracing {
|
|
15
|
-
constructor(
|
|
16
|
-
this.
|
|
17
|
-
utility.requireArgument(
|
|
15
|
+
constructor(_instr) {
|
|
16
|
+
this._instr = _instr;
|
|
17
|
+
utility.requireArgument(_instr, '_instr', 'object');
|
|
18
18
|
}
|
|
19
19
|
static _getB3CompactFormat(traceId, spanId, isSampled, parentSpanId) {
|
|
20
20
|
let b3 = `${traceId}-${spanId}`;
|
|
@@ -49,8 +49,8 @@ class Tracing {
|
|
|
49
49
|
static getHeaders(traceId, spanId, isSampled, options) {
|
|
50
50
|
utility.requireArgument(traceId, 'traceId', 'string');
|
|
51
51
|
utility.requireArgument(spanId, 'spanId', 'string');
|
|
52
|
-
const useB3Headers = options
|
|
53
|
-
traceId = this._conformTextAsId(traceId, options
|
|
52
|
+
const useB3Headers = options === null || options === void 0 ? void 0 : options.useB3Headers;
|
|
53
|
+
traceId = this._conformTextAsId(traceId, (options === null || options === void 0 ? void 0 : options.traceIdEffectiveLength) !== undefined
|
|
54
54
|
? options.traceIdEffectiveLength
|
|
55
55
|
: useB3Headers
|
|
56
56
|
? defaultTraceIdLengthB3
|
|
@@ -62,7 +62,7 @@ class Tracing {
|
|
|
62
62
|
undefined;
|
|
63
63
|
const headers = {};
|
|
64
64
|
if (useB3Headers) {
|
|
65
|
-
const isCompact = options
|
|
65
|
+
const isCompact = options === null || options === void 0 ? void 0 : options.useCompactHeader;
|
|
66
66
|
if (isCompact) {
|
|
67
67
|
headers[headerB3] = this._getB3CompactFormat(traceId, spanId, isSampled, parentSpanId);
|
|
68
68
|
}
|
|
@@ -210,7 +210,7 @@ class Tracing {
|
|
|
210
210
|
if (options) {
|
|
211
211
|
this._disableNetworkInstrumentation();
|
|
212
212
|
const tracingOptions = typeof options === 'object' ? options : {};
|
|
213
|
-
this._enableNetworkInstrumentation(utility.definedValueOrDefault(tracingOptions.instrumentation, this.
|
|
213
|
+
this._enableNetworkInstrumentation(utility.definedValueOrDefault(tracingOptions.instrumentation, this._instr), utility.definedValueOrDefault(tracingOptions.logErrors, true), tracingOptions.activityName, utility.definedValueOrDefault(tracingOptions.useTracing, true), tracingOptions.tracingHeadersOptions);
|
|
214
214
|
}
|
|
215
215
|
else {
|
|
216
216
|
this._disableNetworkInstrumentation();
|
|
@@ -418,21 +418,19 @@ class ActivityImpl {
|
|
|
418
418
|
}
|
|
419
419
|
ActivityImpl._count = 0;
|
|
420
420
|
|
|
421
|
-
const activity={namespace:"sf.instrumentation",name:"Activity",pbjsSchema:{"nested":{"sf":{"nested":{"instrumentation":{"nested":{"Activity":{"reserved":[[5,5],[7,7]],"fields":{"duration":{"
|
|
422
|
-
"
|
|
421
|
+
const activity={namespace:"sf.instrumentation",name:"Activity",pbjsSchema:{"nested":{"sf":{"nested":{"instrumentation":{"nested":{"Activity":{"reserved":[[5,5],[7,7]],"fields":{"duration":{"id":3,"type":"double"},"stopReason":{"id":6,"type":"string"},"isRoot":{"id":8,"type":"bool"},"timerOverridden":{"id":12,"type":"uint32"},"name":{"options":{"(meta.max_length)":25},"id":2,"type":"string"},"isSampled":{"id":11,"type":"bool"},"preRootId":{"id":9,"type":"string"},"id":{"id":1,"type":"string"},
|
|
422
|
+
"userPayload":{"id":4,"type":"Payload"},"errorCount":{"id":10,"type":"uint32"},"parentId":{"id":13,"type":"string"}}},"Payload":{"fields":{"payload":{"id":2,"type":"bytes"},"schemaName":{"id":1,"type":"string"}}}}}}}}}};
|
|
423
423
|
|
|
424
|
-
const error={namespace:"sf.instrumentation",name:"Error",pbjsSchema:{"nested":{"sf":{"nested":{"instrumentation":{"nested":{"Error":{"reserved":[[5,5],[7,7]],"fields":{"activityId":{"
|
|
425
|
-
"schemaName":{"options":{},"id":1,"type":"string"}}}}}}}}}};
|
|
424
|
+
const error={namespace:"sf.instrumentation",name:"Error",pbjsSchema:{"nested":{"sf":{"nested":{"instrumentation":{"nested":{"Error":{"reserved":[[5,5],[7,7]],"fields":{"activityId":{"id":6,"type":"string"},"stack":{"id":3,"type":"string"},"name":{"id":1,"type":"string"},"message":{"options":{"(meta.max_length)":200},"id":2,"type":"string"},"userPayload":{"id":4,"type":"Payload"}}},"Payload":{"fields":{"payload":{"id":2,"type":"bytes"},"schemaName":{"id":1,"type":"string"}}}}}}}}}};
|
|
426
425
|
|
|
427
|
-
const idle_detector_report={namespace:"sf.instrumentation",name:"IdleDetectorReport",pbjsSchema:{"nested":{"sf":{"nested":{"instrumentation":{"nested":{"IdleDetectorReport":{"
|
|
428
|
-
"
|
|
426
|
+
const idle_detector_report={namespace:"sf.instrumentation",name:"IdleDetectorReport",pbjsSchema:{"nested":{"sf":{"nested":{"instrumentation":{"nested":{"IdleDetectorReport":{"fields":{"listenerCount":{"id":3,"type":"uint32"},"busyTasks":{"rule":"repeated","id":5,"type":"string"},"busyDurations":{"rule":"repeated","id":6,"type":"double"},"pollableCount":{"id":4,"type":"uint32"},"pollCounts":{"rule":"repeated","id":8,"type":"double"},"logThreshold":{"id":2,"type":"double"},"maxDuration":{"id":1,
|
|
427
|
+
"type":"double"},"pollables":{"rule":"repeated","id":7,"type":"string"}}}}}}}}}};
|
|
429
428
|
|
|
430
|
-
const instrumented_event={namespace:"sf.instrumentation",name:"InstrumentedEvent",pbjsSchema:{"nested":{"sf":{"nested":{"instrumentation":{"nested":{"MouseEvent":{"fields":{"cancelable":{"
|
|
431
|
-
"type":"bool"},"
|
|
432
|
-
"
|
|
433
|
-
"id":7,"type":"MouseEvent"},"auto":{"options":{},"id":3,"type":"bool"},"parentComponent":{"options":{},"id":2,"type":"string"},"ownerComponent":{"options":{},"id":1,"type":"string"},"userPayload":{"options":{},"id":5,"type":"Payload"},"simplePath":{"options":{},"id":9,"type":"string"}}},"Payload":{"fields":{"payload":{"options":{},"id":2,"type":"bytes"},"schemaName":{"options":{},"id":1,"type":"string"}}}}}}}}}};
|
|
429
|
+
const instrumented_event={namespace:"sf.instrumentation",name:"InstrumentedEvent",pbjsSchema:{"nested":{"sf":{"nested":{"instrumentation":{"nested":{"MouseEvent":{"fields":{"cancelable":{"id":5,"type":"bool"},"ctrlKey":{"id":9,"type":"bool"},"type":{"id":25,"type":"string"},"button":{"id":3,"type":"uint32"},"offsetX":{"id":17,"type":"uint32"},"eventPhase":{"id":12,"type":"uint32"},"shiftKey":{"id":23,"type":"bool"},"offsetY":{"id":18,"type":"uint32"},"composed":{"id":8,"type":"bool"},"altKey":{"id":1,
|
|
430
|
+
"type":"bool"},"isTrusted":{"id":13,"type":"bool"},"buttons":{"id":4,"type":"uint32"},"movementY":{"id":16,"type":"uint32"},"clientY":{"id":7,"type":"uint32"},"clientX":{"id":6,"type":"uint32"},"movementX":{"id":15,"type":"uint32"},"defaultPrevented":{"id":10,"type":"bool"},"metaKey":{"id":14,"type":"bool"},"timeStamp":{"id":24,"type":"double"},"bubbles":{"id":2,"type":"bool"},"detail":{"id":11,"type":"int64"},"pageY":{"id":20,"type":"uint32"},"pageX":{"id":19,"type":"uint32"},"screenX":{"id":21,
|
|
431
|
+
"type":"uint32"},"screenY":{"id":22,"type":"uint32"}}},"InstrumentedEvent":{"oneofs":{"event":{"oneof":["mouseEvent"]}},"reserved":[[4,4],"xpath",[6,6],[8,8]],"fields":{"mouseEvent":{"id":7,"type":"MouseEvent"},"auto":{"id":3,"type":"bool"},"parentComponent":{"id":2,"type":"string"},"ownerComponent":{"id":1,"type":"string"},"userPayload":{"id":5,"type":"Payload"},"simplePath":{"id":9,"type":"string"}}},"Payload":{"fields":{"payload":{"id":2,"type":"bytes"},"schemaName":{"id":1,"type":"string"}}}}}}}}}};
|
|
434
432
|
|
|
435
|
-
const simple={namespace:"sf.instrumentation",name:"Simple",pbjsSchema:{"nested":{"sf":{"nested":{"instrumentation":{"nested":{"Simple":{"
|
|
433
|
+
const simple={namespace:"sf.instrumentation",name:"Simple",pbjsSchema:{"nested":{"sf":{"nested":{"instrumentation":{"nested":{"Simple":{"fields":{"text":{"options":{"(meta.max_length)":25},"id":1,"type":"string"}}}}}}}}}};
|
|
436
434
|
|
|
437
435
|
const id = new Array(16).fill(0).join('');
|
|
438
436
|
class ActivityNoOp {
|
|
@@ -466,9 +464,10 @@ const activityNoOp = Object.freeze(new ActivityNoOp());
|
|
|
466
464
|
|
|
467
465
|
class DomEventHelpers {
|
|
468
466
|
getInstrumentedEventData(eventData, handledBy, userPayload) {
|
|
467
|
+
var _a;
|
|
469
468
|
const instrumentedEvent = {
|
|
470
469
|
ownerComponent: handledBy.tagName,
|
|
471
|
-
parentComponent: (handledBy.parentElement
|
|
470
|
+
parentComponent: ((_a = handledBy.parentElement) === null || _a === void 0 ? void 0 : _a.tagName) || undefined,
|
|
472
471
|
event: eventData,
|
|
473
472
|
simplePath: utility.getXpath(handledBy)
|
|
474
473
|
};
|
|
@@ -554,6 +553,12 @@ class ValidationEntry {
|
|
|
554
553
|
case 7:
|
|
555
554
|
msg = 'Exceeded app limit for item count';
|
|
556
555
|
break;
|
|
556
|
+
case 12:
|
|
557
|
+
msg = 'Value must be an integer';
|
|
558
|
+
break;
|
|
559
|
+
case 13:
|
|
560
|
+
msg = 'Values like null or undefined are not allowed for items in repeated fields';
|
|
561
|
+
break;
|
|
557
562
|
default:
|
|
558
563
|
msg = `Unknown error code: ${this.errorCode}`;
|
|
559
564
|
break;
|
|
@@ -568,113 +573,146 @@ class LogValidator {
|
|
|
568
573
|
const schemaId = schemaUtil.getSchemaId(schema);
|
|
569
574
|
const errorInfos = new Array();
|
|
570
575
|
const nestedSchema = schemaUtil.getTypes(schema);
|
|
571
|
-
this.
|
|
576
|
+
this._validateFields(errorInfos, [], data, nestedSchema[schemaTokens.message], nestedSchema, schemaId);
|
|
572
577
|
if (errorInfos.length && !noThrow) {
|
|
573
578
|
throw new Error(errorInfos[0].asMessage(schemaId));
|
|
574
579
|
}
|
|
575
580
|
return errorInfos;
|
|
576
581
|
}
|
|
577
|
-
|
|
582
|
+
_validateFields(errorInfos, fieldNames, data, message, descriptor, schemaId) {
|
|
578
583
|
const oneofs = message.oneofs || {};
|
|
579
584
|
const fields = message.fields || {};
|
|
580
585
|
for (const key in data) {
|
|
581
586
|
const value = data[key];
|
|
582
|
-
if (
|
|
583
|
-
const mft = (fieldType,
|
|
587
|
+
if (value !== undefined && value !== null) {
|
|
588
|
+
const mft = (fieldType, isRepeated, isItem) => this._matchFieldTypes(errorInfos, [...fieldNames, key], value, fieldType, descriptor, schemaId, key, isRepeated, isItem);
|
|
584
589
|
if (oneofs[key]) {
|
|
585
590
|
mft(fields[oneofs[key].oneof[0]].type);
|
|
586
591
|
}
|
|
587
592
|
else if (fields[key]) {
|
|
588
|
-
mft(fields[key].type, fields[key].rule);
|
|
593
|
+
mft(fields[key].type, fields[key].rule === 'repeated');
|
|
589
594
|
}
|
|
590
595
|
}
|
|
591
596
|
}
|
|
592
597
|
}
|
|
593
|
-
|
|
594
|
-
return val === undefined || val === null || val === '';
|
|
595
|
-
}
|
|
596
|
-
matchFieldTypes(errorInfos, fieldNames, fieldDataValue, protobufType, descriptor, schemaId, key, rule) {
|
|
598
|
+
_matchFieldTypes(errorInfos, fieldNames, fieldDataValue, protobufType, descriptor, schemaId, key, isRepeated, isItem) {
|
|
597
599
|
let errorCode;
|
|
598
|
-
if (
|
|
600
|
+
if (isRepeated) {
|
|
599
601
|
if (Array.isArray(fieldDataValue)) {
|
|
600
602
|
if (fieldDataValue.length > maxItemCountAppLimit) {
|
|
601
603
|
errorCode = 7;
|
|
602
604
|
}
|
|
603
605
|
fieldDataValue.forEach((value, index) => {
|
|
604
|
-
this.
|
|
606
|
+
this._matchFieldTypes(errorInfos, [...fieldNames, index.toString()], value, protobufType, descriptor, schemaId, key, undefined, true);
|
|
605
607
|
});
|
|
606
608
|
}
|
|
607
609
|
else {
|
|
608
610
|
errorCode = 1;
|
|
609
611
|
}
|
|
610
|
-
|
|
611
|
-
|
|
612
|
+
}
|
|
613
|
+
else if (fieldDataValue == null || fieldDataValue === undefined) {
|
|
614
|
+
if (isItem) {
|
|
615
|
+
errorCode = 13;
|
|
612
616
|
}
|
|
613
|
-
return;
|
|
614
617
|
}
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
618
|
+
else {
|
|
619
|
+
let numOpts;
|
|
620
|
+
let javaScriptType;
|
|
621
|
+
switch (protobufType) {
|
|
622
|
+
case 'string':
|
|
623
|
+
javaScriptType = 'string';
|
|
624
|
+
if (fieldDataValue.length > maxStringLengthAppLimit) {
|
|
625
|
+
errorCode = 6;
|
|
626
|
+
}
|
|
627
|
+
break;
|
|
628
|
+
case 'bytes':
|
|
629
|
+
javaScriptType = 'object';
|
|
630
|
+
if (!(fieldDataValue instanceof Uint8Array)) {
|
|
631
|
+
errorCode = 5;
|
|
632
|
+
}
|
|
633
|
+
break;
|
|
634
|
+
case 'bool':
|
|
635
|
+
javaScriptType = 'boolean';
|
|
636
|
+
break;
|
|
637
|
+
case 'uint32':
|
|
638
|
+
javaScriptType = 'number';
|
|
639
|
+
numOpts = {
|
|
640
|
+
min: minUnsigned,
|
|
641
|
+
max: maxFourBytesUnsigned,
|
|
642
|
+
isInt: true,
|
|
643
|
+
isItem
|
|
644
|
+
};
|
|
645
|
+
break;
|
|
646
|
+
case 'int32':
|
|
647
|
+
case 'sint32':
|
|
648
|
+
case 'fixed32':
|
|
649
|
+
case 'sfixed32':
|
|
650
|
+
javaScriptType = 'number';
|
|
651
|
+
numOpts = {
|
|
652
|
+
min: minFourBytes,
|
|
653
|
+
max: maxFourBytes,
|
|
654
|
+
isInt: true,
|
|
655
|
+
isItem
|
|
656
|
+
};
|
|
657
|
+
break;
|
|
658
|
+
case 'uint64':
|
|
659
|
+
javaScriptType = 'number';
|
|
660
|
+
numOpts = {
|
|
661
|
+
min: minUnsigned,
|
|
662
|
+
max: maxEightBytesUnsigned,
|
|
663
|
+
isInt: true,
|
|
664
|
+
isItem
|
|
665
|
+
};
|
|
666
|
+
break;
|
|
667
|
+
case 'fixed64':
|
|
668
|
+
case 'sfixed64':
|
|
669
|
+
case 'int64':
|
|
670
|
+
case 'sint64':
|
|
671
|
+
javaScriptType = 'number';
|
|
672
|
+
numOpts = {
|
|
673
|
+
min: minEightBytes,
|
|
674
|
+
max: maxEightBytes,
|
|
675
|
+
isInt: true,
|
|
676
|
+
isItem
|
|
677
|
+
};
|
|
678
|
+
break;
|
|
679
|
+
case 'double':
|
|
680
|
+
case 'float':
|
|
681
|
+
javaScriptType = 'number';
|
|
682
|
+
numOpts = {
|
|
683
|
+
min: Number.NEGATIVE_INFINITY,
|
|
684
|
+
max: Number.POSITIVE_INFINITY,
|
|
685
|
+
isInt: false,
|
|
686
|
+
isItem
|
|
687
|
+
};
|
|
688
|
+
break;
|
|
689
|
+
default:
|
|
690
|
+
if (new Set(Object.keys(descriptor)).has(protobufType)) {
|
|
691
|
+
this._validateFields(errorInfos, fieldNames, fieldDataValue, descriptor[protobufType], descriptor, schemaId);
|
|
692
|
+
javaScriptType = 'object';
|
|
693
|
+
}
|
|
694
|
+
break;
|
|
695
|
+
}
|
|
696
|
+
if (typeof fieldDataValue !== javaScriptType) {
|
|
697
|
+
errorInfos.push(new ValidationEntry(2, fieldNames, protobufType, typeof fieldDataValue));
|
|
698
|
+
}
|
|
699
|
+
else if (numOpts) {
|
|
700
|
+
if (numOpts.isInt && !Number.isFinite(fieldDataValue)) {
|
|
658
701
|
errorCode = 3;
|
|
659
702
|
}
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
if (new Set(Object.keys(descriptor)).has(protobufType)) {
|
|
663
|
-
this.validateFields(errorInfos, fieldNames, fieldDataValue, descriptor[protobufType], descriptor, schemaId);
|
|
664
|
-
javaScriptType = 'object';
|
|
703
|
+
else if (numOpts.isInt && !Number.isInteger(fieldDataValue)) {
|
|
704
|
+
errorCode = 12;
|
|
665
705
|
}
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
706
|
+
else if (!(!numOpts.isInt && Number.isNaN(fieldDataValue)) &&
|
|
707
|
+
!(fieldDataValue >= numOpts.min && fieldDataValue <= numOpts.max)) {
|
|
708
|
+
errorCode = 4;
|
|
709
|
+
}
|
|
710
|
+
}
|
|
670
711
|
}
|
|
671
712
|
if (errorCode) {
|
|
672
713
|
errorInfos.push(new ValidationEntry(errorCode, fieldNames));
|
|
673
714
|
}
|
|
674
715
|
}
|
|
675
|
-
checkNumberRange(value, min, max) {
|
|
676
|
-
return value > max || value < min ? 4 : undefined;
|
|
677
|
-
}
|
|
678
716
|
}
|
|
679
717
|
const logValidator = new LogValidator();
|
|
680
718
|
|
|
@@ -945,14 +983,9 @@ class MetricsImpl {
|
|
|
945
983
|
}
|
|
946
984
|
}
|
|
947
985
|
|
|
948
|
-
class
|
|
949
|
-
constructor(
|
|
950
|
-
this.
|
|
951
|
-
this.composed = composed;
|
|
952
|
-
this._composedPaths = _composedPaths;
|
|
953
|
-
}
|
|
954
|
-
composedPath() {
|
|
955
|
-
return this._composedPaths;
|
|
986
|
+
class MockBase {
|
|
987
|
+
constructor() {
|
|
988
|
+
this.isMock = true;
|
|
956
989
|
}
|
|
957
990
|
}
|
|
958
991
|
|
|
@@ -1009,7 +1042,7 @@ class InstrumentationImpl {
|
|
|
1009
1042
|
}
|
|
1010
1043
|
return schemaUtil.makePayload(userSchema, userData, onlyIfBoth);
|
|
1011
1044
|
}
|
|
1012
|
-
|
|
1045
|
+
_getEffectiveRootId(options) {
|
|
1013
1046
|
var _a, _b;
|
|
1014
1047
|
return ((_b = (_a = options === null || options === void 0 ? void 0 : options.instrumentationContext) === null || _a === void 0 ? void 0 : _a.rootId) !== null && _b !== void 0 ? _b : this._nextGen.getDefaultInstrumentationContext().rootId);
|
|
1015
1048
|
}
|
|
@@ -1021,7 +1054,7 @@ class InstrumentationImpl {
|
|
|
1021
1054
|
utility.requireArgumentIfDefined(options, 'options', 'object');
|
|
1022
1055
|
const userPayload = this._wrapUserPayload(userSchemaOrText, userData);
|
|
1023
1056
|
if (userPayload === null || userPayload === void 0 ? void 0 : userPayload.payload) {
|
|
1024
|
-
this._logInternal(this.name, userPayload.schema, userPayload.payload, timestamp, this.
|
|
1057
|
+
this._logInternal(this.name, userPayload.schema, userPayload.payload, timestamp, this._getEffectiveRootId(options));
|
|
1025
1058
|
}
|
|
1026
1059
|
});
|
|
1027
1060
|
}
|
|
@@ -1039,7 +1072,7 @@ class InstrumentationImpl {
|
|
|
1039
1072
|
]);
|
|
1040
1073
|
utility.requireArgumentIfDefined(userData, 'userData', 'object');
|
|
1041
1074
|
utility.requireArgumentIfDefined(options, 'options', 'object');
|
|
1042
|
-
const rootId = this.
|
|
1075
|
+
const rootId = this._getEffectiveRootId(options);
|
|
1043
1076
|
this._errorInternal(error, userSchemaOrText, userData, undefined, rootId);
|
|
1044
1077
|
});
|
|
1045
1078
|
}
|
|
@@ -1124,8 +1157,9 @@ class InstrumentationImpl {
|
|
|
1124
1157
|
}
|
|
1125
1158
|
domEvent(event, handledBy, userSchemaOrText, userData, options) {
|
|
1126
1159
|
this._safety.tryCatch(() => {
|
|
1160
|
+
var _a;
|
|
1127
1161
|
const tsNow = utility.time().tsNow;
|
|
1128
|
-
utility.requireArgument(event, 'event', [Event,
|
|
1162
|
+
utility.requireArgument(event, 'event', [Event, MockBase]);
|
|
1129
1163
|
utility.requireArgument(handledBy, 'handledBy', [HTMLElement, 'object']);
|
|
1130
1164
|
let htmlElement;
|
|
1131
1165
|
if (handledBy instanceof HTMLElement) {
|
|
@@ -1133,7 +1167,7 @@ class InstrumentationImpl {
|
|
|
1133
1167
|
}
|
|
1134
1168
|
else {
|
|
1135
1169
|
handledBy = handledBy;
|
|
1136
|
-
if (handledBy.template
|
|
1170
|
+
if (((_a = handledBy.template) === null || _a === void 0 ? void 0 : _a.host) instanceof HTMLElement) {
|
|
1137
1171
|
htmlElement = handledBy.template.host;
|
|
1138
1172
|
}
|
|
1139
1173
|
else {
|
|
@@ -1141,7 +1175,7 @@ class InstrumentationImpl {
|
|
|
1141
1175
|
}
|
|
1142
1176
|
}
|
|
1143
1177
|
const userPayload = this._wrapUserPayload(userSchemaOrText, userData, true);
|
|
1144
|
-
const rootId = this.
|
|
1178
|
+
const rootId = this._getEffectiveRootId(options);
|
|
1145
1179
|
switch (event.type) {
|
|
1146
1180
|
case 'click': {
|
|
1147
1181
|
const mouseEvent = event;
|
|
@@ -1151,7 +1185,7 @@ class InstrumentationImpl {
|
|
|
1151
1185
|
}
|
|
1152
1186
|
const mouseEventData = domEventHelpers.getMouseEventData(mouseEvent);
|
|
1153
1187
|
const instrumentedEvent = domEventHelpers.getInstrumentedEventData(mouseEventData, htmlElement, userPayload);
|
|
1154
|
-
instrumentedEvent.auto = options
|
|
1188
|
+
instrumentedEvent.auto = options === null || options === void 0 ? void 0 : options._auto;
|
|
1155
1189
|
this._logInternal(this.name, instrumented_event, instrumentedEvent, tsNow, rootId);
|
|
1156
1190
|
break;
|
|
1157
1191
|
}
|
|
@@ -1357,7 +1391,7 @@ class AppInstrumentationImpl extends InstrumentationImpl {
|
|
|
1357
1391
|
constructor(_nextGen, _name, _allowMulti) {
|
|
1358
1392
|
super(_nextGen, _name);
|
|
1359
1393
|
this._allowMulti = _allowMulti;
|
|
1360
|
-
this._onRootActivityStoppedCallback = this.
|
|
1394
|
+
this._onRootActivityStoppedCallback = this._handleRootActivityStop.bind(this);
|
|
1361
1395
|
}
|
|
1362
1396
|
startRootActivity(name, rootId, isSampled) {
|
|
1363
1397
|
return this._safety.tryCatchReturn(() => {
|
|
@@ -1374,7 +1408,7 @@ class AppInstrumentationImpl extends InstrumentationImpl {
|
|
|
1374
1408
|
return newRootActivity;
|
|
1375
1409
|
}, rootActivityNoOp);
|
|
1376
1410
|
}
|
|
1377
|
-
|
|
1411
|
+
_handleRootActivityStop(detail) {
|
|
1378
1412
|
if (detail.stopReason === discarded) {
|
|
1379
1413
|
return;
|
|
1380
1414
|
}
|
|
@@ -1403,56 +1437,58 @@ class AppInstrumentationImpl extends InstrumentationImpl {
|
|
|
1403
1437
|
|
|
1404
1438
|
const pathLimit = 5;
|
|
1405
1439
|
class AutomaticClickTracker {
|
|
1406
|
-
constructor(
|
|
1407
|
-
this.
|
|
1408
|
-
this.
|
|
1409
|
-
|
|
1410
|
-
|
|
1411
|
-
|
|
1412
|
-
|
|
1440
|
+
constructor(_instr, _doc) {
|
|
1441
|
+
this._instr = _instr;
|
|
1442
|
+
this._doc = _doc;
|
|
1443
|
+
this._isActive = false;
|
|
1444
|
+
this._boundClickListener = this._clickListener.bind(this);
|
|
1445
|
+
utility.requireArgument(_instr, '_instr');
|
|
1446
|
+
utility.requireArgument(_doc, '_doc');
|
|
1413
1447
|
}
|
|
1414
1448
|
activate() {
|
|
1415
|
-
if (!this.
|
|
1416
|
-
this.
|
|
1417
|
-
this.
|
|
1449
|
+
if (!this._isActive) {
|
|
1450
|
+
this._doc.addEventListener('click', this._boundClickListener, true);
|
|
1451
|
+
this._isActive = true;
|
|
1418
1452
|
}
|
|
1419
1453
|
}
|
|
1420
1454
|
deactivate() {
|
|
1421
|
-
if (this.
|
|
1422
|
-
this.
|
|
1423
|
-
this.
|
|
1455
|
+
if (this._isActive) {
|
|
1456
|
+
this._doc.removeEventListener('click', this._boundClickListener, true);
|
|
1457
|
+
this._isActive = false;
|
|
1424
1458
|
}
|
|
1425
1459
|
}
|
|
1426
1460
|
markEventHandled(event) {
|
|
1427
|
-
this.
|
|
1461
|
+
this._ignoredEvent = event;
|
|
1428
1462
|
}
|
|
1429
|
-
|
|
1430
|
-
|
|
1463
|
+
_clickListener(event) {
|
|
1464
|
+
var _a;
|
|
1465
|
+
let eventTargets = (_a = event.composedPath) === null || _a === void 0 ? void 0 : _a.call(event);
|
|
1431
1466
|
if (!eventTargets || !eventTargets.length) {
|
|
1432
1467
|
eventTargets = event.path;
|
|
1433
1468
|
}
|
|
1434
|
-
const handledBy = this.
|
|
1469
|
+
const handledBy = this._getClickableElement(eventTargets);
|
|
1435
1470
|
if (handledBy) {
|
|
1436
1471
|
setTimeout(() => {
|
|
1437
|
-
if (event !== this.
|
|
1438
|
-
this.
|
|
1472
|
+
if (event !== this._ignoredEvent) {
|
|
1473
|
+
this._instr.domEvent(event, handledBy, undefined, undefined, {
|
|
1439
1474
|
_auto: true
|
|
1440
1475
|
});
|
|
1441
1476
|
}
|
|
1442
1477
|
});
|
|
1443
1478
|
}
|
|
1444
1479
|
}
|
|
1445
|
-
|
|
1480
|
+
_getClickableElement(path) {
|
|
1481
|
+
var _a, _b;
|
|
1446
1482
|
const limit = path ? Math.min(path.length, pathLimit) : 0;
|
|
1447
1483
|
for (let x = 0; x < limit; x += 1) {
|
|
1448
1484
|
const currentElement = path[x];
|
|
1449
|
-
const tagName = currentElement.tagName
|
|
1485
|
+
const tagName = (_a = currentElement.tagName) === null || _a === void 0 ? void 0 : _a.toLowerCase();
|
|
1450
1486
|
if (tagName === 'a' || tagName === 'button') {
|
|
1451
1487
|
return currentElement;
|
|
1452
1488
|
}
|
|
1453
1489
|
if (tagName === 'input') {
|
|
1454
1490
|
const inputElement = currentElement;
|
|
1455
|
-
if (inputElement.type
|
|
1491
|
+
if (((_b = inputElement.type) === null || _b === void 0 ? void 0 : _b.toLowerCase()) === 'button') {
|
|
1456
1492
|
return inputElement;
|
|
1457
1493
|
}
|
|
1458
1494
|
}
|
|
@@ -1497,9 +1533,9 @@ class NextgenImpl {
|
|
|
1497
1533
|
if (instr) {
|
|
1498
1534
|
throw new Error(`The instrumentation name ${name} is already taken`);
|
|
1499
1535
|
}
|
|
1500
|
-
this._appInstr = new AppInstrumentationImpl(this, name, options
|
|
1536
|
+
this._appInstr = new AppInstrumentationImpl(this, name, options === null || options === void 0 ? void 0 : options.allowMultipleRootActivities);
|
|
1501
1537
|
this._instruments.set(name, this._appInstr);
|
|
1502
|
-
this._isBufferingEnabled = options
|
|
1538
|
+
this._isBufferingEnabled = options === null || options === void 0 ? void 0 : options.enableBuffering;
|
|
1503
1539
|
const tracing = new Tracing(this._appInstr);
|
|
1504
1540
|
return {
|
|
1505
1541
|
log: this._appInstr.log.bind(this._appInstr),
|
|
@@ -1538,7 +1574,8 @@ class NextgenImpl {
|
|
|
1538
1574
|
return instr;
|
|
1539
1575
|
}
|
|
1540
1576
|
get appName() {
|
|
1541
|
-
|
|
1577
|
+
var _a;
|
|
1578
|
+
return (_a = this._appInstr) === null || _a === void 0 ? void 0 : _a.name;
|
|
1542
1579
|
}
|
|
1543
1580
|
addLog(loggerName, schema, data, timestamp, rootId, pagePayload, appPayload) {
|
|
1544
1581
|
this._sequence += 1;
|
|
@@ -1560,8 +1597,11 @@ class NextgenImpl {
|
|
|
1560
1597
|
if (this._isBufferingEnabled) {
|
|
1561
1598
|
this._buffer.push({ schema, data: utility.clone(data), logMeta });
|
|
1562
1599
|
}
|
|
1563
|
-
const eligibleCollectors = Array.from(this._logCollectors).filter((collector) =>
|
|
1564
|
-
|
|
1600
|
+
const eligibleCollectors = Array.from(this._logCollectors).filter((collector) => {
|
|
1601
|
+
var _a;
|
|
1602
|
+
return !this._forceDisabledLogCollectors.has(collector) &&
|
|
1603
|
+
!((_a = collector.getIsCollectDisabled) === null || _a === void 0 ? void 0 : _a.call(collector));
|
|
1604
|
+
});
|
|
1565
1605
|
if (eligibleCollectors.length > 0) {
|
|
1566
1606
|
for (const collector of eligibleCollectors) {
|
|
1567
1607
|
const dataClone = utility.clone(data);
|
|
@@ -1606,10 +1646,12 @@ class NextgenImpl {
|
|
|
1606
1646
|
};
|
|
1607
1647
|
}
|
|
1608
1648
|
activateClickTracker() {
|
|
1609
|
-
if (
|
|
1610
|
-
|
|
1649
|
+
if (typeof document !== 'undefined') {
|
|
1650
|
+
if (!this._autoClickTracker) {
|
|
1651
|
+
this._autoClickTracker = new AutomaticClickTracker(this._appInstr, document);
|
|
1652
|
+
}
|
|
1653
|
+
this._autoClickTracker.activate();
|
|
1611
1654
|
}
|
|
1612
|
-
this._autoClickTracker.activate();
|
|
1613
1655
|
}
|
|
1614
1656
|
deactivateClickTracker() {
|
|
1615
1657
|
if (this._autoClickTracker) {
|
|
@@ -1639,20 +1681,20 @@ class NextgenImpl {
|
|
|
1639
1681
|
}
|
|
1640
1682
|
this._metricsCollector = collector;
|
|
1641
1683
|
this._metricsCollector.receiveMetricsExtractors({
|
|
1642
|
-
getAllUpCounters: this.
|
|
1643
|
-
getAllValueRecorders: this.
|
|
1644
|
-
getAllBucketHistograms: this.
|
|
1684
|
+
getAllUpCounters: this._getAllUpCounters.bind(this),
|
|
1685
|
+
getAllValueRecorders: this._getAllValueRecorders.bind(this),
|
|
1686
|
+
getAllBucketHistograms: this._getAllBucketHistograms.bind(this)
|
|
1645
1687
|
});
|
|
1646
1688
|
}
|
|
1647
|
-
|
|
1689
|
+
_getAllUpCounters() {
|
|
1648
1690
|
const arrOfArrs = Array.from(this._instruments.values()).map((instr) => instr.getUpCounters());
|
|
1649
1691
|
return arrOfArrs.reduce((pv, cv) => pv.concat(cv), []);
|
|
1650
1692
|
}
|
|
1651
|
-
|
|
1693
|
+
_getAllValueRecorders() {
|
|
1652
1694
|
const arrOfArrs = Array.from(this._instruments.values()).map((instr) => instr.getValueRecorders());
|
|
1653
1695
|
return arrOfArrs.reduce((pv, cv) => pv.concat(cv), []);
|
|
1654
1696
|
}
|
|
1655
|
-
|
|
1697
|
+
_getAllBucketHistograms() {
|
|
1656
1698
|
const arrOfArrs = Array.from(this._instruments.values()).map((instr) => instr.getBucketHistograms());
|
|
1657
1699
|
return arrOfArrs.reduce((pv, cv) => pv.concat(cv), []);
|
|
1658
1700
|
}
|
|
@@ -1744,7 +1786,6 @@ class IdleDetectorImpl {
|
|
|
1744
1786
|
this._logThreshold = defaultLogThreshold;
|
|
1745
1787
|
this._endedTasks = new Array();
|
|
1746
1788
|
this._pollableReport = new Array();
|
|
1747
|
-
this._timerCheckQueued = 0;
|
|
1748
1789
|
if (utility.requireArgumentIfDefined(options === null || options === void 0 ? void 0 : options.logThreshold, 'options.logThreshold', 'number')) {
|
|
1749
1790
|
this._logThreshold = options.logThreshold;
|
|
1750
1791
|
}
|
|
@@ -1755,9 +1796,9 @@ class IdleDetectorImpl {
|
|
|
1755
1796
|
this._firstCallbackTime = utility.time().perfNow;
|
|
1756
1797
|
}
|
|
1757
1798
|
this._listeners.add(callback);
|
|
1758
|
-
this.
|
|
1799
|
+
this._checkIfLoaded();
|
|
1759
1800
|
}
|
|
1760
|
-
|
|
1801
|
+
_reportTaskEnded(tasker) {
|
|
1761
1802
|
if (this._listeners.size) {
|
|
1762
1803
|
const snapshot = Object.assign({}, this._taskers.get(tasker));
|
|
1763
1804
|
this._endedTasks.push(snapshot);
|
|
@@ -1765,7 +1806,7 @@ class IdleDetectorImpl {
|
|
|
1765
1806
|
}
|
|
1766
1807
|
declareNotifierTaskSingle(name) {
|
|
1767
1808
|
utility.requireArgument(name, 'name', 'string');
|
|
1768
|
-
const tasker = this.
|
|
1809
|
+
const tasker = this._addTasker(name, 1);
|
|
1769
1810
|
const retVal = {
|
|
1770
1811
|
get isBusy() {
|
|
1771
1812
|
return tasker.isBusy;
|
|
@@ -1781,12 +1822,11 @@ class IdleDetectorImpl {
|
|
|
1781
1822
|
utility.requireArgument(name, 'name', 'string');
|
|
1782
1823
|
if (existingBusyCount !== undefined) {
|
|
1783
1824
|
utility.requireArgument(existingBusyCount, 'existingBusyCount', 'number');
|
|
1784
|
-
if (existingBusyCount < 0
|
|
1785
|
-
parseInt(existingBusyCount.toString(), 10) !== existingBusyCount) {
|
|
1825
|
+
if (!Number.isInteger(existingBusyCount) || existingBusyCount < 0) {
|
|
1786
1826
|
throw new Error('existingBusyCount accepts only non-negative integers');
|
|
1787
1827
|
}
|
|
1788
1828
|
}
|
|
1789
|
-
const tasker = this.
|
|
1829
|
+
const tasker = this._addTasker(name, existingBusyCount);
|
|
1790
1830
|
const retVal = {
|
|
1791
1831
|
get isBusy() {
|
|
1792
1832
|
return tasker.isBusy;
|
|
@@ -1808,11 +1848,11 @@ class IdleDetectorImpl {
|
|
|
1808
1848
|
utility.requireArgument(isBusyChecker, 'isBusyChecker', 'function');
|
|
1809
1849
|
this._busyCheckers.set(isBusyChecker, name);
|
|
1810
1850
|
}
|
|
1811
|
-
|
|
1851
|
+
_addTasker(name, existingBusyCount) {
|
|
1812
1852
|
const tasker = new TaskerImpl(name, existingBusyCount, () => {
|
|
1813
1853
|
this._taskers.get(tasker).end = utility.time().perfNow;
|
|
1814
|
-
this.
|
|
1815
|
-
this.
|
|
1854
|
+
this._reportTaskEnded(tasker);
|
|
1855
|
+
this._checkIfLoaded();
|
|
1816
1856
|
}, () => {
|
|
1817
1857
|
this._instr.error(`Overdone: ${tasker.name}`);
|
|
1818
1858
|
utility.noProdThrow(`Tasker '${tasker.name}' is done too many times.`);
|
|
@@ -1824,10 +1864,10 @@ class IdleDetectorImpl {
|
|
|
1824
1864
|
});
|
|
1825
1865
|
return tasker;
|
|
1826
1866
|
}
|
|
1827
|
-
|
|
1867
|
+
_areAllNotifiersIdle() {
|
|
1828
1868
|
return !Array.from(this._taskers.keys()).some((t) => t.isBusy);
|
|
1829
1869
|
}
|
|
1830
|
-
|
|
1870
|
+
_getFirstBusyPollable() {
|
|
1831
1871
|
const entry = Array.from(this._busyCheckers).find((entry) => {
|
|
1832
1872
|
const isBusyChecker = entry[0];
|
|
1833
1873
|
const name = entry[1];
|
|
@@ -1842,29 +1882,29 @@ class IdleDetectorImpl {
|
|
|
1842
1882
|
});
|
|
1843
1883
|
return entry ? entry[1] : undefined;
|
|
1844
1884
|
}
|
|
1845
|
-
|
|
1885
|
+
_checkIfLoaded() {
|
|
1846
1886
|
if (!this._listeners.size) {
|
|
1847
1887
|
return;
|
|
1848
1888
|
}
|
|
1849
1889
|
if (this._timerCheckQueued) {
|
|
1850
|
-
|
|
1890
|
+
clearTimeout(this._timerCheckQueued);
|
|
1851
1891
|
}
|
|
1852
|
-
if (this.
|
|
1853
|
-
this._timerCheckQueued =
|
|
1854
|
-
this._timerCheckQueued =
|
|
1855
|
-
this.
|
|
1892
|
+
if (this._areAllNotifiersIdle()) {
|
|
1893
|
+
this._timerCheckQueued = setTimeout(() => {
|
|
1894
|
+
this._timerCheckQueued = setTimeout(() => {
|
|
1895
|
+
this._doubleCheck();
|
|
1856
1896
|
}, 40);
|
|
1857
1897
|
}, 0);
|
|
1858
1898
|
}
|
|
1859
1899
|
}
|
|
1860
|
-
|
|
1861
|
-
this._timerCheckQueued =
|
|
1862
|
-
if (this.
|
|
1863
|
-
const pollableName = this.
|
|
1900
|
+
_doubleCheck() {
|
|
1901
|
+
this._timerCheckQueued = undefined;
|
|
1902
|
+
if (this._areAllNotifiersIdle()) {
|
|
1903
|
+
const pollableName = this._getFirstBusyPollable();
|
|
1864
1904
|
if (pollableName !== undefined) {
|
|
1865
|
-
this.
|
|
1866
|
-
this._timerCheckQueued =
|
|
1867
|
-
this.
|
|
1905
|
+
this._addToPollableReport(pollableName);
|
|
1906
|
+
this._timerCheckQueued = setTimeout(() => {
|
|
1907
|
+
this._doubleCheck();
|
|
1868
1908
|
}, 15);
|
|
1869
1909
|
}
|
|
1870
1910
|
else {
|
|
@@ -1874,11 +1914,11 @@ class IdleDetectorImpl {
|
|
|
1874
1914
|
this._firstCallbackTime = undefined;
|
|
1875
1915
|
const endedTasks = this._endedTasks.splice(0);
|
|
1876
1916
|
const pollableReport = this._pollableReport.splice(0);
|
|
1877
|
-
this.
|
|
1917
|
+
this._notify(listeners, maxDuration, endedTasks, pollableReport);
|
|
1878
1918
|
}
|
|
1879
1919
|
}
|
|
1880
1920
|
}
|
|
1881
|
-
|
|
1921
|
+
_addToPollableReport(name) {
|
|
1882
1922
|
const lastEntry = this._pollableReport.length
|
|
1883
1923
|
? this._pollableReport[this._pollableReport.length - 1]
|
|
1884
1924
|
: undefined;
|
|
@@ -1892,7 +1932,7 @@ class IdleDetectorImpl {
|
|
|
1892
1932
|
});
|
|
1893
1933
|
}
|
|
1894
1934
|
}
|
|
1895
|
-
|
|
1935
|
+
_notify(listeners, maxDuration, taskReport, pollableReport) {
|
|
1896
1936
|
if (maxDuration >= this._logThreshold) {
|
|
1897
1937
|
const logData = this._getReport(maxDuration, listeners.length, taskReport, pollableReport);
|
|
1898
1938
|
this._instr.log(idle_detector_report, logData);
|
|
@@ -1978,7 +2018,7 @@ class ConsoleCollector {
|
|
|
1978
2018
|
}
|
|
1979
2019
|
}
|
|
1980
2020
|
|
|
1981
|
-
const version = '242.
|
|
2021
|
+
const version = '242.8.1';
|
|
1982
2022
|
|
|
1983
2023
|
const idleDetector = new IdleDetectorImpl({
|
|
1984
2024
|
logThreshold: 300
|