mirror of
https://github.com/balena-os/balena-supervisor.git
synced 2025-02-20 09:46:19 +00:00
Auto-merge for PR #500 via VersionBot
Mixpanel tunneling through resin API, and extra hiding of properties
This commit is contained in:
commit
89607fa2bc
@ -4,6 +4,11 @@ All notable changes to this project will be documented in this file
|
||||
automatically by Versionist. DO NOT EDIT THIS FILE MANUALLY!
|
||||
This project adheres to [Semantic Versioning](http://semver.org/).
|
||||
|
||||
## v6.3.11 - 2017-11-01
|
||||
|
||||
* Add whitelist-based filtering to mixpanel events #500 [Pablo Carranza Velez]
|
||||
* Tunnel all mixpanel events through the resin API #500 [Pablo Carranza Velez]
|
||||
|
||||
## v6.3.10 - 2017-10-31
|
||||
|
||||
* Use a custom webpack loader to avoid uncaught exceptions from JSONStream #517 [Pablo Carranza Velez]
|
||||
|
@ -1,7 +1,7 @@
|
||||
{
|
||||
"name": "resin-supervisor",
|
||||
"description": "This is resin.io's Supervisor, a program that runs on IoT devices and has the task of running user Apps (which are Docker containers), and updating them as Resin's API informs it to.",
|
||||
"version": "6.3.10",
|
||||
"version": "6.3.11",
|
||||
"license": "Apache-2.0",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
@ -34,6 +34,7 @@
|
||||
"docker-toolbelt": "^3.0.3",
|
||||
"event-stream": "^3.0.20",
|
||||
"express": "^4.0.0",
|
||||
"json-mask": "^0.3.8",
|
||||
"knex": "~0.12.3",
|
||||
"lockfile": "^1.0.1",
|
||||
"lodash": "^4.16.3",
|
||||
|
@ -1,10 +1,11 @@
|
||||
{ checkInt, checkString } = require './lib/validation'
|
||||
|
||||
dockerRoot = checkString(process.env.DOCKER_ROOT) ? '/mnt/root/var/lib/rce'
|
||||
apiEndpoint = checkString(process.env.API_ENDPOINT)
|
||||
|
||||
# Defaults needed for both gosuper and node supervisor are declared in entry.sh
|
||||
module.exports =
|
||||
apiEndpoint: checkString(process.env.API_ENDPOINT)
|
||||
apiEndpoint: apiEndpoint
|
||||
apiTimeout: checkInt(process.env.API_TIMEOUT, positive: true) ? 15 * 60 * 1000
|
||||
listenPort: checkInt(process.env.LISTEN_PORT, positive: true) ? 80
|
||||
gosuperAddress: "http://unix:#{process.env.GOSUPER_SOCKET}:"
|
||||
@ -15,6 +16,7 @@ module.exports =
|
||||
publish_key: checkString(process.env.PUBNUB_PUBLISH_KEY) ? process.env.DEFAULT_PUBNUB_PUBLISH_KEY
|
||||
ssl: true
|
||||
mixpanelToken: checkString(process.env.MIXPANEL_TOKEN) ? process.env.DEFAULT_MIXPANEL_TOKEN
|
||||
mixpanelHost: "#{apiEndpoint}/mixpanel"
|
||||
dockerSocket: process.env.DOCKER_SOCKET
|
||||
supervisorImage: checkString(process.env.SUPERVISOR_IMAGE) ? 'resin/rpi-supervisor'
|
||||
configMountPoint: checkString(process.env.CONFIG_MOUNT_POINT) ? '/mnt/mmcblk0p1/config.json'
|
||||
|
@ -14,18 +14,28 @@ TypedError = require 'typed-error'
|
||||
execAsync = Promise.promisify(require('child_process').exec)
|
||||
device = require './device'
|
||||
{ checkTruthy } = require './lib/validation'
|
||||
mask = require 'json-mask'
|
||||
|
||||
exports.supervisorVersion = require('./lib/supervisor-version')
|
||||
|
||||
configJson = JSON.parse(fs.readFileSync('/boot/config.json'))
|
||||
if Boolean(config.apiEndpoint) and !Boolean(configJson.supervisorOfflineMode)
|
||||
mixpanelClient = mixpanel.init(config.mixpanelToken)
|
||||
mixpanelClient = mixpanel.init(config.mixpanelToken, { host: config.mixpanelHost })
|
||||
else
|
||||
mixpanelClient = { track: _.noop }
|
||||
|
||||
exports.mixpanelProperties = mixpanelProperties =
|
||||
username: configJson.username
|
||||
|
||||
mixpanelMask = [
|
||||
'appId'
|
||||
'delay'
|
||||
'error'
|
||||
'interval'
|
||||
'app(appId,imageId,commit,name)'
|
||||
'stateDiff(status,download_progress,commit,os_version,superisor_version,ip_address)'
|
||||
].join(',')
|
||||
|
||||
exports.mixpanelTrack = (event, properties = {}) ->
|
||||
# Allow passing in an error directly and having it assigned to the error property.
|
||||
if properties instanceof Error
|
||||
@ -40,16 +50,8 @@ exports.mixpanelTrack = (event, properties = {}) ->
|
||||
|
||||
properties = _.cloneDeep(properties)
|
||||
|
||||
# Don't log private env vars (e.g. api keys)
|
||||
if properties?.app?.env?
|
||||
try
|
||||
{ env } = properties.app
|
||||
env = JSON.parse(env) if _.isString(env)
|
||||
safeEnv = _.omit(env, config.privateAppEnvVars)
|
||||
properties.app.env = JSON.stringify(safeEnv)
|
||||
catch
|
||||
properties.app.env = 'Fully hidden due to error in selective hiding'
|
||||
|
||||
# Filter properties to only send the whitelisted keys and values
|
||||
properties = mask(properties, mixpanelMask)
|
||||
console.log('Event:', event, JSON.stringify(properties))
|
||||
# Mutation is bad, and it should feel bad
|
||||
properties = _.assign(properties, mixpanelProperties)
|
||||
|
Loading…
x
Reference in New Issue
Block a user