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
dc28dff6
Commit
dc28dff6
authored
Jul 15, 2024
by
Max Alekseenko
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add mixpanel events
parent
64e52b9e
Changes
8
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
39 additions
and
10 deletions
+39
-10
utils.ts
lib/mixpanel/utils.ts
+7
-0
MarketplaceAppCard.tsx
ui/marketplace/MarketplaceAppCard.tsx
+3
-1
MarketplaceAppModal.tsx
ui/marketplace/MarketplaceAppModal.tsx
+3
-1
MarketplaceAppTopBar.tsx
ui/marketplace/MarketplaceAppTopBar.tsx
+1
-0
MarketplaceList.tsx
ui/marketplace/MarketplaceList.tsx
+2
-1
PopoverContent.tsx
ui/marketplace/Rating/PopoverContent.tsx
+6
-4
Rating.tsx
ui/marketplace/Rating/Rating.tsx
+5
-2
useRatings.tsx
ui/marketplace/Rating/useRatings.tsx
+12
-1
No files found.
lib/mixpanel/utils.ts
View file @
dc28dff6
...
...
@@ -20,6 +20,7 @@ export enum EventTypes {
FILTERS
=
'
Filters
'
,
BUTTON_CLICK
=
'
Button click
'
,
PROMO_BANNER
=
'
Promo banner
'
,
APP_FEEDBACK
=
'
App feedback
'
,
}
/* eslint-disable @typescript-eslint/indent */
...
...
@@ -135,5 +136,11 @@ Type extends EventTypes.PROMO_BANNER ? {
'
Source
'
:
'
Marketplace
'
;
'
Link
'
:
string
;
}
:
Type
extends
EventTypes
.
APP_FEEDBACK
?
{
'
Action
'
:
'
Rating
'
;
'
Source
'
:
'
Discovery
'
|
'
App modal
'
|
'
App page
'
;
'
AppId
'
:
string
;
'
Score
'
:
number
;
}
:
undefined
;
/* eslint-enable @typescript-eslint/indent */
ui/marketplace/MarketplaceAppCard.tsx
View file @
dc28dff6
...
...
@@ -5,6 +5,7 @@ import React, { useCallback } from 'react';
import
type
{
MarketplaceAppWithSecurityReport
,
ContractListTypes
}
from
'
types/client/marketplace
'
;
import
useIsMobile
from
'
lib/hooks/useIsMobile
'
;
import
type
{
EventTypes
,
EventPayload
}
from
'
lib/mixpanel/index
'
;
import
IconSvg
from
'
ui/shared/IconSvg
'
;
import
AppSecurityReport
from
'
./AppSecurityReport
'
;
...
...
@@ -21,7 +22,7 @@ interface Props extends MarketplaceAppWithSecurityReport {
className
?:
string
;
showContractList
:
(
id
:
string
,
type
:
ContractListTypes
)
=>
void
;
userRating
:
number
|
undefined
;
rateApp
:
(
appId
:
string
,
recordId
:
string
|
undefined
,
rating
:
number
)
=>
void
;
rateApp
:
(
appId
:
string
,
recordId
:
string
|
undefined
,
rating
:
number
,
source
:
EventPayload
<
EventTypes
.
APP_FEEDBACK
>
[
'
Source
'
]
)
=>
void
;
isSendingRating
:
boolean
;
isRatingLoading
:
boolean
;
canRate
:
boolean
|
undefined
;
...
...
@@ -180,6 +181,7 @@ const MarketplaceAppCard = ({
isSending=
{
isSendingRating
}
isLoading=
{
isRatingLoading
}
canRate=
{
canRate
}
source=
"Discovery"
/>
<
IconButton
aria
-
label=
"Mark as favorite"
...
...
ui/marketplace/MarketplaceAppModal.tsx
View file @
dc28dff6
...
...
@@ -10,6 +10,7 @@ import { ContractListTypes } from 'types/client/marketplace';
import
config
from
'
configs/app
'
;
import
useIsMobile
from
'
lib/hooks/useIsMobile
'
;
import
{
nbsp
}
from
'
lib/html-entities
'
;
import
type
{
EventTypes
,
EventPayload
}
from
'
lib/mixpanel/index
'
;
import
*
as
mixpanel
from
'
lib/mixpanel/index
'
;
import
type
{
IconName
}
from
'
ui/shared/IconSvg
'
;
import
IconSvg
from
'
ui/shared/IconSvg
'
;
...
...
@@ -28,7 +29,7 @@ type Props = {
data
:
MarketplaceAppWithSecurityReport
;
showContractList
:
(
id
:
string
,
type
:
ContractListTypes
,
hasPreviousStep
:
boolean
)
=>
void
;
userRating
:
number
|
undefined
;
rateApp
:
(
appId
:
string
,
recordId
:
string
|
undefined
,
rating
:
number
)
=>
void
;
rateApp
:
(
appId
:
string
,
recordId
:
string
|
undefined
,
rating
:
number
,
source
:
EventPayload
<
EventTypes
.
APP_FEEDBACK
>
[
'
Source
'
]
)
=>
void
;
isSendingRating
:
boolean
;
isRatingLoading
:
boolean
;
canRate
:
boolean
|
undefined
;
...
...
@@ -181,6 +182,7 @@ const MarketplaceAppModal = ({
isLoading=
{
isRatingLoading
}
fullView
canRate=
{
canRate
}
source=
"App modal"
/>
</
Box
>
)
}
...
...
ui/marketplace/MarketplaceAppTopBar.tsx
View file @
dc28dff6
...
...
@@ -96,6 +96,7 @@ const MarketplaceAppTopBar = ({ appId, data, isLoading, securityReport }: Props)
isSending=
{
isSendingRating
}
isLoading=
{
isRatingLoading
}
canRate=
{
canRate
}
source=
"App page"
/>
{
!
isMobile
&&
(
<
Flex
flex=
"1"
justifyContent=
"flex-end"
>
...
...
ui/marketplace/MarketplaceList.tsx
View file @
dc28dff6
...
...
@@ -4,6 +4,7 @@ import type { MouseEvent } from 'react';
import
type
{
MarketplaceAppWithSecurityReport
,
ContractListTypes
,
UserRatings
}
from
'
types/client/marketplace
'
;
import
type
{
EventTypes
,
EventPayload
}
from
'
lib/mixpanel/index
'
;
import
*
as
mixpanel
from
'
lib/mixpanel/index
'
;
import
EmptySearchResult
from
'
./EmptySearchResult
'
;
...
...
@@ -19,7 +20,7 @@ type Props = {
onAppClick
:
(
event
:
MouseEvent
,
id
:
string
)
=>
void
;
showContractList
:
(
id
:
string
,
type
:
ContractListTypes
)
=>
void
;
userRatings
:
UserRatings
;
rateApp
:
(
appId
:
string
,
recordId
:
string
,
rating
:
number
)
=>
void
;
rateApp
:
(
appId
:
string
,
recordId
:
string
,
rating
:
number
,
source
:
EventPayload
<
EventTypes
.
APP_FEEDBACK
>
[
'
Source
'
]
)
=>
void
;
isSendingRating
:
boolean
;
isRatingLoading
:
boolean
;
canRate
:
boolean
|
undefined
;
...
...
ui/marketplace/Rating/PopoverContent.tsx
View file @
dc28dff6
...
...
@@ -2,6 +2,7 @@ import { Text, Flex, Spinner, Button } from '@chakra-ui/react';
import
React
from
'
react
'
;
import
{
mdash
}
from
'
lib/html-entities
'
;
import
type
{
EventTypes
,
EventPayload
}
from
'
lib/mixpanel/index
'
;
import
IconSvg
from
'
ui/shared/IconSvg
'
;
import
Stars
from
'
./Stars
'
;
...
...
@@ -12,11 +13,12 @@ type Props = {
appId
:
string
;
recordId
?:
string
;
userRating
:
number
|
undefined
;
rate
:
(
appId
:
string
,
recordId
:
string
|
undefined
,
rating
:
number
)
=>
void
;
rate
:
(
appId
:
string
,
recordId
:
string
|
undefined
,
rating
:
number
,
source
:
EventPayload
<
EventTypes
.
APP_FEEDBACK
>
[
'
Source
'
]
)
=>
void
;
isSending
?:
boolean
;
source
:
EventPayload
<
EventTypes
.
APP_FEEDBACK
>
[
'
Source
'
];
};
const
PopoverContent
=
({
appId
,
recordId
,
userRating
,
rate
,
isSending
}:
Props
)
=>
{
const
PopoverContent
=
({
appId
,
recordId
,
userRating
,
rate
,
isSending
,
source
}:
Props
)
=>
{
const
[
hovered
,
setHovered
]
=
React
.
useState
(
-
1
);
const
[
selected
,
setSelected
]
=
React
.
useState
(
-
1
);
...
...
@@ -36,8 +38,8 @@ const PopoverContent = ({ appId, recordId, userRating, rate, isSending }: Props)
if
(
selected
<
0
)
{
return
;
}
rate
(
appId
,
recordId
,
selected
+
1
);
},
[
appId
,
recordId
,
selected
,
rate
]);
rate
(
appId
,
recordId
,
selected
+
1
,
source
);
},
[
appId
,
recordId
,
selected
,
rate
,
source
]);
if
(
userRating
)
{
return
(
...
...
ui/marketplace/Rating/Rating.tsx
View file @
dc28dff6
...
...
@@ -2,6 +2,7 @@ import { Text, PopoverTrigger, PopoverBody, PopoverContent, useDisclosure, Skele
import
React
from
'
react
'
;
import
config
from
'
configs/app
'
;
import
type
{
EventTypes
,
EventPayload
}
from
'
lib/mixpanel/index
'
;
import
Popover
from
'
ui/shared/chakra/Popover
'
;
import
Content
from
'
./PopoverContent
'
;
...
...
@@ -16,16 +17,17 @@ type Props = {
rating
?:
number
;
recordId
?:
string
;
userRating
:
number
|
undefined
;
rate
:
(
appId
:
string
,
recordId
:
string
|
undefined
,
rating
:
number
)
=>
void
;
rate
:
(
appId
:
string
,
recordId
:
string
|
undefined
,
rating
:
number
,
source
:
EventPayload
<
EventTypes
.
APP_FEEDBACK
>
[
'
Source
'
]
)
=>
void
;
isSending
?:
boolean
;
isLoading
?:
boolean
;
fullView
?:
boolean
;
canRate
:
boolean
|
undefined
;
source
:
EventPayload
<
EventTypes
.
APP_FEEDBACK
>
[
'
Source
'
];
};
const
Rating
=
({
appId
,
rating
,
recordId
,
userRating
,
rate
,
isSending
,
isLoading
,
fullView
,
canRate
,
isSending
,
isLoading
,
fullView
,
canRate
,
source
,
}:
Props
)
=>
{
const
{
isOpen
,
onToggle
,
onClose
}
=
useDisclosure
();
// have to implement this solution because popover loses focus on button click inside it (issue: https://github.com/chakra-ui/chakra-ui/issues/7359)
...
...
@@ -68,6 +70,7 @@ const Rating = ({
userRating=
{
userRating
}
rate=
{
rate
}
isSending=
{
isSending
}
source=
{
source
}
/>
</
PopoverBody
>
</
PopoverContent
>
...
...
ui/marketplace/Rating/useRatings.tsx
View file @
dc28dff6
...
...
@@ -7,6 +7,8 @@ import type { UserRatings, AppRatings } from 'types/client/marketplace';
import
config
from
'
configs/app
'
;
import
useApiQuery
from
'
lib/api/useApiQuery
'
;
import
useToast
from
'
lib/hooks/useToast
'
;
import
type
{
EventTypes
,
EventPayload
}
from
'
lib/mixpanel/index
'
;
import
*
as
mixpanel
from
'
lib/mixpanel/index
'
;
import
{
ADDRESS_COUNTERS
}
from
'
stubs/address
'
;
const
feature
=
config
.
features
.
marketplace
;
...
...
@@ -89,7 +91,12 @@ export default function useRatings() {
setCanRate
(
canRate
);
},
[
address
,
addressCountersQuery
]);
const
rateApp
=
useCallback
(
async
(
appId
:
string
,
recordId
:
string
|
undefined
,
rating
:
number
)
=>
{
const
rateApp
=
useCallback
(
async
(
appId
:
string
,
recordId
:
string
|
undefined
,
rating
:
number
,
source
:
EventPayload
<
EventTypes
.
APP_FEEDBACK
>
[
'
Source
'
],
)
=>
{
setIsSending
(
true
);
try
{
if
(
!
address
||
!
base
)
{
...
...
@@ -119,6 +126,10 @@ export default function useRatings() {
description
:
'
Your rating improves the service
'
,
});
fetchRatings
();
mixpanel
.
logEvent
(
mixpanel
.
EventTypes
.
APP_FEEDBACK
,
{
Action
:
'
Rating
'
,
Source
:
source
,
AppId
:
appId
,
Score
:
rating
},
);
}
catch
(
error
)
{
toast
({
status
:
'
error
'
,
...
...
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