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

Add Chrome browser event in database during recording #744

Merged
merged 99 commits into from
Sep 11, 2024

Conversation

abrichr
Copy link
Member

@abrichr abrichr commented Jun 13, 2024

What kind of change does this PR introduce?
This PR implements the chrome extension to write DOM and DOM events to the database.

Summary
Motivation: Related Issue: #51

Checklist

  • My code follows the style guidelines of OpenAdapt
  • I have performed a self-review of my code
  • If applicable, I have added tests to prove my fix is functional/effective
  • I have linted my code locally prior to submission
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation (e.g. README.md, requirements.txt)
  • New and existing unit tests pass locally with my changes
  • How can your code be run and tested? -> Add Chrome browser event in database during recording #744 (comment)

Other information
Supercedes #364

Copy link
Member Author

@abrichr abrichr left a comment

Choose a reason for hiding this comment

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

Thank you @KrishPatel13 ! I left a few comments, happy to chat about any of it if you like.

If you could show some console output and/or screenshots in the PR description that would be very much appreciated!

chrome_extension/browser.py Outdated Show resolved Hide resolved
chrome_extension/content.js Outdated Show resolved Hide resolved
chrome_extension/export_messages.py Outdated Show resolved Hide resolved
chrome_extension/install.sh Outdated Show resolved Hide resolved
chrome_extension/mock_client.py Outdated Show resolved Hide resolved
chrome_extension/view_messages.py Outdated Show resolved Hide resolved
@KrishPatel13
Copy link
Collaborator

KrishPatel13 commented Jun 16, 2024

An update for Chrome Extension Issue:

After spending about 4-5 hours debugging nativeMessaging, I was not able to fix the issue. I dropped the idea of using nativeMessaging. Reasons:

  • Setup is complex, and it is different for all types of Os.
  • APIs and example are about 6-7 years old and no debugging features with it, which prevent to make progress.
  • Very less resources to find help about nativeMessaging.

Hence, After an hour of research, I recalled that I had used WebSockets in my assignment in CSC309 to communicate between an web server and my java running process. The task there was that whenever the user click submit I had to sent that api request to my java running client and then, connect to db and save some info about the user (registering).

I thought this might relevant for the task that we are working on too.

Hence, I quickly made a web_socket_extension example to demo this idea for constant communication between extension and a desktop running process (in our case a .py file). I made a dumpy record.py that just listening for incoming messages fromt the websocket and prints them.

Commit for the Web Socket "Ping" Example: https://github.com/OpenAdaptAI/OpenAdapt/pull/744/commits/9c749caef0f0ba9f6e8b79fd57d00309b822d114

Some Screenshots for the output:
image

@KrishPatel13
Copy link
Collaborator

My next step would be to log the dom changes instead of "ping" message.

@KrishPatel13
Copy link
Collaborator

KrishPatel13 commented Jun 16, 2024

My goal is to at least, make a prototype by tonight:

record.py (dummy): that runs and save all the dom changes in a sqlite db and once this is done, I will then manipulate the actual record.py next week so that it records the dom changes in our actual db. (our main goal). I hope this sounds like a good plan to tackle this issue :-)

@KrishPatel13
Copy link
Collaborator

KrishPatel13 commented Jun 16, 2024

Update: Now I am able to log DOM changes
image

Commit: d9f9792

@KrishPatel13
Copy link
Collaborator

Now, I can save all the DOM messages sent by the extension into a db synchronously.

Commit: 1b606fb

Some Screenshots for the work:

image

and

image

This commit proves a working prototype for the chrome extension issue.

Now my next steps shall be to integrate this into our actual application.

chrome_extension/record.py Outdated Show resolved Hide resolved
chrome_extension/record.py Outdated Show resolved Hide resolved
openadapt/record.py Outdated Show resolved Hide resolved
openadapt/sockets.py Outdated Show resolved Hide resolved
openadapt/sockets.py Outdated Show resolved Hide resolved
openadapt/sockets.py Outdated Show resolved Hide resolved
@abrichr abrichr marked this pull request as draft June 16, 2024 22:56
@KrishPatel13
Copy link
Collaborator

KrishPatel13 commented Jul 28, 2024

Also, we want to update visualize.py and the dashboard to display these events. (#744 (comment))

FIxed Visualization here: b3d54eb

I just ran visualize on a browser_event record recording. Here are some screenshots to support:

image,

image

@abrichr abrichr merged commit 49d71d1 into main Sep 11, 2024
1 check passed
@abrichr abrichr deleted the feat/chrome-extension branch September 11, 2024 02:31
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.

2 participants