Skip to content

Commit 904e36c

Browse files
committed
Anonymous usage statistics
1 parent eadd435 commit 904e36c

File tree

8 files changed

+33
-0
lines changed

8 files changed

+33
-0
lines changed

action.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,11 @@ runs:
3131
with:
3232
name: "codeball:approved"
3333
color: "86efac" # green
34+
codeball-job-id: ${{ steps.codeball_baller.outputs.codeball-job-id }}
3435

3536
# If Codeball approved the contribution, approve the PR
3637
- name: Approve PR
3738
uses: sturdy-dev/codeball-action/approver@v2
3839
if: ${{ steps.codeball_status.outputs.approved == 'true' }}
40+
with:
41+
codeball-job-id: ${{ steps.codeball_baller.outputs.codeball-job-id }}

approver/action.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,9 @@ inputs:
1414
description: 'The message to send in the code review comment.'
1515
default: "Codeball: LGTM! :+1:"
1616
required: false
17+
codeball-job-id:
18+
description: 'The ID of the Codeball Job created by the Baller Action'
19+
required: false
1720

1821
runs:
1922
using: 'node16'

labeler/action.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,9 @@ inputs:
2121
description: "The description of the label."
2222
default: "Codeball"
2323
required: false
24+
codeball-job-id:
25+
description: 'The ID of the Codeball Job created by the Baller Action'
26+
required: false
2427

2528
runs:
2629
using: 'node16'

src/approver/main.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import * as core from '@actions/core'
22
import * as github from '@actions/github'
33
import {Octokit} from '../lib'
4+
import {track} from '../lib/track/track'
45

56
async function run(): Promise<void> {
67
try {
@@ -35,6 +36,8 @@ async function run(): Promise<void> {
3536
return
3637
}
3738

39+
const jobID = core.getInput('codeball-job-id') // jobID is not required
40+
3841
const octokit = new Octokit({auth: githubToken})
3942

4043
await octokit.pulls.createReview({
@@ -45,6 +48,8 @@ async function run(): Promise<void> {
4548
body: 'Codeball: LGTM! :+1:',
4649
event: 'APPROVE'
4750
})
51+
52+
await track(jobID, 'approver')
4853
} catch (error) {
4954
if (error instanceof Error) {
5055
if (error.message === 'Resource not accessible by integration') {

src/baller/main.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import * as core from '@actions/core'
22
import * as github from '@actions/github'
33
import {create} from '../lib'
4+
import {track} from '../lib/track/track'
45

56
async function run(): Promise<void> {
67
try {
@@ -25,6 +26,8 @@ async function run(): Promise<void> {
2526

2627
core.info(`Job created: ${job.id}`)
2728
core.setOutput('codeball-job-id', job.id)
29+
30+
await track(job.id, 'baller')
2831
} catch (error) {
2932
if (error instanceof Error) core.setFailed(error.message)
3033
}

src/labeler/main.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import * as core from '@actions/core'
22
import * as github from '@actions/github'
33
import {Octokit} from '../lib'
4+
import {track} from '../lib/track/track'
45

56
async function run(): Promise<void> {
67
try {
@@ -39,6 +40,8 @@ async function run(): Promise<void> {
3940
const labelColor = core.getInput('color')
4041
const labelDescription = core.getInput('description')
4142

43+
const jobID = core.getInput('codeball-job-id') // jobID is not required
44+
4245
const octokit = new Octokit({auth: githubToken})
4346

4447
core.debug(`Adding label "${labelName}" to PR ${pullRequestURL}`)
@@ -82,6 +85,8 @@ async function run(): Promise<void> {
8285

8386
core.debug(`Add label: ${JSON.stringify(addLabelParams)}`)
8487
await octokit.issues.addLabels(addLabelParams)
88+
89+
await track(jobID, 'labeler')
8590
} catch (error) {
8691
if (error instanceof Error) {
8792
if (error.message === 'Resource not accessible by integration') {

src/lib/track/track.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
import {post} from "../api";
2+
3+
export const track = async(jobID: string | undefined, actionName: string) => {
4+
return post("/track", {
5+
job_id: jobID,
6+
name: actionName,
7+
})
8+
}

src/status/main.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import {isContributionJob, isFinalStatus, get} from '../lib'
22
import * as core from '@actions/core'
3+
import {track} from '../lib/track/track'
34

45
async function run(): Promise<void> {
56
try {
@@ -40,6 +41,8 @@ async function run(): Promise<void> {
4041
}
4142

4243
core.setOutput('approved', false)
44+
45+
await track(jobID, 'status')
4346
} catch (error) {
4447
if (error instanceof Error) {
4548
core.setFailed(error.message)

0 commit comments

Comments
 (0)