Skip to content
Merged
Show file tree
Hide file tree
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: 6 additions & 3 deletions src/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ var validateProperties = function validateProperties(properties) {
};

var invalidValueTypes = [
'null', 'nan', 'undefined', 'function', 'arguments', 'regexp', 'element'
'nan', 'undefined', 'function', 'arguments', 'regexp', 'element'
];

var validatePropertyValue = function validatePropertyValue(key, value) {
Expand All @@ -150,11 +150,14 @@ var validatePropertyValue = function validatePropertyValue(key, value) {
for (var i = 0; i < value.length; i++) {
var element = value[i];
var elemType = type(element);
if (elemType === 'array' || elemType === 'object') {
if (elemType === 'array') {
log.warn('WARNING: Cannot have ' + elemType + ' nested in an array property value, skipping');
continue;
} else if (elemType === 'object') {
arrayCopy.push(validateProperties(element));
} else {
arrayCopy.push(validatePropertyValue(key, element));
}
arrayCopy.push(validatePropertyValue(key, element));
}
value = arrayCopy;
} else if (valueType === 'object') {
Expand Down
16 changes: 8 additions & 8 deletions test/amplitude-client.js
Original file line number Diff line number Diff line change
Expand Up @@ -575,9 +575,9 @@ describe('AmplitudeClient', function() {
'bool': true,
'string': 'test',
'array': [0, 1, 2, '3'],
'nested_array': ['a'],
'nested_array': ['a', {'key':'value'}],
'object': {'key':'value'},
'nested_object': {'k':'v', 'l':[0,1], 'o':{'k2':'v2', 'l2': ['e2']}}
'nested_object': {'k':'v', 'l':[0,1], 'o':{'k2':'v2', 'l2': ['e2', {'k3':'v3'}]}}
}

// check that event loaded into memory
Expand All @@ -604,9 +604,9 @@ describe('AmplitudeClient', function() {
'bool': true,
'string': 'test',
'array': [0, 1, 2, '3'],
'nested_array': ['a'],
'nested_array': ['a', {'key':'value'}],
'object': {'key':'value'},
'nested_object': {'k':'v', 'l':[0,1], 'o':{'k2':'v2', 'l2': ['e2']}}
'nested_object': {'k':'v', 'l':[0,1], 'o':{'k2':'v2', 'l2': ['e2', {'k3':'v3'}]}}
}

// check that event loaded into memory
Expand Down Expand Up @@ -710,7 +710,7 @@ it ('should load saved events from localStorage new keys and send events', funct
'bool': true,
'string': 'test',
'array': [0, 1, 2, '3'],
'nested_array': ['a'],
'nested_array': ['a', {'key':'value'}],
'object': {
'key': 'value'
},
Expand All @@ -719,7 +719,7 @@ it ('should load saved events from localStorage new keys and send events', funct
'l': [0, 1],
'o': {
'k2': 'v2',
'l2': ['e2']
'l2': ['e2', {'k3':'v3'}]
}
}
}
Expand Down Expand Up @@ -2348,9 +2348,9 @@ describe('setVersionName', function() {
'error': 'Error: oops',
'string': 'test',
'array': [0, 1, 2, '3'],
'nested_array': ['a'],
'nested_array': ['a', {'key': 'value'}],
'object': {'key':'value', '15':'Error: oops'},
'nested_object': {'k':'v', 'l':[0,1], 'o':{'k2':'v2', 'l2': ['e2']}}
'nested_object': {'k':'v', 'l':[0,1], 'o':{'k2':'v2', 'l2': ['e2', {'k3': 'v3'}]}}
});
});

Expand Down
16 changes: 8 additions & 8 deletions test/amplitude.js
Original file line number Diff line number Diff line change
Expand Up @@ -570,9 +570,9 @@ describe('Amplitude', function() {
'bool': true,
'string': 'test',
'array': [0, 1, 2, '3'],
'nested_array': ['a'],
'nested_array': ['a', {'key':'value'}],
'object': {'key':'value'},
'nested_object': {'k':'v', 'l':[0,1], 'o':{'k2':'v2', 'l2': ['e2']}}
'nested_object': {'k':'v', 'l':[0,1], 'o':{'k2':'v2', 'l2': ['e2', {'k3':'v3'}]}}
}

// check that event loaded into memory
Expand All @@ -599,9 +599,9 @@ describe('Amplitude', function() {
'bool': true,
'string': 'test',
'array': [0, 1, 2, '3'],
'nested_array': ['a'],
'nested_array': ['a', {'key':'value'}],
'object': {'key':'value'},
'nested_object': {'k':'v', 'l':[0,1], 'o':{'k2':'v2', 'l2': ['e2']}}
'nested_object': {'k':'v', 'l':[0,1], 'o':{'k2':'v2', 'l2': ['e2', {'k3':'v3'}]}}
}

// check that event loaded into memory
Expand Down Expand Up @@ -669,7 +669,7 @@ describe('Amplitude', function() {
'bool': true,
'string': 'test',
'array': [0, 1, 2, '3'],
'nested_array': ['a'],
'nested_array': ['a', {'key':'value'}],
'object': {
'key': 'value'
},
Expand All @@ -678,7 +678,7 @@ describe('Amplitude', function() {
'l': [0, 1],
'o': {
'k2': 'v2',
'l2': ['e2']
'l2': ['e2', {'k3':'v3'}]
}
}
}
Expand Down Expand Up @@ -1969,9 +1969,9 @@ describe('setVersionName', function() {
'error': 'Error: oops',
'string': 'test',
'array': [0, 1, 2, '3'],
'nested_array': ['a'],
'nested_array': ['a', {'key': 'value'}],
'object': {'key':'value', '15':'Error: oops'},
'nested_object': {'k':'v', 'l':[0,1], 'o':{'k2':'v2', 'l2': ['e2']}}
'nested_object': {'k':'v', 'l':[0,1], 'o':{'k2':'v2', 'l2': ['e2', {'k3': 'v3'}]}}
});
});

Expand Down
4 changes: 2 additions & 2 deletions test/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,7 @@ describe('utils', function() {
'error': 'Error: oops',
'string': 'test',
'array': [0, 1, 2, '3'],
'nested_array': ['a'],
'nested_array': ['a', {'key': 'value'}],
'object': {
'key': 'value',
'15': 'Error: oops'
Expand All @@ -224,7 +224,7 @@ describe('utils', function() {
'l': [0, 1],
'o': {
'k2': 'v2',
'l2': ['e2']
'l2': ['e2', {'k3': 'v3'}]
}
}
}
Expand Down