diff --git a/src/webhooks.ts b/src/webhooks.ts index 4da00f095..fbfee85cc 100644 --- a/src/webhooks.ts +++ b/src/webhooks.ts @@ -27,7 +27,7 @@ export function webhooks( return { ...event, - octokit: octokit, + octokit, }; } @@ -49,9 +49,19 @@ export function webhooks( }, })) as Octokit; + // set `x-github-delivery` header on all requests sent in response to the current + // event. This allows GitHub Support to correlate the request with the event. + // This is not documented and not considered public API, the header may change. + // Once we document this as best practice on https://docs.github.com/en/rest/guides/best-practices-for-integrators + // we will make it official + /* istanbul ignore next */ + octokit.hook.before("request", (options) => { + options.headers["x-github-delivery"] = event.id; + }); + return { ...event, - octokit: octokit, + octokit, }; }, });