Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
徽霖
Vscode
提交
4e03bf42
V
Vscode
项目概览
徽霖
/
Vscode
通知
9
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
V
Vscode
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
4e03bf42
编写于
3月 08, 2017
作者:
C
Christof Marti
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Send machineId to main process (fixes #22169)
上级
4795fc43
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
32 addition
and
14 deletion
+32
-14
src/vs/base/node/id.ts
src/vs/base/node/id.ts
+4
-5
src/vs/code/electron-main/main.ts
src/vs/code/electron-main/main.ts
+12
-2
src/vs/platform/telemetry/node/commonProperties.ts
src/vs/platform/telemetry/node/commonProperties.ts
+4
-3
src/vs/platform/telemetry/node/workbenchCommonProperties.ts
src/vs/platform/telemetry/node/workbenchCommonProperties.ts
+12
-4
未找到文件。
src/vs/base/node/id.ts
浏览文件 @
4e03bf42
...
...
@@ -99,13 +99,12 @@ export function _futureMachineIdExperiment(): string {
let
machineId
:
TPromise
<
string
>
;
export
function
getMachineId
():
TPromise
<
string
>
{
return
machineId
||
(
machineId
=
get
Stable
MachineId
()
return
machineId
||
(
machineId
=
get
Mac
MachineId
()
.
then
(
id
=>
id
||
uuid
.
generateUuid
()));
// fallback, generate a UUID
}
let
stableMachineId
:
TPromise
<
string
>
;
export
function
getStableMachineId
():
TPromise
<
string
>
{
return
stableMachineId
||
(
stableMachineId
=
new
TPromise
<
string
>
(
resolve
=>
{
function
getMacMachineId
():
TPromise
<
string
>
{
return
new
TPromise
<
string
>
(
resolve
=>
{
try
{
getmac
.
getMac
((
error
,
macAddress
)
=>
{
if
(
!
error
)
{
...
...
@@ -118,5 +117,5 @@ export function getStableMachineId(): TPromise<string> {
errors
.
onUnexpectedError
(
err
);
resolve
(
undefined
);
}
})
)
;
});
}
src/vs/code/electron-main/main.ts
浏览文件 @
4e03bf42
...
...
@@ -52,7 +52,7 @@ import { ITelemetryService } from 'vs/platform/telemetry/common/telemetry';
import
{
NullTelemetryService
}
from
'
vs/platform/telemetry/common/telemetryUtils
'
;
import
{
ITelemetryAppenderChannel
,
TelemetryAppenderClient
}
from
'
vs/platform/telemetry/common/telemetryIpc
'
;
import
{
TelemetryService
,
ITelemetryServiceConfig
}
from
'
vs/platform/telemetry/common/telemetryService
'
;
import
{
resolveCommonProperties
}
from
'
vs/platform/telemetry/node/commonProperties
'
;
import
{
resolveCommonProperties
,
machineIdStorageKey
,
machineIdIpcChannel
}
from
'
vs/platform/telemetry/node/commonProperties
'
;
import
{
getDelayedChannel
}
from
'
vs/base/parts/ipc/common/ipc
'
;
import
product
from
'
vs/platform/node/product
'
;
import
pkg
from
'
vs/platform/node/package
'
;
...
...
@@ -94,6 +94,7 @@ function main(accessor: ServicesAccessor, mainIpcServer: Server, userEnv: platfo
const
environmentService
=
accessor
.
get
(
IEnvironmentService
);
const
lifecycleService
=
accessor
.
get
(
ILifecycleService
);
const
configurationService
=
accessor
.
get
(
IConfigurationService
)
as
ConfigurationService
<
any
>
;
const
storageService
=
accessor
.
get
(
IStorageService
);
let
windowsMainService
:
IWindowsMainService
;
// We handle uncaught exceptions here to prevent electron from opening a dialog to the user
...
...
@@ -118,6 +119,11 @@ function main(accessor: ServicesAccessor, mainIpcServer: Server, userEnv: platfo
}
});
ipc
.
on
(
machineIdIpcChannel
,
(
event
,
machineId
:
string
)
=>
{
logService
.
log
(
'
IPC#vscode-machineId
'
);
storageService
.
setItem
(
machineIdStorageKey
,
machineId
);
});
logService
.
log
(
'
Starting VS Code in verbose mode
'
);
logService
.
log
(
`from:
${
environmentService
.
appRoot
}
`
);
logService
.
log
(
'
args:
'
,
environmentService
.
args
);
...
...
@@ -159,7 +165,11 @@ function main(accessor: ServicesAccessor, mainIpcServer: Server, userEnv: platfo
if
(
environmentService
.
isBuilt
&&
!
environmentService
.
isExtensionDevelopment
&&
!!
product
.
enableTelemetry
)
{
const
channel
=
getDelayedChannel
<
ITelemetryAppenderChannel
>
(
sharedProcessClient
.
then
(
c
=>
c
.
getChannel
(
'
telemetryAppender
'
)));
const
appender
=
new
TelemetryAppenderClient
(
channel
);
const
commonProperties
=
resolveCommonProperties
(
product
.
commit
,
pkg
.
version
);
const
commonProperties
=
resolveCommonProperties
(
product
.
commit
,
pkg
.
version
)
.
then
(
result
=>
Object
.
defineProperty
(
result
,
'
common.machineId
'
,
{
get
:
()
=>
storageService
.
getItem
(
machineIdStorageKey
),
enumerable
:
true
}));
const
piiPaths
=
[
environmentService
.
appRoot
,
environmentService
.
extensionsPath
];
const
config
:
ITelemetryServiceConfig
=
{
appender
,
commonProperties
,
piiPaths
};
services
.
set
(
ITelemetryService
,
new
SyncDescriptor
(
TelemetryService
,
config
));
...
...
src/vs/platform/telemetry/node/commonProperties.ts
浏览文件 @
4e03bf42
...
...
@@ -7,7 +7,9 @@ import * as Platform from 'vs/base/common/platform';
import
*
as
os
from
'
os
'
;
import
{
TPromise
}
from
'
vs/base/common/winjs.base
'
;
import
*
as
uuid
from
'
vs/base/common/uuid
'
;
import
{
getStableMachineId
}
from
'
vs/base/node/id
'
;
export
const
machineIdStorageKey
=
'
telemetry.machineId
'
;
export
const
machineIdIpcChannel
=
'
vscode:machineId
'
;
export
function
resolveCommonProperties
(
commit
:
string
,
version
:
string
):
TPromise
<
{
[
name
:
string
]:
string
;
}
>
{
const
result
:
{
[
name
:
string
]:
string
;
}
=
Object
.
create
(
null
);
...
...
@@ -17,7 +19,6 @@ export function resolveCommonProperties(commit: string, version: string): TPromi
result
[
'
version
'
]
=
version
;
result
[
'
common.osVersion
'
]
=
os
.
release
();
result
[
'
common.platform
'
]
=
Platform
.
Platform
[
Platform
.
platform
];
const
promise
=
getStableMachineId
().
then
(
value
=>
result
[
'
common.mainProcess.machineId
'
]
=
value
);
// dynamic properties which value differs on each call
let
seq
=
0
;
...
...
@@ -37,5 +38,5 @@ export function resolveCommonProperties(commit: string, version: string): TPromi
}
});
return
promise
.
then
(()
=>
result
);
return
TPromise
.
as
(
result
);
}
\ No newline at end of file
src/vs/platform/telemetry/node/workbenchCommonProperties.ts
浏览文件 @
4e03bf42
...
...
@@ -10,7 +10,8 @@ import * as errors from 'vs/base/common/errors';
import
*
as
uuid
from
'
vs/base/common/uuid
'
;
import
{
IStorageService
}
from
'
vs/platform/storage/common/storage
'
;
import
{
getMachineId
,
virtualMachineHint
}
from
'
vs/base/node/id
'
;
import
{
resolveCommonProperties
}
from
'
../node/commonProperties
'
;
import
{
resolveCommonProperties
,
machineIdStorageKey
,
machineIdIpcChannel
}
from
'
../node/commonProperties
'
;
import
{
ipcRenderer
as
ipc
}
from
'
electron
'
;
const
SQM_KEY
:
string
=
'
\\
Software
\\
Microsoft
\\
SQMClient
'
;
...
...
@@ -50,15 +51,22 @@ function getOrCreateInstanceId(storageService: IStorageService): TPromise<string
}
function
getOrCreateMachineId
(
storageService
:
IStorageService
):
TPromise
<
string
>
{
const
key
=
'
telemetry.machineId
'
;
let
result
=
storageService
.
get
(
key
);
return
_getOrCreateMachineId
(
storageService
)
.
then
(
value
=>
{
ipc
.
send
(
machineIdIpcChannel
,
value
);
return
value
;
});
}
function
_getOrCreateMachineId
(
storageService
:
IStorageService
):
TPromise
<
string
>
{
let
result
=
storageService
.
get
(
machineIdStorageKey
);
if
(
result
)
{
return
TPromise
.
as
(
result
);
}
return
getMachineId
().
then
(
result
=>
{
storageService
.
store
(
k
ey
,
result
);
storageService
.
store
(
machineIdStorageK
ey
,
result
);
return
result
;
});
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录