Skip to content

Commit

Permalink
build(deps-dev): Bump mongodb-js-precommit from 2.1.0 to 2.2.0 (#42)
Browse files Browse the repository at this point in the history
* build(deps-dev): Bump mongodb-js-precommit from 2.1.0 to 2.2.0

Bumps [mongodb-js-precommit](https://github.com/mongodb-js/precommit) from 2.1.0 to 2.2.0.
- [Release notes](https://github.com/mongodb-js/precommit/releases)
- [Commits](mongodb-js/precommit@v2.1.0...v2.2.0)

Signed-off-by: dependabot-preview[bot] <support@dependabot.com>

* chore: Fix all long lived lint errors

* chore: normalize travis

per mongodb-js/mongodb-language-model#22

Co-authored-by: Lucas Hrabovsky <hrabovsky.lucas@gmail.com>
  • Loading branch information
dependabot-preview[bot] and imlucas committed Jan 31, 2020
1 parent fed9356 commit 44d16b0
Show file tree
Hide file tree
Showing 7 changed files with 117 additions and 105 deletions.
10 changes: 3 additions & 7 deletions packages/metrics/.travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,7 @@ sudo: false
dist: bionic
language: node_js
node_js:
- 12
- 13
install:
- npm ci
script:
- npm run check
- npm test
- 10.17.0 # 10gen/charts
- 12.4.0 # mongodb-js/compass
script: npm run ci
cache: npm
15 changes: 8 additions & 7 deletions packages/metrics/lib/trackers/bugsnag.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,10 @@ var BugsnagTracker = State.extend({
id: 'bugsnag',
// assign properties to bugsnag handler
props: {
apiKey: ['string', true, ''], // set through metrics.configure()
apiKey: ['string', true, ''], // set through metrics.configure()
autoNotify: ['boolean', true, true],
metaData: ['object', false],
appVersion: ['string', true, ''], // set by App resource
appVersion: ['string', true, ''], // set by App resource
notifyReleaseStages: {
type: 'array',
default: function() {
Expand All @@ -32,8 +32,8 @@ var BugsnagTracker = State.extend({
required: true,
default: false
},
appStage: ['string', true, ''], // set by App resource
userId: ['string', true, ''], // set by User resource
appStage: ['string', true, ''], // set by App resource
userId: ['string', true, ''], // set by User resource
bugsnagHandler: ['object', false, null]
},
derived: {
Expand All @@ -45,7 +45,7 @@ var BugsnagTracker = State.extend({
},
// this is just a rename of `appStage`, set by App resource, but bugsnag
// requires the name to be releaseStage
'releaseStage': {
releaseStage: {
deps: ['appStage'],
fn: function() {
return this.appStage;
Expand Down Expand Up @@ -76,8 +76,9 @@ var BugsnagTracker = State.extend({
_configureBugsnag: function() {
if (this.enabledAndConfigured) {
if (typeof window !== 'undefined') {
this.bugsnagHandler = this.bugsnagHandler || require('bugsnag-js').noConflict();
var options = this.serialize({props: true, derived: true});
this.bugsnagHandler =
this.bugsnagHandler || require('bugsnag-js').noConflict();
var options = this.serialize({ props: true, derived: true });
options.beforeNotify = this.beforeNotify;
delete options.enabledAndConfigured;
debug('configuring bugsnag with %j', options);
Expand Down
64 changes: 33 additions & 31 deletions packages/metrics/lib/trackers/ga.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
var querystring = require('querystring');
var State = require('ampersand-state');
var xhr = (typeof window !== 'undefined') ? require('xhr') : require('request');
var xhr = typeof window !== 'undefined' ? require('xhr') : require('request');
var _ = require('lodash');
var singleton = require('singleton-js');
var redact = require('mongodb-redact');
Expand All @@ -10,38 +10,38 @@ var debug = require('debug')('mongodb-js-metrics:trackers:ga');

// rename property names to google analytics keys
var PROTOCOL_PARAMETER_MAP = {
'version': 'v',
'dataSource': 'ds',
'trackingId': 'tid',
'userId': 'cid',
'hitType': 't',
'appName': 'an',
'appVersion': 'av',
'appPlatform': 'aiid', // we use the app installer id field to track platform
'eventCategory': 'ec',
'eventAction': 'ea',
'eventLabel': 'el',
'eventValue': 'ev',
'timingCategory': 'utc',
'timingVar': 'utv',
'timingValue': 'utt',
'timingLabel': 'utl',
'screenName': 'cd',
'documentPath': 'dp',
'exDescription': 'exd',
'exFatal': 'exf'
version: 'v',
dataSource: 'ds',
trackingId: 'tid',
userId: 'cid',
hitType: 't',
appName: 'an',
appVersion: 'av',
appPlatform: 'aiid', // we use the app installer id field to track platform
eventCategory: 'ec',
eventAction: 'ea',
eventLabel: 'el',
eventValue: 'ev',
timingCategory: 'utc',
timingVar: 'utv',
timingValue: 'utt',
timingLabel: 'utl',
screenName: 'cd',
documentPath: 'dp',
exDescription: 'exd',
exFatal: 'exf'
};

var GATracker = State.extend({
id: 'ga',
props: {
version: ['number', true, 1],
dataSource: ['string', true, 'app'],
trackingId: ['string', true, ''], // set through metrics.configure()
userId: ['string', true, ''], // set by User resource
appName: ['string', true, ''], // set by App resource
appVersion: ['string', true, ''], // set by App resource
appPlatform: ['string', true, ''] // set by App resource
trackingId: ['string', true, ''], // set through metrics.configure()
userId: ['string', true, ''], // set by User resource
appName: ['string', true, ''], // set by App resource
appVersion: ['string', true, ''], // set by App resource
appPlatform: ['string', true, ''] // set by App resource
},
session: {
enabled: {
Expand Down Expand Up @@ -80,11 +80,13 @@ var GATracker = State.extend({
if (!this.enabled) {
return;
}
callback = callback || function(err) {
if (err) {
debug('Google Analytics returned error:', err.message);
}
};
callback =
callback ||
function(err) {
if (err) {
debug('Google Analytics returned error:', err.message);
}
};
// extend options with default options
_.defaults(options || {}, this.serialize());
options = this.shortify(options);
Expand Down
19 changes: 14 additions & 5 deletions packages/metrics/lib/trackers/intercom.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,10 @@ var sentenceCase = require('../shared').sentenceCase;
*/
var MONGO_ERROR = 'MongoError';

var os = (typeof window === 'undefined') ?
require('os') : require('electron').remote.require('os');
var os =
typeof window === 'undefined'
? require('os')
: require('electron').remote.require('os');

var IntercomTracker = State.extend({
id: 'intercom',
Expand Down Expand Up @@ -80,8 +82,11 @@ var IntercomTracker = State.extend({
enabledAndConfigured: {
deps: ['enabled', 'panelEnabled', 'appId', 'userId'],
fn: function() {
return (this.enabled || this.panelEnabled)
&& this.appId !== '' && this.userId !== '';
return (
(this.enabled || this.panelEnabled) &&
this.appId !== '' &&
this.userId !== ''
);
}
}
},
Expand Down Expand Up @@ -253,7 +258,11 @@ var IntercomTracker = State.extend({
// redact metadata
metadata = sentenceCase(redact(metadata));

debug('sending event `%s` to intercom with metadata %j', eventName, metadata);
debug(
'sending event `%s` to intercom with metadata %j',
eventName,
metadata
);
if (typeof window !== 'undefined' && window.Intercom) {
window.Intercom('trackEvent', eventName, metadata);
}
Expand Down
62 changes: 40 additions & 22 deletions packages/metrics/lib/trackers/stitch.js
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,13 @@ var StitchTracker = State.extend({
_usersDatabaseName: 'any',
_usersCollectionName: 'any',
_client: 'any',
_callsQueue: ['array', true, function() { return []; }], // array of object with format: { fn: Function, args: Array }
_callsQueue: [
'array',
true,
function() {
return [];
}
], // array of object with format: { fn: Function, args: Array }
enabled: ['boolean', true, false],
hasBooted: ['boolean', true, false]
},
Expand All @@ -88,11 +94,12 @@ var StitchTracker = State.extend({
_enabledConfiguredChanged: function() {
if (this.enabledAndConfigured) {
// tracks all events from queue and calls _identify only when stitch client has been initialized
this._setup()
.then(function() {
this._setup().then(
function() {
this._trackFromQueue();
this._identify();
}.bind(this));
}.bind(this)
);
}
},
_trackFromQueue: function() {
Expand All @@ -117,23 +124,24 @@ var StitchTracker = State.extend({
}

var self = this;
return stitch.StitchClientFactory.create(this.appId)
.then(function(client) {
return client.login()
.then(function() {
self._client = client;
return stitch.StitchClientFactory.create(this.appId).then(function(client) {
return client
.login()
.then(function() {
self._client = client;

debug('setup client', {
_client: self._client,
_eventsDatabaseName: self._eventsDatabaseName,
_eventsCollectionName: self._eventsCollectionName,
_usersDatabaseName: self._usersDatabaseName,
_usersCollectionName: self._usersCollectionName
});
}).catch(function(e) {
debug('error logging in via stitch: %s', e.message);
debug('setup client', {
_client: self._client,
_eventsDatabaseName: self._eventsDatabaseName,
_eventsCollectionName: self._eventsCollectionName,
_usersDatabaseName: self._usersDatabaseName,
_usersCollectionName: self._usersCollectionName
});
});
})
.catch(function(e) {
debug('error logging in via stitch: %s', e.message);
});
});
},
_identify: function() {
// this is only used when a user is first created ($setOnInsert)
Expand Down Expand Up @@ -194,7 +202,13 @@ var StitchTracker = State.extend({
if (!this._isTrackerReady()) {
return fn(new Error('stitch tracker not configured yet.'));
}
return fn(null, this._client.service('mongodb', 'mongodb-atlas').db(db).collection(name));
return fn(
null,
this._client
.service('mongodb', 'mongodb-atlas')
.db(db)
.collection(name)
);
},

/**
Expand All @@ -217,7 +231,7 @@ var StitchTracker = State.extend({

// toplevel fields
var payload = Object.assign({
_id: metadata['event id'], // lift up from metadata
_id: metadata['event id'], // lift up from metadata
resource: resource,
action: action,
user_id: this.userId,
Expand All @@ -240,7 +254,11 @@ var StitchTracker = State.extend({
if (!this._isTrackerReady()) {
this._callsQueue.push({
fn: this._getCollection,
args: [this._eventsDatabaseName, this._eventsCollectionName, getCollectionCallback]
args: [
this._eventsDatabaseName,
this._eventsCollectionName,
getCollectionCallback
]
});
return;
}
Expand Down
49 changes: 17 additions & 32 deletions packages/metrics/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 44d16b0

Please sign in to comment.