关于访问或获取特定Google app脚本查询参数的问题



我想知道我是否可以从活动的方法访问特定的查询参数。列表API

特别是这段代码

activity.events[0].parameters

我已经尝试过通过数组访问:

activity.events[0].parameters[2]

但是输出不一致,例如索引2不是我需要的,而是一个不同的查询参数。例如,我需要访问

organizer_email

参数(https://developers.google.com/admin-sdk/reports/v1/appendix/activity/meet)

我将在这里附加示例代码。它来自Google API示例(https://developers.google.com/admin-sdk/reports/v1/quickstart/apps-script)

/**
* List login events for a G Suite domain.
* @see https://developers.google.com/admin-sdk/reports/reference/rest/v1/activities/list
*/
function getData() {

var today = new Date();
var oneWeekAgo = new Date(today.getTime() - 7 * 24 * 60 * 60 * 1000);
var timezone = Session.getScriptTimeZone();
var date = Utilities.formatDate(oneWeekAgo, timezone, 'yyyy-MM-dd');

const userKey = 'all';
const applicationName = 'meet';
var pageToken;
const optionalArgs = {
maxResults: 10,
pageToken: pageToken,
};
try {
const response = AdminReports.Activities.list(userKey, applicationName, optionalArgs);
const activities = response.items;
if (!activities || activities.length === 0) {
Logger.log('No logins found.');
return;
}
// Print login events
Logger.log('MEET LOGS:');
for (const activity of activities) {
Logger.log('(%s) %s %s', activity.events[0].parameters, activity.id.time, activity.id.time);
}
} catch (err) {
// TODO (developer)- Handle exception from the Report  API
Logger.log('Failed with error %s', err.message);
}
}

sample array/json result (2 results)

[
{"name":"video_send_seconds","intValue":"40"},
{"name":"screencast_recv_bitrate_kbps_mean","intValue":"128"},
{"value":"email_address","name":"identifier_type"},
{"name":"audio_send_bitrate_kbps_mean","intValue":"2"},
{"name":"video_send_packet_loss_max","intValue":"1"},
{"value":"meetings_android_214151224321356190","name":"endpoint_id"},
{"name":"device_type","value":"android"},{"intValue":"0","name":"video_send_packet_loss_mean"},
{"intValue":"240","name":"video_recv_long_side_median_pixels"},
{"name":"screencast_recv_long_side_median_pixels","intValue":"1072"},
{"name":"screencast_send_seconds","intValue":"0"},
{"name":"video_send_fps_mean","intValue":"15"},
{"intValue":"4","name":"audio_send_packet_loss_max"},
{"intValue":"132","name":"video_recv_short_side_median_pixels"},
{"intValue":"0","name":"video_recv_packet_loss_mean"},
{"name":"screencast_recv_fps_mean","intValue":"8"},
{"intValue":"1267","name":"audio_recv_seconds"},
{"intValue":"0","name":"network_congestion"},
{"name":"network_estimated_download_kbps_mean","intValue":"1398"},
{"intValue":"0","name":"audio_send_packet_loss_mean"},
{"name":"network_transport_protocol","value":"udp"},
{"intValue":"1269","name":"duration_seconds"},
{"intValue":"103","name":"video_send_bitrate_kbps_mean"},
{"name":"identifier","value":"xxxxxx.xxxxx@xxxx.xxx"},
{"intValue":"78","name":"audio_recv_packet_loss_max"},
{"intValue":"10","name":"video_recv_fps_mean"},
{"intValue":"3","name":"audio_recv_packet_loss_mean"},
{"name":"network_recv_jitter_msec_max","intValue":"205"},
{"name":"organizer_email","value":"xxxxxx@xxxxx.xxx"},
{"name":"screencast_recv_short_side_median_pixels","intValue":"480"},
{"name":"network_recv_jitter_msec_mean","intValue":"19"},
{"name":"audio_send_seconds","intValue":"1267"},
{"value":"xxxxxxxxxx","name":"display_name"},
{"name":"screencast_recv_packet_loss_max","intValue":"0"},
{"name":"video_recv_seconds","intValue":"71"},
{"intValue":"35","name":"network_rtt_msec_mean"},
{"name":"video_send_long_side_median_pixels","intValue":"240"},
{"name":"screencast_recv_packet_loss_mean","intValue":"0"},
{"value":"fjqip32o1ru139DFSA2wer23","name":"conference_id"},
{"intValue":"883","name":"screencast_recv_seconds"},
{"name":"product_type","value":"meet"},
{"name":"network_estimated_upload_kbps_mean","intValue":"87"},
{"name":"video_send_short_side_median_pixels","intValue":"132"},
{"intValue":"0","name":"video_recv_packet_loss_max"},
{"name":"meeting_code","value":"ZXWEREHXSG"},
{"name":"is_external","boolValue":true}
]

结果2:

[
{"name":"video_send_seconds","intValue":"0"},
{"name":"identifier_type","value":"email_address"},
{"name":"audio_send_bitrate_kbps_mean","intValue":"5"},
{"value":"meetings_android_23adjfuhvioalu23xpiow;","name":"endpoint_id"},
{"name":"device_type","value":"android"},
{"intValue":"0","name":"screencast_send_seconds"},
{"intValue":"0","name":"audio_recv_seconds"},
{"intValue":"0","name":"network_congestion"},
{"name":"network_estimated_download_kbps_mean","intValue":"0"},
{"value":"udp","name":"network_transport_protocol"},
{"name":"duration_seconds","intValue":"9"},
{"value":"xxxxxxxxxx.xxxxxxxxx@xxxxxx.xxxxxx","name":"identifier"},
{"value":"xxxxxxxxxxx@xxxxxxxx.xxxxx","name":"organizer_email"},
{"name":"audio_send_seconds","intValue":"7"},
{"name":"display_name","value":"xxxxxxxxxxxxx"},
{"intValue":"0","name":"video_recv_seconds"},
{"intValue":"30","name":"network_rtt_msec_mean"},
{"name":"conference_id","value":"4ersdfgwe3re43edf3s"},
{"name":"screencast_recv_seconds","intValue":"0"},
{"name":"product_type","value":"meet"},
{"name":"network_estimated_upload_kbps_mean","intValue":"0"},
{"name":"meeting_code","value":"43eradsfdas23hgrf"},
{"boolValue":true,"name":"is_external"}
]

找到了答案

使用例子:

activity.events[0].parameters.find(x => x.name ==='duration_seconds').intValue

相关内容

  • 没有找到相关文章

最新更新