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

Don't enforce save state when saving is triggered by a timeout and reduce tracing layout analytics event count #5999

Merged
merged 15 commits into from
Feb 14, 2022

Conversation

MichaelBuessemeyer
Copy link
Contributor

@MichaelBuessemeyer MichaelBuessemeyer commented Jan 31, 2022

This PR tackles two small bugs. The first is, that the save queue tried to read a clean save state even when a timeout triggered the updates. This caused a lot of update actions send over the network. Now save updates triggered by a timeout only take the current changes and send these to the backend. It is no longer tried to reach a save state where the backend knows all changes the frontend has made so they are in sync.

The second part fixes that the load_custom_layout analytics event was triggered even when the active viewport was changed (e.g. via clicking). The is omits these updates. @normanrz @philippotto Could you think of anything else that should be ignored? Additionally, I could attach the action that triggered the analytics event (a very small object) to the event. This might give more insight if wanted. Such an action looks like this:
image

URL of deployed dev instance (used for testing):

  • https://___.webknossos.xyz

Steps to test:

  1. Testing the save request changes:
  • Open a tracing.
  • Open the network tab of the browser and clear it.
  • Move through the dataset for at least 30 seconds.
  • Search in the network tab with the string "update"
  • There should only be 2 update calls triggered aber 30 seconds of moving
  • Do the same thing on the master. There should be much more update request. They should continue being sent until you stop moving.
  1. Testing the analytics events changes:
  • Open a tracing and the network tab.
  • Once the tracing is loaded, clear the network tab.
  • Then switch between viewports via clicking.
  • There should not be any analytics update with load_custom_layout as a key.
  • Do the same on the master. There should be some analytics events with the key load_custom_layout.

Issues:


(Please delete unneeded items, merge only when none are left open)

@MichaelBuessemeyer MichaelBuessemeyer self-assigned this Jan 31, 2022
@MichaelBuessemeyer MichaelBuessemeyer changed the title Don't enforce save state when saving is triggered by a timeout Don't enforce save state when saving is triggered by a timeout and reduce tracing layout analytics event count Jan 31, 2022
@MichaelBuessemeyer
Copy link
Contributor Author

@philippotto Do you want to / could you please take a look at this?

@@ -313,7 +315,6 @@ class FlexLayoutWrapper extends React.PureComponent<Props, State> {
}

onLayoutChange = () => {
sendAnalyticsEvent("change_tracing_layout", { viewMode: this.props.layoutKey });
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I removed the analytics here and moved it into onAction as each change to the layout, first triggers an action. This method gets information about what action was done and therefore can better decide whether to send an analytics event.

However, the onAction method is not called when the layout is completely rebuild. For that case the event is also send in rebuildLayout.

Copy link
Member

@philippotto philippotto left a comment

Choose a reason for hiding this comment

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

Great! Works very well 👍 Regarding the events, I noticed two further things which should probably be ignored.

frontend/javascripts/oxalis/model/sagas/save_saga.js Outdated Show resolved Hide resolved
@@ -68,6 +68,8 @@ type State = {
model: Model,
};

const ignoredLayoutChangesByAnalytics = ["FlexLayout_SetActiveTabset"];
Copy link
Member

Choose a reason for hiding this comment

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

I think, the following scenarios shouldn't send an event, either:

  • toggling the side bars
  • switching tabs (in the sidebar, the event is already ignored. but when moving XY and XZ next to each other, switching the tabs sends events)

Copy link
Contributor Author

@MichaelBuessemeyer MichaelBuessemeyer Feb 3, 2022

Choose a reason for hiding this comment

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

But moving the viewport around and resizing them should still send the event? Or should the event only be send when switching between layouts?

Edit: And what about maximizing a viewport?

I think it depends on what exactly we want to track / use this tracking event for.

@normanrz Do you have an opinion what we want to track with the change_tracing_layout event?

Copy link
Member

Choose a reason for hiding this comment

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

I think it depends on what exactly we want to track / use this tracking event for.

Yes, definitely. I don't have a strong opinion about what we really want to track, but I'm leaning towards tracking only stuff which is not "obvious" (e.g., it seems obvious that users will click on tabs to switch between them). With regard to maximizing, resizing and switching layouts, I'm not too sure that this is obvious for all users. Therefore, these events seem more interesting to me. However, in the end, this is also not very high-pri / not worth delving into how to filter the events best. So, maybe opt for the easier route if it makes sense (e.g., only track switches between layouts).

Copy link
Member

@philippotto philippotto left a comment

Choose a reason for hiding this comment

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

Excellent!

@MichaelBuessemeyer
Copy link
Contributor Author

MichaelBuessemeyer commented Feb 7, 2022

With regard to maximizing, resizing and switching layouts, I'm not too sure that this is obvious for all users. Therefore, these events seem more interesting to me.

I just added a commit that adds an additional analytics event that tracks when the user changed between any two layouts. This allows tracking whether multiple layouts are actively used / switched between or whether a user usually stays at only one active layout changing this one over and over again.
Do you think this makes sense @philippotto? If not, I can just revert this commit.

Comment on lines 91 to 103
componentDidUpdate(prevProps: Props) {
const { layoutName, layoutKey } = this.props;
if (layoutName !== prevProps.layoutName || layoutKey !== prevProps.layoutKey) {
sendAnalyticsEvent("switched_layout", {
from: { viewMode: prevProps.layoutKey, layoutName: prevProps.layoutName },
to: {
viewMode: this.props.layoutKey,
layoutName: this.props.layoutName,
},
});
this.rebuildLayout();
}
}
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Here is the change 👀

@philippotto
Copy link
Member

I just added a commit that adds an additional analytics event that tracks when the user changed between any two layouts. This allows tracking whether multiple layouts are actively used / switched between or whether a user usually stays at only one active layout changing this one over and over again.
Do you think this makes sense @philippotto? If not, I can just revert this pr.

Great! Makes total sense 👍

@MichaelBuessemeyer MichaelBuessemeyer enabled auto-merge (squash) February 10, 2022 09:19
@philippotto
Copy link
Member

@MichaelBuessemeyer What's the status here? I think, the PR can be merged?

@MichaelBuessemeyer MichaelBuessemeyer enabled auto-merge (squash) February 14, 2022 15:09
@MichaelBuessemeyer
Copy link
Contributor Author

@MichaelBuessemeyer What's the status here? I think, the PR can be merged?

Whoopsie, I forgot this pr.

@MichaelBuessemeyer MichaelBuessemeyer merged commit 3831806 into master Feb 14, 2022
@MichaelBuessemeyer MichaelBuessemeyer deleted the reduce-save-requests branch February 14, 2022 15:33
@philippotto philippotto mentioned this pull request Feb 16, 2022
7 tasks
hotzenklotz added a commit that referenced this pull request Feb 18, 2022
…ssos into docs

* 'docs' of github.com:scalableminds/webknossos:

* 'master' of github.com:scalableminds/webknossos:
  Split cells via Min Cut (#5885)
  Clean up backend util package (#6048)
  Guard against empty saves (#6052)
  Time tracking: Do not fail on empty timespans list (#6051)
  Fix clip button changing position (#6050)
  Include ParamFailure values in error chains (#6045)
  Fix non-32-aligned bucket requests (#6047)
  Don't enforce save state when saving is triggered by a timeout and reduce tracing layout analytics event count (#5999)
  Bump cached-path-relative from 1.0.2 to 1.1.0 (#5994)
  Volume annotation download: zip with BEST_SPEED (#6036)
  Sensible scalebar values (#6034)
  Faster CircleCI builds (#6040)
  move to Google Analytics 4 (#6031)
  Fix nightly (fix tokens, upgrade puppeteer) (#6032)
  Add neuron reconstruction job backend and frontend part (#5922)
  Allow uploading multi-layer volume annotations (#6028)
hotzenklotz added a commit that referenced this pull request Feb 18, 2022
* docs:
  Split cells via Min Cut (#5885)
  Clean up backend util package (#6048)
  Guard against empty saves (#6052)
  Time tracking: Do not fail on empty timespans list (#6051)
  Fix clip button changing position (#6050)
  Include ParamFailure values in error chains (#6045)
  Fix non-32-aligned bucket requests (#6047)
  Don't enforce save state when saving is triggered by a timeout and reduce tracing layout analytics event count (#5999)
  Bump cached-path-relative from 1.0.2 to 1.1.0 (#5994)
  Volume annotation download: zip with BEST_SPEED (#6036)
  Sensible scalebar values (#6034)
  Faster CircleCI builds (#6040)
  move to Google Analytics 4 (#6031)
  Fix nightly (fix tokens, upgrade puppeteer) (#6032)
  Add neuron reconstruction job backend and frontend part (#5922)
  Allow uploading multi-layer volume annotations (#6028)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
2 participants