Skip to content

Commit

Permalink
ARC-1763 metrics (#1685)
Browse files Browse the repository at this point in the history
* - No configuration page added
- Condition added to display this new page

* - Condition Updated
- Test Case updated

* - Redirect logic added in github-create-branch-get.ts

* - token check removed

* - Updated the names in test case

* added additional analytics for not configured and options page

* reomve prototype code

Co-authored-by: Kayub Maharjan <kay.krazzie@gmail.com>
Co-authored-by: kAy <krazziekay@users.noreply.github.com>
Co-authored-by: Josh Kay <joshk@atlassian.com>
  • Loading branch information
4 people committed Oct 19, 2022
1 parent 33d319b commit 5901ec0
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 3 deletions.
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
7 changes: 6 additions & 1 deletion src/routes/github/create-branch/github-create-branch-get.ts
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

0 comments on commit 5901ec0

Please sign in to comment.