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 ubiquibot logger support #16

Merged
merged 2 commits into from
Jan 31, 2024

Conversation

gitcoindev
Copy link
Contributor

@gitcoindev gitcoindev commented Jan 29, 2024

Resolves #5

@gitcoindev gitcoindev marked this pull request as draft January 29, 2024 22:42
@gitcoindev
Copy link
Contributor Author

This is still a draft pull request. I have to rebase to current development branch, hopefully will be ready for the review tomorrow.

@0x4007 0x4007 requested a review from whilefoo January 30, 2024 00:16
src/context.ts Outdated Show resolved Hide resolved
The ubiquibot-logger integration enables supabase logging for
ubiquibot-kernel.

On top of SUPABASE_KEY and SUPABASE_URL environment variables,
LOG_RETRY_LIMIT and LOG_LEVEL must be specified.

Example:

LOG_RETRY_LIMIT=3
LOG_LEVEL=DEBUG

Resolves: #5
@gitcoindev gitcoindev self-assigned this Jan 30, 2024
@gitcoindev gitcoindev marked this pull request as ready for review January 30, 2024 18:59
@gitcoindev
Copy link
Contributor Author

Hi @pavlovcik @whilefoo I seem to got it right this time -) I rebased the pull request against latest development branch as well.

The QA was done on my ubiquibot-kernel fork and supabase instance:

╭───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮
[wrangler:inf] POST /events 200 OK (1137ms)
Skipping bot comment
        › Event issue_comment received (id: 7f262fc0-bf97-11ee-9890-dc018251cba6)
        › { id: '7f262fc0-bf97-11ee-9890-dc018251cba6',
            caller: 'file:///home/korrrba/work/ubiquibot-kernel-logging/ubiquibot-kernel/.wrangler/tmp/dev-MzUUmX/worker.js:24018:16',
            revision: null }
        › 
        ✓ Event issue_comment received (id: 7f262fc0-bf97-11ee-9890-dc018251cba6)
        ✓ { log: 'Event issue_comment received (id: 7f262fc0-bf97-11ee-9890-dc018251cba6)',
            level: 'info',
            metadata: 
             { id: '7f262fc0-bf97-11ee-9890-dc018251cba6',
               name: 'issue_comment',
               caller: 'file:///home/korrrba/work/ubiquibot-kernel-logging/ubiquibot-kernel/.wrangler/tmp/dev-MzUUmX/worker.js:24018:16',
               revision: null } }
        ✓ 
Event issue_comment received (id: 7f262fc0-bf97-11ee-9890-dc018251cba6)
╭───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮
[wrangler:inf] POST /events 200 OK (11ms)
╭───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮
│ [b] open a browser, [d] open Devtools, [l] turn off local mode, [c] clear console, [x] to exit    

Also tested at gitcoindev/ubiquibot#10 (comment) and received "Hello from the worker" comments.

On the way I also bumped wrangler to the latest version 3.25.0 .

@gitcoindev gitcoindev mentioned this pull request Jan 30, 2024
@0x4007
Copy link
Member

0x4007 commented Jan 31, 2024

Also tested at gitcoindev/ubiquibot#10 (comment) and received "Hello from the worker" comments.

Your test doesn't explicitly show that the logger is working but I trust that you tested that as well

@0x4007 0x4007 merged commit 9ee5c93 into ubiquity:development Jan 31, 2024
2 checks passed
@gitcoindev
Copy link
Contributor Author

Also tested at gitcoindev/ubiquibot#10 (comment) and received "Hello from the worker" comments.

Your test doesn't explicitly show that the logger is working but I trust that you tested that as well

Yes, I can confirm that. I have logged into my Supabase dashboard and checked that a new row appeared in the logs table.

@@ -1,6 +1,7 @@
name = "ubiquibot-worker"
main = "src/worker.ts"
compatibility_date = "2023-12-06"
node_compat = true
Copy link
Member

Choose a reason for hiding this comment

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

Hey @gitcoindev I don't think we can add this

@whilefoo rfc

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@pavlovcik @whilefoo I added this config to silence cloudflare worker warning. I decided to dig into this deeper and discovered that this warning may be related to a bug cloudflare/workers-sdk#4050 which was coincidentally put to in progress 40 minutes ago. Let's monitor this and remove once it will be fixed.

Copy link
Member

Choose a reason for hiding this comment

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

But also doesn't our npm library depend on node APIs at runtime? If so we can't actually use it in our production Worker.

Copy link
Contributor

Choose a reason for hiding this comment

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

ubiquity-logger uses probot's context so that needs to be modified, it uses supabase-js which needs some configuration to work on CF workers (https://github.com/supabase/supabase-js?tab=readme-ov-file#custom-fetch-implementation) and also it uses node's util package

SUPABASE_KEY=

LOG_RETRY_LIMIT=
LOG_LEVEL=
Copy link
Member

Choose a reason for hiding this comment

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

Also should include documentation around this. I'm assuming verbose is fine

This pull request was closed.
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.

Supabase Logger
3 participants