-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathjson.js
More file actions
28 lines (24 loc) · 652 Bytes
/
Copy pathjson.js
File metadata and controls
28 lines (24 loc) · 652 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
const Analytics = require('analytics-node')
const jsonfile = require('jsonfile')
const analytics = new Analytics('YOUR WRITE KEY')
/**
* WARNING: readFile method opens the entire json file at once
* Use a data stream if the file is large to prevent the program from crashing
*/
const file = './src/test.json'
let i = 0
try {
jsonfile.readFile(file, {}, (err, data) => {
while (i < data.length) {
analytics.identify({
userId: data[i]['userId'],
company: data[i]['company'],
email: data[i]['email'],
favorite_band: data[i]['favorite_band']
})
i++
}
})
} catch (e) {
console.log(e)
}