Skip to content

Commit 3c44819

Browse files
authored
Merge pull request #146 from InsForge/feat/marketplace-download-tracking
INS-286: Use PostHog to track template page visits and downloads
2 parents 6a0502b + 63db66f commit 3c44819

2 files changed

Lines changed: 7 additions & 3 deletions

File tree

src/commands/create.marketplace.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ describe('--marketplace flag wiring', () => {
9393
// true — a swallowed network/clone failure (return false) must NOT bump
9494
// the marketplace's install count.
9595
expect(createSource).toMatch(/const downloaded = await downloadGitHubTemplate/);
96-
expect(createSource).toMatch(/if \(downloaded\)[\s\S]{0,80}reportMarketplaceDownload/);
96+
expect(createSource).toMatch(/if \(downloaded\)[\s\S]{0,200}reportMarketplaceDownload/);
9797
});
9898

9999
it('does NOT emit a PostHog template_selected event with a marketplace property', () => {

src/commands/create.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -382,6 +382,9 @@ export function registerCreateCommand(program: Command): void {
382382
json,
383383
);
384384
if (downloaded) {
385+
captureEvent(orgId, 'marketplace_template_downloaded', {
386+
template: opts.marketplace,
387+
});
385388
void reportMarketplaceDownload(opts.marketplace as string);
386389
}
387390
} else if (githubTemplates.includes(template!)) {
@@ -745,8 +748,9 @@ const MARKETPLACE_REPORT_URL =
745748
/**
746749
* Fire-and-forget POST to the marketplace download counter.
747750
* Network errors and non-2xx responses are swallowed — a transient
748-
* counter blip must not kill the install. The DB counter is the source
749-
* of truth; PostHog is intentionally not used (per spec §6.3).
751+
* counter blip must not kill the install. This DB counter only backs
752+
* the download number shown on the template page; PostHog is the
753+
* source of truth for download analytics.
750754
*/
751755
export async function reportMarketplaceDownload(slug: string): Promise<void> {
752756
try {

0 commit comments

Comments
 (0)