Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
// analytics browsers "Site Name or ID" - Get browsers percentage access with "Site Name or ID"
// analytics show email - Get email account api configured to give access to others analytics profiles.
//
// Notes:
//
//
// Author:
// Plan B Comunicação
var google = require("googleapis");
require("date-utils");
var HubotAnalytics = require('./lib/HubotAnalytics.js');
var hubotAnalytics = new HubotAnalytics();
var analytics = google.analytics("v3");
var globalError;
module.exports = function(robot) {
hubotAnalytics.profilesNames = robot.brain.get('profilesNames');
try {
var GOOGLE_API_CLIENT_EMAIL = process.env.GOOGLE_API_CLIENT_EMAIL;
var GOOGLE_API_PRIVATE_KEY = process.env.GOOGLE_API_PRIVATE_KEY.replace(/\\n/g, "\n");
var oauth2Client = new google.auth.JWT(GOOGLE_API_CLIENT_EMAIL, null, GOOGLE_API_PRIVATE_KEY, ["https://www.googleapis.com/auth/analytics.readonly"], null);
} catch(err) {
globalError = "Error on load - check your environments variables GOOGLE_API_CLIENT_EMAIL and GOOGLE_API_PRIVATE_KEY.";
}
robot.hear(/analytics help/i, function(res)
{
function getAnalytics() {
if (!(jwt && analytics) && ENABLED) {
jwt = new google.auth.JWT();
jwt.fromJSON(require(AUTH_PATH));
jwt = Promise.promisifyAll(
jwt.createScoped('https://www.googleapis.com/auth/analytics.readonly')
);
analytics = google.analytics({ version: 'v3', auth: jwt });
Promise.promisifyAll(analytics.data.ga);
Promise.promisifyAll(analytics.data.realtime);
}
return jwt.authorizeAsync().then(() => analytics);
}
"use strict";
let __pluginManager = require('./plugins_manager');
let google = require('googleapis');
let CLIENT_ID = '1088344376413-220618hg1c06d8p3bitjsbt2k74g1l68.apps.googleusercontent.com';
let CLIENT_SECRET = 'cBnnCAb2oaQc4WlxQh8Og7oj';
let oauth2 = new google.auth.OAuth2(CLIENT_ID, CLIENT_SECRET, 'postmessage');
let analytics = google.analytics('v3');
let SERVICE_ACCOUNT_EMAIL = '1088344376413-220618hg1c06d8p3bitjsbt2k74g1l68@developer.gserviceaccount.com';
let SERVICE_ACCOUNT_KEY_FILE = __base + 'config/env/techmaster_key.pem';
let jwt = new google.auth.JWT(
SERVICE_ACCOUNT_EMAIL,
SERVICE_ACCOUNT_KEY_FILE,
null,
['https://www.googleapis.com/auth/analytics.readonly']);
let access_token = '';
let expiry_date = 0;
function GA() {
let self = this;
this.init = function () {
__pluginManager.loadAllPlugins();
var path = require('path')
, fs = require('fs')
, inquirer = require('inquirer')
, async = require('async')
, google = require('googleapis')
, manifest = require('../../src/manifest')
, utils = require('../utils')
, exec = require('child_process').exec
, ejs = require('ejs');
var analytics = google.analytics('v3');
var CWD = process.cwd();
module.exports = function(program, addToReadyQue) {
var PELLET_PROJECT_PATH = (program.pelletConfig && program.pelletConfig._filepath && path.dirname(program.pelletConfig._filepath)) || CWD;
program
.command('gaexperiments')
.alias('gaexp')
.description('Build GA A/B/N experiment config')
.option('--output
jwtClient.authorize((err) => {
if (err) {
return reject(err);
}
const analytics = google.analytics('v3');
return apiUtils.queryData(analytics, jwtClient);
});
});
var google = require("googleapis");
var ga = google.analytics("v3");
var moment = require("moment");
module.exports = function (app) {
var gaQuery = function (req, res, options) {
var jwt = new google.auth.JWT(
options.serviceEmail,
options.pemFilename,
null,
["https://www.googleapis.com/auth/analytics.readonly"],
null);
if (app.get("env") !== "development") {
res.header("Access-Control-Allow-Origin", options.origin);
}
var initializeAnalytics = function(err, authClient, next) {
var analytics = google.analytics({
version: 'v3',
auth: authClient
});
next(null, analytics);
};