diff --git a/packages/editor-core/src/utils/goldlog.ts b/packages/editor-core/src/utils/goldlog.ts deleted file mode 100644 index 4e594b15c..000000000 --- a/packages/editor-core/src/utils/goldlog.ts +++ /dev/null @@ -1,11 +0,0 @@ -/** - * 黄金令箭埋点 - * @param {String} gmKey 为黄金令箭业务类型 - * @param {Object} params 参数 - * @param {String} logKey 属性串 - */ -export function goldlog(gmKey: string, params: object = {}, logKey: string = 'other'): void { - -} - - diff --git a/packages/editor-core/src/utils/index.ts b/packages/editor-core/src/utils/index.ts index 6a4ef399a..8f37753ac 100644 --- a/packages/editor-core/src/utils/index.ts +++ b/packages/editor-core/src/utils/index.ts @@ -1,5 +1,5 @@ export * from './get-public-path'; -export * from './goldlog'; +export * from './monitor'; export * from './obx'; export * from './request'; export * from './focus-tracker'; diff --git a/packages/editor-core/src/utils/monitor.ts b/packages/editor-core/src/utils/monitor.ts new file mode 100644 index 000000000..b4c45bc8b --- /dev/null +++ b/packages/editor-core/src/utils/monitor.ts @@ -0,0 +1,45 @@ +class Monitor { + fn = (params: any) => { + const { AES } = window as any; + if (typeof AES.log === 'function') { + const { p1, p2, p3, p4 = 'OTHER', ...rest } = params || {}; + AES.log('event', { + p1, + p2, + p3, + p4, + ...rest, + }); + } + }; + + constructor() { + (window as any).AES = (window as any).AES || {}; + } + + register(fn: () => any) { + if (typeof fn === 'function') { + this.fn = fn; + } + } + + log(params: any) { + if (typeof this.fn === 'function') { + this.fn(params); + } + } + + setConfig(key: string | object, value?: string): void { + const { AES } = window as any; + if (typeof AES?.setConfig !== 'function') { + return; + } + if (typeof key === 'string' && value) { + AES.setConfig(key, value); + } else if (typeof key === 'object') { + AES.setConfig(key); + } + } +} + +export default new Monitor();