Apps Activity Service

The Apps Activity service allows you to use the Apps Activity API in Apps Script. This API allows users programmatic access to retrieve information about their Google Apps activity.

Reference

For detailed information on this service, see the reference documentation for the Apps Activity API. Like all advanced services in Apps Script, the Apps Activity service uses the same objects, methods, and parameters as the public API.

Sample code

The sample code below uses version 1 of the API.

Open code in new window

Get a file's activity

This sample gets a file's activity and logs the list of unique users that performed the activity.

function getUsersActivity() {
  var fileId = 'YOUR_FILE_ID_HERE';

  var pageToken;
  var users = {};
  do {
    var result = AppsActivity.Activities.list({
      'drive.fileId': fileId,
      'source': 'drive.google.com',
      'pageToken': pageToken
    });
    var activities = result.activities;
    for (var i = 0; i < activities.length; i++) {
      var events = activities[i].singleEvents;
      for (var j = 0; j < events.length; j++) {
        var event = events[j];
        users[event.user.name] = true;
      }
    }
    pageToken = result.nextPageToken;
  } while (pageToken);
  Logger.log(Object.keys(users));
}

发送以下问题的反馈:

此网页
Apps Script
Apps Script