Firestore goal tracker database modeling - firebase

I want to model my flutter firebase app, that will consist of tracking users goal/habits (kind of a todo app) and users can share their own goals and others can add them to become their goals and we can see for example where everyone is progressing on a specific goal for example :
John : 5/7 days checked
William : 3/7 days checked
This is an example of the modal I came with for now, I don't know if I should add a list of "members" for example for adding users that add this goal to their or duplicating the goal itself, the main thing is to watch the progress of all users who added that goal

As per I understood what you can do is create an user collection and goals collection separately.
Register each user under user collection using there auth uid {document} and relevant data.
So if you want to fetch user data all you can do is :
FirebaseFirestore.instance.collection('users').doc(auth.uid).get() and further logic
While in other hand while registering / tracking goals of the users keep all the goals under single collection with a name you prefer {I prefered it as goals} and as you defined additional parameter as owner of the goal pass the user UID as you described.
For the part how are you gonna access the data -
Lets consider I am a user and I have some goals I set, as you can see I am keeping the goals of all users under the same collection. So to fetch the goals for specific user I can do
FirebaseFirestore.instance.collection('goals').where('owner', isEqual: auth.uid)
and get this stream as my user specific goals.
Now second scenario lets suppose I am a user and I want to share the goals to all of the users who are using the app simply I can add one more field to my goals collection as visibility : public/private. So while on a screen where I am fetching goals all over the world (basically goals which are made public to all of the app users) I can write query as
irebaseFirestore.instance.collection('goals').where('visibility', isEqual:'public')
In third scenario lets say you want to send your goals to specific user you can maintain an array of uids you have added in your goals field as access so you can see shared goals by
FirebaseFirestore.instance.collection('goals').where('access', arrayContains: auth.uid)
And last suggestion is time stamping the goals this will help you to fetch the newer goals in order using queries.
I hope it is so much easy than I explained

Related

GA 360 export to Big Query

We have just linked our GA360 account to BigQuery but we noticed from the docs that the userId doesn't get exported. This is really annoying as one of our main use case was to join the userId with our CRM system.
Why is Google not exporting the userId ? Is there workaround ?
Thank you for your answers.
The solution is to create a User level custom dimension and pass your user's ID into that as well.
There's no restriction on exporting your custom dimensions, and these are exported to BigQuery.
Enjoy :)
How User-ID works
User-ID enables the association of one or more sessions (and the activity within those sessions) with a unique and persistent ID that you send to Analytics.
To implement User-ID, you must be able to generate your own unique IDs, consistently assign IDs to users, and include these IDs wherever you send data to Analytics.
For example, you could send the unique IDs generated by your own authentication system to Analytics as values for User-ID. Any engagement, like link clicks and page or screen navigation, that happen while a unique ID is assigned can be sent to Analytics and connected via User-ID.
In an Analytics implementation without the User-ID feature, a unique user is counted each time your content is accessed from a different device and each time there’s a new session. For example, a search on a phone one day, purchase on a laptop three days later, and request for customer service on a tablet a month after that are counted as three unique users in a standard Analytics implementation, even if all those actions took place while a user was signed in to an account. While you can collect data about each of those interactions and devices, you can’t determine their relevance to one another. You only see independent data points.
When you implement User-ID, you can identify related actions and devices and connect these seemingly independent data points. That same search on a phone, purchase on a laptop, and re-engagement on a tablet that previously looked like three unrelated actions on unrelated devices can now be understood as one user’s interactions with your business.
From Google analytics about the userid feature the user id is used in the background by google analytics to analyse your data.
If you want to analyse on the user id you can just add it as a custom dimension you will then be able to see it.

How to make a dynamic room for multiplayer quiz app using firebase?

I am making an app.. I mean a game type app. it's a quiz app where two people can
pair them up and can answer questions one by one and so on.
what I want is:
I want to make a virtual room,
when USER1 want to play he will click search competitor, a virtual room with random string key will be made with one player.
then when USER2 will click on find competitor button his room will also be created and he will also search all rooms created before him, if any room have less than 2 users then he will join that room and start playing.
I am new so I am not sure if that is good approach but that's all I have planned.
how to count childs of a node (node that we does not know whats its key..
)
see attached image
please find image here
Good start. It's always best to articulate precisely what you want before your start coding. It sounds like you have a pretty good idea of what you want.
I would recommend using Firestore and firebase.auth, even if only anonymous, so that each user can have 'state' and univeral id in their app. In other words when they close and re-open the app, the app keeps a universal id, uid, for them.
If I understand your requirements:
each user can have more than one room
each room has a max of 2 users
Scalability
As far as searching existing rooms, this will not scale without some categorization. What happens if you have 1,000 rooms? How will users search all that? So you would want to add subject matter, or tags, to each room. That way you can query where("tag")==chosenTag.
Basically each virtual room has fields identifying the 2 users (uid's), AND has subcollections - each collection has a document
uid has fields (accountCreateDate, favoriteColor, AND the uid of each room (as a key) they engage in where the value would be an integer where, for example (1== awaiting response, 2==closed, 3==whatever).
Firestore Structure
users(collection > userUid(document containing aboce said)
rooms(collection) roomA(Document w field identifying subject/name) AND sub-collection containing a doc for each pair of participants.

Possible to use ecommerce tracking to track multiple users for a single transaction?

We're creating a flow for boarding new customers and would like to use the enhanced ecommerce tracking of universal analytics to track the boarding steps.
A single applicant fills in a form supplying information about their business and delivery addresses and such. The problem is that after the application has been submitted, the applicants need to electronically sign an agreement. There can be multiple people signing, and the person signing therefor doesn't necessarily need to be the same person that filled in the application. Is it possible to track a flow where another user/session takes over and finalizes the application?
If all participants in the application process sign in with a token - same token for all - you can set it as userID and enable session stitching - you'll need special userID view (and update your privacy policy) which will only show visits for which the userID was set and will recognize users across multiple computers, devices etc.
However this will still give you aggregated data only, so if you want to track individual users in addition to the flow you have to set the userID as a custom dimension (talk to your lawyer first, even with an anonymous ID profile building might be a privacy issue). The userID must contain nothing that would allow anybody but your own company to identify a specific user or device (no e-mail-addresses, no MAC addresses etc). Then you can pull the individual data with the custom dimension as key and match it with your CRM data.
No guarantees, but that seems the closest you can get to your requirements using GA.

Getting UserID details into Google Analytics

I'm trying to get the Google UserID working so that I can identify certain users journeys through my website.
I've enabled the USER ID feature as per the docs, which created a new view named Users in my Analytics account. There's data in there, but I can't see to separate it. It looks like a standard account.
How do I spilt data by the user ID I've given them?
You don't. Userid is not displayed. It is used to stitch user sessions together when users come from multiple devices, it does not identify individual users in the interface.
If you want to do that you have to use a custom dimension and store an identifier per user there.

Filtering Repeater items based on user status/role

I have a tricky requirement where I need to categorise documents attached to a product, available for download, based on the status of the user viewing the product. I.e. my site displays a list of products, clicking on one displays a product details page, and this page includes a list a documents related to the product, such as data sheets, user manuals, etc.
I have been asked to group documents into three classes of availability, v.i.z. those available freely to all users, including anonymous; those available to logged on users; and those available to anonymous users that provide contact information before downloading the document, presumably to boost sales leads.
The anonymous and logged on availabilities are quite easy, but the third seems a bit tricky to me. My first question is, is there a way I can filter documents for only logged on users without hooking into ItemDataBound or something, and my second question is, what is recommended for the case where a user must supply contact information to download a document?
In the second question, it has crossed my mind to actually register the user, but without them having to visit the new user registration page, and then I have role based filtering of documents. Currently the new user registration process automatically adds the Member role to all new users. Users I register 'quietly', just so they can download a document, wont be assigned the Member role, distinguishing them from normally logged on members. What other approaches could I take?
A lot of this implementation will depend on exactly what you want to accomplish and how you go about doing it.
For example, if I don't have access to the document, should I see the link?
If your implementation is that all users should be able to see it, but that the actual act of 'getting it' is dependent upon the individual role or membership, you could solve it fairly easy by implementing a "handler" to download the secured documents, that way you are not presenting a direct file link. That handler could then validate security, if they were not allowed, it could then take them to the login or register page as needed.
If the users don't see the documents until they meet the requirement, I would then filter BEFORE you bind to your repeater.

Resources