File tree 1 file changed +14
-17
lines changed
src/webhint-theme/source/js/telemetry
1 file changed +14
-17
lines changed Original file line number Diff line number Diff line change 1
1
"use strict" ;
2
2
( function ( ) {
3
3
const activityKey = 'webhint-activity' ;
4
+ const productKey = 'webhint-online-scanner' ;
4
5
const storage = window . localStorage ;
5
6
const telemetryApiEndpoint = 'http://localhost:7071/api/webhint-telemetry-ingress-api' ;
6
- let nameKey = '' ;
7
7
let sendTimeout = null ;
8
8
let telemetryQueue = [ ] ;
9
9
let options = {
10
10
batchDelay : 15000 ,
11
11
defaultProperties : { } ,
12
- enabled : false ,
13
- instrumentationKey : '8ef2b55b-2ce9-4c33-a09a-2c3ef605c97d' ,
14
12
} ;
15
13
16
14
const post = async ( url , data ) => {
29
27
clearTimeout ( sendTimeout ) ;
30
28
sendTimeout = null ;
31
29
}
32
- const data = JSON . stringify ( telemetryQueue ) ;
30
+ const data = JSON . stringify ( {
31
+ product : productKey ,
32
+ data : telemetryQueue
33
+ } ) ;
34
+
33
35
telemetryQueue = [ ] ;
34
36
try {
35
37
post ( telemetryApiEndpoint , data )
45
47
} ;
46
48
47
49
const track = async ( type , data ) => {
48
- telemetryQueue . push ( {
49
- data : {
50
- baseData : {
51
- name : data . name ,
52
- properties : Object . assign ( Object . assign ( { } , options . defaultProperties ) , data . properties ) ,
53
- ver : 2
54
- } ,
55
- baseType : `${ type } Data`
56
- } ,
57
- iKey : options . instrumentationKey ,
58
- name : `Microsoft.ApplicationInsights.${ nameKey } .${ type } ` ,
59
- time : new Date ( ) . toISOString ( )
60
- } ) ;
50
+ telemetryQueue . push (
51
+ {
52
+ name : data . name ,
53
+ properties : Object . assign ( Object . assign ( { } , options . defaultProperties ) , data . properties ) ,
54
+ ver : 2 ,
55
+ type : `${ type } Data`
56
+ }
57
+ ) ;
61
58
if ( ! options . batchDelay ) {
62
59
await sendTelemetry ( ) ;
63
60
}
You can’t perform that action at this time.
0 commit comments