()
| 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 |
no test coverage detected