@stoe/octokit-plugin-org-activity

2.1.0 • Public • Published

@stoe/octokit-plugin-org-activity

test codeql publish styled with prettier

Octokit plugin to fetch member activity for a given GitHub organization

Install

$ npm install @stoe/octokit-plugin-org-activity

Usage

Personal Access Token authentication:

import {Octokit} from '@octokit/core'
import org_activity_plugin from '@stoe/octokit-plugin-org-activity'

const MyOctokit = Octokit.plugin(org_activity_plugin)

const octokit = new MyOctokit({
  auth: 'GITHUB_TOKEN'
})

const data = await octokit.listMemberActivityByOrganization({org: 'my-org'})

console.log(data)

GitHub App installation authentication:

import {Octokit} from '@octokit/core'
import {createAppAuth} from '@octokit/auth-app'
import org_activity_plugin from '@stoe/octokit-plugin-org-activity'

const MyOctokit = Octokit.plugin(org_activity_plugin)

const auth = createAppAuth({
  id: APP_ID,
  privateKey: Buffer.from(PRIVATE_KEY_BASE64.trim(), 'base64').toString('ascii'),
  installationId: INSTALLATION_ID
})

const {token} = await auth({type: 'installation'})

const octokit = new MyOctokit({
  auth: token
})

const data = await octokit.listMemberActivityByOrganization({org: 'my-org'})

console.log(data)

Output

[
  {
    login: 'monalisa',
    emails: [],
    role: 'MEMBER',
    contributions: {
      periodStart: '2020-07-31T22:00:00Z',
      periodEnd: '2020-09-29T09:55:47Z',
      isSingleDay: false,
      hasAnyContributions: true,
      hasAnyRestrictedContributions: false,
      hasActivityInThePast: true,
      totalCommitContributions: 1,
      totalRepositoriesWithContributedCommits: 1,
      totalIssueContributions: 1,
      totalRepositoriesWithContributedIssues: 1,
      totalPullRequestContributions: 0,
      totalRepositoriesWithContributedPullRequests: 0,
      totalPullRequestReviewContributions: 0,
      totalRepositoriesWithContributedPullRequestReviews: 0,
      totalRepositoryContributions: 0
    }
  },
  {
    login: 'stoe',
    emails: [ 'stoe@github.com' ],
    role: 'ADMIN',
    contributions: {
      periodStart: '2020-07-31T22:00:00Z',
      periodEnd: '2020-09-29T09:55:47Z',
      isSingleDay: false,
      hasAnyContributions: true,
      hasAnyRestrictedContributions: false,
      hasActivityInThePast: true,
      totalCommitContributions: 4,
      totalRepositoriesWithContributedCommits: 2,
      totalIssueContributions: 2,
      totalRepositoriesWithContributedIssues: 1,
      totalPullRequestContributions: 1,
      totalRepositoriesWithContributedPullRequests: 1,
      totalPullRequestReviewContributions: 0,
      totalRepositoriesWithContributedPullRequestReviews: 0,
      totalRepositoryContributions: 0
    }
  }
]

License

Package Sidebar

Install

npm i @stoe/octokit-plugin-org-activity

Weekly Downloads

1

Version

2.1.0

License

MIT

Unpacked Size

12.9 kB

Total Files

4

Last publish

Collaborators

  • stoelzle