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

add analytics to logout warning #426

Merged
merged 1 commit into from
Aug 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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