File tree Expand file tree Collapse file tree 3 files changed +13
-4
lines changed Expand file tree Collapse file tree 3 files changed +13
-4
lines changed Original file line number Diff line number Diff line change 2
2
import Cookies from 'src/frame/components/lib/cookies'
3
3
import { parseUserAgent } from './user-agent'
4
4
import { Router } from 'next/router'
5
+ import { isLoggedIn } from 'src/frame/components/hooks/useHasAccount'
5
6
6
7
const COOKIE_NAME = '_docs-events'
7
8
@@ -18,7 +19,6 @@ let scrollDirection = 1
18
19
let scrollFlipCount = 0
19
20
let maxScrollY = 0
20
21
let previousPath : string | undefined
21
-
22
22
let hoveredUrls = new Set ( )
23
23
24
24
function resetPageParams ( ) {
@@ -158,6 +158,7 @@ export function sendEvent<T extends EventType>({
158
158
page_document_type : getMetaContent ( 'page-document-type' ) ,
159
159
page_type : getMetaContent ( 'page-type' ) ,
160
160
status : Number ( getMetaContent ( 'status' ) || 0 ) ,
161
+ is_logged_in : isLoggedIn ( ) ,
161
162
162
163
// Device information
163
164
// os, os_version, browser, browser_version:
Original file line number Diff line number Diff line change @@ -98,6 +98,10 @@ const context = {
98
98
minimum : 0 ,
99
99
maximum : 999 ,
100
100
} ,
101
+ is_logged_in : {
102
+ type : 'boolean' ,
103
+ description : 'Anonymous -- whether the user has github.com cookies set.' ,
104
+ } ,
101
105
102
106
// Device information
103
107
os : {
Original file line number Diff line number Diff line change @@ -14,10 +14,14 @@ export function useHasAccount() {
14
14
const [ hasAccount , setHasAccount ] = useState < boolean | null > ( null )
15
15
16
16
useEffect ( ( ) => {
17
- const cookieValue = Cookies . get ( 'color_mode' )
18
- const altCookieValue = Cookies . get ( 'preferred_color_mode' )
19
- setHasAccount ( Boolean ( cookieValue || altCookieValue ) )
17
+ setHasAccount ( isLoggedIn ( ) )
20
18
} , [ ] )
21
19
22
20
return { hasAccount }
23
21
}
22
+
23
+ export function isLoggedIn ( ) {
24
+ const cookieValue = Cookies . get ( 'color_mode' )
25
+ const altCookieValue = Cookies . get ( 'preferred_color_mode' )
26
+ return Boolean ( cookieValue || altCookieValue )
27
+ }
You can’t perform that action at this time.
0 commit comments