dosubot[bot] commented on issue #8705: URL: https://github.com/apache/incubator-devlake/issues/8705#issuecomment-3876050893
<!-- Answer --> You can extract "AI Usage" stats from PR descriptions and display them as a new metric in DevLake by following these steps: 1. **Add custom fields**: Use the customize plugin/service to create new columns (e.g., `x_ai_lines`, `x_human_lines`) in the relevant PR metrics table. This is supported by the backend service, which manages dynamic schema changes for custom metrics ["customize plugin service"](https://github.com/apache/incubator-devlake/blob/2c15ad880dce830c6512fa58039527cbf4745b8b/backend/plugins/customize/service/service.go#L39-L293). 2. **Extract values from PR descriptions**: Implement a parser (typically using regex) in your data ingestion pipeline or as a plugin extension to extract the "AI lines" and "Human lines" values from the PR description and populate the custom fields during ingestion. The project settings UI and linker plugin show how regex-based extraction from PR descriptions is supported for other use cases ["project settings UI"](https://github.com/apache/incubator-devlake/blob/main/config-ui/src/routes/project/detail/settings-panel.tsx). 3. **Store and access the metrics**: Once extracted, these values are stored in your database and can be queried like any other metric. DevLake recommends creating a dedicated table per data stream for new metrics, following naming and indexing conventions ["plugin/table conventions"](https://github.com/apache/incubator-devlake/issues/8664). 4. **Visualize in dashboards**: After the data is collected, you can create or modify Grafana dashboard panels to visualize your new metrics. All data is stored in MySQL, and you can use custom SQL queries in Grafana to aggregate and display the extracted "AI Usage" stats ["custom dashboards"](https://github.com/apache/incubator-devlake/wiki/How-to-Set-Up-DevLake-with-Tin) ["dashboard SQL example"](https://github.com/apache/incubator-devlake/issues/8363#issuecomment-2755655469). This approach lets you track and visualize "AI lines" and "Human lines" from PR descriptions alongside your other engineering metrics. <!-- Dosu Comment Footer --> *To reply, just mention [@dosu](https://go.dosu.dev/dosubot).* --- <sup>How did I do? [Good](https://app.dosu.dev/response-feedback/5972df9e-80bb-48d9-a349-5ff0e58c177f?feedback_type=great_response) | [Irrelevant](https://app.dosu.dev/response-feedback/5972df9e-80bb-48d9-a349-5ff0e58c177f?feedback_type=irrelevant_answer) | [Incorrect](https://app.dosu.dev/response-feedback/5972df9e-80bb-48d9-a349-5ff0e58c177f?feedback_type=incorrect_sources) | [Verbose](https://app.dosu.dev/response-feedback/5972df9e-80bb-48d9-a349-5ff0e58c177f?feedback_type=too_verbose) | [Hallucination](https://app.dosu.dev/response-feedback/5972df9e-80bb-48d9-a349-5ff0e58c177f?feedback_type=hallucination) | [Report 🐛](https://app.dosu.dev/response-feedback/5972df9e-80bb-48d9-a349-5ff0e58c177f?feedback_type=bug_report) | [Other](https://app.dosu.dev/response-feedback/5972df9e-80bb-48d9-a349-5ff0e58c177f?feedback_type=other)</sup> [](https://app.dosu.dev/b4e8e847-d479-4541-83a8-d88d83fea5c9/ask?utm_source=github) [](https://cursor.com/link/prompt?text=You%20can%20extract%20%22AI%20Usage%22%20stats%20from%20PR%20descriptions%20and%20display%20them%20as%20a%20new%20metric%20in%20DevLake%20by%20following%20these%20steps%3A%0A%0A1.%20%2A%2AAdd%20custom%20fields%2A%2A%3A%20Use%20the%20customize%20plugin/service%20to%20create%20new%20columns%20%28e.g.%2C%20%60x_ai_lines%60%2C%20%60x_human_lines%60%29%20in%20the%20relevant%20PR%20metrics%20table.%20This%20is%20supported%20by%20the%20backend%20service%2C%20which%20manages%20dynamic%20schema%20changes%20for%20custom%20metrics%20%5B%22customize%20plugin%20service%22%5D%28https%3A//github.com/apache/incubator-devlake/blob/2c15ad880dce830c6512fa58039527cbf4745b8b/backend/plugins/customize/service/service.go%23L39-L293%29.%0A%0A2.%20%2A%2AExtract%20values%20 from%20PR%20descriptions%2A%2A%3A%20Implement%20a%20parser%20%28typically%20using%20regex%29%20in%20your%20data%20ingestion%20pipeline%20or%20as%20a%20plugin%20extension%20to%20extract%20the%20%22AI%20lines%22%20and%20%22Human%20lines%22%20values%20from%20the%20PR%20description%20and%20populate%20the%20custom%20fields%20during%20ingestion.%20The%20project%20settings%20UI%20and%20linker%20plugin%20show%20how%20regex-based%20extraction%20from%20PR%20descriptions%20is%20supported%20for%20other%20use%20cases%20%5B%22project%20settings%20UI%22%5D%28https%3A//github.com/apache/incubator-devlake/blob/main/config-ui/src/routes/project/detail/settings-panel.tsx%29.%0A%0A3.%20%2A%2AStore%20and%20access%20the%20metrics%2A%2A%3A%20Once%20extracted%2C%20these%20values%20are%20stored%20in%20your%20database%20and%20can%20be%20queried%20like%20any%20other%20metric.%20DevLake%20recommends%20creating%20a%20dedicated%20table%20per%20data%20stream%20for%20new%20metrics%2C%20following%20naming%20and%20i ndexing%20conventions%20%5B%22plugin/table%20conventions%22%5D%28https%3A//github.com/apache/incubator-devlake/issues/8664%29.%0A%0A4.%20%2A%2AVisualize%20in%20dashboards%2A%2A%3A%20After%20the%20data%20is%20collected%2C%20you%20can%20create%20or%20modify%20Grafana%20dashboard%20panels%20to%20visualize%20your%20new%20metrics.%20All%20data%20is%20stored%20in%20MySQL%2C%20and%20you%20can%20use%20custom%20SQL%20queries%20in%20Grafana%20to%20aggregate%20and%20display%20the%20extracted%20%22AI%20Usage%22%20stats%20%5B%22custom%20dashboards%22%5D%28https%3A//github.com/apache/incubator-devlake/wiki/How-to-Set-Up-DevLake-with-Tin%29%20%5B%22dashboard%20SQL%20example%22%5D%28https%3A//github.com/apache/incubator-devlake/issues/8363%23issuecomment-2755655469%29.%0A%0AThis%20approach%20lets%20you%20track%20and%20visualize%20%22AI%20lines%22%20and%20%22Human%20lines%22%20from%20PR%20descriptions%20alongside%20your%20other%20engineering%20metrics.) [](https://go.dosu.dev/discord-bot) [](https://twitter.com/intent/tweet?text=%40dosu_ai%20helped%20me%20solve%20this%20issue!&url=https%3A//github.com/apache/incubator-devlake/issues/8705) -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
