I’m using their node.js library and am trying to capture server-side events with:
import { PostHog } from 'posthog-node';
export const posthog = new PostHog(MY_KEY);
posthog.capture({
distinctId: userId,
event: event,
properties: properties
});
For some reason, I’m not seeing the events come through. Any ideas?
There’s also a need to call a PostHog shutdown function when the program exits. I’ve tried the following:
process.on('SIGINT', () => {
console.log('SIGINT');
posthog.shutdown();
process.exit();
});
process.on('exit', () => {
console.log('exit');
posthog.shutdown();
});
But I don’t see either console.logs when I hit Control + C
in the terminal on Mac. Is there a better way to call a function before a Meteor app shuts down?