Skip to content

Commit cf6070f

Browse files
Maidang1mocayo
authored andcommitted
[feat][trace] add observation components (#158)
* feat(trace): add observation components * feat(trace): add observation i18n
1 parent 03bb315 commit cf6070f

87 files changed

Lines changed: 2450 additions & 703 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

frontend/apps/cozeloop/tailwind.config.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,5 +18,7 @@ export default createTailwindcssConfig({
1818
'@cozeloop/trace-list',
1919
'@cozeloop/observation-component-adapter',
2020
'@cozeloop/tag-pages',
21+
'@cozeloop/observation-component',
22+
'@cozeloop/tag-components',
2123
],
2224
}) as TailwindConfig;
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
// Copyright (c) 2025 coze-dev Authors
2+
// SPDX-License-Identifier: Apache-2.0
3+
const { defineConfig } = require('@coze-arch/stylelint-config');
4+
5+
module.exports = defineConfig({
6+
extends: [],
7+
});
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
# @cozeloop/observation-component-adapter
2+
3+
> Project template for react component with storybook.
4+
5+
## Features
6+
7+
- [x] eslint & ts
8+
- [x] esm bundle
9+
- [x] umd bundle
10+
- [x] storybook
11+
12+
## Commands
13+
14+
- init: `rush update`
15+
- dev: `npm run dev`
16+
- build: `npm run build`
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
{
2+
"operationSettings": [
3+
{
4+
"operationName": "test:cov",
5+
"outputFolderNames": ["coverage"]
6+
},
7+
{
8+
"operationName": "ts-check",
9+
"outputFolderNames": ["dist"]
10+
}
11+
]
12+
}
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
// Copyright (c) 2025 coze-dev Authors
2+
// SPDX-License-Identifier: Apache-2.0
3+
const { defineConfig } = require('@coze-arch/eslint-config');
4+
5+
module.exports = defineConfig({
6+
packageRoot: __dirname,
7+
preset: 'web',
8+
rules: {},
9+
});
Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
{
2+
"name": "@cozeloop/observation-component-adapter",
3+
"version": "0.0.1",
4+
"description": "trace detail packages, add extra base on the base observation component",
5+
"license": "Apache-2.0",
6+
"author": "liuwei.felix@bytedance.com",
7+
"maintainers": [],
8+
"main": "src/index.tsx",
9+
"scripts": {
10+
"build": "exit 0",
11+
"dev": "storybook dev -p 6006",
12+
"lint": "eslint ./ --cache",
13+
"test": "vitest --run --passWithNoTests",
14+
"test:cov": "npm run test -- --coverage"
15+
},
16+
"dependencies": {
17+
"@coze-arch/coze-design": "0.0.6-alpha.346d77",
18+
"@cozeloop/api-schema": "workspace:*",
19+
"@cozeloop/biz-hooks-adapter": "workspace:*",
20+
"@cozeloop/components": "workspace:*",
21+
"@cozeloop/observation-component": "workspace:*",
22+
"@cozeloop/tag-components": "workspace:*",
23+
"ahooks": "^3.7.8",
24+
"classnames": "^2.3.2",
25+
"dayjs": "^1.11.7",
26+
"lodash-es": "^4.17.21"
27+
},
28+
"devDependencies": {
29+
"@coze-arch/bot-typings": "workspace:*",
30+
"@coze-arch/eslint-config": "workspace:*",
31+
"@coze-arch/stylelint-config": "workspace:*",
32+
"@coze-arch/ts-config": "workspace:*",
33+
"@coze-arch/vitest-config": "workspace:*",
34+
"@storybook/addon-essentials": "^7.6.7",
35+
"@storybook/addon-interactions": "^7.6.7",
36+
"@storybook/addon-links": "^7.6.7",
37+
"@storybook/addon-onboarding": "^1.0.10",
38+
"@storybook/blocks": "^7.6.7",
39+
"@storybook/react": "^7.6.7",
40+
"@storybook/react-vite": "^7.6.7",
41+
"@storybook/test": "^7.6.7",
42+
"@testing-library/jest-dom": "^6.1.5",
43+
"@testing-library/react": "^14.1.2",
44+
"@testing-library/react-hooks": "^8.0.1",
45+
"@types/react": "18.2.37",
46+
"@types/react-dom": "18.2.15",
47+
"@vitest/coverage-v8": "~3.0.5",
48+
"react": "~18.2.0",
49+
"react-dom": "~18.2.0",
50+
"storybook": "^7.6.7",
51+
"stylelint": "^15.11.0",
52+
"vite-plugin-svgr": "~3.3.0",
53+
"vitest": "~3.0.5"
54+
},
55+
"peerDependencies": {
56+
"react": ">=18.2.0",
57+
"react-dom": ">=18.2.0"
58+
}
59+
}
60+
Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
// Copyright (c) 2025 coze-dev Authors
2+
// SPDX-License-Identifier: Apache-2.0
3+
4+
/* eslint-disable @typescript-eslint/no-explicit-any */
5+
/* eslint-disable @typescript-eslint/naming-convention */
6+
import { AnnotationPanel } from '@cozeloop/tag-components';
7+
import {
8+
TraceDetailPanel as TraceDetailPanelInner,
9+
type TraceDetailPanelProps,
10+
type TraceDetailContext,
11+
tabs,
12+
TraceDetail as TraceDetailInner,
13+
type TraceDetailProps,
14+
} from '@cozeloop/observation-component';
15+
import { type span } from '@cozeloop/api-schema/observation';
16+
17+
interface TraceDetailOpenPanelProps {
18+
forceOverwrite?: boolean;
19+
}
20+
21+
interface TraceDetailOpenPanelProps {
22+
forceOverwrite?: boolean;
23+
}
24+
25+
type TracePanelWrapperProps = TraceDetailPanelProps &
26+
TraceDetailContext &
27+
TraceDetailOpenPanelProps;
28+
29+
type TraceWrapperDetailProps = TraceDetailProps &
30+
TraceDetailContext &
31+
TraceDetailOpenPanelProps;
32+
33+
export const TraceDetailWrapper = <
34+
T extends
35+
| ((props: TraceWrapperDetailProps) => JSX.Element)
36+
| ((props: TracePanelWrapperProps) => JSX.Element),
37+
>({
38+
Component,
39+
}: {
40+
Component: T;
41+
}) => {
42+
const Wrapper = (props: Parameters<T>[number]) => {
43+
const { forceOverwrite } = props;
44+
45+
const traceDetailOpenPanelProps = forceOverwrite
46+
? {
47+
extraSpanDetailTabs: tabs,
48+
spanDetailHeaderSlot: (
49+
span: span.OutputSpan,
50+
platform: string | number,
51+
) => <AnnotationPanel span={span} platformType={platform} />,
52+
...props,
53+
}
54+
: {
55+
...props,
56+
extraSpanDetailTabs: tabs,
57+
spanDetailHeaderSlot: (
58+
span: span.OutputSpan,
59+
platform: string | number,
60+
) => <AnnotationPanel span={span} platformType={platform} />,
61+
};
62+
63+
return <Component {...(traceDetailOpenPanelProps as any)} />;
64+
};
65+
66+
return Wrapper;
67+
};
68+
69+
export const TraceDetailPanel = TraceDetailWrapper({
70+
Component: TraceDetailPanelInner,
71+
});
72+
export const TraceDetail = TraceDetailWrapper({
73+
Component: TraceDetailInner,
74+
});
75+
76+
export {
77+
NODE_CONFIG_MAP,
78+
SpanType,
79+
getEndTime,
80+
getStartTime,
81+
} from '@cozeloop/observation-component';
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
// Copyright (c) 2025 coze-dev Authors
2+
// SPDX-License-Identifier: Apache-2.0
3+
/// <reference types='@coze-arch/bot-typings' />
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
{
2+
"extends": "@coze-arch/ts-config/tsconfig.web.json",
3+
"$schema": "https://json.schemastore.org/tsconfig",
4+
"compilerOptions": {
5+
"outDir": "dist",
6+
"rootDir": "src",
7+
"jsx": "react-jsx",
8+
"lib": ["DOM", "ESNext"],
9+
"module": "ESNext",
10+
"target": "ES2020",
11+
"moduleResolution": "bundler",
12+
"tsBuildInfoFile": "dist/tsconfig.build.tsbuildinfo"
13+
},
14+
"include": ["src"],
15+
"exclude": ["node_modules", "dist"],
16+
"references": [
17+
{
18+
"path": "../../api-schema/tsconfig.build.json"
19+
},
20+
{
21+
"path": "../../../arch/bot-typings/tsconfig.build.json"
22+
},
23+
{
24+
"path": "../../biz-hooks/tsconfig.build.json"
25+
},
26+
{
27+
"path": "../../components/tsconfig.build.json"
28+
},
29+
{
30+
"path": "../../../../config/eslint-config/tsconfig.build.json"
31+
},
32+
{
33+
"path": "../../../../config/stylelint-config/tsconfig.build.json"
34+
},
35+
{
36+
"path": "../../../../config/ts-config/tsconfig.build.json"
37+
},
38+
{
39+
"path": "../../../../config/vitest-config/tsconfig.build.json"
40+
},
41+
{
42+
"path": "../../tag-components/tsconfig.build.json"
43+
},
44+
{
45+
"path": "../trace-detail/tsconfig.build.json"
46+
}
47+
]
48+
}
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
{
2+
"$schema": "https://json.schemastore.org/tsconfig",
3+
"exclude": ["**/*"],
4+
"compilerOptions": {
5+
"composite": true
6+
},
7+
"references": [
8+
{
9+
"path": "./tsconfig.build.json"
10+
},
11+
{
12+
"path": "./tsconfig.misc.json"
13+
}
14+
]
15+
}

0 commit comments

Comments
 (0)