Dịch vụ hoạt động trên Google Drive
Sử dụng bộ sưu tập để sắp xếp ngăn nắp các trang
Lưu và phân loại nội dung dựa trên lựa chọn ưu tiên của bạn.
truy cập thông tin về hoạt động trên Google Drive theo phương thức lập trình.
Dịch vụ Google Drive Activity cho phép bạn sử dụng Google Drive Activity API trong Google Apps Script. API này cho phép người dùng truy xuất thông tin về hoạt động của họ trên Google Drive.
Để biết thông tin chi tiết về dịch vụ này, hãy xem tài liệu tham khảo cho Google Drive Activity API. Giống như tất cả các dịch vụ nâng cao trong Apps Script, dịch vụ Hoạt động trên Google Drive cũng sử dụng các đối tượng, phương thức và tham số giống như API công khai. Để biết thêm thông tin, hãy xem bài viết Cách xác định chữ ký phương thức.
/** * Lists 10 activity for a Drive user. * @see https://developers.google.com/drive/activity/v2/reference/rest/v2/activity/query */functionlistDriveActivity(){constrequest={pageSize:10,// Use other parameter here if needed.};try{// Activity.query method is used Query past activity in Google Drive.constresponse=DriveActivity.Activity.query(request);constactivities=response.activities;if(!activities||activities.length===0){console.log("No activity.");return;}console.log("Recent activity:");for(constactivityofactivities){// get time information of activity.consttime=getTimeInfo(activity);// get the action details/informationconstaction=getActionInfo(activity.primaryActionDetail);// get the actor's details of activityconstactors=activity.actors.map(getActorInfo);// get target information of activity.consttargets=activity.targets.map(getTargetInfo);// print the time,actor,action and targets of drive activity.console.log("%s: %s, %s, %s",time,actors,action,targets);}}catch(err){// TODO (developer) - Handle error from drive activity APIconsole.log("Failed with an error %s",err.message);}}/** * @param {object} object * @return {string} Returns the name of a set property in an object, or else "unknown". */functiongetOneOf(object){for(constkeyinobject){returnkey;}return"unknown";}/** * @param {object} activity Activity object. * @return {string} Returns a time associated with an activity. */functiongetTimeInfo(activity){if("timestamp"inactivity){returnactivity.timestamp;}if("timeRange"inactivity){returnactivity.timeRange.endTime;}return"unknown";}/** * @param {object} actionDetail The primary action details of the activity. * @return {string} Returns the type of action. */functiongetActionInfo(actionDetail){returngetOneOf(actionDetail);}/** * @param {object} user The User object. * @return {string} Returns user information, or the type of user if not a known user. */functiongetUserInfo(user){if("knownUser"inuser){constknownUser=user.knownUser;constisMe=knownUser.isCurrentUser||false;returnisMe?"people/me":knownUser.personName;}returngetOneOf(user);}/** * @param {object} actor The Actor object. * @return {string} Returns actor information, or the type of actor if not a user. */functiongetActorInfo(actor){if("user"inactor){returngetUserInfo(actor.user);}returngetOneOf(actor);}/** * @param {object} target The Target object. * @return {string} Returns the type of a target and an associated title. */functiongetTargetInfo(target){if("driveItem"intarget){consttitle=target.driveItem.title||"unknown";return`driveItem:"${title}"`;}if("drive"intarget){consttitle=target.drive.title||"unknown";return`drive:"${title}"`;}if("fileComment"intarget){constparent=target.fileComment.parent||{};consttitle=parent.title||"unknown";return`fileComment:"${title}"`;}return`${getOneOf(target)}:unknown`;}
[[["Dễ hiểu","easyToUnderstand","thumb-up"],["Giúp tôi giải quyết được vấn đề","solvedMyProblem","thumb-up"],["Khác","otherUp","thumb-up"]],[["Thiếu thông tin tôi cần","missingTheInformationINeed","thumb-down"],["Quá phức tạp/quá nhiều bước","tooComplicatedTooManySteps","thumb-down"],["Đã lỗi thời","outOfDate","thumb-down"],["Vấn đề về bản dịch","translationIssue","thumb-down"],["Vấn đề về mẫu/mã","samplesCodeIssue","thumb-down"],["Khác","otherDown","thumb-down"]],["Cập nhật lần gần đây nhất: 2026-03-03 UTC."],[],[]]