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
798c3bed
Commit
798c3bed
authored
May 12, 2023
by
tom
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix same page type navigation
parent
29e8a6b8
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
8 additions
and
2 deletions
+8
-2
useLogPageView.tsx
lib/mixpanel/useLogPageView.tsx
+8
-2
No files found.
lib/mixpanel/useLogPageView.tsx
View file @
798c3bed
import
{
usePathname
}
from
'
next/navigation
'
;
import
{
useRouter
}
from
'
next/router
'
;
import
React
from
'
react
'
;
...
...
@@ -11,8 +12,8 @@ import { EventTypes } from './utils';
export
default
function
useLogPageView
(
isInited
:
boolean
)
{
const
router
=
useRouter
();
const
pathname
=
usePathname
();
const
pathname
=
router
.
pathname
;
const
tab
=
getQueryParamString
(
router
.
query
.
tab
);
const
page
=
getQueryParamString
(
router
.
query
.
page
);
...
...
@@ -22,9 +23,14 @@ export default function useLogPageView(isInited: boolean) {
}
logEvent
(
EventTypes
.
PAGE_VIEW
,
{
'
Page type
'
:
getPageType
(
pathname
),
'
Page type
'
:
getPageType
(
router
.
pathname
),
Tab
:
getTabName
(
tab
),
Page
:
page
||
undefined
,
});
// 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),
// but we still want to log page view
// so we use pathname from 'next/navigation' instead of router.pathname from 'next/router' as deps
// eslint-disable-next-line react-hooks/exhaustive-deps
},
[
isInited
,
page
,
pathname
,
tab
]);
}
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