Overview

The UI application may want to persistently log errors, warning, notices etc.

Proposed resolution

Implement a route that provides an API endpoint for the UI application to create log entries. The Experience Builder module already defines @logger.channel.experience_builder, which could be used by the route's controller.

#3467844: [PP-1] Log client-side errors will make use of this endpoint in the UI codebase.

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

balintbrews created an issue. See original summary.

balintbrews’s picture

Issue summary: View changes
Related issues: +#3467844: [PP-1] Log client-side errors
wim leers’s picture

Title: Backend route to allow logging from the UI » Back-end route to allow logging from the UI
Component: Data model » Page builder
Issue tags: +blocker, +DX (Developer Experience)

#3461431: Improve client side error handling is in — the next step is #3467844: [PP-1] Log client-side errors, which this is a blocker for.

omkar-pd made their first commit to this issue’s fork.

omkar-pd’s picture

Status: Active » Needs review
wim leers’s picture

Status: Needs review » Needs work
Issue tags: +Needs tests

Thanks, @omkar-pd, looking good! This still needs a functional test 😊

omkar-pd’s picture

Created my first tests.😃 Probably will need some changes.

pooja_sharma’s picture

Assigned: Unassigned » pooja_sharma
pooja_sharma’s picture

Status: Needs work » Needs review

Addressed test coverage issue , test passed on local & attached the screenshot as well however left there one comment on MR for test coverage need suggestion here , fixed undefined variable errors for newly added route, rebased the MR & resolved conflicts.

Please review, moving NR

pooja_sharma’s picture

Assigned: pooja_sharma » Unassigned
pooja_sharma’s picture

StatusFileSize
new130.14 KB
wim leers’s picture

Status: Needs review » Needs work
Issue tags: -Needs tests

#8: Congrats! 😄

This is 99% ready! 👏 The test looks great 😊 — impressive for your very first test! (And thanks @pooja_sharma for putting those nice finishing touches on it!)

pooja_sharma’s picture

Thanks @wim-leers for recognizing efforts happy to contribute , got your concerns regarding test coverage feedback after removing standard profile code, test resource usage goes from Time: 00:16.673, Memory: 4.00 MB to Time: 00:05.687, Memory: 4.00 MB which eliminates the half of test execution time (much faster).

I m here for contributing for test coverage as per request @omkar-pd, also has done great, as it's his first test coverage even fix
the issue that's not replicate on local & found its alternate solution & initially much of the work done by him so letting him to take opportunity to cover up pending feedback.

omkar-pd’s picture

Status: Needs work » Needs review

Thank you @wim-leers and @pooja_sharma.

I've addressed the feedback given. Moving this to NR.

omkar-pd’s picture

Bump

lauriii’s picture

Assigned: Unassigned » wim leers

Assigning to @Wim Leers for review

wim leers’s picture

Title: Back-end route to allow logging from the UI » [PP-1] Back-end route to allow logging from the UI

This should wait for #3466555: Also validate request bodies against the OpenAPI spec to land — it makes openapi.yml more maintainable.

(I expect to land in the next hour or so though 👍)

wim leers’s picture

Issue tags: +openapi
wim leers’s picture

Title: [PP-1] Back-end route to allow logging from the UI » Back-end route to allow logging from the UI
wim leers’s picture

Assigned: wim leers » traviscarden
Status: Needs review » Reviewed & tested by the community

LGTM!

But since I requested @traviscarden to become the CODEOWNER for /openapi.yml at #3466555-21: Also validate request bodies against the OpenAPI spec.3, I'd like him to do the final review 😊

traviscarden’s picture

Assigned: traviscarden » Unassigned
Status: Reviewed & tested by the community » Needs work

Nice contribution! I've requested some changes on the MR.

omkar-pd’s picture

@wim-leers, @traviscarden

Need suggestions for this.
https://git.drupalcode.org/project/experience_builder/-/merge_requests/1...

wim leers’s picture

Assigned: Unassigned » wim leers

Will review/merge in upstream to get this back on track 😊

wim leers’s picture

Assigned: wim leers » Unassigned

To answer #23:

There was 1 error:
1) Drupal\Tests\experience_builder\Functional\LogControllerTest::testLogController
Exception: Warning: Undefined array key "invalid_log_level"
Drupal\Core\Logger\LoggerChannel->log()() (Line: 123)
/builds/issue/experience_builder-3467843/web/core/lib/Drupal/Core/Test/HttpClientMiddleware/TestHttpClientMiddleware.php:55

shows that there's a bug in the controller logic:

    if (empty($error_level)) {
      return new JsonResponse(['error' => 'Log level is required'], 400);
    }

    // Log the error.
    $this->logger->log($error_level, $error_message);

👆 That doesn't verify the log level is valid, only that one is specified.

omkar-pd’s picture

Status: Needs work » Needs review
wim leers’s picture

Version: » 0.x-dev
Status: Needs review » Needs work
Parent issue: » #3450586: [META] Back-end Kanban issue tracker

@larowlan's https://git.drupalcode.org/project/experience_builder/-/merge_requests/1... still needs to be addressed.

Almost there! 😄

deepakkm made their first commit to this issue’s fork.

wim leers’s picture

Issue tags: +Needs tests

Still needs the tests that @larowlan suggested.

omkar-pd’s picture

Status: Needs work » Needs review
wim leers’s picture

Assigned: Unassigned » wim leers
Issue tags: -Needs tests
wim leers’s picture

Assigned: wim leers » traviscarden
Status: Needs review » Reviewed & tested by the community

Final review pass, fixed my own nits. Looked great!


I actually don't quite like that this is now a unit test instead of a functional test. Because it doesn't prove the route actually works, only that the controller works.

But … #3467844: [PP-1] Log client-side errors will have to add an end-to-end test, and that's even better.

So: RTBC! This now only needs MR approval from @traviscarden, so assigning to him.

traviscarden’s picture

Assigned: traviscarden » wim leers

Nice! I prettified openapi.yml and approved it.

  • wim leers committed 9480067e on 0.x authored by omkar-pd
    Issue #3467843 by omkar-pd, pooja_sharma, wim leers, traviscarden,...
wim leers’s picture

Assigned: wim leers » Unassigned
Status: Reviewed & tested by the community » Fixed

Yay! Merged and unpostponing #3467844: [PP-1] Log client-side errors 👍

omkar-pd’s picture

🎉🎉

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.