모바일 사용자의 86% 손실을 멈추세요: Firebase와 Lazy Auth (튜토리얼)
Source: Dev.to
$300 Million 문제 💸
유명한 “$300 Million 버튼” 사례 연구는 결제 전에 사용자를 강제로 회원가입시키는 것이 매출을 크게 감소시킨다는 것을 증명했습니다. 모바일에서는 상황이 더 악화되어, **86 %**에 달하는 사용자가 즉시 로그인 화면을 만나면 앱을 떠납니다.
해결책: Lazy Registration (또는 “Just‑in‑Time” 인증).
이 짧은 튜토리얼을 통해 다음을 배울 수 있습니다:
- 사용자를 익명으로 먼저 로그인시켜, 마찰 없이 앱을 바로 사용할 수 있게 합니다.
- 사용자가 작업을 저장하려고 할 때만 인증 정보를 요청하고, 기존 익명 계정을 업그레이드하여 새 계정을 만들지 않습니다.
Firebase로 익명 로그인 구현
Firebase는 사용자의 데이터를 전혀 묻지 않고 임시이면서 영구적인 세션을 생성하는 메서드를 제공합니다.
Docs:
import { getAuth, signInAnonymously } from "firebase/auth";
const auth = getAuth();
// 1. Log them in silently
await signInAnonymously(auth);
// 2. Listen to the auth state (User ID persists on reload!)
auth.onAuthStateChanged((user) => {
if (user && user.isAnonymous) {
console.log("User is a Guest 👻", user.uid);
}
});
익명 계정 업그레이드
사용자가 회원가입(예: 설정 저장)하려고 할 때 새 계정을 만들지 않습니다. 대신 기존 익명 사용자에 새로운 인증 정보를 연결하여 uid와 그에 연결된 모든 Firestore 데이터를 유지합니다.
Docs:
import { EmailAuthProvider, linkWithCredential } from "firebase/auth";
const upgradeAccount = async (email, password) => {
const credential = EmailAuthProvider.credential(email, password);
const user = auth.currentUser;
try {
// Merge the new credentials into the existing anonymous account
const result = await linkWithCredential(user, credential);
console.log("Guest upgraded to Permanent User! 🎉");
} catch (error) {
console.error("Error linking account:", error);
}
};
방치된 게스트 계정 정리
익명 인증의 단점은 사용되지 않은 수천 개의 게스트 계정이 쌓일 가능성이 있다는 점입니다. Google Cloud Identity Platform을 활성화하고 자동 삭제 정책(예: 30 일 동안 비활성인 익명 사용자 삭제)을 설정하면 별도의 스크립트를 작성하지 않고도 자동으로 제거할 수 있습니다.
Docs:
(관련 문서 링크를 여기 추가할 수 있습니다)
추가 자료
개인 블로그에 자세한 심층 분석 글을 작성했으며, 내용은 다음을 포함합니다:
- React Hooks 구현 방법.
credential-already-in-use오류 처리.- Identity Platform 설정 화면 캡처.
- Windows CLI 학습 앱을 이용한 실시간 데모.
👉 전체 기사와 가이드 스크린샷 보기: Lazy Registrations with Firebase
앱에 연기된 인증을 구현해 보셨나요?