MCPcopy Create free account
hub / github.com/dailydotdev/apps / init

Function init

packages/shared/src/hooks/auth/useGoogleOneTap.ts:146–182  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

144 };
145
146 const init = async () => {
147 try {
148 await loadGsiScript();
149 } catch (error) {
150 // The GSI script is commonly blocked by ad blockers, privacy browsers
151 // and some networks. One Tap is optional, so this is expected and is
152 // logged as its own event instead of a `global error`.
153 logEventRef.current({
154 event_name: LogEvent.GoogleOneTapLoadError,
155 extra: JSON.stringify({
156 msg: error instanceof Error ? error.message : 'unknown',
157 }),
158 });
159 return;
160 }
161
162 const googleId = getGoogleId();
163 if (cancelled || !googleId) {
164 return;
165 }
166
167 initializeOnce(googleId, clientId);
168 activeCredentialHandler = handleCredential;
169 hasPromptedRef.current = true;
170 googleId.prompt((notification) => {
171 if (!notification) {
172 return;
173 }
174 logEventRef.current({
175 event_name: LogEvent.GoogleOneTapPrompt,
176 extra: JSON.stringify({
177 momentType: notification.getMomentType?.(),
178 reason: getMomentReason(notification),
179 }),
180 });
181 });
182 };
183
184 init();
185

Callers 1

useGoogleOneTapFunction · 0.85

Calls 4

loadGsiScriptFunction · 0.85
getGoogleIdFunction · 0.85
initializeOnceFunction · 0.85
getMomentReasonFunction · 0.85

Tested by

no test coverage detected