Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
掘金者说
vscode
提交
273e8857
V
vscode
项目概览
掘金者说
/
vscode
与 Fork 源项目一致
从无法访问的项目Fork
通知
1
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,发现更多精彩内容 >>
提交
273e8857
编写于
6月 07, 2016
作者:
J
Joao Moreno
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
extract idle monitor from telemetry service
上级
5531a3bc
变更
5
展开全部
隐藏空白更改
内联
并排
Showing
5 changed file
with
43 addition
and
273 deletion
+43
-273
src/vs/base/common/idleMonitor.ts
src/vs/base/common/idleMonitor.ts
+0
-24
src/vs/platform/telemetry/browser/idleMonitor.ts
src/vs/platform/telemetry/browser/idleMonitor.ts
+9
-7
src/vs/platform/telemetry/common/telemetryService.ts
src/vs/platform/telemetry/common/telemetryService.ts
+0
-37
src/vs/platform/telemetry/test/node/telemetryService.test.ts
src/vs/platform/telemetry/test/node/telemetryService.test.ts
+23
-197
src/vs/workbench/electron-browser/shell.ts
src/vs/workbench/electron-browser/shell.ts
+11
-8
未找到文件。
src/vs/base/common/idleMonitor.ts
已删除
100644 → 0
浏览文件 @
5531a3bc
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
'
use strict
'
;
import
Event
,
{
Emitter
}
from
'
vs/base/common/event
'
;
import
{
IDisposable
}
from
'
vs/base/common/lifecycle
'
;
export
enum
UserStatus
{
Idle
,
Active
}
export
interface
IIdleMonitor
extends
IDisposable
{
status
:
UserStatus
;
onStatusChange
:
Event
<
UserStatus
>
;
}
export
class
NeverIdleMonitor
implements
IIdleMonitor
{
status
=
UserStatus
.
Active
;
onStatusChange
=
new
Emitter
().
event
;
dispose
()
{}
}
\ No newline at end of file
src/vs/
base
/browser/idleMonitor.ts
→
src/vs/
platform/telemetry
/browser/idleMonitor.ts
浏览文件 @
273e8857
...
...
@@ -4,15 +4,17 @@
*--------------------------------------------------------------------------------------------*/
'
use strict
'
;
import
{
UserStatus
,
IIdleMonitor
}
from
'
vs/base/common/idleMonitor
'
;
import
{
TimeoutTimer
}
from
'
vs/base/common/async
'
;
import
Event
,
{
Emitter
}
from
'
vs/base/common/event
'
;
import
{
Disposable
}
from
'
vs/base/common/lifecycle
'
;
import
{
TimeoutTimer
}
from
'
vs/base/common/async
'
;
import
Event
,
{
Emitter
}
from
'
vs/base/common/event
'
;
import
{
Disposable
}
from
'
vs/base/common/lifecycle
'
;
import
*
as
dom
from
'
vs/base/browser/dom
'
;
export
const
DEFAULT_IDLE_TIME
=
60
*
60
*
1000
;
// 60 minutes
export
enum
UserStatus
{
Idle
,
Active
}
export
class
IdleMonitor
extends
Disposable
implements
IIdleMonitor
{
export
class
IdleMonitor
extends
Disposable
{
private
_lastActiveTime
:
number
;
private
_idleCheckTimeout
:
TimeoutTimer
;
...
...
@@ -22,7 +24,7 @@ export class IdleMonitor extends Disposable implements IIdleMonitor {
private
_onStatusChange
:
Emitter
<
UserStatus
>
;
get
onStatusChange
():
Event
<
UserStatus
>
{
return
this
.
_onStatusChange
.
event
;
}
constructor
(
idleTime
:
number
=
DEFAULT_IDLE_TIME
)
{
constructor
(
idleTime
)
{
super
();
this
.
_status
=
null
;
...
...
src/vs/platform/telemetry/common/telemetryService.ts
浏览文件 @
273e8857
...
...
@@ -11,7 +11,6 @@ import {ITelemetryService, ITelemetryAppender, ITelemetryInfo} from 'vs/platform
import
{
optional
}
from
'
vs/platform/instantiation/common/instantiation
'
;
import
{
IConfigurationService
}
from
'
vs/platform/configuration/common/configuration
'
;
import
{
IConfigurationRegistry
,
Extensions
}
from
'
vs/platform/configuration/common/configurationRegistry
'
;
import
{
IIdleMonitor
,
UserStatus
}
from
'
vs/base/common/idleMonitor
'
;
import
{
TPromise
}
from
'
vs/base/common/winjs.base
'
;
import
{
IDisposable
,
dispose
}
from
'
vs/base/common/lifecycle
'
;
import
{
TimeKeeper
,
ITimerEvent
}
from
'
vs/base/common/timer
'
;
...
...
@@ -20,8 +19,6 @@ import {Registry} from 'vs/platform/platform';
export
interface
ITelemetryServiceConfig
{
appender
:
ITelemetryAppender
[];
hardIdleMonitor
:
IIdleMonitor
;
softIdleMonitor
:
IIdleMonitor
;
commonProperties
?:
TPromise
<
{
[
name
:
string
]:
any
}
>
;
piiPaths
?:
string
[];
userOptIn
?:
boolean
;
...
...
@@ -29,8 +26,6 @@ export interface ITelemetryServiceConfig {
export
class
TelemetryService
implements
ITelemetryService
{
// how long of inactivity before a user is considered 'inactive' - 2 minutes
public
static
SOFT_IDLE_TIME
=
2
*
60
*
1000
;
public
static
IDLE_START_EVENT_NAME
=
'
UserIdleStart
'
;
public
static
IDLE_STOP_EVENT_NAME
=
'
UserIdleStop
'
;
...
...
@@ -39,8 +34,6 @@ export class TelemetryService implements ITelemetryService {
private
_configuration
:
ITelemetryServiceConfig
;
private
_disposables
:
IDisposable
[]
=
[];
private
_timeKeeper
:
TimeKeeper
;
private
_hardIdleMonitor
:
IIdleMonitor
;
private
_softIdleMonitor
:
IIdleMonitor
;
private
_cleanupPatterns
:
[
RegExp
,
string
][]
=
[];
constructor
(
...
...
@@ -49,8 +42,6 @@ export class TelemetryService implements ITelemetryService {
)
{
this
.
_configuration
=
mixin
(
config
,
<
ITelemetryServiceConfig
>
{
appender
:
[],
hardIdleMonitor
:
null
,
softIdleMonitor
:
null
,
commonProperties
:
TPromise
.
as
({}),
piiPaths
:
[],
userOptIn
:
true
...
...
@@ -73,13 +64,6 @@ export class TelemetryService implements ITelemetryService {
this
.
_disposables
.
push
(
this
.
_timeKeeper
);
this
.
_disposables
.
push
(
this
.
_timeKeeper
.
addListener
(
events
=>
this
.
_onTelemetryTimerEventStop
(
events
)));
this
.
_hardIdleMonitor
=
this
.
_configuration
.
hardIdleMonitor
;
this
.
_softIdleMonitor
=
this
.
_configuration
.
softIdleMonitor
;
if
(
this
.
_softIdleMonitor
)
{
this
.
_disposables
.
push
(
this
.
_softIdleMonitor
.
onStatusChange
(
status
=>
this
.
_onIdleStatus
(
status
)));
}
if
(
this
.
_configurationService
)
{
this
.
_updateUserOptIn
();
this
.
_configurationService
.
onDidUpdateConfiguration
(
this
.
_updateUserOptIn
,
this
,
this
.
_disposables
);
...
...
@@ -87,27 +71,11 @@ export class TelemetryService implements ITelemetryService {
}
}
private
_onIdleStatus
(
status
:
UserStatus
):
void
{
if
(
status
===
UserStatus
.
Active
)
{
this
.
_onUserActive
();
}
else
{
this
.
_onUserIdle
();
}
}
private
_updateUserOptIn
():
void
{
const
config
=
this
.
_configurationService
.
getConfiguration
<
any
>
(
TELEMETRY_SECTION_ID
);
this
.
_configuration
.
userOptIn
=
config
?
config
.
enableTelemetry
:
this
.
_configuration
.
userOptIn
;
}
private
_onUserIdle
():
void
{
this
.
publicLog
(
TelemetryService
.
IDLE_START_EVENT_NAME
);
}
private
_onUserActive
():
void
{
this
.
publicLog
(
TelemetryService
.
IDLE_STOP_EVENT_NAME
);
}
private
_onTelemetryTimerEventStop
(
events
:
ITimerEvent
[]):
void
{
for
(
let
i
=
0
;
i
<
events
.
length
;
i
++
)
{
let
event
=
events
[
i
];
...
...
@@ -146,11 +114,6 @@ export class TelemetryService implements ITelemetryService {
}
public
publicLog
(
eventName
:
string
,
data
?:
any
):
TPromise
<
any
>
{
if
(
this
.
_hardIdleMonitor
&&
this
.
_hardIdleMonitor
.
status
===
UserStatus
.
Idle
)
{
return
TPromise
.
as
(
undefined
);
}
// don't send events when the user is optout unless the event is the opt{in|out} signal
if
(
!
this
.
_configuration
.
userOptIn
&&
eventName
!==
'
optInStatus
'
)
{
return
TPromise
.
as
(
undefined
);
...
...
src/vs/platform/telemetry/test/node/telemetryService.test.ts
浏览文件 @
273e8857
此差异已折叠。
点击以展开。
src/vs/workbench/electron-browser/shell.ts
浏览文件 @
273e8857
...
...
@@ -21,7 +21,7 @@ import {Workbench} from 'vs/workbench/browser/workbench';
import
{
Storage
,
inMemoryLocalStorageInstance
}
from
'
vs/workbench/common/storage
'
;
import
{
ITelemetryService
,
NullTelemetryService
}
from
'
vs/platform/telemetry/common/telemetry
'
;
import
{
TelemetryService
,
ITelemetryServiceConfig
}
from
'
vs/platform/telemetry/common/telemetryService
'
;
import
{
IdleMonitor
}
from
'
vs/base
/browser/idleMonitor
'
;
import
{
IdleMonitor
,
UserStatus
}
from
'
vs/platform/telemetry
/browser/idleMonitor
'
;
import
ErrorTelemetry
from
'
vs/platform/telemetry/browser/errorTelemetry
'
;
import
{
createAppender
}
from
'
vs/platform/telemetry/node/appInsightsAppender
'
;
import
{
resolveCommonProperties
}
from
'
vs/platform/telemetry/node/commonProperties
'
;
...
...
@@ -216,22 +216,25 @@ export class WorkbenchShell {
// Telemetry
if
(
this
.
configuration
.
env
.
isBuilt
&&
!
this
.
configuration
.
env
.
extensionDevelopmentPath
&&
!!
this
.
configuration
.
env
.
enableTelemetry
)
{
const
appender
=
createAppender
(
this
.
configuration
.
env
);
const
hardIdleMonitor
=
new
IdleMonitor
();
const
softIdleMonitor
=
new
IdleMonitor
(
TelemetryService
.
SOFT_IDLE_TIME
);
const
config
:
ITelemetryServiceConfig
=
{
appender
,
hardIdleMonitor
,
softIdleMonitor
,
commonProperties
:
resolveCommonProperties
(
this
.
storageService
,
this
.
contextService
),
piiPaths
:
[
this
.
configuration
.
env
.
appRoot
,
this
.
configuration
.
env
.
userExtensionsHome
]
};
const
telemetryService
=
instantiationService
.
createInstance
(
TelemetryService
,
config
);
this
.
telemetryService
=
telemetryService
;
const
errorTelemetry
=
new
ErrorTelemetry
(
telemetryService
);
const
idleMonitor
=
new
IdleMonitor
(
2
*
60
*
1000
);
// 2 minutes
this
.
telemetryService
=
telemetryService
;
disposables
.
add
(
telemetryService
,
errorTelemetry
,
hardIdleMonitor
,
softIdleMonitor
,
...
appender
);
const
listener
=
idleMonitor
.
onStatusChange
(
status
=>
this
.
telemetryService
.
publicLog
(
status
===
UserStatus
.
Active
?
TelemetryService
.
IDLE_STOP_EVENT_NAME
:
TelemetryService
.
IDLE_START_EVENT_NAME
));
disposables
.
add
(
telemetryService
,
errorTelemetry
,
listener
,
idleMonitor
,
...
appender
);
}
else
{
this
.
telemetryService
=
NullTelemetryService
;
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录