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

Better logs V2 #2376

Merged
merged 22 commits into from
Jul 5, 2024
Merged

Better logs V2 #2376

merged 22 commits into from
Jul 5, 2024

Conversation

engelhartrueben
Copy link
Collaborator

Fixes # (issue)

Creates clearer, common occurring logs.

Description

Most information found in console.logs was jumbled, which benefitted from destructuring.
Others, like getConversation were confusing. Take a look at the old log:

getConversations sql undefined { offset: 0, limit: 10 } {} select "campaign_contact"."id" as "cc_id" from "campaign_contact" inner join "campaign" on "campaign"."id" = "campaign_contact"."campaign_id" where "campaign"."organization_id" = '2' and "campaign"."is_archived" = false and "is_opted_out" = false order by "cc_id" desc limit 10

Here, undefined, dealt with awsContext, which is not apparent when looking at the log. Paired with undefined being followed by sql, caused some concern when not privy to what the console.log looks like. However, getConversations sql is a string within the log, and does not call any variable.

Will now read like:

Org ID: ## :: getConversations sql -- 
  awsContext: <>          // true or false rather, than undefined
  cursor: <>              // the {offset: #, limit: #}
  assignmentFilter: <>    // {}
  offsetLimitQuery: <>    // select... from... innerjoin... on...

Most changes to any console.log follows a similar destructuring.

Additionally, most errors, like those commonly found when NGP VAN is not configured correctly, did not share what organization was causing the problem. This update focused on including org ids and other supporting information to help pinpoint any misconfiguration. This is most apparent in multi org situations.

Checklist:

  • I have manually tested my changes on desktop and mobile
  • The test suite passes locally with my changes
  • If my change is a UI change, I have attached a screenshot to the description section of this pull request
  • My change is 300 lines of code or less, or has a documented reason in the description why it’s longer
  • I have made any necessary changes to the documentation
  • I have added tests that prove my fix is effective or that my feature works
  • My PR is labeled [WIP] if it is in progress

…ailed, if any. Added clearer errors to help determine what may be wrong
…ary, instead passing the direct reason like "stop" or "quit". made log one line, breaking up the the information into readable chunks rather than a heap of information.
Both pendingMessagePart and finalMessage contain the same information, causing bloat while logging.
Did not remove any information, so the log would contain everything the previous log had.

Reduced finalMessage.text to only allow up to 45 characters would ever be shown (removing new lines as well).
finalMessage.media is often an empty array (and blocked most times anyway), so added logic to state no media if the array is empty.
…rganization variable in test to pass as the new error contains which organization is causing said error.
…ll organization.name after failing. This is in response to creating better errors that point towards which organization is causing said errors.
@engelhartrueben engelhartrueben requested a review from mau11 July 5, 2024 14:36
@engelhartrueben engelhartrueben merged commit da0cf70 into stage-main-14.1 Jul 5, 2024
17 checks passed
@engelhartrueben engelhartrueben deleted the better-logs-2 branch July 26, 2024 08:38
@engelhartrueben engelhartrueben mentioned this pull request Sep 4, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: 14.1
Development

Successfully merging this pull request may close these issues.

2 participants