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

feat(EMI-2044): Add tracking to Auction Signals #10699

Merged
merged 4 commits into from
Sep 4, 2024
Merged
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
98 changes: 98 additions & 0 deletions src/app/Components/ArtworkGrids/ArtworkGridItem.tests.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ describe("ArtworkGridItem", () => {
title: "Some Kind of Dinosaur",
slug: "cool-artwork",
internalID: "abc1234",
collectorSignals: null,
}),
},
{
Expand Down Expand Up @@ -130,6 +131,103 @@ describe("ArtworkGridItem", () => {
signal_label: "Limited-Time Offer",
})
})

describe("with auction signals", () => {
beforeEach(() => {
__globalStoreTestUtils__?.injectFeatureFlags({ AREnableAuctionImprovementsSignals: true })
})

it("sends a tracking event when with time left to bid label", () => {
renderWithRelay(
{
Artwork: () => ({
title: "Some Kind of Dinosaur",
slug: "cool-artwork",
internalID: "abc1234",
sale: { isAuction: true },
collectorSignals: {
partnerOffer: null,
auction: {
lotClosesAt: DateTime.fromMillis(Date.now()).plus({ days: 1 }).toISO(),
registrationEndsAt: DateTime.fromMillis(Date.now()).minus({ days: 1 }).toISO(),
bidCount: 7,
lotWatcherCount: 49,
},
},
}),
},
{
contextScreenOwnerType: OwnerType.artist,
contextScreenOwnerId: "abc124",
contextScreenOwnerSlug: "andy-warhol",
itemIndex: 0,
}
)

const touchableArtwork = screen.getByTestId("artworkGridItem-Some Kind of Dinosaur")
fireEvent.press(touchableArtwork)

expect(mockTrackEvent).toBeCalledWith({
action: "tappedMainArtworkGrid",
context_module: "artworkGrid",
context_screen_owner_id: "abc124",
context_screen_owner_slug: "andy-warhol",
context_screen_owner_type: "artist",
destination_screen_owner_id: "abc1234",
destination_screen_owner_slug: "cool-artwork",
destination_screen_owner_type: "artwork",
position: 0,
sort: "-decayed_merch",
type: "thumbnail",
signal_bid_count: 7,
signal_lot_watcher_count: 49,
signal_label: "Time left to bid",
})
})

it("sends a tracking event when with live bidding signal", () => {
renderWithRelay(
{
Artwork: () => ({
title: "Some Kind of Dinosaur",
slug: "cool-artwork",
internalID: "abc1234",
sale: { isAuction: true },
collectorSignals: {
partnerOffer: null,
auction: { liveBiddingStarted: true, bidCount: 2, lotWatcherCount: 29 },
},
}),
},
{
contextScreenOwnerType: OwnerType.artist,
contextScreenOwnerId: "abc124",
contextScreenOwnerSlug: "andy-warhol",
itemIndex: 0,
}
)

const touchableArtwork = screen.getByTestId("artworkGridItem-Some Kind of Dinosaur")
fireEvent.press(touchableArtwork)

expect(mockTrackEvent).toBeCalledWith({
action: "tappedMainArtworkGrid",
context_module: "artworkGrid",
context_screen_owner_id: "abc124",
context_screen_owner_slug: "andy-warhol",
context_screen_owner_type: "artist",
destination_screen_owner_id: "abc1234",
destination_screen_owner_slug: "cool-artwork",
destination_screen_owner_type: "artwork",
position: 0,
sort: "-decayed_merch",
type: "thumbnail",
signal_bid_count: 2,
signal_lot_watcher_count: 29,
signal_label: "Bidding live now",
})
})
})
})

describe("recent searches", () => {
Expand Down
9 changes: 5 additions & 4 deletions src/app/Components/ArtworkGrids/ArtworkGridItem.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ import { formattedTimeLeft } from "app/Scenes/Activity/utils/formattedTimeLeft"
import { GlobalStore } from "app/store/GlobalStore"
import { navigate } from "app/system/navigation/navigate"
import { useArtworkBidding } from "app/utils/Websockets/auctions/useArtworkBidding"
import { getArtworkSignalTrackingFields } from "app/utils/getArtworkSignalTrackingFields"
import { saleMessageOrBidInfo } from "app/utils/getSaleMessgeOrBidInfo"
import { getTimer } from "app/utils/getTimer"
import { getUrgencyTag } from "app/utils/getUrgencyTag"
Expand Down Expand Up @@ -226,10 +227,10 @@ export const Artwork: React.FC<ArtworkProps> = ({
query: contextScreenQuery,
sort: filterParams?.sort,
type: "thumbnail",
}

if (AREnablePartnerOfferSignals && collectorSignals?.partnerOffer?.isAvailable) {
genericTapEvent.signal_label = "Limited-Time Offer"
...getArtworkSignalTrackingFields(
artwork.collectorSignals,
AREnableAuctionImprovementsSignals
),
Comment on lines +230 to +233
Copy link
Contributor

Choose a reason for hiding this comment

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

👍

}

tracking.trackEvent(genericTapEvent)
Expand Down
7 changes: 7 additions & 0 deletions src/app/Components/ArtworkRail/LargeArtworkRail.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,13 @@ const largeArtworksFragment = graphql`
href
slug
collectorSignals {
auction {
bidCount
liveBiddingStarted
lotClosesAt
lotWatcherCount
registrationEndsAt
}
partnerOffer {
isAvailable
}
Expand Down
7 changes: 7 additions & 0 deletions src/app/Components/ArtworkRail/SmallArtworkRail.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,13 @@ const smallArtworksFragment = graphql`
partnerOffer {
isAvailable
}
auction {
bidCount
liveBiddingStarted
lotClosesAt
lotWatcherCount
registrationEndsAt
}
}
}
`
153 changes: 151 additions & 2 deletions src/app/Scenes/Artwork/Components/ArtworkCommercialButtons.tests.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import { ArtworkInquiryStateProvider } from "app/utils/ArtworkInquiry/ArtworkInq
import { extractNodes } from "app/utils/extractNodes"
import { mockTrackEvent } from "app/utils/tests/globallyMockedStuff"
import { setupTestWrapper } from "app/utils/tests/setupTestWrapper"
import { DateTime } from "luxon"
import { graphql } from "react-relay"
import { ArtworkCommercialButtons } from "./ArtworkCommercialButtons"

Expand Down Expand Up @@ -462,7 +463,6 @@ describe("ArtworkCommercialButtons", () => {
"context_owner_id": "5b2b745e9c18db204fc32e11",
"context_owner_slug": "andreas-rod-prinzknecht",
"context_owner_type": "artwork",
"signal_label": undefined,
},
]
`)
Expand Down Expand Up @@ -494,11 +494,160 @@ describe("ArtworkCommercialButtons", () => {
"context_owner_id": "5b2b745e9c18db204fc32e11",
"context_owner_slug": "andreas-rod-prinzknecht",
"context_owner_type": "artwork",
"signal_label": undefined,
},
]
`)
})

describe("with an active partner offer", () => {
it("trackEvent called when Contact Gallery pressed given Offerable and Inquireable artwork", () => {
const artwork = {
...ArtworkFixture,
isOfferable: true,
isInquireable: true,
collectorSignals: { partnerOffer: { internalID: "partnerOfferID" } },
}

renderWithRelay(
{
Artwork: () => artwork,
Me: () => meFixture,
},
{ auctionState: AuctionTimerState.LIVE_INTEGRATION_UPCOMING }
)

fireEvent.press(screen.getByText("Contact Gallery"))

expect(mockTrackEvent.mock.calls[0]).toMatchInlineSnapshot(`
[
{
"action": "tappedContactGallery",
"context_owner_id": "5b2b745e9c18db204fc32e11",
"context_owner_slug": "andreas-rod-prinzknecht",
"context_owner_type": "artwork",
"signal_label": "Limited-Time Offer",
},
]
`)
})

it("trackEvent called when Contact Gallery pressed given Inquireable artwork", () => {
const artwork = {
...ArtworkFixture,
isOfferable: true,
isInquireable: true,
collectorSignals: { partnerOffer: { internalID: "partnerOfferID" } },
}

renderWithRelay(
{
Artwork: () => artwork,
Me: () => meFixture,
},
{
auctionState: AuctionTimerState.LIVE_INTEGRATION_UPCOMING,
}
)

fireEvent.press(screen.getByText("Contact Gallery"))

expect(mockTrackEvent.mock.calls[0]).toMatchInlineSnapshot(`
[
{
"action": "tappedContactGallery",
"context_owner_id": "5b2b745e9c18db204fc32e11",
"context_owner_slug": "andreas-rod-prinzknecht",
"context_owner_type": "artwork",
"signal_label": "Limited-Time Offer",
},
]
`)
})
})

describe("with auction signals", () => {
beforeEach(() => {
__globalStoreTestUtils__?.injectFeatureFlags({ AREnableAuctionImprovementsSignals: true })
})

it("trackEvent called when Contact Gallery pressed given Offerable and Inquireable artwork", () => {
const artwork = {
...ArtworkFixture,
isOfferable: true,
isInquireable: true,
collectorSignals: {
auction: {
lotClosesAt: DateTime.fromMillis(Date.now()).plus({ days: 1 }).toISO(),
registrationEndsAt: DateTime.fromMillis(Date.now()).minus({ days: 1 }).toISO(),
liveBiddingStarted: false,
bidCount: 7,
lotWatcherCount: 49,
},
},
}

renderWithRelay(
{
Artwork: () => artwork,
Me: () => meFixture,
},
{ auctionState: AuctionTimerState.LIVE_INTEGRATION_UPCOMING }
)

fireEvent.press(screen.getByText("Contact Gallery"))

expect(mockTrackEvent.mock.calls[0]).toMatchInlineSnapshot(`
[
{
"action": "tappedContactGallery",
"context_owner_id": "5b2b745e9c18db204fc32e11",
"context_owner_slug": "andreas-rod-prinzknecht",
"context_owner_type": "artwork",
"signal_bid_count": 7,
"signal_label": "Time left to bid",
"signal_lot_watcher_count": 49,
},
]
`)
})

it("trackEvent called when Contact Gallery pressed given Inquireable artwork", () => {
const artwork = {
...ArtworkFixture,
isOfferable: true,
isInquireable: true,
collectorSignals: {
auction: { liveBiddingStarted: true, bidCount: 3, lotWatcherCount: 29 },
},
}

renderWithRelay(
{
Artwork: () => artwork,
Me: () => meFixture,
},
{
auctionState: AuctionTimerState.LIVE_INTEGRATION_UPCOMING,
}
)

fireEvent.press(screen.getByText("Contact Gallery"))

expect(mockTrackEvent.mock.calls[0]).toMatchInlineSnapshot(`
[
{
"action": "tappedContactGallery",
"context_owner_id": "5b2b745e9c18db204fc32e11",
"context_owner_slug": "andreas-rod-prinzknecht",
"context_owner_type": "artwork",
"signal_bid_count": 3,
"signal_label": "Bidding live now",
"signal_lot_watcher_count": 29,
},
]
`)
})
})
})

describe("With AREnablePartnerOfferOnArtworkScreen turned off", () => {
Expand Down
35 changes: 35 additions & 0 deletions src/app/Scenes/Artwork/Components/ArtworksInSeriesRail.tests.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,7 @@ describe("ArtworksInSeriesRail", () => {
Artwork: () => ({
internalID: "artwork124",
slug: "my-cool-artwork",
collectorSignals: null,
artistSeriesConnection: {
edges: [
{
Expand Down Expand Up @@ -208,4 +209,38 @@ describe("ArtworksInSeriesRail", () => {
signal_label: "Limited-Time Offer",
})
})

it("tracks clicks on an individual artwork with auction signals", () => {
__globalStoreTestUtils__?.injectFeatureFlags({ AREnableAuctionImprovementsSignals: true })

renderWithRelay({
Artwork: () => ({
internalID: "artwork124",
slug: "my-cool-artwork",
collectorSignals: {
auction: { liveBiddingStarted: true, bidCount: 7, lotWatcherCount: 49 },
},
artistSeriesConnection: {
edges: [{ node: { slug: "alex-katz-departure-28", id: "abctest" } }],
},
}),
})

fireEvent.press(screen.getByTestId("artwork-my-cool-artwork"))

expect(mockTrackEvent).toHaveBeenCalledWith({
action: "tappedArtworkGroup",
context_module: "moreFromThisSeries",
context_screen_owner_id: "artwork124",
context_screen_owner_slug: "my-cool-artwork",
context_screen_owner_type: "artwork",
destination_screen_owner_id: "artwork124",
destination_screen_owner_slug: "my-cool-artwork",
destination_screen_owner_type: "artwork",
type: "thumbnail",
signal_label: "Bidding live now",
signal_bid_count: 7,
signal_lot_watcher_count: 49,
})
})
})
Loading