Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
}
// Standard Events only contains custom properties defined in the configuration
// If the property is not listed there, we just drop it.
if (
isStandardEvent &&
standardEventsCustomProperties.indexOf(property) < 0
) {
continue;
}
var value = properties[property];
// Dates
if (dateFields.indexOf(camel(property)) >= 0) {
if (is.date(value)) {
payload[property] = value.toISOString().split('T')[0];
continue;
}
}
// Custom PII properties
if (customPiiProperties.hasOwnProperty(property)) {
// hash or drop
if (customPiiProperties[property] && typeof value === 'string') {
payload[property] = sha256(value);
}
continue;
}
// Default PII properties
var isPropertyPii = defaultPiiProperties.indexOf(property) >= 0;
// send event data
var properties = track.properties();
// Cxense requires property values be strings or numbers.
// Need to sanitize as it will drop events if the payload has other data types.
var payload = {};
for (var key in properties) {
if (properties.hasOwnProperty(key)) {
var property = properties[key];
// Numbers and strings are passed as they are.
// Booleans and dates can be stringified.
// All other data types are discarded.
if (is.number(property) || is.string(property)) {
payload[key] = property;
} else if (is.bool(property) || is.date(property)) {
payload[key] = property.toString();
}
}
}
window.cX.callQueue.push(['sendEvent', track.event(), payload]);
};
return {
booleanValue: val,
};
}
if (is.integer(val)) {
return {
integerValue: val,
};
}
// Integers are handled above, the remaining numbers are treated as doubles
if (is.number(val)) {
return {
doubleValue: val,
};
}
if (is.date(val)) {
return {
timestampValue: val.toISOString(),
};
}
if (is.array(val)) {
var encodedElements = [];
for (var i = 0; i < val.length; ++i) {
var enc = encodeHelper(val[i]);
if (enc) {
encodedElements.push(enc);
}
}
return {
arrayValue: {
values: encodedElements,
},
method: function(reqOpts, metadata, grpcOpts) {
assert(is.date(grpcOpts.deadline));
assert(grpcOpts.deadline.getTime() > expectedDeadlineRange[0]);
assert(grpcOpts.deadline.getTime() < expectedDeadlineRange[1]);
done();
}
};
function(results, value, key) {
var r = results;
r[convertKey(key, value)] = is.date(value) ? convertDate(value) : value;
return r;
},
{},
return 'float64';
}
if (is.number(field) || field instanceof Int) {
return 'int64';
}
if (is.string(field)) {
return 'string';
}
if (Buffer.isBuffer(field)) {
return 'bytes';
}
if (is.date(field)) {
return 'timestamp';
}
if (field instanceof SpannerDate) {
return 'date';
}
if (Struct.isStruct(field)) {
const fields = field.map(field => {
return {
name: field.name,
type: getType(field.value),
};
});
return {
w.formatValue = function (value) {
if (!value) {
return null;
}
var date = is.date(value) ? value : new Date(value);
if (isNaN(date.getTime())) {
return null;
}
return date.toISOString().slice(0, 10);
};
return w;
}
const customTypeConstructorNames = [
'BigQueryDate',
'BigQueryDatetime',
'BigQueryTime',
'BigQueryTimestamp',
];
const constructorName = value.constructor.name;
const isCustomType = customTypeConstructorNames.indexOf(constructorName) > -1;
if (isCustomType) {
return value.value;
}
if (is.date(value)) {
return value.toJSON();
}
if (is.array(value)) {
return value.map((Table as any).encodeValue_);
}
if (is.object(value)) {
return Object.keys(value).reduce((acc, key) => {
acc[key] = (Table as any).encodeValue_(value[key]);
return acc;
}, {});
}
return value;
}
Mutation.createTimeRange = function(start, end) {
var range = {};
if (is.date(start)) {
range.startTimestampMicros = start.getTime();
}
if (is.date(end)) {
range.endTimestampMicros = end.getTime();
}
return range;
};