Skip to content

Instantly share code, notes, and snippets.

@thameera
Last active January 1, 2020 01:57
Show Gist options
  • Save thameera/bdac7d410b70f2a20d84ed8ccd08137d to your computer and use it in GitHub Desktop.
Save thameera/bdac7d410b70f2a20d84ed8ccd08137d to your computer and use it in GitHub Desktop.
Breakdown of connections usage

This script counts how many users are coming from each connection in an Auth0 tenant.

The input file is an unzipped JSON file obtained using the User Import/Export extension. Use the gunzip command to extract the file.

Run the script with: node count.js

const fs = require('fs')
const FILENAME = 'tham.json'
const lines = fs.readFileSync(FILENAME, 'utf8').split('\n').filter(x => !!x)
const connections = {}
lines.map(l => JSON.parse(l)).forEach(user => {
user.identities.forEach(id => {
const conn = id.connection
if (connections[conn]) {
connections[conn]++
} else {
connections[conn] = 1
}
})
})
console.log(connections)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment