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

ERROR in setScreenNameAndScreenClass - FA: Name must consist of letters, digits or _ #68

Open
rushisaband opened this issue Jan 7, 2022 · 1 comment

Comments

@rushisaband
Copy link

rushisaband commented Jan 7, 2022

Over the last few months I've started seeing errors when invoking the 'setScreenNameAndScreenClass' methods. I had been using strings with forward slashes in them for several years without issue, but after upgrading the FA module in the last year (I think when I jumped from android v3.x to v5.x), I started seeing errors like "FA: Name must start with a letter" or "FA: Name must consist of letters, digits or _". After looking at the Firebase docs, I did see that EVENT names must follow this format, but the strings themselves shouldn't be restricted by that. If I changed the 'screen name' string to something that met the alphanumeric and length requirements then I did NOT see the error. I noticed that Firebase had deprecated the 'setScreenName' method at some point - and suggested using the 'logEvent' SCREEN_VIEW event in its place, which is how the Ti FA module's 'setScreenNameAndScreenClass' method had been updated. However, after looking at the specific code, I saw a potential issue that might be causing the issue.

Using the Android version as an example (although I see the same thing on iOS as well) - specifically the TitaniumFirebaseAnalyticsModule.java file, on lines 120-2 we have this:

Bundle bundle = new Bundle(1);
bundle.putString(screenName, screenClass);
instance.logEvent(FirebaseAnalytics.Event.SCREEN_VIEW, bundle);

I think this makes it possibly view 'screenName' as an 'event type' and therefore needing the string restrictions (alphanumeric, <40 chars). But I think that should instead be something like this:

Bundle params = new Bundle();
params.putString(Param.SCREEN_CLASS, screenClass);
params.putString(Param.SCREEN_NAME, screenName);
instance.logEvent(FirebaseAnalytics.Event.SCREEN_VIEW, bundle);

I'm not an Android dev, so I may be off on the specific syntax/usage, but I'm basing this off the SCREEN_VIEW (and SCREEN_NAME/SCREEN_CLASS) docs here: https://firebase.google.com/docs/reference/android/com/google/firebase/analytics/FirebaseAnalytics.Event#public-static-final-string-screen_view

There may be something else going on, but I thought this might be at least a starting point. I'm not sure why else this occurs. This issue is causing all my custom screenviews to come through to Firebase as 'not set'. One work-around that I'm currently using is to manually set a 'screen_view' event using the Ti FA method 'logEvent'. That seems to work, but thought I would point this out.

@rushisaband
Copy link
Author

Looking more closely at my Firebase console, it looks like these events ARE coming through as 'screen_view' events despite the error I'm seeing. It looks like all the 'screen_view' events associated with a '(not set)' screen name, have a corresponding 'screen_class' of TiActivity. And it almost looks like there's one '(not set)' for every manually tracked 'screen_view'. So now I'm thinking that the '(not set)' entries are due to 'automatic screen tracking', which seems to be on by default. It's all a bit confusing. It still doesn't explain WHY I see an "FA" error every time I invoke the 'setScreenNameAndScreenClass' method with a non-compliant string (non-alphanumeric chars and/or > 40 chars). And why that error goes away when I change it to a compliant, alphanumeric string.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant