I have the following code (from Google Doc Api
resources) to fetch changes from google drive. However, I want to retrieve the changes made by each user on a specific google doc. Is there a way to achieve this?
var _driveService = GetDriveServiceInstance();
var requestxx = _driveService.Changes.GetStartPageToken();
var response = requestxx.Execute();
var savedStartPageToken = response.StartPageTokenValue;
// Begin with our last saved start token for this user or the
// current token from GetStartPageToken()
string pageToken = savedStartPageToken;
while (pageToken != null)
{
var request = _driveService.Changes.List(pageToken);
request.Spaces = "drive";
var changes = request.Execute();
foreach (var change in changes.Changes)
{
// Process change
Console.WriteLine("Change found for file: " + change.FileId);
}
if (changes.NewStartPageToken != null)
{
// Last page, save this token for the next polling interval
savedStartPageToken = changes.NewStartPageToken;
}
pageToken = changes.NextPageToken;
}
You can see changes that have been made to a document in Google Docs, Sheets, or Slides. On your computer, open a document, spreadsheet, or presentation. At the top, click File Version history See version history. Choose the latest version. You can find who updated the file and their changes.
In Docs, tracked changes are called "suggested edits." Here's how to enable them: On your computer, open a document at docs.google.com . In the top right, if you don’t see "Suggesting," click Editing Suggesting. If you don’t see this option, ask the file owner to let you suggest changes. Edit the document. You’ll see your change in a new color.
On your computer, open a spreadsheet at sheets.google.com . Right-click a cell Show edit history . Note: Some changes might not show up in the edit history. Some examples are: On your computer, open a document, spreadsheet, or presentation. At the top, click File Version history See version history.
You can see changes that have been made to a document in Google Docs, Sheets, or Slides. On your computer, open a document, spreadsheet, or presentation. At the top, click File Version history See version history.
I think the best way would be using Google Drive Activity API, which can provide more information on changes made to specific files. By calling activity.query you can get all past activity from a certain file, including information on the user that's behind each activity. Using this response, you could count the number of changes made by each user.
Another way, albeit incomplete, would be getting the list of Revisions of the file and then getting lastModifyingUser
from each revision. As you said, though, a revision might include many changes, so the retrieved data could be incomplete.
Also, if you consider it would be useful for Drive API to provide that level of detail regarding changes made to files, you could file a feature request in Issue Tracker.
I hope this is of any help.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With