-
Notifications
You must be signed in to change notification settings - Fork 13
feature: adding telemetry #70
feature: adding telemetry #70
Conversation
Review or Edit in CodeSandboxOpen the branch in Web Editor • VS Code • Insiders |
@@ -27,6 +34,16 @@ export const devCmd = async (ctx: AppContext, args: any) => { | |||
const { port } = params | |||
const { cwd } = ctx | |||
|
|||
const projectHash = crypto.createHash('md5').update(cwd).digest('hex') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ahh this is a nice method
lib/cmd-fns/dev/index.ts
Outdated
import crypto from 'crypto' | ||
|
||
const posthog = new PostHog( | ||
'your_posthog_api_key_here', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ideally we bake in the secret as a build variable somehow then add it as a secret in github actions. Since this project uses tsup
we can look at how to configure this using tsup
(which uses esbuild
behind the scenes)
@DamilolaAlao it looks like some of the tests are broken, looks related |
This PR is almost ready but tests are broken because of the missing env var. |
lib/cmd-fns/dev/index.ts
Outdated
@@ -19,7 +19,7 @@ import { uploadExamplesFromDirectory } from "./upload-examples-from-directory" | |||
import { PostHog } from "posthog-node" | |||
import crypto from 'crypto' | |||
|
|||
declare const POSTHOG_API_KEY: string; | |||
const POSTHOG_API_KEY: string = process.env.POSTHOG_API_KEY || ''; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i'm not sure it's a good idea to initialize posthog without an api key, or to initialize it in this file specifically because it's more of a global singleton, what if you did something like this in a global lib/posthog.ts
file, then imported and used it
import PostHog from 'posthog-node'
const POSTHOG_API_KEY: string | undefined = process.env.POSTHOG_API_KEY
let posthogInstance: PostHog | null = null
if (POSTHOG_API_KEY) {
posthogInstance = new PostHog(
POSTHOG_API_KEY,
{ host: 'https://us.i.posthog.com' }
)
}
const posthogProxy = new Proxy<PostHog>({} as PostHog, {
get(target, prop) {
if (posthogInstance) {
return Reflect.get(posthogInstance, prop)
}
// Return a no-op function for any method call if PostHog is not initialized
return () => {}
}
})
export default posthogProxy
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nice!
Issue tscircuit/tscircuit#222