File tree Expand file tree Collapse file tree 1 file changed +26
-15
lines changed Expand file tree Collapse file tree 1 file changed +26
-15
lines changed Original file line number Diff line number Diff line change @@ -38,26 +38,37 @@ const instrumented: { [key in InstrumentHandlerType]?: boolean } = {};
38
38
39
39
/** Instruments given API */
40
40
function instrument ( type : InstrumentHandlerType ) : void {
41
- if ( type === 'console' ) {
42
- instrumentConsole ( ) ;
43
- instrumented [ type ] = true ;
44
- }
45
- if ( type === 'dom' ) {
46
- instrumentDOM ( ) ;
47
- }
48
- if ( type === 'xhr' ) {
49
- instrumentXHR ( ) ;
50
- }
51
- if ( type === 'fetch' ) {
52
- instrumentFetch ( ) ;
41
+ if ( instrumented [ type ] ) {
42
+ return ;
53
43
}
54
- if ( type === 'history' ) {
55
- instrumentHistory ( ) ;
44
+
45
+ instrumented [ type ] = true ;
46
+
47
+ switch ( type ) {
48
+ case 'console' :
49
+ instrumentConsole ( ) ;
50
+ break ;
51
+ case 'dom' :
52
+ instrumentDOM ( ) ;
53
+ break ;
54
+ case 'xhr' :
55
+ instrumentXHR ( ) ;
56
+ break ;
57
+ case 'fetch' :
58
+ instrumentFetch ( ) ;
59
+ break ;
60
+ case 'history' :
61
+ instrumentHistory ( ) ;
62
+ break ;
63
+ default :
64
+ logger . warn ( 'unknown instrumentation type:' , type ) ;
56
65
}
57
66
}
58
67
59
68
/**
60
- * Add handler that will be called when given type of instrumentation triggers
69
+ * Add handler that will be called when given type of instrumentation triggers.
70
+ * Use at your own risk, this might break without changelog notice, only used internally.
71
+ * @hidden
61
72
*/
62
73
export function addInstrumentationHandler ( handler : InstrumentHandler ) : void {
63
74
// tslint:disable-next-line:strict-type-predicates
You can’t perform that action at this time.
0 commit comments