Disable or reset the Execution Transcript in Google Apps Script

…衆ロ難τιáo~ 提交于 2020-04-30 13:58:23

问题


Is it possible to disable or reset the Execution Transcript in Google Apps Script?

If not, what would be the best way to run a script that requires sensitive access tokens for API calls?


回答1:


Use a time-based trigger to invoke a simple dummy script:

function clearIt() {
  Logger.log("hi");
}

This script could be invoked every minute, or specifically invoked via one-time trigger to occur after specific other functions. If you go the one-time route you'll need to delete the invoking trigger to avoid accumulation:

function sensitive() {
  ...
  ScriptApp.newTrigger("newExecutionTranscript")
    .timeBased().after(1) // runs at up to 15m later
    .create();
}

function newExecutionTranscript(e) {
  const invoker = (!e) ? null : ScriptApp.getProjectTriggers()
      .filter(function (t) {
        return t.getUniqueId() === e.triggerUid;
      })[0];
  if (invoker)
    ScriptApp.deleteTrigger(invoker);
  Logger.log("Done");
}

References

  • Time-driven trigger event object
  • Trigger#getUniqueId
  • ClockTriggerBuilder#after


来源:https://stackoverflow.com/questions/54941355/disable-or-reset-the-execution-transcript-in-google-apps-script

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!