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

fix(tracker): metadata being overwritten #1792

Open
wants to merge 24 commits into
base: main
Choose a base branch
from

Conversation

Titozzz
Copy link

@Titozzz Titozzz commented Dec 20, 2023

When calling multiple time metadata in a row for different metadata, I noticed that sometime only the last metadata get registered. Sending all metadata on update fixes it. There might be another way 😄

Summary by CodeRabbit

  • Refactor
    • Enhanced the session metadata handling to support updates with the full metadata object for improved performance and consistency.

rjshrjndrn and others added 24 commits December 13, 2023 09:26
* refactor(chalice): moved db_request_handler to utils package

* refactor(chalice): moved db_request_handler to utils package
fix(chalice): supported usability tests in EE
* refactor(chalice): moved db_request_handler to utils package

* refactor(chalice): moved db_request_handler to utils package
fix(chalice): supported usability tests in EE

* refactor(crons): changed assist_events_aggregates_cron to have only 1 execution every hour
refactor(crons): optimized assist_events_aggregates_cron to use only 1 DB cursor for successive queries
* fix(ui): xray check for data load

* fix(ui): api client catch errors
When calling multiple time metadata in a row for different metadata, I noticed that _sometime_ only the last metadata get registered. Sending all metadata on update fixes it. There might be another way 😄
Copy link

coderabbitai bot commented Dec 20, 2023

Walkthrough

The update in the codebase involves a refinement to the Session class's setMetadata method. Instead of updating metadata piece by piece, the method has been enhanced to apply changes to the entire metadata object at once. This could potentially streamline the update process and make the handling of session metadata more efficient.

Changes

File Path Change Summary
.../tracker/src/main/app/session.ts Modified setMetadata to pass the entire metadata object to handleUpdate instead of individual key-value pairs.

🐇✨
To the code we hop and tweak,
With every push, we seek to peak.
Metadata flows, now full and sleek,
A rabbit’s touch, unique and chic. 🎩🚀

Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on X ?


Tips

Chat with CodeRabbit Bot (@coderabbitai)

  • You can reply to a review comment made by CodeRabbit.
  • You can tag CodeRabbit on specific lines of code or files in the PR by tagging @coderabbitai in a comment.
  • You can tag @coderabbitai in a PR comment and ask one-off questions about the PR and the codebase. Use quoted replies to pass the context for follow-up questions.

CodeRabbit Commands (invoked as PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger a review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai help to get help.

Additionally, you can add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.

CodeRabbit Configration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • The JSON schema for the configuration file is available here.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/coderabbit-overrides.v2.json

@CLAassistant
Copy link

CLAassistant commented Dec 20, 2023

CLA assistant check
All committers have signed the CLA.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Review Status

Actionable comments generated: 2

Configuration used: CodeRabbit UI

Commits Files that changed from the base of the PR and between 7e672e2 and c22a8bb.
Files selected for processing (1)
  • tracker/tracker/src/main/app/session.ts (1 hunks)
Additional comments: 1
tracker/tracker/src/main/app/session.ts (1)
  • 78-80: The change to pass the entire metadata object to handleUpdate is consistent with the PR's objective to address the issue of metadata updates not being registered correctly. This should ensure that all metadata changes are captured, even when they occur in quick succession.

tracker/tracker/src/main/app/session.ts Show resolved Hide resolved
@nick-delirium
Copy link
Contributor

https://docs.openreplay.com/en/sdk/set-metadata/

image

There is an API limitation regarding that, handleUpdate sends key-value pair directly to backend and then it applies new values in DB.

@Titozzz
Copy link
Author

Titozzz commented Dec 21, 2023

https://docs.openreplay.com/en/sdk/set-metadata/

There is an API limitation regarding that, handleUpdate sends key-value pair directly to backend and then it applies new values in DB.


I don't understand how that is related to my issue, my current problem is that when you call:

setMetadata('a', 1);
setMetadata('b', 1);
setMetadata('c', 1);
setMetadata('d', 1);

It will call handleUpdate with

handleUpdate({ metadata : { a: 1 } });
handleUpdate({ metadata : { b: 1 } });
handleUpdate({ metadata : { c: 1 } });
handleUpdate({ metadata : { d: 1 } });

And I end up with only d: 1 in the user metadata.

My "fix" isn't clean but sends this instead

handleUpdate({ metadata : { a: 1 } });
handleUpdate({ metadata : { a:1, b: 1 } });
handleUpdate({ metadata : { a:1, b: 1, c: 1 } });
handleUpdate({ metadata : { a:1, b: 1, c: 1, d: 1 } });

And now all the metadata are set properly...
Hoping I clarified the issue @nick-delirium

@nick-delirium
Copy link
Contributor

Yes indeed this would help @Titozzz if we were sending everything at once, but metadata is sent as single k-v pair message, so in reality this will only cause tracker to send previously sent pairs every time you add a new one, so in the end it will not change the end result, but will cause message duplication (which then leads to added processing time and costs - even if its small, its visible on large scale)

image

This message is then being sent to /ingest point, parsed along side with other messages and (iirc) appended into metadata column in db afterwards.

So if you happen to see missing metadata in sessions, there could be another issue involved in that, which I will be happy to investigate with you

@Titozzz
Copy link
Author

Titozzz commented Dec 21, 2023

Happy to debug further then. I'm also available on Slack if that helps, feel free to DM

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.

None yet

6 participants