Firebase Analytics: combine paramaters/values in console-view - firebase

I'm new to Firebase (and stackoverflow) and have a question:
Is it possible in the console view for firebase to combine the data? What I want to achieve is that when in "parameter_name" I select for example the "scene_interaction" and automatically the "scene_name" displays only the values for the "scene_interaction"-parameter (and ignoring "button_pressed" and "main"). See screenshot for this:
The event is logged as follow:
parameterEntry = new Firebase.Analytics.Parameter[]
{
new Firebase.Analytics.Parameter("parameter_name", parameterList[i].parameterName),
new Firebase.Analytics.Parameter("action_value", parameterList[i].value),
new Firebase.Analytics.Parameter("action_type", parameterList[i].type),
new Firebase.Analytics.Parameter("scene_name", parameterList[i].scene),
new Firebase.Analytics.Parameter("scene_type", parameterList[i].scene_type)
};
}
Firebase.Analytics.FirebaseAnalytics.LogEvent(eventName, parameterEntry);
I hope someone can help me. Preferably without the use of BigQuery.

Related

How to efficiently update a field in Firestore from Google Sheets

I am working with Google Sheets, and I am trying to send data to my Firestore database. I have been able to write to Firestore from Google Sheets, but I can't seem to update a field without completely messing things up.
This is my current testing code:
function getFireStore() {
const email = "your#email.gserviceaccount.com"
const key = "-----BEGIN PRIVATE KEY-----\n your key here \n-----END PRIVATE KEY-----\n";
const id = "project_id";
var firestore = FirestoreApp.getFirestore(email, key, id);
var spreadsheet = SpreadsheetApp.getActive()
var sheet = spreadsheet.getActiveSheet()
var data = {
numIndividuals: sheet.getRange(23, individuals).getValue(),
numTeams: sheet.getRange(23, teams).getValue(),
schoolID: sheet.getRange(23, schoolID).getValue(),
uid: sheet.getRange(23, uid).getValue(),
};
firestore.createDocument("competitions/" + sheet.getRange(23, compId).getValue() + "/registration/abcdefg", data)
}
I understand after playing around with this that it will create a new subcollection titled "registration" with the document "abcdefg." The same thing happens when I use the updateDocument function, as well.
For the website that is reading and writing to this particular Firestore database, I use a similar function .update() to update the document with the correct information. However, in Google Sheets, while it would work the same way it is much more convoluted and tedious to do so.
The way that I came up with for trying to update the document was basically copying everything and adding in the new data.
However, this is seriously tedious and messy. Just copying the data that isn't changed looks like this:
var data = {
compDate: competitions.fields.compDate.stringValue,
contact: competitions.fields.contact.stringValue,
email: competitions.fields.email.stringValue,
grade: competitions.fields.grade.stringValue,
id: competitions.fields.id.integerValue,
maxTeams: competitions.fields.maxTeams.integerValue,
regDate: competitions.fields.regDate.stringValue,
schTeams: competitions.fields.schTeams.integerValue,
schedule: competitions.fields.schedule.stringValue,
site: competitions.fields.site.stringValue,
status: competitions.fields.status.stringValue,
timestamp: competitions.fields.timestamp.integerValue,
user: competitions.fields.user.stringValue,
year: competitions.fields.year.stringValue,
}
The data I want to change is a .mapValue with multiple fields where one of the fields can have multiple fields, which also have multiple fields.
Here's the hierarchy for the field I need to update:
first registration and first team
I know I could do multiple for-loops and whatnot on this, but my question is: is there a simpler way to do this, or do I have to go through and loop over everything to extract only what I want?
As a sidenote, what gets sent to Firestore if I put in the data I got from Firestore using the spread operator, without any editing, it includes every child from the above image. As in, I would have registration -> mapValue -> fields -> 0 -> mapValue -> fields -> etc. And, I don't want those mapValue and fields included, just that actual data (i.e. registration -> 0 -> {schoolID, uid, names, etc.}).

Sync google Form via Spreadsheet to Firebase

I have a survey in a google form which gets stored in a google sheet. From the google sheet data get synchronized with firebase.
I have my trigger "when changes occur" made in the google sheet since my answers are automatically stored in there.
The Problem is, that the trigger does not get called, when a user is submitting the answers.
But if I write directly in the google sheet, my script gets called and data are stored in firebase.
But when I perform my script manually it also gets stored in firebase.
So it basically seems that the google sheet trigger does not get triggered when data are getting passed by the form itself.
Do I have to write a script for the form as well?
This is my script for the sheet:
function writeDataToFirebase() {
var ss = SpreadsheetApp.openById("SpreadsheetID");
var sheet = ss.getSheets()[0];
var data = sheet.getDataRange().getValues();
var dataToImport = {};
for(var i = 1; i < data.length; i++) {
var timeStamp = data[i][0];
var uuid = data[i][62];
dataToImport[timeStamp] = {
timeStamp:timeStamp,
uuid:uuid,
a:data[i][1],
b:data[i][2],
c:data[i][3],
d:data[i][4],
e:data[i][5],
f:data[i][6],
g:data[i][7],
var1:data[i][8],
var2:data[i][9],
var3:data[i][10],
var4:data[i][11],
var5:data[i][12],
var6:data[i][13],
var7:data[i][14],
var8:data[i][15],
var9:data[i][16]
};
}
var firebaseUrl = "URL" ;
var secret = "Secret
var base = FirebaseApp.getDatabaseByUrl(firebaseUrl, secret);
base.setData("", dataToImport);
}
Maybe someone can help me how I can fully automate this procedure
When using Apps Script triggers it is important to keep the following in mind:
Script executions and API requests do not cause triggers to run. For example, calling Range.setValue() to edit a cell does not cause the spreadsheet's onEdit trigger to run.
The same scenario applies to your situation when using the trigger you chose.
Since you want this function to run when you receive an answer in your form, the best approach in this situation is to use an onFormSubmit trigger.
Reference
Apps Script Triggers.

How to Set/Get "Last Saved on" Information for a baseline using Aspose.Tasks

I want to export data and create MsProject File using Aspose.Tasks. I am able to export data from my local db to project file successfully but while exporting Baseline information I am not able to find how to set "Last Saved on" information for the baseline. I am using below code to create and set baseline.
project.SetBaseline(BaselineType.Baseline, new Task[] { task });
var baselineType=BaselineType.Baseline;
TaskBaseline baseline = task.Baselines.FirstOrDefault(x =>
x.BaselineNumber.Equals(baselineType));
if (baseline != null)
{
if (!String.IsNullOrEmpty(baselineDto.Cost))
baseline.Cost = Convert.ToDecimal(baselineDto.Cost);
}
If Anyone has any idea how to Get/Set "Last Saved on" Information for a baseline, please share.
Thanks.
Bhupesh
I have observed your requirements and like to inform that we can only get Last Saved information using Aspose.Tasks. I have shared following sample code. This will help you to achieve your requirements.
var s = #"c:\test\baseline msp 2016.mpp"; Project p = new Project(s);
Console.WriteLine(p.GetBaselineSaveTime(BaselineType.Baseline));
Console.WriteLine(p.GetBaselineSaveTime(BaselineType.Baseline1));
Console.WriteLine(p.GetBaselineSaveTime(BaselineType.Baseline2));
I am working as Support developer/ Evangelist at Aspose.

Firebase "child_added" event

I want a function to be called whenever a new child is added to "chat". I know this can be done using "child_added" event. However, from that function, I want to modify the newly created child.
So suppose a new child "123456" is added to chat and I want to update the "123456" object in the DB. I think I could solve the problem if I somehow manage to get the key (in this case it's 123456) of the newly added object. Is there a way to achieve this?
That should do the trick:
ref.on('child_added', function(childSnapshot, prevChildKey) {
var key = childSnapshot.key;
...
});
You will find more info at:
https://firebase.google.com/docs/reference/js/firebase.database.Query#on
u can also use firebase cloud functions as well by putting a trigger, so that this can be handled by server.
export const onNewChatTrigger = functions.database.ref('chat/{chatId}').onCreate(event => {
let key = event.params.chatId;
let data = event.data.val();
...
});

firebase - Accessing child of of database

Im new to Firebase and am having trouble access some nested JSON data. Here is my data structure:
In Samples I have a set of JSON data which I am trying to access. Previously I had the database setup so that there was no "users" subcategory and all the samples JSON data was in the root and the data was loading fine like this. Since creating parent categories i've had trouble trying to access the Samples data. Here is how i'm trying to reach it (using React):
componentWillMount() {
var db = firebase.database();
var ref = db.ref('music-app-7a4d3').child("samples");
ref.once('value')
.then((snapshot) => {
var samplesObject = snapshot.val();
this.setState({
samples: samplesObject
});
});
},
The componentWillMount function basically sets the initial state of the app with the objects found in samples. I'm a little bit lost as I thought I could access the next tier down by using the .child method but its not finding the data. Where am I going wrong here?
As requested heres an expanded view of my data:
Try this:
var ref = db.ref('music-app-7a4d3/samples/your/awesome/subitem');
EDIT:
try remove the music-app-7a4d3 keep only this: /samples/your/awesome/subitem

Resources