Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: fix dependencies of telemetry #3280

Merged
merged 1 commit into from
Sep 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ export class SheetRenderController extends RxDisposable implements IRenderModule
@Inject(SheetSkeletonManagerService) private readonly _sheetSkeletonManagerService: SheetSkeletonManagerService,
@Inject(SheetsRenderService) private readonly _sheetRenderService: SheetsRenderService,
@ICommandService private readonly _commandService: ICommandService,
@Optional(ITelemetryService) private readonly _telemetryService: ITelemetryService
@Optional(ITelemetryService) private readonly _telemetryService?: ITelemetryService
) {
super();
this._addNewRender();
Expand All @@ -83,9 +83,10 @@ export class SheetRenderController extends RxDisposable implements IRenderModule
private _renderFrameTimeMetric: Nullable<Record<string, number[]>> = null;
private _renderFrameTags: Record<string, any> = {};

afterRenderMetric$: Subject<IAfterRender$Info> = new Subject<IAfterRender$Info>();
private _afterRenderMetric$: Subject<IAfterRender$Info> = new Subject<IAfterRender$Info>();
private _initRenderMetricSubscriber() {
if (!this._telemetryService) return;

const { engine } = this._context;

engine.beginFrame$.subscribe(() => {
Expand All @@ -98,7 +99,7 @@ export class SheetRenderController extends RxDisposable implements IRenderModule
Object.keys(this._renderFrameTimeMetric).filter((key) => key.startsWith(SHEET_EXTENSION_PREFIX)).length > 0;

if (validRenderInfo) {
this.afterRenderMetric$.next({
this._afterRenderMetric$.next({
frameTimeMetric: this._renderFrameTimeMetric,
tags: this._renderFrameTags,
} as IAfterRender$Info);
Expand All @@ -119,27 +120,24 @@ export class SheetRenderController extends RxDisposable implements IRenderModule
});

const frameInfoList: IExtendFrameInfo[] = [];
this.afterRenderMetric$.pipe(
withLatestFrom(engine.endFrame$)
).subscribe(([sceneRenderDetail, basicFrameTimeInfo]: [IAfterRender$Info, IBasicFrameInfo ]) => {
this._afterRenderMetric$.pipe(withLatestFrom(engine.endFrame$)).subscribe(([sceneRenderDetail, basicFrameTimeInfo]: [IAfterRender$Info, IBasicFrameInfo ]) => {
frameInfoList.push({
...{
FPS: basicFrameTimeInfo.FPS,
elapsedTime: basicFrameTimeInfo.elapsedTime,
frameTime: Math.round(basicFrameTimeInfo.frameTime * 100) / 100,

},
...sceneRenderDetail.frameTimeMetric,
...sceneRenderDetail.tags,
});
if (frameInfoList.length > FRAME_STACK_THRESHOLD) {
this._renderMetryCapture(frameInfoList);
this._renderMetricCapture(frameInfoList);
frameInfoList.length = 0;
}
});
}

private _renderMetryCapture(frameInfoList: IExtendFrameInfo[]) {
private _renderMetricCapture(frameInfoList: IExtendFrameInfo[]) {
const filteredFrameInfo = frameInfoList;//.filter((info) => info.scrolling);
if (filteredFrameInfo.length === 0) return;

Expand Down Expand Up @@ -201,7 +199,7 @@ export class SheetRenderController extends RxDisposable implements IRenderModule
const sheetId = this._context.unit.getActiveSheet().getSheetId();
const unitId = this._context.unit.getUnitId();
const telemetryData = { sheetId, unitId, elapsedTimeToStart, ...summaryFrameStats };
this._telemetryService.capture(TelemetryEventNames.sheet_render_cost, telemetryData);
this._telemetryService!.capture(TelemetryEventNames.sheet_render_cost, telemetryData);
}

private _addComponent(workbook: Workbook) {
Expand Down
1 change: 0 additions & 1 deletion packages/telemetry/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,6 @@
"devDependencies": {
"@univerjs/core": "workspace:*",
"@univerjs/shared": "workspace:*",
"@wendellhu/redi": "0.16.1",
"react": "18.3.1",
"rxjs": "^7.8.1",
"typescript": "^5.5.3",
Expand Down
4 changes: 3 additions & 1 deletion packages/telemetry/src/services/telemetry-service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@
* limitations under the License.
*/

import { createIdentifier } from '@wendellhu/redi';
import { createIdentifier } from '@univerjs/core';

// Enum for telemetry event names
export enum TelemetryEventNames {
/** space */
Expand All @@ -32,6 +33,7 @@ export enum TelemetryEventNames {

sheet_render_cost = 'sheet_render_timecost',
};

// Base interface for telemetry service
export interface ITelemetryService {
identify: (id: string, params?: Record<string, any>) => void;
Expand Down
3 changes: 0 additions & 3 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading