Skip to content

Commit 7986550

Browse files
committed
fix telemetry & configurable cart timeout
1 parent e5b46c3 commit 7986550

File tree

4 files changed

+16
-5
lines changed

4 files changed

+16
-5
lines changed

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,18 @@ All notable changes to this project will be documented in this file.
33

44
## [0.13.14]
55

6+
### Added
7+
- Added Config parameter maxShoppingCartAge
8+
9+
### Removed
10+
- Removed config parameter enableReceiptAutoDownload as it is no longer used
611

712
### Changes
813
- Add keepScreenOn flag on checkout view
914

1015
### Fixed
1116
- Null pointer in very rare circumstances using ZXing Barcode Detector
17+
- CheckoutSuccessful Telemetry Event was not firing
1218

1319
## [0.13.13]
1420

core/src/main/java/io/snabble/sdk/ShoppingCart.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@
2020

2121
public class ShoppingCart {
2222
public static final int MAX_QUANTITY = 99999;
23-
public static final long TIMEOUT = TimeUnit.HOURS.toMillis(4);
2423

2524
private String id;
2625
private long lastModificationTime;
@@ -224,7 +223,8 @@ public void updatePrices(boolean debounce) {
224223
public void checkForTimeout() {
225224
long currentTime = System.currentTimeMillis();
226225

227-
if (lastModificationTime + TIMEOUT < currentTime) {
226+
long timeout = Snabble.getInstance().getConfig().maxShoppingCartAge;
227+
if (lastModificationTime + timeout < currentTime) {
228228
invalidate();
229229
}
230230
}

core/src/main/java/io/snabble/sdk/Snabble.java

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -532,10 +532,13 @@ public static class Config {
532532
public long maxProductDatabaseAge = TimeUnit.HOURS.toMillis(1);
533533

534534
/**
535-
* If set to true, downloads receipts automatically and stores them in the projects
536-
* internal storage folder.
535+
* The time that the shopping cart is allowed to be alive after the last modification.
536+
*
537+
* The time is specified in milliseconds.
538+
*
539+
* The default value is 4 hours.
537540
*/
538-
public boolean enableReceiptAutoDownload;
541+
public long maxShoppingCartAge = TimeUnit.HOURS.toMillis(4);
539542

540543
/** If set to true, disables certificate pinning **/
541544
public boolean disableCertificatePinning;

ui/src/main/java/io/snabble/sdk/ui/checkout/CheckoutView.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
import io.snabble.sdk.encodedcodes.EncodedCodesOptions;
2020
import io.snabble.sdk.ui.R;
2121
import io.snabble.sdk.ui.SnabbleUI;
22+
import io.snabble.sdk.ui.telemetry.Telemetry;
2223
import io.snabble.sdk.ui.utils.DelayedProgressDialog;
2324
import io.snabble.sdk.ui.utils.UIUtils;
2425
import io.snabble.sdk.utils.SimpleActivityLifecycleCallbacks;
@@ -91,6 +92,7 @@ public void onStateChanged(Checkout.State state) {
9192
case PAYMENT_APPROVED:
9293
if (!checkout.getSelectedPaymentMethod().isOfflineMethod()) {
9394
displayView(new CheckoutDoneView(getContext()));
95+
Telemetry.event(Telemetry.Event.CheckoutSuccessful);
9496
}
9597
break;
9698
case PAYMENT_ABORTED:

0 commit comments

Comments
 (0)