From c19c009f612bde7bec8f7cc08c22ef362aa53c9d Mon Sep 17 00:00:00 2001 From: Pieter Uyttersprot Date: Mon, 15 Jul 2024 17:23:12 +0200 Subject: [PATCH] feat(analytics): allow custom event parameters for Item in events --- packages/analytics/__tests__/analytics.test.ts | 6 ++++++ packages/analytics/lib/index.d.ts | 5 +++++ packages/analytics/lib/structs.js | 2 +- 3 files changed, 12 insertions(+), 1 deletion(-) diff --git a/packages/analytics/__tests__/analytics.test.ts b/packages/analytics/__tests__/analytics.test.ts index 86520877b4..1453dc7f8b 100644 --- a/packages/analytics/__tests__/analytics.test.ts +++ b/packages/analytics/__tests__/analytics.test.ts @@ -311,6 +311,12 @@ describe('Analytics', function () { }), ).toThrowError('firebase.analytics().logAddToWishlist(*):'); }); + + it('items accept arbitrary custom event parameters', function () { + expect(() => + firebase.analytics().logAddToWishlist({ items: [{ foo: 'bar' }] }), + ).not.toThrow(); + }); }); describe('logBeginCheckout()', function () { diff --git a/packages/analytics/lib/index.d.ts b/packages/analytics/lib/index.d.ts index cac30af0ce..0477832883 100644 --- a/packages/analytics/lib/index.d.ts +++ b/packages/analytics/lib/index.d.ts @@ -141,6 +141,11 @@ export namespace FirebaseAnalyticsTypes { * The promotion name associated with the item. */ promotion_name?: string; + /** + * Custom event parameters. The parameter names can be up to 40 characters long and must start with an alphabetic character and contain only alphanumeric characters and underscores. String parameter values can be up to 100 characters long. + * The "firebase_", "google_" and "ga_" prefixes are reserved and should not be used for parameter names. + */ + [key: string]: string | number; } export interface AddPaymentInfoEventParameters { diff --git a/packages/analytics/lib/structs.js b/packages/analytics/lib/structs.js index e0c1acf32f..d5bdb0e2e0 100644 --- a/packages/analytics/lib/structs.js +++ b/packages/analytics/lib/structs.js @@ -15,7 +15,7 @@ */ import struct from '@react-native-firebase/app/lib/common/struct'; -const Item = struct({ +const Item = struct.interface({ item_brand: 'string?', item_id: 'string?', item_name: 'string?',