@@ -13,6 +13,7 @@ import { atomWithHash } from "jotai-location";
13
13
import { compress , decompress } from "@/compress" ;
14
14
import { CopyButton } from "@/components/CopyButton" ;
15
15
import { Button } from "@/components/ui/button" ;
16
+ import posthog from "posthog-js" ;
16
17
17
18
const originalOpenAPI = atomWithHash ( "originalOpenAPI" , petstore , {
18
19
setHash : throttledPushState ,
@@ -58,7 +59,7 @@ function Playground() {
58
59
const getShareUrl = useCallback ( async ( ) => {
59
60
try {
60
61
setShareUrlLoading ( true ) ;
61
- const info = await GetInfo ( original ) ;
62
+ const info = await GetInfo ( original , false ) ;
62
63
const start = JSON . stringify ( { result, original, info } ) ;
63
64
const blob = await compress ( start ) ;
64
65
@@ -79,6 +80,10 @@ function Playground() {
79
80
80
81
setShareUrl ( currentUrl . toString ( ) ) ;
81
82
history . pushState ( null , "" , currentUrl . toString ( ) ) ;
83
+ posthog . capture ( "overlay.speakeasy.com:share" , {
84
+ openapi : JSON . parse ( info ) ,
85
+ currentUrl : currentUrl . toString ( ) ,
86
+ } ) ;
82
87
} else {
83
88
setError ( "Failed to create share URL" ) ;
84
89
}
@@ -108,7 +113,16 @@ function Playground() {
108
113
setOriginal ( original ) ;
109
114
setResult ( result ) ;
110
115
111
- const changed = await ApplyOverlay ( original , result , true ) ;
116
+ const changed = await ApplyOverlay ( original , result , false ) ;
117
+ const info = await GetInfo ( original , false ) ;
118
+ const bestURL = new URL ( window . location . href ) ;
119
+ bestURL . searchParams . set ( "s" , hash ) ;
120
+ bestURL . hash = "" ;
121
+ posthog . capture ( "overlay.speakeasy.com:load-shared" , {
122
+ openapi : JSON . parse ( info ) ,
123
+ currentUrl : bestURL . toString ( ) ,
124
+ } ) ;
125
+
112
126
setChanged ( changed ) ;
113
127
} catch ( error : any ) {
114
128
console . error ( "invalid share url:" , error . message ) ;
0 commit comments