Skip to content

Commit 9ac13a1

Browse files
author
winjo
committed
feat: 增加 reporter 配置
1 parent 51e612e commit 9ac13a1

7 files changed

Lines changed: 85 additions & 7 deletions

File tree

packages/alex/src/api/createApp.tsx

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,13 @@ import {
77
IAppOpts,
88
STORAGE_DIR,
99
} from '@alipay/alex-core';
10-
import { SlotRenderer, SlotLocation, IAppRenderer, FILES_DEFAULTS } from '@ali/ide-core-browser';
10+
import {
11+
SlotRenderer,
12+
SlotLocation,
13+
IAppRenderer,
14+
FILES_DEFAULTS,
15+
IReporter,
16+
} from '@ali/ide-core-browser';
1117
import { BoxPanel, SplitPanel } from '@ali/ide-core-browser/lib/components';
1218
import { IThemeService } from '@ali/ide-theme/lib/common';
1319
import '@ali/ide-core-browser/lib/style/index.less';
@@ -150,6 +156,14 @@ export function createApp({ appConfig, runtimeConfig }: IConfig): IAppInstance {
150156
useValue: runtimeConfig,
151157
});
152158

159+
if (runtimeConfig.reporter) {
160+
app.injector.addProviders({
161+
token: IReporter,
162+
useValue: runtimeConfig.reporter,
163+
override: true,
164+
});
165+
}
166+
153167
(window as any)[RuntimeConfig] = runtimeConfig;
154168

155169
return app;

packages/alex/src/api/createEditor.tsx

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,13 @@ import {
77
IAppOpts,
88
STORAGE_DIR,
99
} from '@alipay/alex-core';
10-
import { SlotRenderer, SlotLocation, IAppRenderer, FILES_DEFAULTS } from '@ali/ide-core-browser';
10+
import {
11+
SlotRenderer,
12+
SlotLocation,
13+
IAppRenderer,
14+
FILES_DEFAULTS,
15+
IReporter,
16+
} from '@ali/ide-core-browser';
1117
import { BoxPanel, SplitPanel } from '@ali/ide-core-browser/lib/components';
1218
import { IThemeService } from '@ali/ide-theme/lib/common';
1319
import '@ali/ide-core-browser/lib/style/index.less';
@@ -129,6 +135,14 @@ export function createEditor({ appConfig, runtimeConfig }: IConfig): IAppInstanc
129135
useValue: runtimeConfig,
130136
});
131137

138+
if (runtimeConfig.reporter) {
139+
app.injector.addProviders({
140+
token: IReporter,
141+
useValue: runtimeConfig.reporter,
142+
override: true,
143+
});
144+
}
145+
132146
(window as any)[RuntimeConfig] = runtimeConfig;
133147

134148
return app;

packages/alex/src/api/exports.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,5 @@
1+
import { REPORT_NAME } from '@alipay/alex-core';
2+
13
export { getDefaultLayoutConfig } from '../core/layout';
4+
5+
export { REPORT_NAME };

packages/alex/src/editor.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,4 @@ export * from './api/createEditor';
22
export * from './api/renderEditor';
33
export * from './api/register';
44
export * from './api/types';
5+
export * from './api/exports';

packages/core/src/common/enum.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
export enum REPORT_NAME {
22
ALEX_APP_START_ERROR = 'alex.appStartError',
33
CODE_SERVICE_REQUEST_ERROR = 'code-service.requestError',
4+
LSIF_LANGUAGE_SERVICE = 'lsif.languageService',
45
}

packages/core/src/common/types.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import { IReporter } from '@ali/ide-core-common';
12
import { BrowserFS, FileSystemConfiguration, FileSystemInstance } from '../server/node';
23

34
export { AppConfig } from '@ali/ide-core-browser';
@@ -80,4 +81,8 @@ export interface RuntimeConfig {
8081
* 隐藏编辑器区 tab
8182
*/
8283
hideEditorTab?: boolean;
84+
/**
85+
* reporter 服务,可获取内部上报的埋点相关数据
86+
*/
87+
reporter?: IReporter;
8388
}

packages/lsif-service/src/language-service.contribution.ts

Lines changed: 44 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,12 @@
11
import { Autowired } from '@ali/common-di';
2-
import { CommandService, Disposable, Domain, URI, Uri } from '@ali/ide-core-common';
2+
import {
3+
CommandService,
4+
Disposable,
5+
Domain,
6+
URI,
7+
Uri,
8+
IReporterService,
9+
} from '@ali/ide-core-common';
310
import {
411
ClientAppContribution,
512
PreferenceService,
@@ -15,7 +22,7 @@ import { EditorComponentRegistry, ResourceService, IResource } from '@ali/ide-ed
1522

1623
import * as vscode from 'vscode';
1724
import { LSIF_PROD_API_HOST, LSIF_TEST_API_HOST, LsifClient } from '@alipay/lsif-client';
18-
import { RuntimeConfig } from '@alipay/alex-core';
25+
import { RuntimeConfig, REPORT_NAME } from '@alipay/alex-core';
1926
import {
2027
BrowserEditorContribution,
2128
IEditorDocumentModelContentRegistry,
@@ -57,6 +64,9 @@ export class LsifContribution
5764
@Autowired()
5865
labelService: LabelService;
5966

67+
@Autowired(IReporterService)
68+
reporterService: IReporterService;
69+
6070
readonly schema = lsifPreferenceSchema;
6171

6272
private async getCodeServiceProject(): Promise<
@@ -133,15 +143,26 @@ export class LsifContribution
133143
const path = _rootUri.relative(new URI(document.uri));
134144
if (!path) return;
135145

136-
return await this.lsifClient.hover({
146+
const params = {
137147
repository: project,
138148
commit,
139149
path: path.toString(),
140150
position: {
141151
character: position.character,
142152
line: position.line,
143153
},
154+
};
155+
156+
const ret = await this.lsifClient.hover(params);
157+
158+
setTimeout(() => {
159+
this.reporterService.point(REPORT_NAME.LSIF_LANGUAGE_SERVICE, 'provideHover', {
160+
params,
161+
response: ret,
162+
});
144163
});
164+
165+
return ret;
145166
},
146167
}
147168
)
@@ -163,14 +184,23 @@ export class LsifContribution
163184
const path = _rootUri.relative(new URI(document.uri));
164185
if (!path) return;
165186

166-
const ret = await this.lsifClient.reference({
187+
const params = {
167188
repository: project,
168189
commit,
169190
path: path.toString(),
170191
position: {
171192
character: position.character,
172193
line: position.line,
173194
},
195+
};
196+
197+
const ret = await this.lsifClient.reference(params);
198+
199+
setTimeout(() => {
200+
this.reporterService.point(REPORT_NAME.LSIF_LANGUAGE_SERVICE, 'provideReferences', {
201+
params,
202+
response: ret,
203+
});
174204
});
175205

176206
if (!ret) {
@@ -234,14 +264,23 @@ export class LsifContribution
234264
const path = _rootUri.relative(new URI(document.uri));
235265
if (!path) return;
236266

237-
const ret = await this.lsifClient.definition({
267+
const params = {
238268
repository: project,
239269
commit,
240270
path: path.toString(),
241271
position: {
242272
character: position.character,
243273
line: position.line,
244274
},
275+
};
276+
277+
const ret = await this.lsifClient.definition(params);
278+
279+
setTimeout(() => {
280+
this.reporterService.point(REPORT_NAME.LSIF_LANGUAGE_SERVICE, 'provideDefinition', {
281+
params,
282+
response: ret,
283+
});
245284
});
246285

247286
if (!ret) {

0 commit comments

Comments
 (0)