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

[expo-firebase-analytics] Updates Regex To Allow Numeric Chars #8516

Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 2 additions & 0 deletions packages/expo-firebase-analytics/CHANGELOG.md
Expand Up @@ -8,6 +8,8 @@

### 🐛 Bug fixes

- Fixes `parseEvent` to allow numeric characters as part of the `eventName` since the name can be alphanumeric. ([#8516](https://github.com/expo/expo/pull/8516) by [@thorbenprimke](https://github.com/thorbenprimke))

## 2.4.0 — 2020-05-27

### 🎉 New features
Expand Down
3 changes: 3 additions & 0 deletions packages/expo-firebase-analytics/package.json
Expand Up @@ -32,6 +32,9 @@
"author": "650 Industries, Inc.",
"license": "MIT",
"homepage": "https://github.com/expo/expo/tree/master/packages/expo-firebase-analytics",
"jest": {
"preset": "expo-module-scripts/ios"
thorbenprimke marked this conversation as resolved.
Show resolved Hide resolved
},
"unimodulePeerDependencies": {
"@unimodules/core": "*",
"expo-constants": "*"
Expand Down
Expand Up @@ -189,7 +189,8 @@ class FirebaseAnalyticsJS {
!eventName.length ||
eventName.length > 40 ||
eventName[0] === '_' ||
!eventName.match(/^[A-Za-z_]+$/) ||
eventName[0].match(/^\d$/) ||
!eventName.match(/^[A-Za-z_0-9]+$/) ||
thorbenprimke marked this conversation as resolved.
Show resolved Hide resolved
eventName.startsWith('firebase_') ||
eventName.startsWith('google_') ||
eventName.startsWith('ga_')
Expand Down
@@ -0,0 +1,27 @@
import FirebaseAnalyticsJS from '../FirebaseAnalyticsJS';

it(`Verfies parseEvent eventName validation`, async () => {
expect.assertions(2);
const expectedErrorMessage =
'Invalid event-name specified. Should contain 1 to 40 alphanumeric characters or underscores. The name must start with an alphabetic character.';
const options = {
clientId: '0',
sessionId: '0',
};

FirebaseAnalyticsJS.parseEvent(options, 'MyAnalyticsEvent');

try {
FirebaseAnalyticsJS.parseEvent(options, '_MyAnalyticsEvent');
} catch (error) {
expect(error.message).toBe(expectedErrorMessage);
}

try {
FirebaseAnalyticsJS.parseEvent(options, '0MyAnalyticsEvent');
} catch (error) {
expect(error.message).toBe(expectedErrorMessage);
}

FirebaseAnalyticsJS.parseEvent(options, 'MyAnalyticsEvent0');
});