Skip to content

Commit

Permalink
add analytics to logout warning (#426)
Browse files Browse the repository at this point in the history
  • Loading branch information
andnorda authored Aug 7, 2024
1 parent b5738ae commit 2b4cc85
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
8 changes: 7 additions & 1 deletion packages/client/src/views/logout-warning/session-dialog.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { logAmplitudeEvent } from "../../analytics/amplitude";
import { logout } from "../../helpers/auth";
import { getSecondsRemaining } from "../../helpers/time";
import { defineCustomElement } from "../custom-elements";
Expand All @@ -21,9 +22,11 @@ export class SessionDialog extends HTMLElement {
event.preventDefault();
const action = new FormData(form, event.submitter).get("action");
if (action === "renew") {
logAmplitudeEvent("session dialog renew");
this.silenceWarning = true;
dialog.close();
} else {
logAmplitudeEvent("session dialog logout");
logout();
}
});
Expand All @@ -35,7 +38,10 @@ export class SessionDialog extends HTMLElement {
dialog.querySelector(".session-time-remaining")!.innerHTML =
Math.ceil(this.secondsRemaining / 60).toString();

dialog.showModal();
if (!dialog.open) {
dialog.showModal();
logAmplitudeEvent("session dialog shown");
}
} else {
dialog.close();
}
Expand Down
8 changes: 7 additions & 1 deletion packages/client/src/views/logout-warning/token-dialog.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { logAmplitudeEvent } from "../../analytics/amplitude";
import { logout } from "../../helpers/auth";
import { getSecondsRemaining } from "../../helpers/time";
import { defineCustomElement } from "../custom-elements";
Expand All @@ -20,9 +21,11 @@ export class TokenDialog extends HTMLElement {
event.preventDefault();
const action = new FormData(form, event.submitter).get("action");
if (action === "renew") {
logAmplitudeEvent("token dialog renew");
this.dispatchEvent(new Event("renew"));
dialog.close();
} else {
logAmplitudeEvent("token dialog logout");
logout();
}
});
Expand All @@ -31,7 +34,10 @@ export class TokenDialog extends HTMLElement {
if (this.secondsRemaining < 0) {
logout();
} else if (this.secondsRemaining < 5 * 60) {
dialog.showModal();
if (!dialog.open) {
logAmplitudeEvent("token dialog shown");
dialog.showModal();
}
} else {
dialog.close();
}
Expand Down

0 comments on commit 2b4cc85

Please sign in to comment.