Count User interaction with Issue

Hi,
I want to calculate the total of Interaction a user has had with an Issue.
Scenario: Any history log that the user has with the Issue: Add a comment, add an attachment, transition an issue, update a field, etc.

Basically in need to be able to count the information inside: /rest/api/3/issue/ISSUE-123.json?expand=changelog

Hi @Daniel_Luevano,

With eazyBI you can analyze change history that is visible to eazyBI app as well as comments. While eazyBI for Jira Cloud can access all history records with Rest API, the eazyBI for Jira Server version can access only limited part of history records (status transitions, changes in single-select standard fields imported in eazyBI, and logged hours).
You may check which JSON objects are visible to eazyBI in section import options, tab “Additional options” (JavaScript calculated custom fields).

Anyhow, you may import count of activities (change history and comments) visible to eazyBI using JavaScript calculated custom field.

  1. In advanced settings, add the definition of new JavaScript calculated measure “Activity history”. The script for Jira Cloud version might look like this:
[jira.customfield_activities]
name = "Activity History"
data_type = "integer"
measure = true
multiple_dimensions = ["Assignee","Time"]
javascript_code = '''
var activities = [];
//check history records for each issue
if (issue.changelog.histories && issue.changelog.histories.length > 0) {
  for (i=0; i<issue.changelog.histories.length; i++) {
    if (issue.changelog.histories[i].author && issue.changelog.histories[i].author.accountId) {
      //get date and author of each history record
      var activityDate = issue.changelog.histories[i].created;
      var activityAuthor = issue.changelog.histories[i].author.accountId;
      activities.push(activityAuthor + ',' + activityDate.toString().substr(0,10) + ',1');
    }
  }
}
//check comments for each issue
if (issue.fields.comment.comments && issue.fields.comment.comments.length>0) {
  for (j=0; j<issue.fields.comment.comments.length; j++) {
    if (issue.fields.comment.comments[j].author && issue.fields.comment.comments[j].author.accountId) {
    //get date and author of each comment
      var activityDate = issue.fields.comment.comments[j].created;
      var activityAuthor = issue.fields.comment.comments[j].author.accountId;
      activities.push(activityAuthor + ',' + activityDate.toString().substr(0,10) + ',1');
    }
  }
}
//get the array of changelogs and comments
issue.fields.customfield_activities = activities.join("\n");
'''

Advanced settings and JavaScript code for the Jira Server version are similar. Use author.key instead of author.accountId to retrieve the author of the activity.

  1. Then import “Activity history” as a measure in eazyBI.

  2. In the reports, use “Activity history” together with dimension Time (when was activity) and Assignee (who made activity).

Best,
Zane / support@eazyBI.com

2 Likes

Zane, you are the best!!! :love_you_gesture:

Hello Zane

This is a very useful script.
However, it does not work for all users. In my example, users left comments and updated tasks, but their Activity History is empty.
what could be the problem?