Skip to content
Open
Show file tree
Hide file tree
Changes from all 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
14 changes: 14 additions & 0 deletions src/app/Scenes/Activity/components/CollectorUpdateNotification.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
import { ActionType, ContextModule, OwnerType, TappedCompleteYourProfile } from "@artsy/cohesion"
import { Flex, Text, Touchable } from "@artsy/palette-mobile"
import { CollectorUpdateNotification_item$key } from "__generated__/CollectorUpdateNotification_item.graphql"
import { CollectorUpdateNotification_notification$key } from "__generated__/CollectorUpdateNotification_notification.graphql"
import { MyCollectionBottomSheetModalArtistsPrompt } from "app/Scenes/MyCollection/Components/MyCollectionBottomSheetModals/MyCollectionBottomSheetModalArtistsPrompt"
import { FC, useState } from "react"
import { graphql, useFragment } from "react-relay"
import { useTracking } from "react-tracking"
import { CollectorProfilePrompt } from "./CollectorProfilePrompt"

interface CollectorUpdateNotificationProps {
Expand All @@ -18,6 +20,7 @@ export const CollectorUpdateNotification: FC<CollectorUpdateNotificationProps> =
onPress,
}) => {
const [promptVisible, setPromptVisible] = useState(false)
const { trackEvent } = useTracking()
const notification = useFragment(NOTIFICATION_FRAGMENT, _notification)
const item = useFragment(ITEM_FRAGMENT, _item)

Expand All @@ -30,6 +33,9 @@ export const CollectorUpdateNotification: FC<CollectorUpdateNotificationProps> =
const itemInfo = hasEmptyCollection ? addArtistsToCollectiontInfo : collectorProfileInfo

const handleOnPress = () => {
if (itemInfo.prompt === "CollectorProfile") {
trackEvent(tracks.tappedCompleteYourProfile())
}
setPromptVisible(true)
onPress()
}
Expand Down Expand Up @@ -99,3 +105,11 @@ const collectorProfileInfo = {
body: "By completing your profile, you’re more likely to receive quick responses from galleries.",
prompt: "CollectorProfile",
}

const tracks = {
tappedCompleteYourProfile: (): TappedCompleteYourProfile => ({
action: ActionType.tappedCompleteYourProfile,
context_module: ContextModule.collectorProfileCard,
context_screen_owner_type: OwnerType.profile,
Comment on lines +112 to +113
Copy link
Member

Choose a reason for hiding this comment

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

I would have assumed this to be the Activity screen

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Copy link
Member

Choose a reason for hiding this comment

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

I think that was most likely for the other "CompleMyProfile" that we used to have (maybe still do) inside the profile.

}),
}
Original file line number Diff line number Diff line change
@@ -1,12 +1,17 @@
import { fireEvent, screen } from "@testing-library/react-native"
import { CollectorUpdateNotification_Test_Query } from "__generated__/CollectorUpdateNotification_Test_Query.graphql"
import { CollectorUpdateNotification } from "app/Scenes/Activity/components/CollectorUpdateNotification"
import { mockTrackEvent } from "app/utils/tests/globallyMockedStuff"
import { setupTestWrapper } from "app/utils/tests/setupTestWrapper"
import { Suspense } from "react"
import { graphql } from "react-relay"

describe("CollectorUpdateNotification", () => {
const onPress = jest.fn()

beforeEach(() => {
jest.clearAllMocks()
})
const { renderWithRelay } = setupTestWrapper<CollectorUpdateNotification_Test_Query>({
Component: ({ notificationsConnection }) => {
if (!notificationsConnection.edges?.[0]?.node) {
Expand Down Expand Up @@ -90,4 +95,25 @@ describe("CollectorUpdateNotification", () => {

expect(onPress).toHaveBeenCalledTimes(1)
})

it("tracks tappedCompleteYourProfile event when collector profile notification is pressed", async () => {
renderWithRelay({
Me: () => ({
profession: "Blacksmith",
location: { display: "" },
}),
CollectorProfileType: () => ({
lastUpdatePromptAt: "2021-09-01T00:00:00Z",
}),
})

const title = await screen.findByText("Tell us a little bit more about you.")
fireEvent.press(title)

expect(mockTrackEvent).toHaveBeenCalledWith({
action: "tappedCompleteYourProfile",
context_module: "collectorProfileCard",
context_screen_owner_type: "profile",
})
})
})
Original file line number Diff line number Diff line change
Expand Up @@ -64,11 +64,11 @@ describe(makeCareerHighlightMap, () => {

it("Prepares the eventDigest and creates a map of each year to the highlight kind", () => {
const result = makeCareerHighlightMap(
"2017 Group Show @ MOCA Los Angeles; 2015 Reviewed Solo Show @ The Guardian; 2015 Reviewed Solo Show @ Art in America"
"2020 Group Show @ MOCA Los Angeles; 2015 Reviewed Solo Show @ The Guardian; 2015 Reviewed Solo Show @ Art in America"
)

expect(result).toEqual({
2017: { "Group Show": ["MOCA Los Angeles"] },
2020: { "Group Show": ["MOCA Los Angeles"] },
})
})

Expand Down