Skip to content

Commit

Permalink
fix(analytics): added a validation for length in analytics().logEvent…
Browse files Browse the repository at this point in the history
…(name, params) (#4522)

* Needs to check the length for name of analytics().logEvent(name, params): 1-40 alphanumeric
  • Loading branch information
railsjack authored Nov 9, 2020
1 parent f23de50 commit 107b07d
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion packages/analytics/__tests__/analytics.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ describe('Analytics', () => {

it('errors if name not alphanumeric', () => {
expect(() => firebase.analytics().logEvent('!@£$%^&*')).toThrowError(
"firebase.analytics().logEvent(*) 'name' invalid event name '!@£$%^&*'. Names should contain 1 to 32 alphanumeric characters or underscores.",
"firebase.analytics().logEvent(*) 'name' invalid event name '!@£$%^&*'. Names should contain 1 to 40 alphanumeric characters or underscores.",
);
});

Expand Down
4 changes: 2 additions & 2 deletions packages/analytics/lib/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -76,9 +76,9 @@ class FirebaseAnalyticsModule extends FirebaseModule {
}

// name format validation
if (!isAlphaNumericUnderscore(name)) {
if (!isAlphaNumericUnderscore(name) || name.length > 40) {
throw new Error(
`firebase.analytics().logEvent(*) 'name' invalid event name '${name}'. Names should contain 1 to 32 alphanumeric characters or underscores.`,
`firebase.analytics().logEvent(*) 'name' invalid event name '${name}'. Names should contain 1 to 40 alphanumeric characters or underscores.`,
);
}

Expand Down

1 comment on commit 107b07d

@vercel
Copy link

@vercel vercel bot commented on 107b07d Nov 9, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.