Closed TheCodeKing closed 6 years ago
Actually, I just realised the observed behaviour is that all items are deleted and the filter is ignored.
@TheCodeKing - thanks for reporting! We'll get that syntax error fixed up. I think I've found the issue with the DELETE
request as well, and will open a separate issue.
@TheCodeKing this example should work properly.. apologies for the error!
import Keen from 'keen-js';
const client = new Keen({
projectId: 'PROJECT_ID',
masterKey: 'MASTER_KEY'
});
/*
Filters and timeframe must be passed as encoded query string parameters.
This example constructs a complete URL to ensure the request is executed properly.
*/
const url = client.url('events', 'my-event-stream', {
api_key: client.masterKey(),
filters: encodeURIComponent(JSON.stringify([
{
property_name: 'user.id',
operator: 'eq',
property_value: 'f1243353243fdb'
}
])),
timeframe: encodeURIComponent(JSON.stringify({
start: '2015-05-15T19:00:00.000Z',
end: '2015-06-07T19:00:00.000Z'
})),
timezone: 'US/Pacific'
});
client
.del(url)
.send()
.then(res => {
// Handle response
})
.catch(err => {
// Handle error
});
fixed in keen-analysis@1.3.2, keen-js@4.3.1
I'm using the example in the docs to delete some events from nodejs version v7.9.0. It seems to actually succeed as the events disappear, but the delete function returns an error. I'm using keen-js version 4.3.0.
Also there's an error in the documentation. You are missing the braces inside the filter array in the example code for JS. The code from your docs I'm using with braces added. Obviously I've changed the property_name and property_value in my actual code.