FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
vscode-pull-request-github/src/experimentationService.ts at main · tamird/vscode-pull-request-github · GitHub
tamird
/
vscode-pull-request-github
Public
forked from
microsoft/vscode-pull-request-github
Notifications
You must be signed in to change notification settings
Fork
0
Star
0
Code
Pull requests
0
Actions
Projects
Security and quality
0
Insights
Additional navigation options
Code
Pull requests
Actions
Projects
Security and quality
Insights
Expand file tree
Breadcrumbs
vscode-pull-request-github
/
src
/
experimentationService.ts
Copy path
More file actions
More file actions
Latest commit
History
History
History
129 lines (112 loc) · 3.65 KB
Breadcrumbs
vscode-pull-request-github
/
src
/
experimentationService.ts
Copy path
File metadata and controls
129 lines (112 loc) · 3.65 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
import
{
TelemetryReporter
}
from
'@vscode/extension-telemetry'
;
import
*
as
vscode
from
'vscode'
;
import
{
getExperimentationService
,
IExperimentationService
,
IExperimentationTelemetry
,
TargetPopulation
,
}
from
'vscode-tas-client'
;
import
{
Disposable
}
from
'./common/lifecycle'
;
/* __GDPR__
"query-expfeature" : {
"ABExp.queriedFeature": { "classification": "SystemMetaData", "purpose": "FeatureInsight" }
}
*/
export
class
ExperimentationTelemetry
extends
Disposable
implements
IExperimentationTelemetry
{
private
sharedProperties
:
Record
<
string
,
string
>
=
{
}
;
constructor
(
private
baseReporter
:
TelemetryReporter
|
undefined
)
{
super
(
)
;
if
(
baseReporter
)
{
this
.
_register
(
baseReporter
)
;
}
}
sendTelemetryEvent
(
eventName
:
string
,
properties
?:
Record
<
string
,
string
>
,
measurements
?:
Record
<
string
,
number
>
)
{
this
.
baseReporter
?.
sendTelemetryEvent
(
eventName
,
{
...
this
.
sharedProperties
,
...
properties
,
}
,
measurements
,
)
;
}
sendTelemetryErrorEvent
(
eventName
:
string
,
properties
?:
Record
<
string
,
string
>
,
_measurements
?:
Record
<
string
,
number
>
,
)
{
this
.
baseReporter
?.
sendTelemetryErrorEvent
(
eventName
,
{
...
this
.
sharedProperties
,
...
properties
,
}
)
;
}
setSharedProperty
(
name
:
string
,
value
:
string
)
:
void
{
this
.
sharedProperties
[
name
]
=
value
;
}
postEvent
(
eventName
:
string
,
props
:
Map
<
string
,
string
>
)
:
void
{
const
event
:
Record
<
string
,
string
>
=
{
}
;
for
(
const
[
key
,
value
]
of
props
)
{
event
[
key
]
=
value
;
}
this
.
sendTelemetryEvent
(
eventName
,
event
)
;
}
}
function
getTargetPopulation
(
)
:
TargetPopulation
{
switch
(
vscode
.
env
.
uriScheme
)
{
case
'vscode'
:
return
TargetPopulation
.
Public
;
case
'vscode-insiders'
:
return
TargetPopulation
.
Insiders
;
case
'vscode-exploration'
:
return
TargetPopulation
.
Internal
;
case
'code-oss'
:
return
TargetPopulation
.
Team
;
default
:
return
TargetPopulation
.
Public
;
}
}
class
NullExperimentationService
implements
IExperimentationService
{
readonly
initializePromise
:
Promise
<
void
>
=
Promise
.
resolve
(
)
;
readonly
initialFetch
:
Promise
<
void
>
=
Promise
.
resolve
(
)
;
isFlightEnabled
(
_flight
:
string
)
:
boolean
{
return
false
;
}
isCachedFlightEnabled
(
_flight
:
string
)
:
Promise
<
boolean
>
{
return
Promise
.
resolve
(
false
)
;
}
isFlightEnabledAsync
(
_flight
:
string
)
:
Promise
<
boolean
>
{
return
Promise
.
resolve
(
false
)
;
}
getTreatmentVariable
<
T
extends
boolean
|
number
|
string
>
(
_configId
:
string
,
_name
:
string
)
:
T
|
undefined
{
return
undefined
;
}
getTreatmentVariableAsync
<
T
extends
boolean
|
number
|
string
>
(
_configId
:
string
,
_name
:
string
,
)
:
Promise
<
T
|
undefined
>
{
return
Promise
.
resolve
(
undefined
)
;
}
}
export
async
function
createExperimentationService
(
context
:
vscode
.
ExtensionContext
,
experimentationTelemetry
:
ExperimentationTelemetry
,
)
:
Promise
<
IExperimentationService
>
{
const
id
=
context
.
extension
.
id
;
const
name
=
context
.
extension
.
packageJSON
[
'name'
]
;
const
version
:
string
=
context
.
extension
.
packageJSON
[
'version'
]
;
const
targetPopulation
=
getTargetPopulation
(
)
;
// We only create a real experimentation service for the stable version of the extension, not insiders.
return
name
===
'vscode-pull-request-github'
?
getExperimentationService
(
id
,
version
,
targetPopulation
,
experimentationTelemetry
,
context
.
globalState
,
)
:
new
NullExperimentationService
(
)
;
}
Back
|
FazBrowse Home
|
New Git URL