Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
private initKeen() {
const { projectId, writeKey } = environment;
this.client = new Keen({
projectId,
writeKey
});
if (!environment.production) {
Keen.enabled = false;
Keen.debug = true;
this.client.on('recordEvent', (event, data) => {
console.log('event:', event);
console.log('data:', data);
});
}
const timer = Keen.utils.timer();
timer.start();
// Batch-record events every 5s
this.client.queueInterval(5);
this.client.extendEvents(() => {
return {
geo: {
// Record all mutations to a single event stream
const EVENT_STREAM_NAME = 'app-mutations';
// Omit noisy mutations if necessary
const OMITTED_MUTATIONS = [
// 'KEYPRESS',
// 'WINDOW_RESIZED'
];
// Define a client instance
const client = new KeenTracking({
projectId: 'YOUR_PROJECT_ID',
writeKey: 'YOUR_WRITE_KEY'
});
// Optional debugging
KeenTracking.debug = true;
client.on('recordEvent', Keen.log);
// Track a 'pageview' event and initialize auto-tracking data model
client.initAutoTracking({
recordClicks: false,
recordFormSubmits: false,
recordPageViews: true
});
const vuexLogger = store => {
// Called when the store is initialized
store.subscribe((mutation, state) => {
// Called after every mutation.
// The mutation comes in the format of `{ type, payload }`.
const eventBody = {
'mutation': mutation,