Revert "Add a controlling variable for mixpanel reporting"

This reverts commit 1a7ed0f95b.

Change-type: patch
Signed-off-by: Cameron Diver <cameron@balena.io>
This commit is contained in:
Cameron Diver 2019-06-10 11:45:11 +01:00
parent 24f5c7f7c7
commit 9c486275c9
No known key found for this signature in database
GPG Key ID: 49690ED87032539F
8 changed files with 17 additions and 52 deletions

View File

@ -166,10 +166,6 @@ export const schemaTypes = {
type: PermissiveBoolean,
default: false,
},
mixpanelReport: {
type: PermissiveBoolean,
default: true,
},
// Function schema types
// The type should be the value that the promise resolves

View File

@ -190,11 +190,6 @@ export const schema = {
mutable: true,
removeIfNull: false,
},
mixpanelReport: {
source: 'db',
mutable: true,
removeIfNull: false,
},
};
export type Schema = typeof schema;

View File

@ -129,11 +129,6 @@ export class DeviceConfig {
defaultValue: 'false',
rebootRequired: true,
},
mixpanelReport: {
envVarName: 'SUPERVISOR_MIXPANEL_REPORT',
varType: 'bool',
defaultValue: 'true',
},
};
public static validKeys = [

View File

@ -1,10 +1,10 @@
import * as Bluebird from 'bluebird';
import mask = require('json-mask');
import * as _ from 'lodash';
import * as memoizee from 'memoizee';
import Mixpanel = require('mixpanel');
import Config from './config';
import log from './lib/supervisor-console';
import supervisorVersion = require('./lib/supervisor-version');
@ -15,7 +15,6 @@ interface InitArgs {
unmanaged: boolean;
mixpanelHost: { host: string; path: string } | null;
mixpanelToken: string;
config: Config;
}
// The minimum amount of time to wait between sending
@ -36,20 +35,19 @@ const mixpanelMask = [
export class EventTracker {
private defaultProperties: EventTrackProperties | null;
private client: any;
private isEnabled: boolean = true;
public constructor() {
this.client = null;
this.defaultProperties = null;
}
public async init({
public init({
unmanaged,
mixpanelHost,
mixpanelToken,
uuid,
config,
}: InitArgs): Promise<void> {
}: InitArgs): Bluebird<void> {
return Bluebird.try(() => {
this.defaultProperties = {
distinct_id: uuid,
uuid,
@ -62,17 +60,6 @@ export class EventTracker {
host: mixpanelHost.host,
path: mixpanelHost.path,
});
this.isEnabled = await config.get('mixpanelReport');
log.info(
`Mixpanel reporting is ${this.isEnabled ? 'enabled' : 'disabled'}`,
);
config.on('change', conf => {
const mixpanelReport = conf.mixpanelReport;
if (mixpanelReport != null && mixpanelReport !== this.isEnabled) {
this.isEnabled = mixpanelReport;
log.info(`${mixpanelReport ? 'A' : 'Dea'}ctivating mixpanel reporting`);
}
});
}
@ -93,7 +80,7 @@ export class EventTracker {
// Don't send potentially sensitive information, by using a whitelist
properties = mask(properties, mixpanelMask);
this.logEvent('Event:', event, JSON.stringify(properties));
if (this.client == null || !this.isEnabled) {
if (this.client == null) {
return;
}

View File

@ -1,5 +1,3 @@
_ = require 'lodash'
EventEmitter = require 'events'
{ EventTracker } = require './event-tracker'
@ -72,7 +70,7 @@ module.exports = class Supervisor extends EventEmitter
# so we leave a trail of breadcrumbs in the logs in case runtime
# fails to get to the first dashboard logs
log.debug('Starting event tracker')
@eventTracker.init(_.assign({}, conf, { @config }))
@eventTracker.init(conf)
.then =>
log.debug('Starting up api binder')
@apiBinder.initClient()

View File

@ -45,7 +45,6 @@ testTarget1 = {
'SUPERVISOR_LOCAL_MODE': 'false'
'SUPERVISOR_LOG_CONTROL': 'true'
'SUPERVISOR_OVERRIDE_LOCK': 'false'
'SUPERVISOR_MIXPANEL_REPORT': 'true'
'SUPERVISOR_POLL_INTERVAL': '60000'
'SUPERVISOR_VPN_CONTROL': 'true'
'SUPERVISOR_PERSISTENT_LOGGING': 'false'
@ -131,7 +130,6 @@ testTargetWithDefaults2 = {
'SUPERVISOR_OVERRIDE_LOCK': 'false'
'SUPERVISOR_POLL_INTERVAL': '60000'
'SUPERVISOR_VPN_CONTROL': 'true'
'SUPERVISOR_MIXPANEL_REPORT': 'true'
'SUPERVISOR_PERSISTENT_LOGGING': 'false'
}
apps: {

View File

@ -42,9 +42,6 @@ describe 'EventTracker', ->
mixpanelToken: 'someToken'
uuid: 'barbaz'
mixpanelHost: { host: '', path: '' }
config:
get: -> Promise.resolve(true)
on: ->
})
expect(promise).to.be.fulfilled
.then =>

View File

@ -177,7 +177,6 @@ describe 'DeviceConfig', ->
SUPERVISOR_DELTA_APPLY_TIMEOUT: '0',
SUPERVISOR_DELTA_RETRY_COUNT: '30',
SUPERVISOR_DELTA_RETRY_INTERVAL: '10000',
SUPERVISOR_MIXPANEL_REPORT: 'true'
SUPERVISOR_DELTA_VERSION: '2',
SUPERVISOR_INSTANT_UPDATE_TRIGGER: 'true',
SUPERVISOR_OVERRIDE_LOCK: 'false',