Skip to content

Commit

Permalink
feat(analytics): allow custom event parameters for Item in events
Browse files Browse the repository at this point in the history
  • Loading branch information
Pietahr authored and mikehardy committed Oct 31, 2024
1 parent a5feba3 commit d55e891
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 1 deletion.
6 changes: 6 additions & 0 deletions packages/analytics/__tests__/analytics.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 () {
Expand Down
5 changes: 5 additions & 0 deletions packages/analytics/lib/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
2 changes: 1 addition & 1 deletion packages/analytics/lib/structs.js
Original file line number Diff line number Diff line change
Expand Up @@ -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?',
Expand Down

0 comments on commit d55e891

Please sign in to comment.