Skip to content

Commit 8776698

Browse files
feat(EventBuilder): allow in_app_purchase events for app streams (#2265)
* allow in app purchase events for app streams * increase jest timeout * add comment explanation
1 parent da12b8b commit 8776698

4 files changed

Lines changed: 27 additions & 0 deletions

File tree

src/components/CampaignURLBuilder/index.spec.tsx

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,10 @@ import { GAVersion } from "../../constants"
2222

2323
// Capture original error global so it's easier to replace after a mock.
2424
const originalError = console.error
25+
26+
// Increase the timeout for this test suite. The userEvent.type calls can
27+
// be slow, and the default 5s timeout is not always enough.
28+
jest.setTimeout(10000)
2529
describe("for the Campaign URL Builder component", () => {
2630
beforeEach(() => {
2731
process.env.BITLY_CLIENT_ID = "bitly-client-id"

src/components/ga4/EventBuilder/event.ts

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -201,6 +201,22 @@ const generate_lead = eventFor(
201201
[stringParam("currency", "USD"), numberParam("value", 99.99)]
202202
)
203203

204+
const in_app_purchase = eventFor(
205+
EventType.InAppPurchase,
206+
[Category.AllApps],
207+
[
208+
stringParam("currency", "USD"),
209+
numberParam("value", 30.03),
210+
numberParam("quantity", 3),
211+
stringParam("product_id", "ABC123456789"),
212+
stringParam("subscription", "true"),
213+
stringParam("free_trial", "false"),
214+
stringParam("price_is_discounted", "false"),
215+
],
216+
undefined,
217+
["app"]
218+
)
219+
204220
const join_group = eventFor(
205221
EventType.JoinGroup,
206222
[Category.AllApps],
@@ -548,6 +564,8 @@ export const suggestedEventFor = (eventType: EventType): Event2 => {
548564
return earn_virtual_currency
549565
case EventType.GenerateLead:
550566
return generate_lead
567+
case EventType.InAppPurchase:
568+
return in_app_purchase
551569
case EventType.JoinGroup:
552570
return join_group
553571
case EventType.LevelUp:

src/components/ga4/EventBuilder/index.spec.tsx

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,10 @@ import { Label } from "./types"
2323
import userEvent from "@testing-library/user-event"
2424
import { within } from "@testing-library/react"
2525

26+
// Increase the timeout for this test suite. The userEvent.type calls can
27+
// be slow, and the default 5s timeout is not always enough.
28+
jest.setTimeout(10000)
29+
2630
describe("Event Builder", () => {
2731
test("can render page without error", () => {
2832
const { wrapped } = withProviders(<Sut />)

src/components/ga4/EventBuilder/types.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ export enum EventType {
6060
ViewItemList = "view_item_list",
6161
ViewPromotion = "view_promotion",
6262
ViewSearchResults = "view_search_results",
63+
InAppPurchase = "in_app_purchase",
6364
}
6465

6566
export interface NumberParameter {

0 commit comments

Comments
 (0)