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

feat: add monitor #43

Merged
merged 1 commit into from
Jun 8, 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
5 changes: 5 additions & 0 deletions app/src/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,11 @@ import TenantPage from "./pages/tenant/tenant";
import SettingPage from "./pages/setting/setting";
import ProductPage from "./pages/product/product";
import { isVerifiedAccount } from "./service/auth";
import { performanceTrace } from "./tools/performaceMonitoring";
yamashita-kenngo marked this conversation as resolved.
Show resolved Hide resolved


const root = document.getElementById("root");
const rootPerformanceTrace = performanceTrace("performanceTrace");

if (import.meta.env.DEV && !(root instanceof HTMLElement)) {
throw new Error(
Expand All @@ -21,6 +24,7 @@ if (import.meta.env.DEV && !(root instanceof HTMLElement)) {
}

if (root) {
rootPerformanceTrace.start();
render(
() => (
<Router>
Expand Down Expand Up @@ -60,6 +64,7 @@ if (root) {
),
root,
);
rootPerformanceTrace.stop();
}

async function checkAuth() {
Expand Down
4 changes: 4 additions & 0 deletions app/src/pages/login/login.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
import { createSignal } from "solid-js";
import { signIn } from "../../service/auth";
import { performanceTrace } from "../../tools/performaceMonitoring";

const Login = () => {
const [email, setEmail] = createSignal("");
const [password, setPassword] = createSignal("");
const loginPerformanceTrace = performanceTrace("loginPerformanceTrace");

const validateEmail = (email: string) => {
const re = /\S+@\S+\.\S+/;
Expand All @@ -25,12 +27,14 @@ const Login = () => {
};

const handleLogin = async () => {
loginPerformanceTrace.start();
const userCredential = await signIn(email(), password());
if (userCredential instanceof Error) {
window.alert(userCredential.message);
} else {
window.location.href = "/dashboard/account";
}
loginPerformanceTrace.stop();
};

return (
Expand Down
11 changes: 11 additions & 0 deletions app/src/tools/performaceMonitoring.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import { getPerformance, trace } from "firebase/performance";
import type { PerformanceTrace } from "firebase/performance";
import { firebaseApp } from "../service/firebase";

const perf = getPerformance(firebaseApp);



export function performanceTrace(customTraceName: string):PerformanceTrace {
return trace(perf, customTraceName);
}