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

fix(analytics): allow custom event parameters for screen_view events #5811

Merged
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
7 changes: 7 additions & 0 deletions packages/analytics/__tests__/analytics.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,13 @@ describe('Analytics', function () {
'firebase.analytics().logScreenView(*):',
);
});
it('accepts arbitrary custom event parameters while rejecting defined parameters with wrong types', function () {
expect(() => firebase.analytics().logScreenView({ foo: 'bar' })).not.toThrow();
// @ts-ignore test
expect(() => firebase.analytics().logScreenView({ screen_name: 123, foo: 'bar' })).toThrowError(
'firebase.analytics().logScreenView(*):',
);
});
});

describe('logAddPaymentInfo()', function () {
Expand Down
4 changes: 4 additions & 0 deletions packages/analytics/lib/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -344,6 +344,10 @@ export namespace FirebaseAnalyticsTypes {
* Current class associated with the view the user is currently viewing.
*/
screen_class?: string;
/**
* Custom event parameters.
*/
[key: string]: any;
}

export interface RefundEventParameters {
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 @@ -32,7 +32,7 @@ const Item = struct({
price: 'number?',
});

export const ScreenView = struct({
export const ScreenView = struct.interface({
screen_class: 'string?',
screen_name: 'string?',
});
Expand Down