Saving queries in keen io

35 views
Skip to first unread message

awardperez

unread,
Jul 21, 2016, 11:52:18 AM7/21/16
to Keen IO Community
Basically copied the code from the docs, but when i try to run the .savedQueries() function i get this error: Uncaught TypeError: client.savedQueries is not a function. Having trouble understanding why.

var client = new Keen({
    projectId
: "...",
    masterKey
: "..."
 
});
 
var savedQueries = client.savedQueries();


  savedQueries
.create("purchases-past-week",
   
{
      refresh_rate
: 0,
      query
: {
        analysisType
: "count",
        event_collection
: "purchases",
        timeframe
: "previous_1_weeks",
        filters
: [
         
{
              property_name
: "product_id",
             
operator: "eq",
              property_value
: product_id.value
         
}
       
]
     
},
      metadata
: {
        display_name
: "Purchases (past week)",
     
}
   
},
   
function(err, response) {
     
// if (err) handle error
      console
.log(response);
   
}
 
);

Taylor Barnett

unread,
Jul 21, 2016, 12:08:14 PM7/21/16
to awardperez, Keen IO Community
Hi! 

Could you share how you are including the keen-js library in your code? It can help us debug. 

Thanks!

-Taylor 
--
Taylor Barnett
Developer Evangelist at Keen IO

Come hangout with me on Slack

Taylor Barnett

unread,
Jul 21, 2016, 2:27:40 PM7/21/16
to Keen IO Community
Just an update for anyone else with this issue:

It was a versioning issue. Older versions of keen-js didn't have Saved Queries. Update and you should be good! :)
Reply all
Reply to author
Forward
0 new messages