This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| cron: | |
| - description: update Data Studio reports | |
| url: / | |
| schedule: every 2 minutes from 05:00 to 18:00 #UTC so translate to 7am to 8pm CET | |
| target: data-studio-monkey-refresher |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| runtime: nodejs8 | |
| service: data-studio-monkey-refresher | |
| instance_class: F4_1G #recommanded instance for headless Chrome see https://cloud.google.com/appengine/docs/standard/nodejs/using-headless-chrome-with-puppeteer |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| const winston = require('winston'); | |
| const monkey = require('./data-studio-monkey-refresher'); | |
| const express = require('express'); | |
| (async () => { | |
| const Logger = winston.Logger; | |
| const Console = winston.transports.Console; | |
| // Imports the Google Cloud client library for Winston | |
| const LoggingWinston = require('@google-cloud/logging-winston').LoggingWinston; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| const puppeteer = require('puppeteer'); | |
| (() => { | |
| const urls = [ | |
| 'https://datastudio.google.com/u/0/reporting/XXX' // url for report 1 | |
| 'https://datastudio.google.com/u/0/reporting/YYY' // url for report 2 | |
| // ... | |
| ]; | |
| // helper function to check if a CSS element is present on the page |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| { | |
| "name": "data-studio-refresh-monkey", | |
| "version": "1.0.0", | |
| "description": "Headless Chrome script to refresh Data Studio reports", | |
| "main": "app.js", | |
| "scripts": { | |
| "start": "node app.js" | |
| }, | |
| "engines": { | |
| "node": "8.x.x" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| var bleno = require('bleno'); | |
| var noble = require('noble'); | |
| var currentPeripheral = null; | |
| noble.on('stateChange', function(state) { | |
| console.log("stateChange " + state); | |
| if (state === 'poweredOn') { | |
| console.log("start peripheral discovery"); | |
| noble.startScanning(); | |
| startIBeaconAdvertising(); |