In a large app which uses Firebase extensively, I'm trying analytics,
-FIRDebugEnabled is set fine.
The date/time on the devices is set correctly.
I have tried all of simulator, tethered device, and even building through to TestFlight.
The needed stuff is in app startup ..
FirebaseConfiguration.shared.setLoggerLevel(.max)
FirebaseApp.configure()
// helps Analytics get going:
AnalyticsConfiguration.shared().setAnalyticsCollectionEnabled(true)
Again, Firebase realtime and database works perfectly throughout.
So using Analytics.logEvent# ...
Note that the items appear perfectly in Xcode console:
2018-07-24 08:27:23.868 Blah[7501] <Debug> [Firebase/Analytics][I-ACS023105] Event is
not subject to real-time event count daily limit. Marking an event as
real-time. Event name, parameters: select_content, {
firebase_event_origin (_o) = app;
firebase_realtime (_r) = 1;
item_name = tapMyProfile;
firebase_screen_class (_sc) = Blah.SomeScreen;
firebase_debug (_dbg) = 1;
firebase_screen_id (_si) = 8314738347840858914;
item_id = Blah-tapMyProfile;
content_type = tapMyProfile;
}
or ...
2018-07-24 08:56:12.393306-0500 Blah[7501:135963] [Firebase/Analytics][I-ACS023073] Debug
mode is enabled. Marking event as debug and real-time. Event name,
parameters: select_content, {
firebase_event_origin (_o) = app;
firebase_screen (_sn) = MyProfile;
item_name = tapCamera;
firebase_realtime (_r) = 1;
firebase_screen_class (_sc) = Blah.OldDevDotScreen;
firebase_debug (_dbg) = 1;
firebase_screen_id (_si) = 8314738347840858915;
item_id = Blah-tapCamera;
content_type = tapCamera;
}
Notice tapMyProfile or tapCamera, one of my custom events from Analytics.logEvent#
Analytics as such does seem to be working perfectly:
so, those numbers update every few hours etc.
Again every item appears perfectly in the Xcode console ..
But no matter what, nothing will show up on the Firebase debug console!
Nothing!
What the hell could the problem be?
(Additionally I have waited a day or more and they don't show up as events either.)
How can it be that just nothing is showing up in Debug???
TL:DR - Delete your app from your device / simulator, rebuild and launch from XCode.
I faced this exact same issue even though Firebase and Firebase Analytics in particular seemed to be set up perfectly.
I cannot give the exact logical explanation yet as to why this worked, however one hint came from this Firebase events tutorial at around 5 mins 30.
He mentions that the -FIRAnalyticsDebugEnabled settings get saved to disk.
So after configuring & integrating Firebase, I ran my app which was already installed to test everything works fine and it did but the Firebase Console did not show me any messages of app events.
It's good to double check that you are not using special characters when sending your events and also not going over the character threshold, however even if you make these errors, you should see default events of screen_open, app_open, user_engagement which were not showing up for me.
My only theory is that launching the app from an already installed state does not impact the new settings of -FIRAnalyticsDebugEnabled.
So when I deleted my app, re-build and run from XCode, the events start showing up.
Finally, while testing, you might use another device and you might wonder, I was seeing my events from the previous device but nothing happens for the next one which baffled me for a few moments, remember to switch the device
However, in conclusion, I can say this behavior is far from reliable and because after a period of time (2-3 hours) when I ran my app again, nothing showed up on the Firebase Console again as if -FIRAnalyticsDebugEnabled had been disabled.
Deleting and reinstalling worked again.
Update for 2022
The above steps still applies. Just 2 more additions of why you might not see events you seem to be logging successfully:
Do a clean + build + run
There are some keywords that seem to not get logged because they are probably already in use by the Analytics framework. For example when I was trying to track a search event and one of the keys in my parameters dictionary was keyword and this never seemed to get tracked so use something else and give it a go
Check your device's time setting. Time needs to be accurate.
Did you enable Debug View for your app?
As per the docs, there is a minor difference on enabling debug events on the real-time and debug view that is embedded into Firebase Console UI.
To enable Analytics Debug mode on your development device, specify the following command line argument in Xcode :
-FIRDebugEnabled
For real-time logs on XCode console for the Arguments Passed On Launch section, add:
-FIRAnalyticsDebugEnabled.
It is been a long time since this question has been post. I have been struggling with this problem for over a week.
Everything was ok in my side, I saw it worked, like yours, in the Xcode debug mode. My issue was I did not look to the Debug View which is under the Analytics -> DebbugView in Firebase Console
Here is Debug View at the end of the analytics: Debug View
Documents in Firebase is here: In the firebase documents but the image is old.
It is in Analytics -> Debug View
Hope this will help someone!
Simply select which device you want from this "DebugDevice" dropdown menu. It's on the top left corner.
(It was driving me crazy for couple of hours! I hope Google will improve the UI of Firebase)
Make sure that the logged event name is longer than 40 characters, there is a limit for the length of the event name and parameter name.
https://support.google.com/firebase/answer/9237506?hl=en
Maybe it's not related to the question above, but I think it could help someone. Here's my case:
I was misunderstanding about when the user engagement update, I was thinking that it would be updated immediately after I've sent the event!
But it's not. You must to wait.
If you're wondering that, have you been successful sent the event to the board or not. You should check on the Debug-View section.
Related
I'm watching a cloud firestore list for changes using query.onSnapshop in a react-native-firestore app, currently testing on iOS.
While my app is in the foreground, I can make data changes elsewhere (eg. in my companion web app) and the mobile app immediately updates as expected. Usually, if I make changes while the app is closed or offline, they get picked up no problem once it is re-opened or comes online again. Happy days.
However, sometimes, when the app is in the background (not closed, just some other apps have been used in the meantime), I'll make a change elsewhere (eg. add/delete a record which meets the query's criteria), then when I come back to the app, the list does not change - eg. it contains deleted records, or doesn't contain the new ones. Nothing I do on the app can change this - it remains out-of-sync, even if I make local changes, like editing one of the records (even a deleted one). Changing network conditions also does nothing (eg. switching airplane mode off/on again).
The only way the list will get back in sync is if I make another change elsewhere, while the app is still in the foreground, or if I force-close the app and re-open it again.
The issue seems to occur when connecting to both the emulator, and the actual firestore.
I don't think I'm doing anything fancy. Basically following the examples in the documentation:
import React, { useEffect, useState } from 'react';
import firestore from '#react-native-firebase/firestore';
const MyAssignments = (props) => {
const [records, setRecords] = useState([])
useEffect(() => {
const onSnapshot = (snapshot) => {
console.log(snapshot) // this IS triggered but data is stale
setRecords(snapshot)
}
return firestore()
.collection('assignments')
.where('assignedTo', 'array-contains', props.userId)
.onSnapshot(onSnapshot, console.error);
}, [props.userId]);
// render the list
return ...
}
I'm not sure if this is a general firestore issue, a react-native-firebase issue, an issue with the underlying firebase ios SDK, or just my own misunderstanding?
In either case, is there a way to force the local cache to re-sync programatically, ideally when the app regains focus? Or has anyone solved a similar issue or have any ideas what to try next?
Edit 1: Note the code example above is slightly simplified for readability, as parts are spread across a few files and typed with typescript. In reality, I'm using crashlytics.recordError(e) for error handling in production, but console logging, as above, in development.
Edit 2: To debug, I've tried the following:
Switch on debug logging:
import firebase from '#react-native-firebase/app';
firebase.firestore.setLogLevel('debug');
However, this gave no extra logs in my javascript console.
I found I could view native device logs by following this guide and then filtering for Firebase, like so: idevicesyslog --match Firebase
This still shows very few logs, so I don't think debug logging is switched on properly. However, it does log this error every time I foreground the app:
<Notice>: 8.9.1 - [Firebase/Firestore][I-FST000001] WatchStream (10c244d58) Stream error: 'Unavailable: Network connectivity changed'
This error happens every time though. Even when the onSnapshot successfully picks up changes
On running purchase UITests with XCUitest, sometimes after tapping on the purchase button in the IOS native pop-up
Sign-in Required
doesn't display for a long time (more than 2 min).
The tests are running on a real device(iPhone 6 ios 12).
I've tried to reproduce it manually with no success.
Every time I tried it manually it works fine and most of the time it works fine with the automatic test.
This is the code that waits for the alerts and handles with the alerts with "addUIInterruptionMonitor"
func PurchaseTest1(elementName: String) -> Bool {
if TestUtilities.wait(forMax: 120.0, condition: { return app.buttons[elementName].exists }, doPerIteration: { self.app.swipeDown() } ) == false {
return false
}
return true
}
It's waiting for an element to appear, after every iteration, it swipes down to call to "addUIInterruptionMonitor" to check if there is an iOS pop-up to handle.
Most of the time it works and the pop-up appear but sometimes pop-up doesn't appear at all (I can see in the screenshots that I have for every test).
I had a similar problem. I saw network error, and some time didn't see any errors. I would do the following steps, I hope, It will fix your issue.
reset your device; When I was debugging an issue, I realize there is some certificate related issue that causing this problem.
I think you are making apple purchase, Sandbox allows for a certain time for one user. You can't buy a continuous basis like running over and over again. May be 30 min before you can start purchase again using the same users
Under subscription, Make sure you don't have an active subscription, It can be already purchased and didn't show that button
I think the test will pass if you change device and use new apple sandbox users.
EDIT: DEAR PEOPLE FROM THE FUTURE, trey-jones has fixed this issue by implementing setLoginBehavior, FBSDKLoginNative seems to have issues on FB's end not with the module.
Environment:
MacOS X 10.10.5
Ti SDK 5.1.1.GA - 5.1.2.GA
iOS 9.2
Ti.Facebook 5.0.0 - 5.0.1
My project settings (tiapp.xml) are fine (it works on every other case on both iOS and Android).
Code I'm using to invoke the login:
var fb = require('facebook');
fb.initialize();
fb.authorize();
If the Facebook app is installed to the device the fb.authorize() doesn't open up. I did not see any iOS system level messages when this happened either.
Has anyone else had luck using fb.authorize with the new sdk on iOS devices WITH the app installed. With no fb app on the system it correctly opens the browser based view.
EDIT: I have managed a workaround for this (it is not pretty) based on the fact that login works with AppC's KitchenSink.
The workaround is to add a Ti.FB loginButton to the code, doesn't matter if its not visible, initializing this will fix whatever is causing custom login's .authorize() to not work.
//Workaround button:
if(OS_IOS){
var fbHaxBtn = fb.createLoginButton({
readPermissions: ['email'],
visible: false
});
}
//It needs to be added to the window/doesn't need to be visible though
$.login_window.add(fbHaxBtn);
//Then in our custom button's code, we can fire as normal:
function doLoginClick{
fb.initialize(); //I was having unexpected issues dropping this line on Android, although the docs say its deprecated.
fb.authorize();
}
Will keep this ticket updated if/when this thing gets a formal fix.
This is my second answer on this question. I believe that my original answer offers some value to the conversation and that is why I am leaving it, but it still did not consistently solve the problem of the facebook authorization not working.
The consistent solution turned out to be modifying the official Ti.Facebook module. I will submit a pull request for this change (1 line), but for now, you can get the working module here:
Source
Pre-built
This consistently allows users to authorize by explicitly setting the login behavior to use the browser, rather than the native facebook app through fast app-switching. This is actually the intent of Facebook's developers.
I was unable to determine what is causing it to fizzle when trying to use the native app to login - it should try the next option, which is the browser - but this works, and doesn't require a TiFacebookButton either.
I hope it helps someone else!
EDIT: This answer does not solve the original question. I have left it here in case it helps with related difficulties using the Ti.Facebook module. See my other answer, to actually solve the problem. END EDIT
I commented above, but after doing so encountered some more strange behavior, with the result being that I could not reliably use the workaround given (fbHaxButton). I want to explain what was happening in my case, and show my own workaround (which is also not pretty). It's possible that the root cause is the same for both of us.
I have not bothered with Android yet, so this answer is specific to iOS.
When I started this process, I came to the conclusion that authorize was correctly opening the facebook website in safari to allow authorization, but was not firing the login event upon returning. To handle this I had already implemented the following:
facebook = require('facebook');
Ti.App.addEventListener('resumed', function (e) {
var launchOptions = Ti.App.getArguments();
if(!launchOptions.url) {
return console.warn('Ignoring resume event with no url argument.');
}
// this lib = https://github.com/garycourt/uri-js
var URI = require('vendor/uri'),
uriComponents = URI.parse(launchOptions.url),
expectedScheme = 'fb',
expectedHost = 'authorize';
// I would like to be more specific about the uri, but we are limited
// in Titanium, and this will allow us to pretty certain
// that FB is sending us back to our app
if(uriComponents.scheme.search(expectedScheme) < 0 || uriComponents.host !== expectedHost) {
return console.warn('Resume event received, but scheme is incorrect. Ignoring.');
}
// synthesize login event
facebook.fireEvent('myapp:login', {
success: 1,
token: facebook.getAccessToken(),
uid: result.id
});
});
facebook.addEventListener('myapp:login', function onFacebookAuth(e) {
facebook.removeEventListener('myapp:login', onFacebookAuth);
if(!e.success) {
// do fail action
}
// do success action
});
facebook.initialize();
facebook.authorize();
So, originally I was firing and listening for an event called 'login', which the facebook module supposedly (according to the docs) will fire after authorization is complete.
In my case, this event was being fired while my app was in the background, after authorize was called, but before the user actually clicked 'OK' in facebook. My listener would respond to this event (logging, etc), but seemed to occur in a separate thread, or somehow otherwise become disconnected from my app, as it never passed its result along to the UI. I am using Q.js (kriw-kowal) and I belive this is where the disconnect is occuring.
Ceasing to listen to 'login', and simply handling my own synthesized event has fixed my issue.
I felt that this was very difficult to explain. If you have feedback about that, and how I can be more clear about what I believe is happening, or if you believe that I have reached wrong or incomplete conclusion, let me know - I'll try to update this answer to be better.
I have a strange problem. After I logged in with the standard SPLoginViewController, I save the username and the credential. After I startup again, I try to call:
[[SPSession sharedSession] attemptLoginWithUserName:
existingCredential:
On the iOS Simulator (iOS 6.0), it works just fine. On my iPhone (iOS 6.0.1), it does not. SPSession is logging in exactly five minutes after I called the attemptLogin method. SPSession is also logging in when I put my app in the background.
Does anyone know more about this and maybe a solution?
Thanks
It appears there's a known bug in libspotify where sp_session_process_events() will sometimes return excessively high values in next_timeout. I've seen values such as 300100 and 300195 come out of the routine.
One workaround is to set your wait to the max of next_timeout and 50. (Or 100 or whatever your heart desires.) See https://github.com/spotify/cocoalibspotify/issues/140
I wish Spotify would start a known-issues list for libspotify. I wasted over a day trying to dig this one out. Hopefully this post will save someone else the same fate.
I am testing the new Google-powered Firebase, and have implemented remote notifications and crash reporting. I am, however, having massive problems with getting Analytics to work.
I track events with FIRAnalytics.logEventWithName(...) and save user pproperties with FIRAnalytics.setUserPropertyString(...). However, no matter what I do, no data shows up in the Firebase Analytics Console.
Well, I do receive some events, but those are not sent by me (like first_open and session_start). Also, this data seems to drop in after a very long time.
Furthermore, when I track events and save user data, I receive the following:
Upload task scheduled to be executed in approx. (s): 3102.294599890709
This seems really strange - Firebase waiting almost an hour before trying to send the next batch of data must be a bug, or is it configurable? When I waited that extremely long delay out, data was sent...but does not show up.
Firebase events are batched together and uploaded once every hour in order to prevent excessive battery drain on the devices. On iOS when you background the app before the 1h upload target the events will be dispatched at this time in the background.
You can enable debug logging for iOS (https://firebase.google.com/docs/analytics/ios/events#view_events_in_the_xcode_debug_console) to see when events are uploaded in debug console.
Once the events are uploaded there is delay at about 3h before the data will show up in the Firebase Analytics dashboard. Also the default day range excludes "today" so you only see events from yesterday. You can switch the date picker to include Today if you like to see the latest events.
The main reason to delay/batch data uploading is to save battery. Each time the network is used the device mobile network modem is put in hi power mode and stay in this mode for a while. If network is used regularly it has sever impact on the battery life. By batching the uploads together and delaying the upload the impact on the battery is significantly reduced.
In Swift it should be like:
FIRAnalytics.logEvent(withName: "SignUp", parameters: ["user_id": userid, "user_name": username])
To view this event in Firebase:
Go to Firebase console → Analytics tab
Click on DebugView tab; your Events are shown there
To view this event in Xcode:
In Xcode, select Product → Scheme → EditScheme
Select Run from left Menu
Select Arguments tab
In the Arguments Passed on Launch, add -FIRAnalyticsDebugEnabled
One dash only!!
Note that -FIRAnalyticsDebugEnabled has only ONE dash in front of it.
If you are not receiving events in console, it may be because you are not following naming convention, as I experienced if there is a space in event name it will never show up in the console like following:
mFirebaseAnalytics.logEvent("Add Camera", bundle);
But when you remove the space like following:
mFirebaseAnalytics.logEvent("Add_Camera", bundle);
Now you will see events in console, after approximately 3 hours.
Application will dispatch the data to console in following cases:
1- Data is more than an hours old
2- App goes into the background
You can watch this tutorial for more information:
Getting Started with Firebase Analytics on iOS: Events - Firecasts
Another thing to check is making sure your logging entries in the Arguments Passed on Launch are correct. They should start with a - e.g
-FIRAnalyticsDebugEnabled
and not
FIRAnalyticsDebugEnabled
I wasted an hour the other day wondering why nothing gets logged.
React-Native App (IOS/Android)
I had the same problem, debugView wasn't working, and streamView glitches a few times, the best way ive found to test my events was to logEvents with my createPageEvent() and then
the important thing is to put the app into background after logging the events, they will show up almost in realtime on firebase events or in streamView (check this article to see when events are sent to firebase)
events are only sent after 1 hour since they have been logged or immediately if you put your app in background.
import firebase, { RNFirebase } from 'react-native-firebase';
export default class AnalyticsService {
static async initialize() {
firebase.analytics().setAnalyticsCollectionEnabled(true);
}
static async createPageEvent(screen: string) {
firebase.analytics().setCurrentScreen(screen)
firebase.analytics().logEvent(`open_${screen}`)
}
}
the result is this in streamView almost realtime ->
Now you can start building funnels and stuff
first_open, session_start are listed by Firebase as Automatically collected events.
I can not help you with the extreme upload task delay you encounter on your custom events.. but Firebase Analytics is less than a week old and it may be just a bug on their side.
I found this StackOverflow question which mention the same debug lines but related to Google App Measurement or old Google Mobile Analytics SDK.
Also, be aware that Firebase Console won't show events in real-time (source):
You can view aggregrated statistics about your events in the Firebase console dashboards. These dashboards update periodically throughout the day. For immediate testing, use the logcat output as described in the previous section.
Just a simple note here: according to this little video https://www.youtube.com/watch?v=5pYdTgSkW5E after playing with your simulator you must press the home button on the Xcode, otherwise the data will not be sent to the server.
The most common problem most of the people are facing is the firebase is not logging events even though everything is working perfectly fine
This is what i found in there docs
If you need to deactivate Analytics collection permanently in a version of your app, set FIREBASE_ANALYTICS_COLLECTION_DEACTIVATED to YES in your app's Info.plist file. Setting FIREBASE_ANALYTICS_COLLECTION_DEACTIVATED to YES takes priority over any values for FIREBASE_ANALYTICS_COLLECTION_ENABLED in your app's Info.plist as well as any values set with setAnalyticsCollectionEnabled.
To re-enable collection, remove FIREBASE_ANALYTICS_COLLECTION_DEACTIVATED from your Info.plist. Setting FIREBASE_ANALYTICS_COLLECTION_DEACTIVATED to NO has no effect and results in the same behavior as not having FIREBASE_ANALYTICS_COLLECTION_DEACTIVATED set in your Info.plist file.
So you have to remove FIREBASE_ANALYTICS_COLLECTION_DEACTIVATED from your google-servicesinfo.plist file to make analytics work
Make sure your device is not set to battery save mode. In this mode events may be accumulated and sent only once in a while, even if you run firebase in debug mode as explained by others.
It takes too much time to update events in Firebase. Probably it is done once a day. See iOS or Android logging of Firebase events.
You can enable verbose logging to monitor logging of events by the SDK
to help verify that events are being logged properly. This includes
both automatically and manually logged events.
You can enable verbose logging as follows:
In Xcode, select Product > Scheme > Edit scheme...
Select Run from the left menu.
Select the Arguments tab.
In the Arguments Passed On Launch section, add
-FIRAnalyticsDebugEnabled.
The next time you run your app, your events will display in the Xcode
debug console, helping you immediately verify that events are being
sent.