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

Auto-Save Form on Pause #2802

Merged
merged 10 commits into from
Aug 8, 2024
Merged

Auto-Save Form on Pause #2802

merged 10 commits into from
Aug 8, 2024

Conversation

shubham1g5
Copy link
Contributor

@shubham1g5 shubham1g5 commented Aug 6, 2024

Summary

Context Doc

Feature Flag

None at the moment, will be behind a custom property when merged to master

Product Description

Auto-Saves a CC form when CC goes in background

Safety Assurance

  • If the PR is high risk, "High Risk" label is set
  • I have confidence that this PR will not introduce a regression for the reasons below
  • Do we need to enhance manual QA test coverage ? If yes, "QA Note" label is set correctly

Automated test coverage

None

Safety story

We call an existing method we already use to save form session at the time of user session expiry

cross-request: dimagi/commcare-core#1426

public String getSerializedFormIndex() {
try{
byte[] serializedFormIndex = SerializationUtil.serialize(getFormIndex());
return Base64.encodeToString(serializedFormIndex, Base64.DEFAULT);
Copy link
Contributor Author

Choose a reason for hiding this comment

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

can the value for Base64.DEFAULT change with OS updates ? If so, I would like to pass a concrete encoding here like Charset.forName("UTF-8")

Copy link
Contributor

Choose a reason for hiding this comment

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

That's a good point, I'm not sure, let's lean to the safe side (but I will take note and look into that later)

byte[] serializedFormIndex = SerializationUtil.serialize(getFormIndex());
return Base64.encodeToString(serializedFormIndex, Base64.DEFAULT);
} catch (Exception e){
return null;
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Think it's better to fail fast here instead of swallowing the errors here unless there is a strong reason to do otherwise. At the very least we should be logging the exceptions encountered here.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Actually think again it makes sense to catch any errors here as we would not want to loose on saving form because of an error here.

@shubham1g5 shubham1g5 marked this pull request as ready for review August 8, 2024 09:18
@shubham1g5 shubham1g5 merged commit c36a831 into feature/givewell Aug 8, 2024
1 check was pending
@shubham1g5 shubham1g5 deleted the saveFormOnPause branch August 8, 2024 10:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants