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

Actually send heartbeats in appropriate situation, as stated in docs #7

Merged
merged 4 commits into from
Apr 12, 2021
Merged

Conversation

mvolfik
Copy link
Contributor

@mvolfik mvolfik commented Nov 16, 2020

See https://wakatime.com/help/creating-plugin#plugin-overview
I believe this deserves a version bump, as it changes heartbeat frequency significantly.

I've also found some other minor issues in the plugin, I'll address these in a separate issue

and file_uri == _last_heartbeat_file
and now - _last_heartbeat_time < ACTION_FREQUENCY
):
logger.debug("Not necessary to send heartbeat")
Copy link
Member

@alanhamlett alanhamlett Feb 1, 2021

Choose a reason for hiding this comment

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

This will generate too many logs, how about leaving this code but commenting it out?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is only debug logs, so it's printed only with env GEDIT_WAKATIME_PLUGIN_DEBUG=1, and there are two other messages from this plugin emitted in the same sequence anyway. Should this really be commented out?

Copy link
Member

Choose a reason for hiding this comment

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

Looks like the plugin already has debug logs on every cursor change, so this one more is fine too.

@mvolfik
Copy link
Contributor Author

mvolfik commented Feb 2, 2021

Btw, what is the desired behavior with unsaved files ('Untitled document 1' etc.)? Currently, we're logging them just by this name, but after some digging, I found a way to detect them:

location = document.get_file().get_location()
if location is None:
    print("Unsaved file")
else:
    print(location.get_path()) # likely the same as get_uri_for_display() (?)

@alanhamlett
Copy link
Member

For unsaved files, all other editor plugins exclude sending any heartbeat. In current master I've updated the code to match that and prevent heartbeats for unsaved files.

@alanhamlett alanhamlett merged commit 9230822 into wakatime:master Apr 12, 2021
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