Skip to content
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
4 changes: 4 additions & 0 deletions src/components/CampaignURLBuilder/index.spec.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,10 @@ import { GAVersion } from "../../constants"

// Capture original error global so it's easier to replace after a mock.
const originalError = console.error

// Increase the timeout for this test suite. The userEvent.type calls can
// be slow, and the default 5s timeout is not always enough.
jest.setTimeout(10000)
describe("for the Campaign URL Builder component", () => {
beforeEach(() => {
process.env.BITLY_CLIENT_ID = "bitly-client-id"
Expand Down
18 changes: 18 additions & 0 deletions src/components/ga4/EventBuilder/event.ts
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,22 @@ const generate_lead = eventFor(
[stringParam("currency", "USD"), numberParam("value", 99.99)]
)

const in_app_purchase = eventFor(
EventType.InAppPurchase,
[Category.AllApps],
[
stringParam("currency", "USD"),
numberParam("value", 30.03),
numberParam("quantity", 3),
stringParam("product_id", "ABC123456789"),
stringParam("subscription", "true"),
stringParam("free_trial", "false"),
stringParam("price_is_discounted", "false"),
],
undefined,
["app"]
)

const join_group = eventFor(
EventType.JoinGroup,
[Category.AllApps],
Expand Down Expand Up @@ -548,6 +564,8 @@ export const suggestedEventFor = (eventType: EventType): Event2 => {
return earn_virtual_currency
case EventType.GenerateLead:
return generate_lead
case EventType.InAppPurchase:
return in_app_purchase
case EventType.JoinGroup:
return join_group
case EventType.LevelUp:
Expand Down
4 changes: 4 additions & 0 deletions src/components/ga4/EventBuilder/index.spec.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,10 @@ import { Label } from "./types"
import userEvent from "@testing-library/user-event"
import { within } from "@testing-library/react"

// Increase the timeout for this test suite. The userEvent.type calls can
// be slow, and the default 5s timeout is not always enough.
jest.setTimeout(10000)

describe("Event Builder", () => {
test("can render page without error", () => {
const { wrapped } = withProviders(<Sut />)
Expand Down
1 change: 1 addition & 0 deletions src/components/ga4/EventBuilder/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ export enum EventType {
ViewItemList = "view_item_list",
ViewPromotion = "view_promotion",
ViewSearchResults = "view_search_results",
InAppPurchase = "in_app_purchase",
}

export interface NumberParameter {
Expand Down
Loading