Skip to content

Commit 260e259

Browse files
committed
added telemetry events
1 parent ba8c0ce commit 260e259

File tree

10 files changed

+38
-1
lines changed

10 files changed

+38
-1
lines changed

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,11 @@
11
# Changelog
22
All notable changes to this project will be documented in this file.
33

4+
## [0.16.8]
5+
6+
### Added
7+
- Added additional telemetry events
8+
49
## [0.16.7]
510

611
### Added

build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ allprojects {
2323
}
2424

2525
project.ext {
26-
sdkVersion='0.16.7'
26+
sdkVersion='0.16.8'
2727
versionCode=1
2828

2929
compileSdkVersion=28

ui-integration/src/main/java/io/snabble/sdk/ui/integration/ShoppingCartFragment.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ public boolean onOptionsItemSelected(MenuItem item) {
5757
public void onClick(DialogInterface dialog, int which) {
5858
SnabbleUI.getProject().getShoppingCart().clearBackup();
5959
SnabbleUI.getProject().getShoppingCart().clear();
60+
onCartCleared();
6061
}
6162
})
6263
.setNegativeButton(R.string.Snabble_No, null)
@@ -68,6 +69,10 @@ public void onClick(DialogInterface dialog, int which) {
6869
return false;
6970
}
7071

72+
public void onCartCleared() {
73+
74+
}
75+
7176
public ShoppingCartView getShoppingCartView() {
7277
return shoppingCartView;
7378
}

ui/src/main/java/io/snabble/sdk/ui/cart/ShoppingCartView.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -647,6 +647,7 @@ public void bindTo(final ProductRow row) {
647647
@Override
648648
public void onClick(View v) {
649649
row.item.setQuantity(row.item.getQuantity() + 1);
650+
Telemetry.event(Telemetry.Event.CartAmountChanged, row.item.getProduct());
650651
}
651652
});
652653

@@ -660,6 +661,7 @@ public void onClick(View v) {
660661
removeAndShowUndoSnackbar(p, row.item);
661662
} else {
662663
row.item.setQuantity(newQuantity);
664+
Telemetry.event(Telemetry.Event.CartAmountChanged, row.item.getProduct());
663665
}
664666
}
665667
});
@@ -669,6 +671,7 @@ public void onClick(View v) {
669671
public void click() {
670672
row.item.setQuantity(getQuantityEditValue());
671673
hideInput();
674+
Telemetry.event(Telemetry.Event.CartAmountChanged, row.item.getProduct());
672675
}
673676
});
674677

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,7 @@ public void click() {
7171
if (isAtLastBarcode()) {
7272
Project project = SnabbleUI.getProject();
7373
project.getCheckout().approveOfflineMethod();
74+
Telemetry.event(Telemetry.Event.CheckoutFinishByUser);
7475
} else {
7576
scrollTo(getNextBarcodeIndex());
7677
}

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

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ public class CheckoutView extends FrameLayout implements Checkout.OnCheckoutStat
3232
private Checkout.State currentState;
3333
private View successView;
3434
private View failureView;
35+
private OnCheckoutScreenChangedListener onCheckoutScreenChangedListener;
3536

3637
public CheckoutView(Context context) {
3738
super(context);
@@ -167,6 +168,10 @@ public void displayView(View view) {
167168
viewAnimator.addView(view, new ViewGroup.LayoutParams(
168169
ViewGroup.LayoutParams.MATCH_PARENT,
169170
ViewGroup.LayoutParams.MATCH_PARENT));
171+
172+
if (onCheckoutScreenChangedListener != null) {
173+
onCheckoutScreenChangedListener.onCheckoutScreenChanged(view);
174+
}
170175
}
171176

172177
/** Sets the view to be shown after a successful checkout (for online methods) **/
@@ -242,4 +247,12 @@ public void onActivityStopped(Activity activity) {
242247
}
243248
}
244249
};
250+
251+
public interface OnCheckoutScreenChangedListener {
252+
void onCheckoutScreenChanged(View view);
253+
}
254+
255+
public void setOnCheckoutScreenChangedListener(OnCheckoutScreenChangedListener onCheckoutScreenChangedListener) {
256+
this.onCheckoutScreenChangedListener = onCheckoutScreenChangedListener;
257+
}
245258
}

ui/src/main/java/io/snabble/sdk/ui/payment/CreditCardInputView.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@
3535
import io.snabble.sdk.ui.R;
3636
import io.snabble.sdk.ui.SnabbleUI;
3737
import io.snabble.sdk.ui.SnabbleUICallback;
38+
import io.snabble.sdk.ui.telemetry.Telemetry;
3839
import io.snabble.sdk.ui.utils.UIUtils;
3940
import io.snabble.sdk.utils.Logger;
4041
import io.snabble.sdk.utils.SimpleActivityLifecycleCallbacks;
@@ -235,6 +236,7 @@ private void save(CreditCardInfo info) {
235236
.show();
236237
} else {
237238
Snabble.getInstance().getPaymentCredentialsStore().add(pc);
239+
Telemetry.event(Telemetry.Event.PaymentMethodAdded, pc.getType().name());
238240
}
239241

240242
if (isShown()) {

ui/src/main/java/io/snabble/sdk/ui/payment/PaymentCredentialsListView.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
import io.snabble.sdk.payment.PaymentCredentials;
2828
import io.snabble.sdk.payment.PaymentCredentialsStore;
2929
import io.snabble.sdk.ui.R;
30+
import io.snabble.sdk.ui.telemetry.Telemetry;
3031
import io.snabble.sdk.ui.utils.KeyguardUtils;
3132
import io.snabble.sdk.ui.utils.OneShotClickListener;
3233
import io.snabble.sdk.ui.utils.UIUtils;
@@ -228,6 +229,8 @@ public void onClick(DialogInterface dialog, int which) {
228229
.setNegativeButton(R.string.Snabble_No, null)
229230
.create()
230231
.show();
232+
233+
Telemetry.event(Telemetry.Event.PaymentMethodDeleted, e.paymentCredentials.getType());
231234
}
232235
});
233236
}

ui/src/main/java/io/snabble/sdk/ui/payment/SEPACardInputView.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
import io.snabble.sdk.ui.R;
2929
import io.snabble.sdk.ui.SnabbleUI;
3030
import io.snabble.sdk.ui.SnabbleUICallback;
31+
import io.snabble.sdk.ui.telemetry.Telemetry;
3132
import io.snabble.sdk.ui.utils.OneShotClickListener;
3233
import io.snabble.sdk.ui.utils.UIUtils;
3334
import io.snabble.sdk.utils.SimpleActivityLifecycleCallbacks;
@@ -243,6 +244,7 @@ private void add(String name, String iban) {
243244
.show();
244245
} else {
245246
Snabble.getInstance().getPaymentCredentialsStore().add(pc);
247+
Telemetry.event(Telemetry.Event.PaymentMethodAdded, pc.getType().name());
246248
}
247249

248250
if (isShown() || !isAttachedToWindow) {

ui/src/main/java/io/snabble/sdk/ui/telemetry/Telemetry.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,10 @@ public enum Event {
2020
ToggleTorch,
2121
DeletedFromCart,
2222
UndoDeleteFromCart,
23+
CartAmountChanged,
2324
SelectedBundleProduct,
25+
PaymentMethodAdded,
26+
PaymentMethodDeleted
2427
}
2528

2629
private static OnEventListener onEventListener;

0 commit comments

Comments
 (0)