Skip to content

Commit b7f5066

Browse files
author
winjo
committed
feat: 增加埋点配置
1 parent 2170a38 commit b7f5066

4 files changed

Lines changed: 46 additions & 0 deletions

File tree

packages/alex/src/api/createApp.tsx

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ import { IconSlim, IDETheme } from '../core/extensions';
2424
import { mergeConfig, themeStorage } from '../core/utils';
2525
import { LayoutComponent, getDefaultLayoutConfig } from '../core/layout';
2626
import { IConfig, IAppInstance } from './types';
27+
import { logPv } from '../core/tracert';
2728

2829
export { SlotLocation, SlotRenderer, BoxPanel, SplitPanel };
2930

@@ -105,6 +106,13 @@ export function createApp({ appConfig, runtimeConfig }: IConfig): IAppInstance {
105106
});
106107
// IDE 销毁时,组件会触发 handleTreeBlur,但是 FileContextKey 实例尚未初始化,此时在 dispose 阶段,injector.get(FileContextKey) 会抛出错误
107108
app.injector.get(FileTreeModelService).handleTreeBlur();
109+
110+
if (runtimeConfig?.biz) {
111+
const { biz } = runtimeConfig;
112+
setTimeout(() => {
113+
logPv(biz);
114+
});
115+
}
108116
};
109117

110118
/**

packages/alex/src/core/tracert.ts

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
/**
2+
* 记录 PV,UV 埋点
3+
*/
4+
5+
declare var Tracert: {
6+
get: Function;
7+
set: Function;
8+
call: Function;
9+
};
10+
11+
const CLOUD_IDE_SPM_A = 'a1654';
12+
13+
export function logPv(spmBPos: string) {
14+
if (
15+
'Tracert' in window &&
16+
typeof Tracert.get === 'function' &&
17+
typeof Tracert.set === 'function' &&
18+
typeof Tracert.call === 'function'
19+
) {
20+
const originSpmA = Tracert.get('spmAPos');
21+
const originSpmB = Tracert.get('spmBPos');
22+
23+
Tracert.set({
24+
spmAPos: CLOUD_IDE_SPM_A,
25+
spmBPos,
26+
});
27+
28+
Tracert.call('logPv');
29+
30+
Tracert.set({
31+
spmAPos: originSpmA,
32+
spmBPos: originSpmB,
33+
});
34+
}
35+
}

packages/alex/src/integration/startup/index.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,7 @@ ReactDOM.render(
9999
}}
100100
runtimeConfig={{
101101
codeService: config as CodeServiceConfig,
102+
biz: 'alex',
102103
// unregisterActivityBarExtra: true,
103104
// hideLeftTabBar: true
104105
}}

packages/core/src/common/types.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,8 @@ export interface RuntimeConfig {
4747
* 如果指定为 null,表示不作为一个场景,此时不使用 indexedDB,也即不缓存工作空间及全局偏好设置等数据
4848
*/
4949
scenario?: string | null;
50+
/** 业务标识,用于内部埋点 */
51+
biz?: string;
5052
/** 工作空间配置 */
5153
workspace?: {
5254
filesystem?: FileSystemConfiguration;

0 commit comments

Comments
 (0)