11<script setup lang="ts">
2+ import { hash } from ' ohash' ;
23import type { MarketplaceExtension } from ' ~/types/marketplace' ;
34import { formatFilesize } from ' ~/utils/formatFilesize' ;
45
@@ -10,9 +11,15 @@ const directusInstanceUrl = useCookie('directus-instance-url', {
1011 default : () => ' ' ,
1112});
1213
14+ const { $posthog } = useNuxtApp ();
15+
1316const showInstallModal = ref (false );
1417const inputUrl = ref (directusInstanceUrl .value || ' ' );
1518
19+ function hashedUrl(url : string ) {
20+ return hash (new URL (url ).origin );
21+ }
22+
1623const installExtension = () => {
1724 if (! inputUrl .value ) {
1825 return ;
@@ -22,6 +29,24 @@ const installExtension = () => {
2229
2330 const installUrl = ` ${inputUrl .value }/admin/settings/marketplace/extension/${props .extension .id } ` ;
2431
32+ const hashed_instance_url = hashedUrl (inputUrl .value );
33+
34+ $posthog ?.capture (' marketing.website.marketplace.extension.instance_url.saved' , {
35+ marketplace_extension_id: props .extension .id ,
36+ marketplace_extension_name: props .extension .name ,
37+ marketplace_extension_version: props .extension .versions ?.[0 ]?.version || null ,
38+ marketplace_instance_url: hashed_instance_url ,
39+ $set: {
40+ latest_marketplace_instance_url: hashed_instance_url ,
41+ },
42+ });
43+
44+ $posthog ?.capture (' marketing.website.marketplace.extension.install.launch' , {
45+ marketplace_extension_id: props .extension .id ,
46+ marketplace_extension_name: props .extension .name ,
47+ marketplace_extension_version: props .extension .versions ?.[0 ]?.version || null ,
48+ });
49+
2550 navigateTo (installUrl , {
2651 external: true ,
2752 open: {
@@ -37,10 +62,28 @@ const handleInstallClick = () => {
3762 // Show modal if no URL is set
3863 showInstallModal .value = true ;
3964 inputUrl .value = ' ' ;
65+
66+ $posthog ?.capture (' marketing.website.marketplace.extension.instance_url.opened' , {
67+ extension_id: props .extension .id ,
68+ marketplace_extension_name: props .extension .name ,
69+ marketplace_extension_version: props .extension .versions ?.[0 ]?.version || null ,
70+ });
4071 } else {
4172 // Go directly to marketplace if URL is already set
4273 const installUrl = ` ${directusInstanceUrl .value }/admin/settings/marketplace/extension/${props .extension .id } ` ;
4374
75+ const hashed_instance_url = hashedUrl (directusInstanceUrl .value );
76+
77+ $posthog ?.capture (' marketing.website.marketplace.extension.install.launch' , {
78+ marketplace_extension_id: props .extension .id ,
79+ marketplace_extension_name: props .extension .name ,
80+ marketplace_extension_version: props .extension .versions ?.[0 ]?.version || null ,
81+ marketplace_instance_url: hashed_instance_url ,
82+ $set: {
83+ latest_marketplace_instance_url: hashed_instance_url ,
84+ },
85+ });
86+
4487 navigateTo (installUrl , {
4588 external: true ,
4689 open: {
@@ -53,6 +96,18 @@ const handleInstallClick = () => {
5396const handleEditUrl = () => {
5497 showInstallModal .value = true ;
5598 inputUrl .value = directusInstanceUrl .value ;
99+
100+ const hashed_instance_url = hashedUrl (inputUrl .value );
101+
102+ $posthog ?.capture (' marketing.website.marketplace.extension.instance_url.edit' , {
103+ marketplace_extension_id: props .extension .id ,
104+ marketplace_extension_name: props .extension .name ,
105+ marketplace_extension_version: props .extension .versions ?.[0 ]?.version || null ,
106+ marketplace_instance_url: hashed_instance_url ,
107+ $set: {
108+ latest_marketplace_instance_url: hashed_instance_url ,
109+ },
110+ });
56111};
57112
58113const isSandboxed = computed (() => {
@@ -218,7 +273,19 @@ function formatSingleVersion(version: string): string {
218273 <div v-if =" extension?.name" class =" row" >
219274 <span class =" meta-item" >
220275 <BaseIcon name =" fa6-brands:npm" size =" small" />
221- <NuxtLink :href =" `https://www.npmjs.com/package/${extension.name}`" target =" _blank" class =" link" >
276+ <NuxtLink
277+ :href =" `https://www.npmjs.com/package/${extension.name}`"
278+ target =" _blank"
279+ class =" link"
280+ v-capture =" {
281+ event: 'marketing.website.marketplace.extension.npm.open',
282+ props: {
283+ extension_id: extension.id,
284+ extension_name: extension.name,
285+ extension_version: latestVersion?.version || null,
286+ },
287+ }"
288+ >
222289 npm
223290 </NuxtLink >
224291 </span >
@@ -227,14 +294,42 @@ function formatSingleVersion(version: string): string {
227294 <div v-if =" latestVersion?.url_repository" class =" row" >
228295 <span class =" meta-item" >
229296 <BaseIcon name =" fa6-brands:github" size =" small" />
230- <a :href =" latestVersion.url_repository" target =" _blank" class =" link" >Repository</a >
297+ <a
298+ :href =" latestVersion.url_repository"
299+ target =" _blank"
300+ class =" link"
301+ v-capture =" {
302+ event: 'marketing.website.marketplace.extension.github.open',
303+ props: {
304+ extension_id: extension.id,
305+ extension_name: extension.name,
306+ extension_version: latestVersion?.version || null,
307+ },
308+ }"
309+ >
310+ Repository
311+ </a >
231312 </span >
232313 </div >
233314
234315 <div v-if =" latestVersion?.url_bugs" class =" row" >
235316 <span class =" meta-item" >
236317 <BaseIcon name =" bug_report" size =" small" />
237- <a :href =" latestVersion.url_bugs" target =" _blank" class =" link" >Report Issue</a >
318+ <a
319+ :href =" latestVersion.url_bugs"
320+ target =" _blank"
321+ class =" link"
322+ v-capture =" {
323+ event: 'marketing.website.marketplace.extension.bugs.open',
324+ props: {
325+ extension_id: extension.id,
326+ extension_name: extension.name,
327+ extension_version: latestVersion?.version || null,
328+ },
329+ }"
330+ >
331+ Report Issue
332+ </a >
238333 </span >
239334 </div >
240335
0 commit comments