new Insights(config)
Insights
Parameters:
| Name | Type | Description | |||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
config |
Object | configuration object
Properties
|
Example
new Insights({
accountId: '...',
insertKey: '...',
queryKey: '...',
});
Methods
add(data, eventTypeopt)
Add insights data to the queue.
It is sent when the queue reaches a max size or a period of time has elapsed
Parameters:
| Name | Type | Attributes | Description |
|---|---|---|---|
data |
object | data to flatten and send to insights | |
eventType |
string |
<optional> |
event type to associate with data |
finish()
Stop the timer after flushing.
nrql(params)
Build a nrql query string
Parameters:
| Name | Type | Description |
|---|---|---|
params |
object | object containing key/values of nrql query |
Example
nrql = insights.nrql({
select: 'uniqueCount(session)',
from: 'PageView',
since: '1 week ago',
until: '1 day ago',
timeseries: '1 hour'
});
insights.query(nrql);
query(query, done)
Execute a nrql query
Parameters:
| Name | Type | Description |
|---|---|---|
query |
object | string | query object to build and execute or query string to execute |
done |
function | callback |
send(done)
Send accumulated insights data to new relic (if enabled)
Parameters:
| Name | Type | Description |
|---|---|---|
done |
function | callback |
start()
Start the timer that will send insights after some interval of time
this is called implicitly when data is added via the add method
stop()
Stop the timer that will send insights after some interval of time
this is called implicitly when the amount of data exceeds maxPending and the queue is sent
where()
nrql where clause builder