Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
F
frontend
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
vicotor
frontend
Commits
fb6b1b1b
Unverified
Commit
fb6b1b1b
authored
Aug 28, 2024
by
tom goriunov
Committed by
GitHub
Aug 28, 2024
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Mixpanel - add Theme parameter to Page view event (#2193)
Fixes #2126
parent
5c1ecb32
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
15 additions
and
0 deletions
+15
-0
useLogPageView.tsx
lib/mixpanel/useLogPageView.tsx
+13
-0
utils.ts
lib/mixpanel/utils.ts
+2
-0
No files found.
lib/mixpanel/useLogPageView.tsx
View file @
fb6b1b1b
import
type
{
ColorMode
}
from
'
@chakra-ui/react
'
;
import
{
useColorMode
}
from
'
@chakra-ui/react
'
;
import
{
useColorMode
}
from
'
@chakra-ui/react
'
;
import
{
usePathname
}
from
'
next/navigation
'
;
import
{
usePathname
}
from
'
next/navigation
'
;
import
{
useRouter
}
from
'
next/router
'
;
import
{
useRouter
}
from
'
next/router
'
;
import
React
from
'
react
'
;
import
React
from
'
react
'
;
import
config
from
'
configs/app
'
;
import
config
from
'
configs/app
'
;
import
*
as
cookies
from
'
lib/cookies
'
;
import
getQueryParamString
from
'
lib/router/getQueryParamString
'
;
import
getQueryParamString
from
'
lib/router/getQueryParamString
'
;
import
{
COLOR_THEMES
}
from
'
lib/settings/colorTheme
'
;
import
getPageType
from
'
./getPageType
'
;
import
getPageType
from
'
./getPageType
'
;
import
getTabName
from
'
./getTabName
'
;
import
getTabName
from
'
./getTabName
'
;
import
logEvent
from
'
./logEvent
'
;
import
logEvent
from
'
./logEvent
'
;
import
{
EventTypes
}
from
'
./utils
'
;
import
{
EventTypes
}
from
'
./utils
'
;
function
getColorTheme
(
hex
:
string
|
undefined
,
colorMode
:
ColorMode
)
{
const
colorTheme
=
COLOR_THEMES
.
find
((
theme
)
=>
theme
.
hex
===
hex
)
||
COLOR_THEMES
.
filter
((
theme
)
=>
theme
.
colorMode
===
colorMode
).
slice
(
-
1
)[
0
];
return
colorTheme
.
id
;
}
export
default
function
useLogPageView
(
isInited
:
boolean
)
{
export
default
function
useLogPageView
(
isInited
:
boolean
)
{
const
router
=
useRouter
();
const
router
=
useRouter
();
const
pathname
=
usePathname
();
const
pathname
=
usePathname
();
...
@@ -24,11 +34,14 @@ export default function useLogPageView(isInited: boolean) {
...
@@ -24,11 +34,14 @@ export default function useLogPageView(isInited: boolean) {
return
;
return
;
}
}
const
cookieColorModeHex
=
cookies
.
get
(
cookies
.
NAMES
.
COLOR_MODE_HEX
);
logEvent
(
EventTypes
.
PAGE_VIEW
,
{
logEvent
(
EventTypes
.
PAGE_VIEW
,
{
'
Page type
'
:
getPageType
(
router
.
pathname
),
'
Page type
'
:
getPageType
(
router
.
pathname
),
Tab
:
getTabName
(
tab
),
Tab
:
getTabName
(
tab
),
Page
:
page
||
undefined
,
Page
:
page
||
undefined
,
'
Color mode
'
:
colorMode
,
'
Color mode
'
:
colorMode
,
'
Color theme
'
:
getColorTheme
(
cookieColorModeHex
,
colorMode
),
});
});
// these are only deps that should trigger the effect
// these are only deps that should trigger the effect
// in some scenarios page type is not changing (e.g navigation from one address page to another),
// in some scenarios page type is not changing (e.g navigation from one address page to another),
...
...
lib/mixpanel/utils.ts
View file @
fb6b1b1b
import
type
{
WalletType
}
from
'
types/client/wallets
'
;
import
type
{
WalletType
}
from
'
types/client/wallets
'
;
import
type
{
ColorThemeId
}
from
'
types/settings
'
;
export
enum
EventTypes
{
export
enum
EventTypes
{
PAGE_VIEW
=
'
Page view
'
,
PAGE_VIEW
=
'
Page view
'
,
...
@@ -31,6 +32,7 @@ Type extends EventTypes.PAGE_VIEW ?
...
@@ -31,6 +32,7 @@ Type extends EventTypes.PAGE_VIEW ?
'
Tab
'
:
string
;
'
Tab
'
:
string
;
'
Page
'
?:
string
;
'
Page
'
?:
string
;
'
Color mode
'
:
'
light
'
|
'
dark
'
;
'
Color mode
'
:
'
light
'
|
'
dark
'
;
'
Color theme
'
:
ColorThemeId
|
undefined
;
}
:
}
:
Type
extends
EventTypes
.
SEARCH_QUERY
?
{
Type
extends
EventTypes
.
SEARCH_QUERY
?
{
'
Search query
'
:
string
;
'
Search query
'
:
string
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment