How to See User Activity in Bitbucket Data Center

September 21, 2023
#Project management#Analytics#How To#Bitbucket
7 min

Tracking user activity is essential for maintaining transparency, accountability, and efficient teamwork. As Bitbucket does not provide an opportunity to see a particular user’s contributions, additional tools are needed. One of them is Awesome Graphs for Bitbucket. The app seamlessly integrates into Bitbucket and offers a comprehensive view of invisible engineering activities. With this tool, you can easily track commits, lines of code, and pull requests data on the instance, project, repository, team, and user levels. Let’s dive into how Awesome Graphs helps see user activity in Bitbucket.

See user activity in Bitbucket over the past year

The Contribution graph displays the activity of a particular Bitbucket user over the past year. Each square represents the number of commits and pull requests a developer made on a particular day. Below the graph, some key insights are displayed as well as a list of all user’s commits and pull requests with their details.

bitbucket see user activity

Switching to the detailed view allows you to check how the developer distributed efforts between different projects and repositories and see a list of their activities on a specific one.

bitbucket view user activity

This graph will give you a comprehensive overview of Bitbucket user activity over the past year, along with daily statistics. It highlights not only the key trends but also provides detailed information, helping analyze how a developer allocates their efforts, find patterns in their work, and see their contributions to project development.

Track recent Bitbucket user activity

The Activity graph allows you to see recent user contributions to a particular project or repository. By default, it displays commits and pull requests charts with the number of activities made by top contributors. However, you can choose a particular user and see their activities on the project over the selected period. Below the graph, a list of all commits and pull requests with links to Jira issues, hashes, and Change Type lozenges are shown depending on the filters applied.

track recent user activity
Here, you can easily track recent users’ activity on a particular project or repository, enhancing transparency and collaboration within your teams.

Export data using REST API

To build custom reports and meet particular requirements, Awesome Graphs for Bitbucket provides an opportunity to export user‘s commit, lines of code, or pull request data via REST API. It lets you get general statistics, retrieve all the details, and export data to a CSV file. Here is an example of the curl command to get a list of commits of a particular user, including commits made by the user’s aliases:

curl -X GET -u username:password "https://bitbucket.your-company-name.com/rest/awesome-graphs-api/latest/users/{userSlug}/commits"

This is what the response will look like:

{
  "values": [
    {
      "user": {
        "emailAddress": "yorlov@stiltsoft.com",
        "displayName": "Administrator",
        "name": "admin"
      },
      "author": {
        "displayName": "admin",
        "emailAddress": "yorlov@stiltsoft.com"
      },
      "authorTimestamp": "2023-03-05T22:58:18Z",
      "linesOfCode": {
        "added": 1,
        "deleted": 0
      },
      "parents": [],
      "repository": {
        "slug": "Commit Hook",
        "name": "commit-hook",
        "project": {
          "key": "TESTCONTAINERS",
          "name": "Testcontainers",
          "type": "NORMAL"
        }
      },
      "id": "9f2e24a147bb8f5a5a3d10b692703cc5784df8b5"
    },
    {
      "author": {
        "displayName": "avoronova",
        "emailAddress": "avoronova@stiltsoft.com"
      },
      "authorTimestamp": "2023-03-05T22:58:18Z",
      "linesOfCode": {
        "added": 2,
        "deleted": 2
      },
      "parents": [
        {
          "id": "06572e813597bc7d77c8"
        }
      ],
      "repository": {
        "slug": "Awesome Graphs for Bitbucket Server",
        "name": "awesome-graphs-for-bitbucket-server",
        "project": {
          "key": "AWEGRAPHS",
          "name": "Awesome Graphs",
          "type": "NORMAL"
        }
      },
      "id": "295760238d83b84647ae4c10ce16f13fa4d24672"
    }
  ],
  "isLastPage": false,
  "nextPageStart": 2,
  "start": 0,
  "size": 2,
  "limit": 2
}

You can find more information about the Export feature in our documentation. Awesome Graphs’ users can access the in-app documentation through the Export menu in the top-right corner of the People page.

Apart from this, Awesome Graphs allows you to see the following data on a user level:

  • dynamics of commit or pull request activity
  • total number of commits or pull requests made or total number of lines of code added and deleted over a particular period
  • activity in the code review process

Thus, seamlessly integrating with Bitbucket, Awesome Graphs provides three easy ways to see user activity in Bitbucket and get a comprehensive view of their contributions, enabling an understanding of personal and team efforts, making informed decisions, and enhancing overall project success.

Related posts

    Enhance Developer Productivity with the SPACE Framework in Bitbucket

    June 13, 2023
    #Reporting#Analytics#Bitbucket
    11 min

    Measuring developer productivity is a challenging task that goes beyond individual skills and the number of lines of code written. It encompasses a wide range of factors, and relying solely on a single metric or activity data cannot accurately reflect it. The SPACE framework was introduced to capture the main factors influencing developer productivity. It recognizes that productivity extends individual performance and metrics and offers five key dimensions for a comprehensive view.

    In this article, we’ll cover what the SPACE framework is, explore its five key dimensions, and see how to implement it in Bitbucket.

    What is the SPACE framework?

    The SPACE framework is a complex approach to a comprehensive understanding of developer productivity. It was presented by a group of researchers from Microsoft, GitHub, and the University of Victoria and acknowledges that productivity extends beyond individual performance and metrics.

    This framework helps organizations measure and optimize developers’ productivity by considering five key dimensions:

    • Satisfaction and well-being
    • Performance
    • Activity
    • Communication and collaboration
    • Efficiency and flow.

    All these dimensions should be considered on three levels: Individual, team, and system.

    SPACE metrics

    Source: The SPACE of Developer Productivity.

    Let’s explore these dimensions in more detail.

    SPACE dimensions of developer productivity

    Satisfaction and well-being

    The level of developer satisfaction refers to how satisfied they feel with their work, team, equipment, and corporate culture. The level of well-being refers to their health, happiness, and work impact. Measuring satisfaction and well-being not only helps understand productivity but can also indicate potential burnout or poor performance. By monitoring these aspects, organizations can take measures like “mental health” days or extra vacation days to prevent burnout and improve overall well-being.

    Surveys can often be very helpful in measuring the well-being and satisfaction of your employees.

    Examples of metrics:

    • Employee satisfaction
    • Perception of code reviews
    • Satisfaction with engineering systems

    Performance

    Measuring software developers’ performance is challenging due to the difficulty in directly attributing individual contributions to product outcomes. A high quantity of code does not necessarily mean high-quality code, and neither does customer satisfaction always correlate with positive business outcomes. Therefore, evaluating performance in terms of outcomes rather than outputs is often a better approach. In the most simplistic view, software developer performance could be summarized as “Did the code written by the developer perform as expected?”

    Examples of metrics:

    • Code review velocity
    • Story points shipped
    • Reliability
    • Feature usage
    • Customer satisfaction

    Activity

    Activity, measured as the count of actions or outputs, gives useful but limited insights into productivity, engineering systems, and team performance. However, developers engage in a wide range of complex and diverse activities that are difficult to measure comprehensively. While activity metrics can provide some understanding, they should always be combined with other dimensions to assess developer productivity. These metrics serve as starting points and must be customized according to organizational needs and development processes.

    Example of metrics:

    • Number of code reviews completed
    • Coding time
    • # commits or lines of code
    • Frequency of deployments

    Communication and collaboration

    Effective communication and collaboration are vital for successful project development. Collaboration within and between teams, supported by high transparency and awareness of team member activities, dramatically impacts productivity. Informed teams tend to be more effective as they work on the right problems, generate innovative ideas, and make better decisions.

    Example of metrics:

    • PR merge times
    • Quality of code reviews
    • Knowledge sharing
    • Onboarding time

    Efficiency and flow

    Efficiency and flow refer to how quickly progress can be made with minimal interruptions or delays. Individual efficiency is achieved by setting boundaries, reducing distractions, and optimizing software development flow. Team and system efficiency embodies the process of transforming software concepts into product deliveries while eliminating any delays or handoffs in this flow. Team flow can be monitored using DORA metrics such as deployment frequency or lead time for changes.

    Example of metrics:

    • Code review timing
    • Lack of interruptions
    • Number of handoffs
    • Lead time for changes

    How to use the SPACE metrics

    Here are the best practices on how effectively implement the SPACE framework:

    1. Choose multiple metrics. To obtain a holistic view of developer productivity, it is important to include several metrics from multiple dimensions. The recommended number of dimensions is at least three. For example, if you track an activity metric, add metrics from other dimensions, perhaps performance and efficiency & flow. Avoid focusing on a single aspect and consider the broader impact on the entire system.
    2. Add perceptual measures. Include survey data to gain a comprehensive understanding of developers’ productivity. Perceptions provide valuable insights that cannot be obtained solely from system behavior.
    3. Avoid excessive metrics. Capturing too many metrics can lead to confusion and decreased motivation. Select a few metrics to maintain focus and set achievable improvement goals.
    4. Set important metrics. Choose metrics that align with organizational values and goals as they affect decision-making and individual behavior and indicate what is important.
    5. Protect privacy. When reporting metrics, respect developer privacy and share only anonymized and aggregated results. However, individual productivity analysis may be useful for developers, as it will assist them in optimizing their work and identifying inefficiencies.
    6. Consider norms and biases. Take into account that no metric is perfect, and some may have limitations or biases like cultural aspects or parental leave for metrics counted over a year. Consider these factors and the broader context when interpreting chosen metrics.

    How to Implement the SPACE Framework in Bitbucket

    Implementing the SPACE framework in Bitbucket can be facilitated using Awesome Graphs for Bitbucket. It is an on-prem solution that transforms invisible engineering activities into actionable insights and reports empowering managers and their teams to gain a deeper understanding of the development process and drive continuous improvement.

    Awesome Graphs seamlessly integrates into Bitbucket and provides the following capabilities:

    • Tracking commits, pull requests, and lines of code. You can monitor the number of commits or pull requests on the instance, team, or user levels, analyze and compare progress to past sprints or quarters, and see the engineering contribution for each repo and project. Thus, you can easily track, for instance, activity metrics from the SPACE framework, such as commits or lines of code.
    • Analyzing code review process. Awesome Graphs shows how the code review process is going. You can analyze PR merge times, see the quality of code reviews, find the most active reviewers, and identify areas for improvement. It helps in monitoring performance as well as communication and collaboration metrics.
    • Exporting data to a CSV file or via REST API. You can retrieve raw data about commits, lines of code, or pull requests at different levels and blend it with information from other applications to gain deeper insights. This feature allows you to build custom reports and track metrics aligned with your organization’s values and goals.

    The SPACE framework offers a holistic approach to tracking the development process, empowering engineering managers and their teams with valuable insights into developer productivity. Awesome Graphs opens up opportunities to effortlessly implement this framework in your Bitbucket and effectively measure and improve teams’ productivity.

    Start your free trial and reach a new level of visibility and efficiency in your development process and productivity.

    Related posts

      How to Export Commit and Pull Request Data from Bitbucket to CSV

      November 26, 2022
      #How To#Bitbucket#Reporting
      11 min

      Being a universal file type, CSV serves as a go-to format for integrations between the applications. It allows for transferring a large amount of data across the systems, blending it, and building custom reports. To export commit and pull request data from Bitbucket, you can use the Awesome Graphs for Bitbucket app, which gives you the capability to export to CSV in different ways.

      In this article, we’ll show you how to use the app to export engineering data to CSV for further integration, organization, and processing in analytics tools and custom solutions.

      What you will get

      The described ways of exporting will give you two kinds of generated CSV files, depending on the type of data exported. 

      In the case of commit data, you’ll get a list of commits with their details:

      commits export

      And the resulting CSV with a list of pull requests will look like this:

      pr export

      Exporting from the People page

      You can export raw commit and pull request data to CSV directly from Bitbucket. When you click All users in the People dropdown menu at the header, you’ll get to the People page with a global overview of developers’ activity in terms of commits or pull requests.

      At the top-right corner, you’ll notice the Export menu, where you can choose CSV.

      Export Commit and Pull Request Data from Bitbucket

      By default, the page shows contributions made within a month, but you can choose a longer period up to a quarter. The filtering applies not only to the GUI but also to the data exported, so if you don’t change the timespan, you’ll get a list of commits or pull requests for the last 30 days.

      Exporting via the REST API resources

      Beginning with version 5.5.0, Awesome Graphs REST API allows you to retrieve and export commit and pull request data to CSV on global, project, repository, and user levels, using the dedicated resources. This functionality is aimed to automate the processes you used to handle manually and streamline the existing workflows.

      You can access the in-app documentation (accessible to Awesome Graphs’ users) by choosing Export → REST API on the People page or go to our documentation website.

      We’ll show you two examples of the resources and how they work: one for exporting commits and another for pull requests. You’ll be able to use the rest of the resources as they follow the model.

      Export commits to CSV

      This resource exports a list of commits with their details from all Bitbucket projects and repositories to a CSV file.

      Here is the curl request example:

      curl -X GET -u username:password "https://bitbucket.your-company-name.com/rest/awesome-graphs-api/latest/commits/export/csv" --output commits.csv

      Alternatively, you can use any REST API client like Postman or put the URL directly into your browser’s address bar (you need to be authenticated in Bitbucket in this browser), and you’ll get a generated CSV file.

      By default, it exports the data for the last 30 days. You can set a timeframe for exported data up to one year (366 days) with sinceDate / untilDate parameters:

      curl -X GET -u username:password "https://bitbucket.your-company-name.com/rest/awesome-graphs-api/latest/commits/export/csv?sinceDate=2020-10-01&untilDate=2020-10-13" --output commits.csv

      For commit resources, you can also use the query parameters such as merges to filter merge/non-merge commits or order to specify the order to return commits in.

      Read more about the resource and its parameters.

      Export pull requests to CSV

      The pull request resources work similarly, so to export a list of pull requests with their details from all Bitbucket projects and repositories to a CSV file, make the following curl request:

      curl -X GET -u username:password "https://bitbucket.your-company-name.com/rest/awesome-graphs-api/latest/pull-requests/export/csv" --output pullrequests.csv

      The sinceDate / untilDate parameters can also be applied to state the timespan up to a year, but here you have an additional parameter dateType, allowing you to choose either the creation date or the date of the last update as a filtering criterion. So, if you set dateType to created, only the pull requests created during the stated period will be returned, while dateType set to updated will include the pull requests that were updated within the time frame.

      Another pull request specific parameter is state, which allows you to filter the response to only include openmerged, or declined pull requests.

      For example, the following request will return a list of open pull requests, which were updated between October 1st and October 13th:

      curl -X GET -u username:password "https://bitbucket.your-company-name.com/rest/awesome-graphs-api/latest/commits/export/csv?dateType=updated&state=open&sinceDate=2020-10-01&untilDate=2020-10-13" --output pullrequests.csv

      Learn more about this resource.

      Integrate intelligently

      While CSV is supported by many systems and is quite comfortable to manage, it is not the only way for software integrations the Awesome Graphs for Bitbucket app offers. Using the REST API, you can make the data flow between the applications and automate the workflow, eliminating manual work. And we want to make it easier for you and save your time.
      Let us know what integrations you are interested in, and we’ll try to bring them to you, so you don’t have to spend time and energy creating workarounds.

      How to Get the Number of Commits and Lines of Code in Pull Requests

      February 4, 2021
      #How To#Bitbucket#Reporting
      9 min

      According to the research conducted by the Cisco Systems programming team, where they tried to determine the best practices for code review, they found out that the pull request size should not include more than 200 to 400 lines of code. Keeping the size of your pull requests within these limits not only will speed up the review but also this amount of information is optimal for the brain to process effectively at a time.

      In case you’d like to analyze your current database, counting lines of code manually for each pull request could take years, so we suggest automating this process with the help of Awesome Graphs for Bitbucket and Python. This article will show you how you can build a report with pull request size statistics in terms of lines of code and commits on the repository level.

      What you will get

      As a result, you’ll get a CSV file containing a detailed list of pull requests created during the specified period with the number of commits, lines of code added and deleted in them.

      How to get it

      To get the report described above, we’ll run the following script that will make requests into the REST API, and do all the calculations and aggregation for us.

      import requests
      import csv
      import sys
      
      bitbucket_url = sys.argv[1]
      login = sys.argv[2]
      password = sys.argv[3]
      project = sys.argv[4]
      repository = sys.argv[5]
      since = sys.argv[6]
      until = sys.argv[7]
      
      get_prs_url = bitbucket_url + '/rest/awesome-graphs-api/latest/projects/' + project + '/repos/' + repository \
                  + '/pull-requests'
      
      s = requests.Session()
      s.auth = (login, password)
      
      
      class PullRequest:
      
          def __init__(self, title, pr_id, author, created, closed):
              self.title = title
              self.pr_id = pr_id
              self.author = author
              self.created = created
              self.closed = closed
      
      
      class PullRequestWithCommits:
      
          def __init__(self, title, pr_id, author, created, closed, commits, loc_added, loc_deleted):
              self.title = title
              self.pr_id = pr_id
              self.author = author
              self.created = created
              self.closed = closed
              self.commits = commits
              self.loc_added = loc_added
              self.loc_deleted = loc_deleted
      
      
      def get_pull_requests():
      
          pull_request_list = []
      
          is_last_page = False
      
          while not is_last_page:
      
              response = s.get(get_prs_url, params={'start': len(pull_request_list), 'limit': 1000,
                                            'sinceDate': since, 'untilDate': until}).json()
      
              for pr_details in response['values']:
      
                  title = pr_details['title']
                  pd_id = pr_details['id']
                  author = pr_details['author']['user']['emailAddress']
                  created = pr_details['createdDate']
                  closed = pr_details['closedDate']
      
                  pull_request_list.append(PullRequest(title, pd_id, author, created, closed))
      
              is_last_page = response['isLastPage']
      
          return pull_request_list
      
      
      def get_commit_statistics(pull_request_list):
      
          pr_list_with_commits = []
      
          for pull_request in pull_request_list:
      
              print('Processing Pull Request', pull_request.pr_id)
      
              commit_ids = []
      
              is_last_page = False
      
              while not is_last_page:
      
                  url = bitbucket_url + '/rest/api/latest/projects/' + project + '/repos/' + repository \
                      + '/pull-requests/' + str(pull_request.pr_id) + '/commits'
                  response = s.get(url, params={'start': len(commit_ids), 'limit': 25}).json()
      
                  for commit in response['values']:
                      commit_ids.append(commit['id'])
      
                  is_last_page = response['isLastPage']
      
              commits = 0
              loc_added = 0
              loc_deleted = 0
      
              for commit_id in commit_ids:
      
                  commits += 1
      
                  url = bitbucket_url + '/rest/awesome-graphs-api/latest/projects/' + project + '/repos/' + repository \
                      + '/commits/' + commit_id
                  response = s.get(url).json()
      
                  if 'errors' not in response:
                      loc_added += response['linesOfCode']['added']
                      loc_deleted += response['linesOfCode']['deleted']
                  else:
                      pass
      
              pr_list_with_commits.append(PullRequestWithCommits(pull_request.title, pull_request.pr_id, pull_request.author,
                                                                 pull_request.created, pull_request.closed, commits,
                                                                 loc_added, loc_deleted))
      
          return pr_list_with_commits
      
      
      with open('{}_{}_pr_size_stats_{}_{}.csv'.format(project, repository, since, until), mode='a', newline='') as report_file:
      
          report_writer = csv.writer(report_file, delimiter=',', quotechar='"', quoting=csv.QUOTE_MINIMAL)
          report_writer.writerow(['title', 'id', 'author', 'created', 'closed', 'commits', 'loc_added', 'loc_deleted'])
      
          for pr in get_commit_statistics(get_pull_requests()):
              report_writer.writerow([pr.title, pr.pr_id, pr.author, pr.created, pr.closed, pr.commits, pr.loc_added, pr.loc_deleted])
      
      print('The resulting CSV file is saved to the current folder.')
      
      

      To make this script work, you’ll need to install the requests module in advance, the csv and sys modules are available in Python out of the box. Then you need to pass seven arguments to the script when executed: the URL of your Bitbucket, login, password, project key, repository name, since date, until date. Here’s an example:

      py script.py https://bitbucket.your-company-name.com login password PRKEY repo-name 2020-11-31 2021-02-01

      As you’ll see at the end of the execution, the resulting file will be saved to the same folder next to the script.

      Want more?

      The Awesome Graphs for Bitbucket app and its REST API, in particular, allow you to get much more than described here, and we want to help you to get the most of it. If you have an idea in mind or a problem that you’d like us to solve, write here in the comments or create a request in our Help Center, and we’ll cover it in future posts! In fact, the idea for this very article was brought to us by our customers, so there is a high chance that your case will be the next one. 

      Here are a few how-tos that you can read right now:

      Related posts