Hello
Options for using Google Apps Scripts are many. My friend worked with a foreign customer and he asked every day for a report to him on the mail with the text of who did what. As a result, he asked the staff to track everything into a Google table no later than 21:00, then the script started and collected the data and sent it to the correct address.
In the article I will give a simple and, I think, a useful example of using Google Apps Scripts.
What is Google Apps Scripts?
In short, this is a service that allows JavaScript to write scripts running in the Google cloud. The service provides a wide API, for example, in this article we will create a Google table based on the application metrics from Flurry.
')
What is the problem to be solved and what would I like to receive?
I work in a company that develops games for mobile platforms for statistics. We use our server data + data from Flurry. In order to somehow combine all this, I decided to use the services provided by Google and as a result get one report with data and charts.
What do you get at the end of this article?
The script which, according to the schedule, requests the application metrics from the Flurry service, parses them and makes a simple Google table (similar to Microsoft excel) with this data and a simple schedule.
the main goal
I do not set the goal of creating a benchmark statistics report. I was surprised by the availability of such functionality and decided to share a little experience in the form of a test script.
Let's start with simple steps.
What is needed?
- gmail account
- Flurry account
Gmail setup
- Go to the “Google Drive” tab
- Click the “Create” button

- Click the “Connect more apps” button
- A window will open and enter “google script” in the search bar

- On the “Google Apps Script” application, click “+ connect”
- On dialogs, click Ok
- On the “Google Drive” tab, click the “Create” button and create a “Script”

- Choose “Blank project”

- A window opens with the project. In the upper right corner, double-click on the project name and rename it to “Flurry statistic”, in the left panel, right-click on the script name and rename it to “createStatisticReport”
- At the root of your “Google Drive” create a folder “Statistic”
- Now we are ready to write the first Google apps script.
Flurry setup
I mean that you already have a configured Flurry account with data.
For programmatic access to data from Flurry follow the link:
support.flurry.com/index.php?title=API/GettingStarted
As a result, you will receive a key that you need to save for use in the script.
You also need the “ProjectApiKey” from Flurry, which you are already using in the mobile application.
We write a script
More precisely, everything is already written, then I will just describe how to run it.
Follow the link and take the scripts texts
github.com/chapayGhub/flurrymetricstospreadsheet
In the project that we created before, you need to create the same.
Now, after you've done everything, open Settings.gs and in it
Enter your Flurry keys
Then enter your e-mail name, it is better from Google (I have not checked the others)
obj.emails = ["?????email1", "?????email2", "?????email3"];
The script is configured to receive application metrics from Flurry + to your mailbox will receive a letter that you added as an editor.
Launch and debass
In the left pane, select the script “CreateStatisticReport”
In the top panel near the button with the bug in the drop-down list, select "makeStatisticReport"
Now everything is just the top panel has two “super” buttons that any programmer can understand.
Scheduled run
Follow the steps in the pictures
Nuances
Make the script work every time with one document.
Immediately run on the execution is not on debag. A document should be created in the “Statistic” folder and letters will come to you in the mail, one of which will contain the identifier of the created document.
Assign it to a variable located in the Settings.gs script.
obj.mainStatisticDocID
Now the script will update this particular document and not create a new one every time. If this parameter is not entered, then at startup the script tries to find a document by a non-existing identifier, naturally does not find it, throws an exception (there may be a stop at this place of execution in debug), but this exception is caught and a new document is created.
Logging
Use the following method
Logger.log("!");
To view the output, select the next item from the menu.
Help is needed
The browser editor is a convenient thing, but if the script is more voluminous, then it is not very convenient to work in it.
This link below describes how to upload and download a project.
developers.google.com/apps-script/import-export
I had an idea to write a script which, at the entrance, received the project identifier unloaded it on a local disk into separate files. These files could then be refactored humanly and at the end, again through this script, download back.
It seems everything is described, but something did not shoot me).
Maybe someone has already done this or have useful links? I will be grateful.
Links
The heading from this point you can begin to search for answers to questions on Google Apps Scripts
developers.google.com/apps-script
Link to how to work with Google Sheets
developers.google.com/apps-script/guides/sheets
Google Sheets API Help
developers.google.com/apps-script/reference/spreadsheet
PS
I have never worked with such services and have a superficial knowledge of JavaScript, I will be glad to constructive comments.