Skip to content

Commit

Permalink
feat: (unstable) set x-github-delivery header on requests sent in r…
Browse files Browse the repository at this point in the history
…esponse to webhook event (#367)
  • Loading branch information
gr2m committed Dec 1, 2022
1 parent ef57164 commit 3e44c5d
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions src/webhooks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ export function webhooks(

return {
...event,
octokit: octokit,
octokit,
};
}

Expand All @@ -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,
};
},
});
Expand Down

0 comments on commit 3e44c5d

Please sign in to comment.