Skip to content

Commit ef8d368

Browse files
committed
chore: track copy more precisely
1 parent 125cbd3 commit ef8d368

File tree

2 files changed

+26
-15
lines changed

2 files changed

+26
-15
lines changed

src/demo/CodeGen.vue

Lines changed: 26 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -136,8 +136,13 @@ const importCode = computed(() => {
136136
const messageOpen = ref(false);
137137
let messageTimer;
138138
139+
function trackCopy(from) {
140+
va.track("copy-code", { from });
141+
console.log("copied");
142+
}
143+
139144
function copy() {
140-
va.track("copy-code");
145+
trackCopy("button");
141146
clearTimeout(messageTimer);
142147
143148
navigator.clipboard.writeText(importCode.value);
@@ -220,15 +225,16 @@ onBeforeUnmount(() => {
220225
:disabled="initializing"
221226
autofocus
222227
></textarea>
223-
<code-highlight
224-
class="import-code"
225-
:language="codegenOptions.includeType ? 'typescript' : 'javascript'"
226-
:code="importCode"
227-
/>
228+
<div class="import-code" @copy="trackCopy('system')">
229+
<code-highlight
230+
:language="codegenOptions.includeType ? 'typescript' : 'javascript'"
231+
:code="importCode"
232+
/>
233+
</div>
228234
<button
229235
class="copy"
230236
@click="copy"
231-
:disabled="importCode.startsWith('/*')"
237+
:disabled="importCode.startsWith('/*') || importCode.startsWith('//')"
232238
>
233239
Copy
234240
</button>
@@ -307,8 +313,8 @@ input[type="number"] {
307313
min-height: 0;
308314
tab-size: 4;
309315
310-
textarea,
311-
pre {
316+
.option-code,
317+
.import-code {
312318
flex: 0 0 50%;
313319
margin: 0;
314320
border: none;
@@ -317,18 +323,24 @@ input[type="number"] {
317323
overflow: auto;
318324
}
319325
320-
pre {
321-
padding: 0;
326+
.import-code {
322327
border-left: 1px solid rgba(0, 0, 0, 0.1);
323-
background: #fff;
324-
box-shadow: none;
328+
329+
pre {
330+
width: 100%;
331+
height: 100%;
332+
margin: 0;
333+
padding: 0;
334+
background: #fff;
335+
box-shadow: none;
336+
}
325337
326338
code {
327339
height: 100%;
328340
}
329341
}
330342
331-
textarea {
343+
.option-code {
332344
padding: 1em;
333345
outline: none;
334346
resize: none;

src/demo/Demo.vue

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -187,7 +187,6 @@ pre {
187187
padding: 0.8em;
188188
background-color: #f9f9f9;
189189
box-shadow: 0 1px 2px rgba(0, 0, 0, 0.125);
190-
font-size: 0.8em;
191190
text-align: left;
192191
}
193192
pre,

0 commit comments

Comments
 (0)