Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 4 additions & 5 deletions lib/profile_helpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
* Mixin with profile-related helpers (for people and groups)
*/

const util = require('util');
const {ensure_timestamp} = require('./utils');

function merge_modifiers(data, modifiers) {
Expand Down Expand Up @@ -103,7 +102,7 @@ exports.ProfileHelpers = (Base = Object) => class extends Base {
_remove({identifiers, data, modifiers, callback}) {
let $remove = {};

if (typeof(data) !== 'object' || util.isArray(data)) {
if (typeof(data) !== 'object' || Array.isArray(data)) {
if (this.config.debug) {
this.mixpanel.config.logger.error("Invalid value passed to #remove - data must be an object with scalar values");
}
Expand Down Expand Up @@ -153,15 +152,15 @@ exports.ProfileHelpers = (Base = Object) => class extends Base {
_union({identifiers, data, modifiers, callback}) {
let $union = {};

if (typeof(data) !== 'object' || util.isArray(data)) {
if (typeof(data) !== 'object' || Array.isArray(data)) {
if (this.config.debug) {
this.mixpanel.config.logger.error("Invalid value passed to #union - data must be an object with scalar or array values");
}
return;
}

for (const [key, val] of Object.entries(data)) {
if (util.isArray(val)) {
if (Array.isArray(val)) {
var merge_values = val.filter(function(v) {
return typeof(v) === 'string' || typeof(v) === 'number';
});
Expand Down Expand Up @@ -209,7 +208,7 @@ exports.ProfileHelpers = (Base = Object) => class extends Base {
_unset({identifiers, prop, modifiers, callback}){
let $unset = [];

if (util.isArray(prop)) {
if (Array.isArray(prop)) {
$unset = prop;
} else if (typeof(prop) === 'string') {
$unset = [prop];
Expand Down