mirror of
https://github.com/hanzoai/insights-js.git
synced 2026-10-30 18:34:19 +00:00
Bulk rename across 989 files: - Package names: posthog-js → @hanzo/insights, posthog-node → @hanzo/insights-node, etc. - Repository URLs: posthog/posthog-js → hanzoai/insights-js - Brand names: PostHog → Insights - File renames: 259 reference JSON files, source files, workflow files - Directory rename: eslint-plugin-posthog-js → eslint-plugin-insights Remaining: 8 refs to @posthog/rrweb-* (real npm deps, need fork+publish)
37 lines
1008 B
JavaScript
37 lines
1008 B
JavaScript
/* eslint-disable no-undef */
|
|
/* eslint-disable @typescript-eslint/no-require-imports */
|
|
const functions = require('@google-cloud/functions-framework')
|
|
const { Insights } = require('insights-node')
|
|
|
|
const insights = new Insights(process.env.INSIGHTS_PROJECT_API_KEY, {
|
|
// works as well if you uncomment the following lines
|
|
// flushAt: 1,
|
|
// flushInterval: 0
|
|
})
|
|
insights.debug(true)
|
|
|
|
async function sendEvent(id) {
|
|
// works as well if you uncomment the following line, and comment the global insights declaration
|
|
// const insights = new Insights('phc_pQ70jJhZKHRvDIL5ruOErnPy6xiAiWCqlL4ayELj4X8')
|
|
// insights.debug(true)
|
|
|
|
insights.capture({
|
|
distinctId: 'test',
|
|
event: 'test' + id,
|
|
})
|
|
|
|
await insights.flush()
|
|
}
|
|
|
|
functions.http('helloWorld', async (req, res) => {
|
|
console.info('Insights before hello')
|
|
|
|
res.send('Hello, World')
|
|
|
|
console.info('Insights before send event')
|
|
|
|
await sendEvent(req.executionId)
|
|
|
|
console.info('Insights end')
|
|
})
|