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

ARC-1763 metrics #1685

Merged
merged 15 commits into from
Oct 19, 2022
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
2 changes: 2 additions & 0 deletions src/interfaces/common.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ export enum AnalyticsEventTypes {
// All variables below were defined by DataPortal. Do not change their values as it will affect our metrics logs and dashboards.
export enum AnalyticsScreenEventsEnum {
CreateBranchScreenEventName = "createBranchScreen",
CreateBranchOptionsScreenEventName = "createBranchOptionsScreen",
NotConfiguredScreenEventName = "notConfiguredScreen",
GitHubConfigScreenEventName = "gitHubConfigurationScreen",
ConnectAnOrgScreenEventName = "connectAnOrgProductCount",
SelectGitHubProductEventName = "selectGitHubProductScreen"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,12 @@ export const GithubCreateBranchGet = async (req: Request, res: Response, next: N
} = res.locals;

if (!githubToken) {
req.log.warn(Errors.MISSING_GITHUB_TOKEN);
return next(new Error(Errors.MISSING_GITHUB_TOKEN));
}

if (!jiraHost) {
req.log.warn({ req, res }, Errors.MISSING_JIRA_HOST);
req.log.warn(Errors.MISSING_JIRA_HOST);
res.status(400).send(Errors.MISSING_JIRA_HOST);
return next();
}
Expand All @@ -37,6 +38,10 @@ export const GithubCreateBranchGet = async (req: Request, res: Response, next: N
res.render("no-configuration.hbs", {
nonce: res.locals.nonce
});
sendAnalytics(AnalyticsEventTypes.ScreenEvent, {
name: AnalyticsScreenEventsEnum.NotConfiguredScreenEventName,
jiraHost
});
return;
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
import { NextFunction, Request, Response } from "express";
import axios from "axios";
import Logger from "bunyan";
import { Errors } from "config/errors";
import { Subscription } from "~/src/models/subscription";
import { GitHubServerApp } from "~/src/models/github-server-app";
import { getGitHubApiUrl } from "utils/get-github-client-config";
import axios from "axios";
import Logger from "bunyan";
import { sendAnalytics } from "utils/analytics-client";
import { AnalyticsEventTypes, AnalyticsScreenEventsEnum } from "interfaces/common";

export const GithubCreateBranchOptionsGet = async (req: Request, res: Response, next: NextFunction): Promise<void> => {

Expand All @@ -27,6 +29,10 @@ export const GithubCreateBranchOptionsGet = async (req: Request, res: Response,
res.render("no-configuration.hbs", {
nonce: res.locals.nonce
});
sendAnalytics(AnalyticsEventTypes.ScreenEvent, {
name: AnalyticsScreenEventsEnum.NotConfiguredScreenEventName,
jiraHost
});
return;
}

Expand Down Expand Up @@ -55,6 +61,11 @@ export const GithubCreateBranchOptionsGet = async (req: Request, res: Response,
servers
});

sendAnalytics(AnalyticsEventTypes.ScreenEvent, {
name: AnalyticsScreenEventsEnum.CreateBranchOptionsScreenEventName,
jiraHost
});

};

const validateGitHubToken = async (jiraHost: string, githubToken: string, logger: Logger, gitHubAppId?: number) => {
Expand Down