Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(deploy): print edge function logs url #6851

Merged
merged 6 commits into from
Oct 8, 2024

Conversation

serhalp
Copy link
Contributor

@serhalp serhalp commented Oct 2, 2024

Summary

The netlify deploy command prints the build logs URL and the function logs URL:

Screenshot 2024-10-02 at 10 59 27

It's inconvenient and inconsistent that this doesn't also include a link to edge function logs. So this PR adds it.

Changes

4d5ebca: add missing types to printResults and neighbouring code

bee888c: fix issues uncovered by above

  • name in the JSON output was coming from a field that did not exist, so it was always undefined (and undefined values are omitted when JSON stringifying), so I just removed it, as it's effectively never truly existed
    • I'm not sure what this was supposed to be anyway. There's already a site_name field which is working as intended.
  • site_id never worked (or at least hasn't for some time) as it was reading from a field that didn't exist. I fixed this one.

8bee1a9: add edge function logs URL to pretty output

Example:
Screenshot 2024-10-02 at 11 00 49

aed9afe: add function_logs and edge_function_logs to --json output

It wasn't consistent that these weren't included in the JSON output. These also could be useful to users. But mostly it allowed me to more easily add test coverage (none of the printed URLs — neither pretty nor json — had test coverage).

Example before:

{
  "site_name": "hydrogen-remix-template",
  "deploy_id": "66fd5eacf914aa188272ebe8",
  "deploy_url": "https://66fd5eacf914aa188272ebe8--hydrogen-remix-template.netlify.app",
  "logs": "https://app.netlify.com/sites/hydrogen-remix-template/deploys/66fd5eacf914aa188272ebe8"
}

Example after:

{
  "site_id": "da7ae002-b3be-4dd5-a294-d44321e2459f",
  "site_name": "hydrogen-remix-template",
  "deploy_id": "66fd5ef32443dc1423ce705b",
  "deploy_url": "https://66fd5ef32443dc1423ce705b--hydrogen-remix-template.netlify.app",
  "logs": "https://app.netlify.com/sites/hydrogen-remix-template/deploys/66fd5ef32443dc1423ce705b",
  "function_logs": "https://app.netlify.com/sites/hydrogen-remix-template/logs/functions?scope=deploy:66fd5ef32443dc1423ce705b",
  "edge_function_logs": "https://app.netlify.com/sites/hydrogen-remix-template/logs/edge-functions?scope=deploy:66fd5ef32443dc1423ce705b"
}

Future improvements

💡 We should only include the function logs URL when the deploy included >0 functions and only include the edge function logs URL when the deploy included >0 edge functions.

Comment on lines 677 to +679
logs: results.logsUrl,
function_logs: results.functionLogsUrl,
edge_function_logs: results.edgeFunctionLogsUrl,
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would rather have suffixed these with _url but since logs was already named logs I erred toward internal consistency 😞.

})
await builder.build()

const deploy = await callCli(['deploy', '--json', '--dir', 'public', '--prod'], {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fun fact: this is the very first test coverage of ntl deploy --prod 😬😬😬

@serhalp serhalp marked this pull request as ready for review October 2, 2024 16:23
@serhalp serhalp requested a review from a team as a code owner October 2, 2024 16:23
src/commands/deploy/deploy.ts Outdated Show resolved Hide resolved
src/commands/deploy/deploy.ts Show resolved Hide resolved
@serhalp serhalp merged commit b996f92 into main Oct 8, 2024
48 checks passed
@serhalp serhalp deleted the feat/print-edge-function-logs-url-on-deploy branch October 8, 2024 19:09
serhalp added a commit that referenced this pull request Oct 17, 2024
Follow-up to #6851.

You can see here it says "Show logs for deploy...":
https://app.netlify.com/sites/hydrogen-advanced-caching/logs/
edge-functions?scope=deployid:6705473738103f2856071dbd.

This doesn't work with `?scope=deploy:`

This is a bit of a footgun since the Functions log URL takes `deploy:` but the Edge Functions log
URL takes `deployid:`.
serhalp added a commit that referenced this pull request Oct 17, 2024
Follow-up to #6851.

You can see here it says "Show logs for deploy...":
https://app.netlify.com/sites/hydrogen-advanced-caching/logs/
edge-functions?scope=deployid:6705473738103f2856071dbd.

This doesn't work with `?scope=deploy:`

This is a bit of a footgun since the Functions log URL takes `deploy:` but the Edge Functions log
URL takes `deployid:`.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants