-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #194 from 0xsequence/databeat
Databeat
- Loading branch information
Showing
9 changed files
with
269 additions
and
82 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
import type { Event as DatabeatEvent } from '@databeat/tracker'; | ||
import { Databeat } from '@databeat/tracker'; | ||
|
||
import { useConfig } from '../../hooks'; | ||
import type { | ||
EventType, | ||
TrackCreateListing, | ||
TrackCreateOffer, | ||
TrackSellItems, | ||
TrackTransactionFailed, | ||
} from './types'; | ||
|
||
export type EventTypes = keyof typeof EventType; | ||
export type Event = DatabeatEvent<EventTypes>; | ||
|
||
export class DatabeatAnalytics extends Databeat<Extract<EventTypes, string>> { | ||
// Currently handled by kit-checkout | ||
// trackBuyItems(args: TrackBuyItems) { | ||
// this.track({ | ||
// event: 'BUY_ITEMS', | ||
// props: args.props, | ||
// nums: args.nums | ||
// }) | ||
// } | ||
|
||
trackSellItems(args: TrackSellItems) { | ||
this.track({ | ||
event: 'SELL_ITEMS', | ||
props: args.props, | ||
nums: args.nums, | ||
}); | ||
} | ||
|
||
trackCreateListing(args: TrackCreateListing) { | ||
this.track({ | ||
event: 'CREATE_LISTING', | ||
props: args.props, | ||
nums: args.nums, | ||
}); | ||
} | ||
|
||
trackCreateOffer(args: TrackCreateOffer) { | ||
this.track({ | ||
event: 'CREATE_OFFER', | ||
props: args.props, | ||
nums: args.nums, | ||
}); | ||
} | ||
|
||
trackTransactionFailed(args: TrackTransactionFailed) { | ||
this.track({ | ||
event: 'TRANSACTION_FAILED', | ||
props: args, | ||
}); | ||
} | ||
} | ||
|
||
export const useAnalytics = () => { | ||
const config = useConfig(); | ||
return new DatabeatAnalytics('https://databeat.sequence.app', { | ||
jwt: config.projectAccessKey, | ||
}); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
import type { MarketplaceKind, OrderbookKind } from '../api'; | ||
|
||
export enum EventType { | ||
BUY_ITEMS = 0, | ||
SELL_ITEMS = 1, | ||
CREATE_LISTING = 2, | ||
CREATE_OFFER = 3, | ||
CANCEL_LISTING = 4, | ||
CANCEL_OFFER = 5, | ||
TRANSACTION_FAILED = 6, | ||
} | ||
|
||
interface PropsEvent { | ||
[key: string]: string; | ||
} | ||
|
||
interface NumsEvent { | ||
[key: string]: number; | ||
} | ||
|
||
interface Transaction extends PropsEvent { | ||
chainId: string; | ||
txnHash: string; | ||
} | ||
|
||
interface TradeItemsInfo extends PropsEvent { | ||
marketplaceKind: MarketplaceKind; | ||
collectionAddress: string; | ||
currencyAddress: string; | ||
currencySymbol: string; | ||
} | ||
|
||
interface TradeItemsValues extends NumsEvent { | ||
currencyValueDecimal: number; | ||
currencyValueRaw: number; | ||
} | ||
|
||
export interface TrackBuyItems { | ||
props: TradeItemsInfo & Transaction; | ||
nums: TradeItemsValues; | ||
} | ||
|
||
export interface TrackSellItems { | ||
props: TradeItemsInfo & Transaction; | ||
nums: TradeItemsValues; | ||
} | ||
|
||
interface ListOfferItemsInfo extends PropsEvent { | ||
orderbookKind: OrderbookKind; | ||
collectionAddress: string; | ||
currencyAddress: string; | ||
currencySymbol: string; | ||
} | ||
|
||
interface ListOfferItemsValues extends NumsEvent { | ||
currencyValueDecimal: number; | ||
currencyValueRaw: number; | ||
} | ||
|
||
export interface TrackCreateListing { | ||
props: ListOfferItemsInfo & Transaction; | ||
nums: ListOfferItemsValues; | ||
} | ||
|
||
export interface TrackCreateOffer { | ||
props: ListOfferItemsInfo & Transaction; | ||
nums: ListOfferItemsValues; | ||
} | ||
|
||
export interface TrackTransactionFailed extends Transaction, PropsEvent {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
17 changes: 10 additions & 7 deletions
17
packages/sdk/src/react/ui/modals/SellModal/hooks/useSell.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.