Skip to content

Commit

Permalink
added importer from google analytics to index export
Browse files Browse the repository at this point in the history
  • Loading branch information
kanekotic committed Jul 2, 2018
1 parent c199137 commit bbeb06c
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 1 deletion.
21 changes: 21 additions & 0 deletions example/metrics.js
@@ -0,0 +1,21 @@
const importer = require('../lib/index').importer
path = require('path')

const email = 'your email' //email account from the user credentials
keyPath = path.join(__dirname, 'your credentials')// path to credentials json or pem
config = {
viewId: "some viewId",//the view id to query
daterange:{
"endDate":"2017-06-30",
"startDate":"2016-06-30"
},
metrics: "ga:users",
dimensions: "ga:date"
}

const example = async () => {
const result = await importer(email, keyPath, config)
console.log(JSON.stringify(result.data))
}

example()
5 changes: 4 additions & 1 deletion lib/index.js
@@ -1 +1,4 @@
module.exports = {}
const importer = require('./importer')

module.exports = { importer }

10 changes: 10 additions & 0 deletions test/lib/index-test.js
@@ -0,0 +1,10 @@
jest.mock('../../lib/importer', () => jest.fn())

const index = require('../../lib/index')
importer = require('../../lib/importer')

describe('index', () => {
it('exports the importer',async () => {
expect(index.importer).toBe(importer)
})
})

0 comments on commit bbeb06c

Please sign in to comment.