Flush for analytics-node

This commit is contained in:
Andrew Fong 2015-10-15 23:14:04 +00:00
parent dd92c920b0
commit 741c1c4b53
2 changed files with 19 additions and 0 deletions

View File

@ -80,3 +80,12 @@ function testIntegrations(): void {
}
});
}
function testFlush(): void {
analytics.flush();
analytics.flush(function(err, batch) {
if (err) { alert("Oh nos!"); }
else { console.log(batch.batch[0].type); }
});
}

View File

@ -65,6 +65,16 @@ declare module AnalyticsNode {
anonymous_id?: string | number;
integrations?: Integrations;
}): Analytics;
/* Flush batched calls to make sure nothing is left in the queue */
flush(fn?: (err: Error, batch: {
batch: Array<{
type: string;
}>;
messageId: string;
sentAt: Date;
timestamp: Date;
}) => void): Analytics;
}
}