Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[PAY-2767] Premium albums mobile analytics #8549

Merged
merged 3 commits into from
May 20, 2024
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import {
} from '@audius/common/models'
import type { ID, AccessConditions, User } from '@audius/common/models'
import { FeatureFlags } from '@audius/common/services'
import type { PurchaseableContentType } from '@audius/common/store'
import { PurchaseableContentType } from '@audius/common/store'
import {
usersSocialActions,
tippingActions,
Expand Down Expand Up @@ -226,7 +226,12 @@ export const DetailsTileNoAccess = ({
const handlePurchasePress = useCallback(() => {
openPremiumContentPurchaseModal(
{ contentId: trackId, contentType },
{ source: ModalSource.TrackDetails }
{
source:
contentType === PurchaseableContentType.ALBUM
? ModalSource.CollectionDetails
: ModalSource.TrackDetails
}
)
}, [trackId, openPremiumContentPurchaseModal, contentType])

Expand Down
10 changes: 8 additions & 2 deletions packages/mobile/src/components/lineup-tile/CollectionTile.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ import { getIsCollectionMarkedForDownload } from 'app/store/offline-downloads/se

import { CollectionTileTrackList } from './CollectionTileTrackList'
import { LineupTile } from './LineupTile'
import type { LineupItemProps } from './types'
import { LineupTileSource, type LineupItemProps } from './types'
const { getUid } = playerSelectors
const { requestOpen: requestOpenShareModal } = shareModalUIActions
const { open: openOverflowMenu } = mobileOverflowMenuUIActions
Expand All @@ -51,7 +51,12 @@ const { getCollection, getTracksFromCollection } = cacheCollectionsSelectors
const getUserId = accountSelectors.getUserId

export const CollectionTile = (props: LineupItemProps) => {
const { uid, collection: collectionOverride, tracks: tracksOverride } = props
const {
uid,
collection: collectionOverride,
tracks: tracksOverride,
source = LineupTileSource.LINEUP_COLLECTION
} = props

const collection = useProxySelector(
(state) => {
Expand Down Expand Up @@ -89,6 +94,7 @@ export const CollectionTile = (props: LineupItemProps) => {
collection={collection}
tracks={tracks}
user={user}
source={source}
/>
)
}
Expand Down
3 changes: 3 additions & 0 deletions packages/mobile/src/components/lineup-tile/LineupTile.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ export const LineupTile = ({
index,
isTrending,
isUnlisted,
source,
onPress,
onPressOverflow,
onPressRepost,
Expand Down Expand Up @@ -147,6 +148,7 @@ export const LineupTile = ({
isArtistPick={isArtistPick}
showArtistPick={showArtistPick}
releaseDate={item?.release_date ? item.release_date : undefined}
source={source}
/>
</View>
{children}
Expand All @@ -167,6 +169,7 @@ export const LineupTile = ({
}
streamConditions={streamConditions}
hasStreamAccess={hasStreamAccess}
source={source}
onPressOverflow={onPressOverflow}
onPressRepost={onPressRepost}
onPressSave={onPressSave}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ import { useCallback } from 'react'

import type { ID, AccessConditions } from '@audius/common/models'
import { ModalSource, isContentUSDCPurchaseGated } from '@audius/common/models'
import type { PurchaseableContentType } from '@audius/common/store'
import {
PurchaseableContentType,
usePremiumContentPurchaseModal,
gatedContentActions,
gatedContentSelectors
Expand All @@ -25,6 +25,8 @@ import { useIsUSDCEnabled } from 'app/hooks/useIsUSDCEnabled'
import { setVisibility } from 'app/store/drawers/slice'
import { makeStyles } from 'app/styles'

import { LineupTileSource } from './types'

const { getGatedContentStatusMap } = gatedContentSelectors
const { setLockedContentId } = gatedContentActions

Expand All @@ -45,12 +47,14 @@ export const LineupTileAccessStatus = ({
contentId,
contentType,
streamConditions,
hasStreamAccess
hasStreamAccess,
source: tileSource
}: {
contentId: ID
contentType: PurchaseableContentType
streamConditions: AccessConditions
hasStreamAccess: boolean | undefined
source?: LineupTileSource
}) => {
const styles = useStyles()
const { color } = useTheme()
Expand All @@ -69,20 +73,34 @@ export const LineupTileAccessStatus = ({
return
}
if (isUSDCPurchase) {
const determineModalSource = () => {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: does this need to be a function instead of a let + if statements?

if (tileSource === LineupTileSource.DM_COLLECTION) {
return ModalSource.DirectMessageCollectionTile
}
if (tileSource === LineupTileSource.DM_TRACK) {
return ModalSource.DirectMessageTrackTile
}
return contentType === PurchaseableContentType.ALBUM
? ModalSource.LineUpCollectionTile
: ModalSource.LineUpTrackTile
}
openPremiumContentPurchaseModal(
{ contentId, contentType },
{ source: ModalSource.TrackTile }
{
source: determineModalSource()
}
)
} else if (contentId) {
dispatch(setLockedContentId({ id: contentId }))
dispatch(setVisibility({ drawer: 'LockedContent', visible: true }))
}
}, [
isUSDCPurchase,
hasStreamAccess,
isUSDCPurchase,
contentId,
openPremiumContentPurchaseModal,
contentType,
tileSource,
dispatch
])

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import { flexRowCentered, makeStyles } from 'app/styles'
import type { GestureResponderHandler } from 'app/types/gesture'

import { LineupTileAccessStatus } from './LineupTileAccessStatus'
import type { LineupTileSource } from './types'

const messages = {
shareButtonLabel: 'Share Content',
Expand All @@ -38,6 +39,7 @@ type Props = {
contentType?: PurchaseableContentType
streamConditions?: Nullable<AccessConditions>
hasStreamAccess?: boolean
source?: LineupTileSource
onPressOverflow?: GestureResponderHandler
onPressRepost?: GestureResponderHandler
onPressSave?: GestureResponderHandler
Expand Down Expand Up @@ -81,6 +83,7 @@ export const LineupTileActionButtons = ({
hasStreamAccess = false,
readonly = false,
streamConditions,
source,
onPressOverflow,
onPressRepost,
onPressSave,
Expand Down Expand Up @@ -146,6 +149,7 @@ export const LineupTileActionButtons = ({
contentType={contentType}
streamConditions={streamConditions}
hasStreamAccess={hasStreamAccess}
source={source}
/>
</View>
)
Expand All @@ -160,6 +164,7 @@ export const LineupTileActionButtons = ({
contentType={contentType}
streamConditions={streamConditions}
hasStreamAccess={hasStreamAccess}
source={source}
/>
) : null}
{showLeftButtons && (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ import { LineupTileAccessStatus } from './LineupTileAccessStatus'
import { LineupTileGatedContentTypeTag } from './LineupTilePremiumContentTypeTag'
import { LineupTileRankIcon } from './LineupTileRankIcon'
import { useStyles as useTrackTileStyles } from './styles'
import type { LineupItemVariant } from './types'
import type { LineupItemVariant, LineupTileSource } from './types'
const { setFavorite } = favoritesUserListActions
const { setRepost } = repostsUserListActions

Expand Down Expand Up @@ -111,6 +111,7 @@ type Props = {
isArtistPick?: boolean
showArtistPick?: boolean
releaseDate?: string
source?: LineupTileSource
}

export const LineupTileStats = ({
Expand All @@ -132,7 +133,8 @@ export const LineupTileStats = ({
isOwner,
isArtistPick,
showArtistPick,
releaseDate
releaseDate,
source
}: Props) => {
const styles = useStyles()
const trackTileStyles = useTrackTileStyles()
Expand Down Expand Up @@ -175,6 +177,7 @@ export const LineupTileStats = ({
}
streamConditions={streamConditions}
hasStreamAccess={hasStreamAccess}
source={source}
/>
)
}
Expand Down
16 changes: 15 additions & 1 deletion packages/mobile/src/components/lineup-tile/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@ import type {
ID,
UID,
Track,
User
User,
ModalSource
} from '@audius/common/models'
import type { RepostType, EnhancedCollectionTrack } from '@audius/common/store'
import type { StyleProp, ViewStyle } from 'react-native'
Expand All @@ -23,6 +24,13 @@ import type { TileProps } from '../core'
*/
export type LineupItemVariant = 'readonly'

export enum LineupTileSource {
DM_COLLECTION = 'DM - Collection',
DM_TRACK = 'DM - Track',
LINEUP_COLLECTION = 'Lineup - Collection',
LINEUP_TRACK = 'Lineup - Track'
}

export type LineupItemProps = {
/** Index of tile in lineup */
index: number
Expand Down Expand Up @@ -59,6 +67,9 @@ export type LineupItemProps = {

/** Passed in styles */
styles?: StyleProp<ViewStyle>

/** Tell the tile where it's being used */
source?: LineupTileSource
}

export type LineupTileProps = Omit<LineupItemProps, 'togglePlay'> & {
Expand Down Expand Up @@ -125,4 +136,7 @@ export type LineupTileProps = Omit<LineupItemProps, 'togglePlay'> & {
isPlayingUid: boolean

TileProps?: Partial<TileProps>

/** Analytics context about where this tile is being used */
source?: LineupTileSource
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import {
} from '@audius/common/api'
import { usePlayTrack, usePauseTrack } from '@audius/common/hooks'
import type { TrackPlayback } from '@audius/common/hooks'
import { Name, PlaybackSource, Kind } from '@audius/common/models'
import { Name, PlaybackSource, Kind, ModalSource } from '@audius/common/models'
import type { ID } from '@audius/common/models'
import {
accountSelectors,
Expand All @@ -18,6 +18,7 @@ import { getPathFromPlaylistUrl, makeUid } from '@audius/common/utils'
import { useSelector } from 'react-redux'

import { CollectionTile } from 'app/components/lineup-tile'
import { LineupTileSource } from 'app/components/lineup-tile/types'
import { make, track as trackEvent } from 'app/services/analytics'

const { getUserId } = accountSelectors
Expand Down Expand Up @@ -171,6 +172,7 @@ export const ChatMessagePlaylist = ({
showRankIcon={false}
styles={styles}
variant='readonly'
source={LineupTileSource.DM_COLLECTION}
/>
) : null
}
2 changes: 2 additions & 0 deletions packages/mobile/src/screens/chat-screen/ChatMessageTrack.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import { getPathFromTrackUrl, makeUid } from '@audius/common/utils'
import { useSelector } from 'react-redux'

import { TrackTile } from 'app/components/lineup-tile'
import { LineupTileSource } from 'app/components/lineup-tile/types'
import { make, track as trackEvent } from 'app/services/analytics'

const { getUserId } = accountSelectors
Expand Down Expand Up @@ -87,6 +88,7 @@ export const ChatMessageTrack = ({
showRankIcon={false}
styles={styles}
variant='readonly'
source={LineupTileSource.DM_TRACK}
/>
) : null
}