Skip to content

Commit

Permalink
feat: nft events
Browse files Browse the repository at this point in the history
  • Loading branch information
rsteubs-bc committed Apr 28, 2022
1 parent 832f9a1 commit 7b016a0
Show file tree
Hide file tree
Showing 2 changed files with 105 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ export enum Events {
NFT_AMOUNT_ENTERED_SWITCHED = 'NFT Amount Entered Switched',
NFT_ATTRIBUTES_CLICKED = 'NFT Attributes Clicked',
NFT_BUY_NOW_CLICKED = 'NFT Buy Now Clicked',
NFT_BUY_SUCCESS_FAIL = 'NFT Buy Success/Fail',
NFT_CLICKED = 'NFT Clicked',
NFT_CLOSE_AND_VIEW_ITEM_CLICKED = 'NFT Close And View Item Clicked',
NFT_CONTRACT_ADDRESS_CLICKED = 'NFT Contract Address Clicked',
Expand All @@ -18,17 +19,20 @@ export enum Events {
NFT_GO_TO_PORTFOLIO_CLICKED = 'NFT Go To Portfolio Clicked',
NFT_LEFT_MENU_CLOSED = 'NFT Left Menu Closed',
NFT_LEFT_MENU_EXPANDED = 'NFT Left Menu Expanded',
NFT_LISTING_SUCCESS_FAIL = 'NFT Listing Success/Fail',
NFT_LOAD_MORE_CLICKED = 'NFT Load More Clicked',
NFT_MAKE_AN_OFFER_CLICKED = 'NFT Make An Offer Clicked',
NFT_MAKE_AN_OFFER_VIEWED = 'NFT Make An Offer Viewed',
NFT_MARK_FOR_SALE = 'NFT Mark For Sale',
NFT_MORE_CLICKED = 'NFT More Clicked',
NFT_OFFER_SUCCESS_FAIL = 'NFT Offer Success/Fail',
NFT_OFFER_WITH_CLICKED = 'NFT Offer With Clicked',
NFT_OWNER_CLICKED = 'NFT Owner clicked',
NFT_RECENTLY_LISTED_CLICKED = 'NFT Recently Listed Clicked',
NFT_REFRESH_METADATA_CLICKED = 'NFT Refresh Metadata Clicked',
NFT_RETURN_TO_MARKETPLACE_CLICKED = 'NFT Return To Marketplace Clicked',
NFT_SELL_ITEM_CLICKED = 'NFT Sell Item Clicked',
NFT_SEND_SUCCESS_FAIL = 'NFT Send Success/Fail',
NFT_SHARE_CLICKED = 'NFT Share Clicked',
NFT_TRANSFER_CLICKED = 'NFT Transfer Clicked',
NFT_VIEW_BUTTON_VIEWED = 'NFT View Button Viewed',
Expand All @@ -41,6 +45,8 @@ type TurnOffOn = 'TURN_OFF' | 'TURN_ON'

type SaleType = 'FIXED_PRICE' | 'TIME_AUCTION'

type Outcome = 'DROP-OFF' | 'FAILED' | 'SUCCESS'

type AcceptedAccountsAction = {
key: Events.NFT_ACCEPTED_ACCOUNTS
properties: {
Expand Down Expand Up @@ -84,6 +90,13 @@ type BuyNowClickedAction = {
}
}

type BuySuccessFailAction = {
key: Events.NFT_BUY_SUCCESS_FAIL
properties: {
outcome: Outcome
}
}

type ClickedAction = {
key: Events.NFT_CLICKED
properties: {
Expand Down Expand Up @@ -162,6 +175,13 @@ type LeftMenuExpandedAction = {
properties: {}
}

type ListingSuccessFailAction = {
key: Events.NFT_LISTING_SUCCESS_FAIL
properties: {
outcome: Outcome
}
}

type LoadMoreClickedAction = {
key: Events.NFT_LOAD_MORE_CLICKED
properties: {}
Expand Down Expand Up @@ -195,7 +215,14 @@ type OfferWithClickedAction = {
properties: {}
}

type OwnerclickedAction = {
type OfferSuccessFailAction = {
key: Events.NFT_OFFER_SUCCESS_FAIL
properties: {
outcome: Outcome
}
}

type OwnerClickedAction = {
key: Events.NFT_OWNER_CLICKED
properties: {}
}
Expand Down Expand Up @@ -226,6 +253,13 @@ type SellItemClickedAction = {
}
}

type SendSuccessFailAction = {
key: Events.NFT_SEND_SUCCESS_FAIL
properties: {
outcome: Outcome
}
}

type ShareClickedAction = {
key: Events.NFT_SHARE_CLICKED
properties: {}
Expand Down Expand Up @@ -253,6 +287,7 @@ export type TrackEventAction =
| AmountEnteredSwitchedAction
| AttributesClickedAction
| BuyNowClickedAction
| BuySuccessFailAction
| ClickedAction
| CloseAndViewItemClickedAction
| ContractAddressClickedAction
Expand All @@ -265,17 +300,20 @@ export type TrackEventAction =
| GoToPortfolioClickedAction
| LeftMenuClosedAction
| LeftMenuExpandedAction
| ListingSuccessFailAction
| LoadMoreClickedAction
| MakeAnOfferClickedAction
| MakeAnOfferViewedAction
| MarkForSaleAction
| MoreClickedAction
| OfferSuccessFailAction
| OfferWithClickedAction
| OwnerclickedAction
| OwnerClickedAction
| RecentlyListedClickedAction
| RefreshMetadataClickedAction
| ReturnToMarketplaceClickedAction
| SellItemClickedAction
| SendSuccessFailAction
| ShareClickedAction
| TransferClickedAction
| ViewButtonViewedAction
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ import { errorHandler } from '@core/utils'
import { getPrivateKey } from '@core/utils/eth'
import { actions, selectors } from 'data'
import { ModalName } from 'data/modals/types'
import { Analytics } from 'data/types'
import { promptForSecondPassword } from 'services/sagas'

import * as S from './selectors'
Expand Down Expand Up @@ -352,7 +353,23 @@ export default ({ api }: { api: APIType }) => {
const order = yield call(fulfillNftOrder, { buy, gasData, signer })
yield call(api.postNftOrder, order)
yield put(A.setNftOrderStatus(NftOrderStatusEnum.POST_OFFER_SUCCESS))
yield put(
actions.analytics.trackEvent({
key: Analytics.NFT_OFFER_SUCCESS_FAIL,
properties: {
outcome: 'SUCCESS'
}
})
)
} catch (e) {
yield put(
actions.analytics.trackEvent({
key: Analytics.NFT_OFFER_SUCCESS_FAIL,
properties: {
outcome: 'FAILED'
}
})
)
yield put(A.setOrderFlowStep({ step: NftOrderStepEnum.MAKE_OFFER }))
let error = errorHandler(e)
if (error.includes(INSUFFICIENT_FUNDS))
Expand All @@ -376,7 +393,23 @@ export default ({ api }: { api: APIType }) => {
`Successfully created order! It may take a few minutes to appear in your collection.`
)
)
yield put(
actions.analytics.trackEvent({
key: Analytics.NFT_OFFER_SUCCESS_FAIL,
properties: {
outcome: 'SUCCESS'
}
})
)
} catch (e) {
yield put(
actions.analytics.trackEvent({
key: Analytics.NFT_BUY_SUCCESS_FAIL,
properties: {
outcome: 'FAILED'
}
})
)
let error = errorHandler(e)
if (error.includes(INSUFFICIENT_FUNDS))
error = 'You do not have enough funds to create this order.'
Expand Down Expand Up @@ -410,7 +443,23 @@ export default ({ api }: { api: APIType }) => {
yield put(A.clearAndRefetchAssets())
yield put(actions.modals.closeAllModals())
yield put(actions.alerts.displaySuccess('Sell order created!'))
yield put(
actions.analytics.trackEvent({
key: Analytics.NFT_LISTING_SUCCESS_FAIL,
properties: {
outcome: 'SUCCESS'
}
})
)
} catch (e) {
yield put(
actions.analytics.trackEvent({
key: Analytics.NFT_LISTING_SUCCESS_FAIL,
properties: {
outcome: 'FAILED'
}
})
)
let error = errorHandler(e)
if (error.includes(INSUFFICIENT_FUNDS))
error = 'You do not have enough funds to sell this asset.'
Expand All @@ -433,7 +482,23 @@ export default ({ api }: { api: APIType }) => {
yield put(A.clearAndRefetchAssets())
yield put(actions.modals.closeAllModals())
yield put(actions.alerts.displaySuccess('Transfer successful!'))
yield put(
actions.analytics.trackEvent({
key: Analytics.NFT_LISTING_SUCCESS_FAIL,
properties: {
outcome: 'SUCCESS'
}
})
)
} catch (e) {
yield put(
actions.analytics.trackEvent({
key: Analytics.NFT_SEND_SUCCESS_FAIL,
properties: {
outcome: 'FAILED'
}
})
)
let error = errorHandler(e)
if (error.includes(INSUFFICIENT_FUNDS))
error = 'You do not have enough funds to transfer this asset.'
Expand Down

0 comments on commit 7b016a0

Please sign in to comment.