Skip to content

Commit

Permalink
Fix: deleted user error and analytics (#36)
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexSim93 committed Apr 17, 2024
1 parent ab91846 commit b78f8b2
Show file tree
Hide file tree
Showing 9 changed files with 236 additions and 117 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Pull request analytics action

![Version](https://img.shields.io/badge/version-2.2.5-blue) ![License](https://img.shields.io/badge/license-MIT-green)
![Version](https://img.shields.io/badge/version-2.2.6-blue) ![License](https://img.shields.io/badge/license-MIT-green)

**pull-request-analytics-action**: A powerful tool for analyzing the effectiveness of both teams and individual developers. This action generates reports based on data from pull requests, code reviews, and comments, enabling you to identify your team's strengths as well as areas needing improvement. The statistics collected by this GitHub Action can be displayed in the form of tables and graphs or passed on for further operations as markdown or a data collection.

Expand Down
167 changes: 119 additions & 48 deletions build/index.js

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

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "pull-request-analytics-action",
"version": "2.2.5",
"version": "2.2.6",
"description": "Generates detailed PR analytics reports within GitHub, focusing on review efficiency and team performance.",
"main": "build/index.js",
"scripts": {
Expand Down
3 changes: 2 additions & 1 deletion src/analytics/index.ts
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
export { sendActionRun } from './sendActionRun';
export { sendActionRun } from "./sendActionRun";
export { sendActionError } from "./sendActionError";
3 changes: 3 additions & 0 deletions src/analytics/mixpanel.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import Mixpanel from "mixpanel";

export const mixpanel = Mixpanel.init("8d55eb8bf093d728a0c42616f890bad1");
41 changes: 41 additions & 0 deletions src/analytics/sendActionError.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
import { getMultipleValuesInput, getValueAsIs } from "../common/utils";
import { mixpanel } from "./mixpanel";

export const sendActionError = (error: Error) => {
if (getValueAsIs("ALLOW_ANALYTICS") === "true") {
mixpanel.track("Action error", {
error: error?.message,
stack: error?.stack,
GITHUB_OWNERS_REPOS: getMultipleValuesInput("GITHUB_OWNERS_REPOS").length,
ORGANIZATIONS: getMultipleValuesInput("ORGANIZATIONS").length,
SHOW_STATS_TYPES: getMultipleValuesInput("SHOW_STATS_TYPES"),
AMOUNT: getValueAsIs("AMOUNT"),
TIMEZONE: getValueAsIs("TIMEZONE"),
REPORT_DATE_START: getValueAsIs("REPORT_DATE_START"),
REPORT_DATE_END: getValueAsIs("REPORT_DATE_END"),
REPORT_PERIOD: getValueAsIs("REPORT_PERIOD"),
CORE_HOURS_START: getValueAsIs("CORE_HOURS_START"),
CORE_HOURS_END: getValueAsIs("CORE_HOURS_END"),
PERCENTILE: getMultipleValuesInput("PERCENTILE"),
TOP_LIST_AMOUNT: getValueAsIs("TOP_LIST_AMOUNT"),
PERIOD_SPLIT_UNIT: getValueAsIs("PERIOD_SPLIT_UNIT"),
LABELS: getMultipleValuesInput("LABELS").length,
ASSIGNEES: getMultipleValuesInput("ASSIGNEES").length,
ISSUE_TITLE: !!getValueAsIs("ISSUE_TITLE"),
AGGREGATE_VALUE_METHODS: getMultipleValuesInput(
"AGGREGATE_VALUE_METHODS"
),
HIDE_USERS: getMultipleValuesInput("HIDE_USERS").length,
SHOW_USERS: getMultipleValuesInput("SHOW_USERS").length,
INCLUDE_LABELS: getMultipleValuesInput("INCLUDE_LABELS").length,
EXCLUDE_LABELS: getMultipleValuesInput("EXCLUDE_LABELS").length,
EXECUTION_OUTCOME: getMultipleValuesInput("EXECUTION_OUTCOME"),
HOLIDAYS: getMultipleValuesInput("HOLIDAYS").length,
REVIEW_TIME_INTERVALS: getMultipleValuesInput("REVIEW_TIME_INTERVALS"),
APPROVAL_TIME_INTERVALS: getMultipleValuesInput(
"APPROVAL_TIME_INTERVALS"
),
MERGE_TIME_INTERVALS: getMultipleValuesInput("MERGE_TIME_INTERVALS"),
});
}
};
4 changes: 1 addition & 3 deletions src/analytics/sendActionRun.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
import Mixpanel from "mixpanel";
import { getMultipleValuesInput, getValueAsIs } from "../common/utils";
import crypto from "crypto";

const mixpanel = Mixpanel.init("8d55eb8bf093d728a0c42616f890bad1");
import { mixpanel } from "./mixpanel";

export const sendActionRun = () => {
if (getValueAsIs("ALLOW_ANALYTICS") === "true") {
Expand Down
2 changes: 1 addition & 1 deletion src/converters/utils/calculations/getApproveTime.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ export const getApproveTime = (
acc: Record<string, { state: string; submittedAt: string }>,
review: any
) => {
const user = review.user.login || invalidUserLogin;
const user = review.user?.login || invalidUserLogin;
const statusesEntries = Object.keys(acc) as string[];
const isApproved =
statusesEntries.some((user) => acc[user].state === "approved") &&
Expand Down
Loading

0 comments on commit b78f8b2

Please sign in to comment.