I want to track a simple Firebase event in my mobile game - When the player hits a score of 25, I want them to be labeled as an "active_player"
The code I got from my programmer looks like this, but it doesn't track in Firebase. Any thoughts of what could be wrong?
public void ReportScore(int score)
{
Social.ReportScore(score, GPGSIds.leaderboard_total_icons,(bool success) =>
{
Debug.Log("Score reported: " + score);
if (score == 25)
{
Firebase.Analytics.FirebaseAnalytics.LogEvent(
Firebase.Analytics.FirebaseAnalytics.EventSelectContent,
new Firebase.Analytics.Parameter("active_player", score));
}
}
}
If I understand the question correctly, you want to create an audience of players whose scores are above 25. What the code there does is log an EventSelectContent event with a parameter "active_player" whose value is 25.
To create an Audience of people who have logged that event with that parameter.
I don't think this is the best way to achieve your goal though. You can create your own events. For example, you could replace the above line with:
Firebase.Analytics.FirebaseAnalytics.LogEvent("active_player");
at which point you could create an audience of everyone whose logged that event without diving into parameters.
But what I think you really should do is set a user property. This way you can easily categorize all the users who've achieved this goal. You could say something like:
FirebaseAnalytics.SetUserProperty("gamertype", "active");
to mark a user as active.
Finally, I'm not sure what your overall goals are, but you may actually be better served by Firebase Predictions. A prediction that's automatically calculated for you is "churn" or "a user about to stop playing your game" or "not churn" which is basically your active player. Predictions do need more daily active users before they're active, but they have the potential of being the most beneficial if you're trying to take pre-emptive measures to retain your users. I think this Medium post can shed more light on why you might choose predictions over just an analytics property.
Hopefully this helps!
--Patrick
Related
I am trying to build a quiz game using alexa.net. However i´ve run into a potential problem.
Whenever the user has answered a question and the answer has been evaluated i want to immediately ask another question.
As it is right now, the user has to manually request another question. What i would like to have happen, was that the intent that handles the question keeps calling itself until the user actively chooses to end the game.
Is that even possible? If so, can anyone point me in the right direction, maybe even write up a brief hello-world style example?
Suppose you want to create a math quiz game where Alexa will ask you random math questions and you have to provide the right answer. The game has to continue until the user ask specifically to quit.
Create an AnswerIntent which is triggered when the user says an answer. Our answers are numbers, so create this intent with AMAZON.NUMBER slot which lets you capture the numbers spoken. (Choose your slot according to the answers for your questions).
Sample utterance for AnswerIntent:
{number}
the answer is {number}
is it {number}
{number} -> AMAZON.NUMBER slot
So each time when the user says an answer to your question you will receive a POST request in your backend with the intent triggered (in this case AnswerIntent), slot and its value. Then:
Validate the answer.
Update the score (if at all your usecase has a score)
Generate the next question.
Provide a response with the next question.
You will only receive a request at your backend when there is a user interaction. So make sure that when the user says an answer, your response has the next question to asked. In this way the user can continue answering questions without asking for a question explicitly.
Sample Interaction:
User : Alexa, open math quiz
Alexa: Welcome to math quiz. Here is your first question.
What is the sum of five and four.
[you will receive the launch request and your response has the first question]
User : Nine
[you will receive AnswerIntent request, with number slot having value 9.
Validate the answer and generate the next question]
Alexa: Correct!. Here is your next question.
What is the product of ten and five.
User : Twenty.
Alexa: Wrong, the right answer is fifty.
here is your next question.
What is sum of two and six.
User : Stop
[AMAZON.StopIntent is triggered and you can now end the game.]
Alexa: Bye.
Use sessionAttributes to store some information about the question or its answer so that you can validate it easily at the backend when your receive a response from the user.
there are a lot of websites where you can get a list of all followers from an Instagram profile. For example the profile of Jennifer Lopez. If I click on followers and scroll the hole list down, I only see round about 1000 users. Is there any way to get a list of all followers, or something in the range between 10 thousand and 100 thousand users? How do the others do it?
Here are a few pages where it seems to work:
crowdbabble
Instagram Scraper
magimetrics
I would be very grateful if you could help me!
I believe most of the pages you are seeing is using the Instagram API (or the method described below). However, that is a bit hard to get access to without an application that they are happy with. As far as I have understood it, you will have to make the application before you know if you will have access, which is a bit stupid. I guess they are trying to stop new users from using it while they keep letting the people already using it keep using it.
The documentation for their API seems to be missing a lot of what was available earlier, and right now there is no endpoint to get followers(that might be something temporarily wrong with the documentation page: https://www.instagram.com/developer/endpoints/).
You could get the followers the same way the Instagram webpage is doing it. However, it seems only to work if you request up to around 5000-6000 followers at a time, and you might get rate limited.
They are making a GET request to: https://www.instagram.com/graphql/query/ with the query parameters query_hash and variables.
The query_hash I guess is a hash of the variables. However, I might be wrong since it will keep working even tho you change the variables. The same hash might not work forever, so its possible you would have to get the same way the Instagram page is doing it. You will get that even tho you are not logged in, so I would not think it would be very hard.
The variables parameter is an URL encoded JSON object containing your search variables.
The JSON should look like this:
{
"id":"305701719",
"first":20
}
The id is the user's id. The first is the number of followers you want.
The URL would look like this when you encode it. https://www.instagram.com/graphql/query/?query_hash=bfe6fc64e0775b47b311fc0398df88a9&variables=%7B%22id%22%3A%22305701719%22%2C%22first%22%3A20%7D
This will return a json object like this:
"data": {
"user": {
"edge_followed_by": {
"count": 73785285,
"page_info": {
"has_next_page": true,
"end_cursor": "AQDJzGlG3jGfM6KGYF7oOhlMqDm9_-db8DW_8gKYTeKO5eIca7cRqL1ODK1SsMA33BYBbAZz3BdC3ImMT79a1YytB1j9z7f-ZaTIkQKEoBGepA"
},
"edges": [
{
"node": {}
}
]
}
}
}
The edges array will contain a list of node elements containg user info about people that are following the person you where searching for.
To get the next x number of followers, you would have to change the json used in the variables query to something like this:
{
"id":"305701719",
"first":10,
"after":"AQDJzGlG3jGfM6KGYF7oOhlMqDm9_-db8DW_8gKYTeKO5eIca7cRqL1ODK1SsMA33BYBbAZz3BdC3ImMT79a1YytB1j9z7f-ZaTIkQKEoBGepA"
}
after would be what you received as an end_cursor in the previous request.
and your new URL would look like this: https://www.instagram.com/graphql/query/?query_hash=bfe6fc64e0775b47b311fc0398df88a9&variables=%7B%22id%22%3A%22305701719%22%2C%22first%22%3A10%2C%22after%22%3A%22AQDJzGlG3jGfM6KGYF7oOhlMqDm9_-db8DW_8gKYTeKO5eIca7cRqL1ODK1SsMA33BYBbAZz3BdC3ImMT79a1YytB1j9z7f-ZaTIkQKEoBGepA%22%7D
This way you can keep looping until has_next_page is false in the response.
EDIT 23/08/2018
Instagram seems to have blocked any scrolling/query hash request to get followers list/likers list on a post, at least on desktop, even for your own account.
https://developers.facebook.com/blog/post/2018/01/30/instagram-graph-api-updates/
It should be although still possible from a phone, maybe following a Selenium-like for mobile, using Appmium : http://appium.io/
Maybe some reverse app engineering may also be the key, if any idea from that side :
https://www.blackhatworld.com/seo/journey-instagram-app-reverse-engineer.971468/
EDIT 25/08/2018
It seems to be back... if any information about it ?
I have a question I am stumped on.
Okay, this is for a game of mine in Unity3D.
To make this make sense in terms of what people normally play.
Let's say the player has 500 Gold in their account (saved on database).
And the player earns 243 gold by doing some kind of task, how could the game
(Unity3D) tell the PHP file they earned specifically 243 Gold?
Because here's where the issue lies,
In Unity3D there's a class called WWW.
It allows you to send some sort of string to a PHP file.
int currentGold;
string goldToSend = currentGold.ToString(); // Only using that for example.
WWWForm form = new WWWForm();
form.AddField("NameOfPostRequestInPHPFile",goldToSend);
WWW www = new WWW("website.com/PHPFile.php", form);
Now as you can see, I am in a pretty big dilemma, being you can't trust the client with anything, how would one actually send a random gold amount from the client side to the PHP to then put into a database.
The issue I am facing is, how can one really make a PHP understand what's going on in the game without the client actually telling it a thing, and being you can't trust the client, how can the client actually tell the PHP to load, use this data and then put it into the database.
I thought about using hashes an stuff, but then that still brings up the problem client side.
Lets say
if(sentGold == 243){
string hash = hash01;
// Change it to hash1000 (to get 1000 gold).
}
if(sentGold == 1000){
string hash = hash1000;
}
As you can see, using if statements clearly wouldn't work either, because then the hashes could just be changed locally to fit their devious attempts. Plus it looks like garbage to had 20K if statements.
I know it's impossible to entirely stop hacking. But at the same time, if I do something i want to do it right, not half-a**ed if you get what I mean?
If you've made it to this point reading my help message.
I really appreciate the time you've put into reading it,
it means a lot to me.
Now, if there's some other technology or hints you might know that could help me with this, or heck even a tutorial on it (i've been looking for days), but I'm still deadlocked because nobody is addressing the fact that yeah they might use secret keys and so forth, but they are failing to address that the string they send can be easily tampered with. All they gotta do is change for 243 to 9999999999 and then they are rich.
You can't trust the client? Correct.
But...You are the captain of this ship. So your server need to be smart enough to detect the cheating.If a certain task in game gives 200 gold, you can send the reference of that task along with the value (200,"SomeTask"). Now if client tries to send (10000,"SomeTask"), server would consider it cheating. You might say that client can earn variable gold based on how good they perform the task, in that case you can have a max-limit value for every task and check before adding the gold to database.
And never send total gold from client to be saved in database. Client should only be able to send newly earned gold and will gets back total value.
For Example:
Database: 2000 gold -> Game: 2000 gold
Game: POST (130,"pickupjewel");
Databse: if (130 <= MaxValue("pickupjewel")) [TRUE] -> SUCCESS
Database: 2130 gold -> Game: 2130 gold
Game: POST (999999,"pickupjewel");
Databse: if (999999<= MaxValue("pickupjewel")) [FALSE] -> FAILURE
Database: 2130 gold -> Game: 2130 gold
I hope this helps. Let me know if you have any specific issue.
I'm really interested in the Numl.net library to scan incoming email and extract bits of data. As an example, let's imagine I want to extract a customer reference number from an email, which could be in the subject line or body content.
void Main()
{
// get the descriptor that describes the features and label from the training objects
var descriptor = Descriptor.Create<Email>();
// create a decision tree generator and teach it about the Email descriptor
var decisionTreeGenerator = new DecisionTreeGenerator(descriptor);
// load the training data
var repo = new EmailTrainingRepository(); // inject this
var trainingData = repo.LoadTrainingData(); // returns List<Email>
// create a model based on our training data using the decision tree generator
var decisionTreeModel = decisionTreeGenerator.Generate(trainingData);
// create an email that should find C4567890
var example1 = new Email
{
Subject = "Regarding my order C4567890",
Body = "I am very unhappy with your level of service. My order has still not arrived."
};
// create an email that should find C89779237
var example2 = new Email
{
Subject = "I want to return my goods",
Body = "My customer number is C89779237 and I want to return my order."
};
// create an email that should find C3239544-1
var example3 = new Email
{
Subject = "Customer needs an electronic invoice",
Body = "Please reissue the invoice as a PDF for customer C3239544-1."
};
var email1 = decisionTreeModel.Predict<Email>(example1);
var email2 = decisionTreeModel.Predict<Email>(example2);
var email3 = decisionTreeModel.Predict<Email>(example3);
Console.WriteLine("The example1 was predicted as {0}", email1.CustomerNumber);
if (ReadBool("Was this answer correct? Y/N"))
{
repo.Add(email1);
}
Console.WriteLine("The example2 was predicted as {0}", email2.CustomerNumber);
if (ReadBool("Was this answer correct? Y/N"))
{
repo.Add(email2);
}
Console.WriteLine("The example3 was predicted as {0}", email3.CustomerNumber);
if (ReadBool("Was this answer correct? Y/N"))
{
repo.Add(email3);
}
}
// Define other methods and classes here
public class Email
{
// Subject
[Feature]
public string Subject { get; set; }
// Body
[Feature]
public string Body { get; set; }
[Label]
public string CustomerNumber { get; set; } // This is the label or value that we wish to predict based on the supplied features
}
static bool ReadBool(string question)
{
while (true)
{
Console.WriteLine(question);
String r = (Console.ReadLine() ?? "").ToLower();
if (r == "y")
return true;
if (r == "n")
return false;
Console.WriteLine("!!Please Select a Valid Option!!");
}
}
There are a few things I haven't quite grasped though.
In a supervised network, do I need to re-build the decision tree every time I run the application, or can I store it off somehow and then reload it as and when required? I'm trying to save the processing time in order to rebuild that decision tree every time.
Also, can the network continually add to it's own training data as the data gets validated by a human? I.e. we have an initial training set, the network decides on an outcome and if a human says 'well done' the new example gets added to the training set in order to improve it. Also vice versa when the network gets it wrong. I assume I can just add to the training set once a human has validated that a prediction is correct? Does my repo.Add(email) seem like a logical way to do this?
If I do add to the training data, at what point does the training data become "more than required"?
I don't think this is a good problem to solve using machine learning (although I am interested in your findings). My concerns would be that customer numbers change over time requiring you to regenerate the model each time. Binary classification algorithms such as Naïve Bayes, Decision Trees, Logistic Regression and SVMs require you to know ahead of time each class (i.e. Customer Ref No).
You could try using feature engineering and predicting whether a given word is or is not a customer reference number (i.e. 1 or 0). To do this you simply engineer features like the below:
IsWordStartsWithC (bool)
WordLength
Count of Digits / Word Length
Count of Letters / Word Length
Then use Decision Tree or Logistic Regression classifier to predict if the word is a CRN or not. To extract the CRN out of the email, simply iterate over each word in an email and if Model.Predict(word) outputs a 1 you hopefully have captured the CRN for that email.
This method should not need to be retrained.
In a supervised network, do I need to re-build the decision tree every time I run the application, or can I store it off somehow and
then reload it as and when required? I'm trying to save the processing
time in order to rebuild that decision tree every time.
You can store the generated model using any stream object via the Model.Save() method. All supervised models in numl currently implement this base class. Apart from the Neural Network model they should save fine.
Also, can the network continually add to it's own training data as the data gets validated by a human? I.e. we have an initial training
set, the network decides on an outcome and if a human says 'well done'
the new example gets added to the training set in order to improve it.
Also vice versa when the network gets it wrong. I assume I can just
add to the training set once a human has validated that a prediction
is correct? Does my repo.Add(email) seem like a logical way to do
this?
This is a good reinforcement learning example. At present numl doesn't implement this but hopefully it will in the near future :)
If I do add to the training data, at what point does the training data become "more than required"?
The best way to check this is through validation of the training and test set accuracy measures. You can keep adding more training data while the accuracy of the test set goes up. If you find that the accuracy goes down on the test set and continues to go up on the training set, it is now overfitting and it's safe to stop adding more data.
It's a little late, but I'm also learning the numl library, and I think I can shed some light on some of your questions.
In a supervised network, do I need to re-build the decision tree every time I run the application, or can I store it off somehow and
then reload it as and when required? I'm trying to save the processing
time in order to rebuild that decision tree every time.
There is currently a IModel.Save method that is supposed to be implemented in each class. However, as best I can tell it isn't yet implemented. There are, however, serialization tests that work for most models, including the DecisionTree, as shown in the DecisionTreeSerializationTests:
Serialize(model);
Which simply calls:
internal void Serialize(object o)
{
var caller = new StackFrame(1, true).GetMethod().Name;
string file = string.Format(_basePath, caller);
if (File.Exists(file)) File.Delete(file);
JsonHelpers.Save(file, o);
}
They have a bunch of custom created converters for using json serialization, and I think that this can be used until the model.Save is implemented. You basically just use the numl.Utils.JsonHelpers to serialize/deserialize the model to/from json (which you can persist however you want). Also, I think this is one thing that they are currently working on.
Also, can the network continually add to it's own training data as the data gets validated by a human? I.e. we have an initial training
set, the network decides on an outcome and if a human says 'well done'
the new example gets added to the training set in order to improve it.
Also vice versa when the network gets it wrong. I assume I can just
add to the training set once a human has validated that a prediction
is correct? Does my repo.Add(email) seem like a logical way to do
this?
You can always add data points to train your model at any point in time. However, I think you would have to retrain the model from scratch. There is Online Machine Learning that trains as data points come in individually, but I don't think numl currently implements this. So, to do this you would probably run a daily/weekly job depending on your requirements to retrain the model with the expanded training data.
If I do add to the training data, at what point does the training data become "more than required"?
The general rule is "more data means better prediction." You can always look to see at your gains and decide for yourself if you aren't getting benefit out of increasing your training data sample size. That said, this is not a hard and fast rule (go figure). If you just google "machine learning more data better accuracy" you will find a ton of information on the subject, all of which I cull down to "more data means better prediction" and "see what works best for you". In your particular example of training against email text, it is my understanding that more data will only help you.
All of that being said, I'd also say a couple other things:
It sounds like if you're just trying to get customer/order numbers from emails, a good regex would do you better than analyzing with ML. At the very least, I would have regexs a part of the feature set of your training data, so maybe you could be training it to learn typos or input variations of your structure.
I'm not an expert on ML, nor on numl. I just happen to be learning numl as well. They have so far been very responsive to me on gitter, which you and anyone else interested in the pretty awesome open-source, mature, MIT licensed library should definitely check out.
I'm not to familiar with the SO user tags, so I hope that this works: #aaron
This is the closest question that I could find that relates to my issue, but it's not exactly the issue. (I tried Google, Bing, and SO's own search.)
https://stackoverflow.com/questions/25014006/nullreferenceexception-with-parseobjects-in-array-of-pointers
My issue: I have a Unity Web-Player game that interfaces with both Facebook and Parse. after resolving many issues in it, I have it to where it will easily connect to Facebook, pull in the user's profile information and picture. It then attempts to connect to parse to log the user into parse to retrieve their game related data (like high scores, currency stats, power ups, etc.) and when it tries to do that, I get a NullReferenceException. The specific contents of the error message is:
"NullReferenceException: Object reference not set to an instance of an object
at GameStateController.ParseFBConnect (System.String userId, System.String accessToken, DateTime tokenExpiration) [0x0001a] in C:...\Assets\Scripts\CSharp\CharacterScripts\GameStateController.cs:1581
at GameStateController.Update () [0x0011f] in C:\Users\Michieal\Desktop\Dragon Rush Game\Assets\Scripts\CSharp\CharacterScripts\GameStateController.cs:382"
The code that generates this error message is:
public void ParseFBConnect(string userId, string accessToken, DateTime tokenExpiration)
{
Task<ParseUser> logInTask = ParseFacebookUtils.LogInAsync (userId, accessToken, tokenExpiration).ContinueWith<ParseUser> (t =>
{
if (t.IsFaulted || t.IsCanceled)
{
if (t.IsCanceled)
Util.LogError ("LoginTask::ParseUser:: Cancelled. >.<");
// The login failed. Check the error to see why.
Util.LogError ("Error Result: " + t.Result.ToString ());
Util.LogError ("Error Result (msg): " + t.Exception.Message);
Util.LogError ("Error Result (inmsg): " + t.Exception.InnerException.Message);
}
if (t.IsCompleted)
{ // No need to link the user to a FB account, as there are no "real" (non fb) accounts yet.
Util.Log ("PFBC::Login result reports successful. You Go Gurl!");
// Login was successful.
user = t.Result; // assign the resultant user to our "user"...
RetryPFBC = false;
return user;
}
return t.Result;
});
if (user.ContainsKey ("NotNew"))
{ // on true, then we don't have to set up the keys...
Util.Log ("User, " + user.Username + ", contains NotNew Key.");
}
else
{
CreateKeys (); // Create Keys will only build MISSING Keys, setting them to the default data specifications.
user.Email = Email;
user.SaveAsync (); // if we have created the keys data, save it out.
}
}
It is being passed the proper (post authenticated) Facebook values (FB.UserId, FB.AccessToken, FB.AccessTokenExpiresAt) in that order. I'm using FB Sdk version 6.0.0 and Parse Unity SDK version 1.2.16.
In the log file, instead of any of the debug.log/Util.log comments, it does the "Null Reference" error (above), followed by "About to parse url: https://api.parse.com/1/classes/_User
Checking if https://api.parse.com/1/classes/_User is a valid domain
Checking request-host: api.parse.com against valid domain: *"
And that is where it just stopped. So, I built a simple retry block in the Update() function to call the ParseFBConnect() function every 10 or so seconds. Which, seems to only fill up my log file with the same error sets. After searching across the internet for help, I tried changing the FB.AccessTokenExpiresAt to DateTime.UtcNow.AddDays(1) as others have said that this works for them. I cannot seem to get either to work for me. When I check the Dashboard in Parse to see if it shows any updates or activity, it doesn't, and hasn't for a few days now. The Script Execution Order is as follows:
Parse.ParseInitialzeBehaviour -- -2875 (very first thing)
Facebook loaders (FB, Editor, Canvas, etc) -- -1000 to -900
GameStateController -- -875
...
So, I know that the Parse.ParseInitializeBehaviour is being loaded first (another result of searching), and I have tracked the NullReference down to the Parse.Unity.dll by changing where the login method is stored; The GSC is on the player (the Player starts in the splash screen and remains throughout the entire game). I have also tried placing the Parse.ParseInitializeBehaviour on the Player gameobject and on an empty gameobject (with a simple dontdestroy(gameObject) script on that). And, I have my Application ID and my DotNet Key correctly filled in on the object.
When I first set up parse, and on the current production version of the game, it can successfully create a user account based off of the code snippet above. Now, it just breaks at the trying to parse the url...
So, My Question is: What am I doing wrong? Does anyone else have this issue? and does anyone have any ideas/suggestions/etc., on what to do to fix this? I really just want this to work, and to log the user in, so that I can grab their data and go on to breaking other things in my game :D
All help is appreciated!! and I thank you for taking the time to read this.
The Answer to this question is as follows:
backend as a service - Bing
Ditch parse because it doesn't work well with Unity3d, the support (obviously, judging by the sheer number answers to this question and other questions from people that need help getting it to work) is extremely lacking, and most, if not all, of the examples to show how to use it are broken / missing parts / etc. I see this as a failure on the part of the creators. I also see it as False Advertising. So, to answer this question - PARSE is a waste of time, cut to the chase and grab something that does work, has real, WORKING examples, and that is maintained by someone that knows HOW TO PROGRAM in the UNITY3d environment.
A great example of this would be the Photon Networking service, App42 by Shephertz.com, Azure by Microsoft, etc. With the overwhelming number of answers to this, if you exclude PARSE, This should have been a no-brainer. I've included a Bing Search link, you can also do a quick search for Gaming Backends (you'll find blogs and reviews.)
I suggest strongly, that you read the reviews on these services, read the questions (and make note of whether they have been answered, or, in the case of Parse, if they simply closed the forum rather than answering their customers)... And, just bounce around through the examples that they give for using their products. If they show how it works, and expected results (like the MSDN does) you'll have a lot better and a lot easier time getting it work.
FYI - My game now has all of the back end integrations, saves/creates/gets users & their data, has a store, and is moving right along, since I dropped PARSE.
To make things correct, I WAS using Parse 1.2.16 for unity, and the Facebook for Unity SDK 6.0.0... I tried Parse 1.2.14, with the same results, and I tried both Unity 4.5.2 and 4.5.3. My opinion of Parse is based off of their documentation, these 2 API versions, and the very long days that I pulled trying to get it to work. I then added in the fact that NO ONE here answered this question AT ALL (Sadly, Stack Over flow is Facebook's preferred Help/Support forum. They even say in their blogs, help documentation, etc., that if you have an issue - post your question on Stack Overflow.com with relevant tags. Which, I did.)
Oh, and the final star rating of Parse (to clarify it) is "-2 out of 5" -- That's a NEGATIVE 2 stars... out of 5. as in, run away from it... far, far away. Just to clarify.