Skip to content

added licenseKey to posthog events#104

Merged
KIvanow merged 3 commits intomasterfrom
add-license-id-to-posthog
Apr 9, 2026
Merged

added licenseKey to posthog events#104
KIvanow merged 3 commits intomasterfrom
add-license-id-to-posthog

Conversation

@KIvanow
Copy link
Copy Markdown
Member

@KIvanow KIvanow commented Apr 9, 2026

Summary

Added license key to the posthog metrics for tracking

Changes

Checklist

  • Unit / integration tests added
  • Docs added / updated
  • Roborev review passed — run roborev review --branch or /roborev-review-branch in Claude Code (internal)
  • Competitive analysis done / discussed (internal)
  • Blog post about it discussed (internal)

Note

Medium Risk
Telemetry now emits license keys, which is sensitive metadata and may have privacy/compliance implications if not properly handled downstream. Logic changes are small and guarded, but any misconfiguration could leak identifiers to analytics.

Overview
Usage telemetry now attaches a licenseKey property to PostHog identify and all captured events, using a defensive getLicenseKeySafely() helper so telemetry remains best-effort even when the license module/version doesn’t expose the key.

LicenseService exposes a new getLicenseKey() accessor, and the migration validation e2e tests now skip when licensing is enforced via either 402 or 403 responses.

Reviewed by Cursor Bugbot for commit aefddb5. Bugbot is set up for automated code reviews on this repo. Configure here.

@KIvanow KIvanow requested a review from jamby77 April 9, 2026 07:01
Comment thread apps/api/src/telemetry/usage-telemetry.service.ts Outdated
@BetterDB-inc BetterDB-inc deleted a comment from cursor Bot Apr 9, 2026
Co-authored-by: Kristiyan Ivanov <k.ivanow@gmail.com>
@github-actions
Copy link
Copy Markdown

github-actions Bot commented Apr 9, 2026

Thank you for your contribution! Before we can merge this PR, you need to sign our Contributor License Agreement.

To sign, please comment below with:

I have read the CLA Document and I hereby sign the CLA


I have read the CLA Document and I hereby sign the CLA


1 out of 2 committers have signed the CLA.
✅ (KIvanow)[https://github.com/KIvanow]
@cursoragent
You can retrigger this bot by commenting recheck in this Pull Request. Posted by the CLA Assistant Lite bot.

const licenseService = this.licenseService as { getLicenseKey?: () => string } | undefined;
if (typeof licenseService?.getLicenseKey !== 'function') return undefined;
try {
return licenseService.getLicenseKey();
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It might be good idea to send partial license key - first / last 10 characters for example, if it is considered private data

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we are fine for now. The licenses are not identifiable information in the public sense. We can strip it when we improve the telemetry. For now I just want a more accurate tying up the license to the events. The licenses are also free, so even if PostHog has a leak, it won't compromise the user's usage. It is something to revisit once payments are setup in the future

Copy link
Copy Markdown

@cursor cursor Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit aefddb5. Configure here.

} catch {
return undefined;
}
}
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Type cast masks null return, leaking null as undefined

Low Severity

The getLicenseKeySafely method's type assertion for licenseService.getLicenseKey() doesn't account for null. This leads to null being returned by getLicenseKeySafely for community-tier users, despite its string | undefined return type. Consequently, telemetry payloads send "licenseKey": null instead of omitting the field as undefined would.

Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit aefddb5. Configure here.

@KIvanow KIvanow merged commit 74a5beb into master Apr 9, 2026
2 of 3 checks passed
@KIvanow KIvanow deleted the add-license-id-to-posthog branch April 9, 2026 08:43
@github-actions github-actions Bot locked and limited conversation to collaborators Apr 9, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants