Output telemetry when clicking links
This commit is contained in:
@@ -8,6 +8,7 @@ import {
|
||||
} from "../../../remote-queries/shared/analysis-result";
|
||||
import { createRemoteFileRef } from "../../../pure/location-link-utils";
|
||||
import { VerticalSpace } from "../VerticalSpace";
|
||||
import { sendTelemetry } from "../Telemetry";
|
||||
|
||||
const getSeverityColor = (severity: ResultSeverity) => {
|
||||
switch (severity) {
|
||||
@@ -65,6 +66,7 @@ export const CodeSnippetMessage = ({
|
||||
return (
|
||||
<LocationLink
|
||||
key={index}
|
||||
onClick={() => sendTelemetry("alert-message-link")}
|
||||
href={createRemoteFileRef(
|
||||
token.location.fileLink,
|
||||
token.location.highlightedRegion?.startLine,
|
||||
|
||||
@@ -12,6 +12,7 @@ import {
|
||||
import { createRemoteFileRef } from "../../../pure/location-link-utils";
|
||||
import { CodeSnippetMessage } from "./CodeSnippetMessage";
|
||||
import { CodeSnippetLine } from "./CodeSnippetLine";
|
||||
import { sendTelemetry } from "../Telemetry";
|
||||
|
||||
const borderColor = "var(--vscode-editor-snippetFinalTabstopHighlightBorder)";
|
||||
|
||||
@@ -67,7 +68,12 @@ export const FileCodeSnippet = ({
|
||||
return (
|
||||
<Container>
|
||||
<TitleContainer>
|
||||
<VSCodeLink href={titleFileUri}>{fileLink.filePath}</VSCodeLink>
|
||||
<VSCodeLink
|
||||
onClick={() => sendTelemetry("file-code-snippet-title-link")}
|
||||
href={titleFileUri}
|
||||
>
|
||||
{fileLink.filePath}
|
||||
</VSCodeLink>
|
||||
</TitleContainer>
|
||||
{message && severity && (
|
||||
<CodeSnippetMessage message={message} severity={severity}>
|
||||
@@ -83,7 +89,12 @@ export const FileCodeSnippet = ({
|
||||
return (
|
||||
<Container>
|
||||
<TitleContainer>
|
||||
<VSCodeLink href={titleFileUri}>{fileLink.filePath}</VSCodeLink>
|
||||
<VSCodeLink
|
||||
onClick={() => sendTelemetry("file-code-snippet-title-link")}
|
||||
href={titleFileUri}
|
||||
>
|
||||
{fileLink.filePath}
|
||||
</VSCodeLink>
|
||||
</TitleContainer>
|
||||
<CodeContainer>
|
||||
{code.map((line, index) => (
|
||||
|
||||
@@ -33,19 +33,13 @@ export function useStateWithTelemetry<S>(
|
||||
>(() => {
|
||||
if (filterTelemetryOnValue === undefined) {
|
||||
return (x: React.SetStateAction<S>) => {
|
||||
vscode.postMessage({
|
||||
t: "telemetry",
|
||||
action: telemetryAction,
|
||||
});
|
||||
sendTelemetry(telemetryAction);
|
||||
setter(x);
|
||||
};
|
||||
} else {
|
||||
return (x: S) => {
|
||||
if (filterTelemetryOnValue(x)) {
|
||||
vscode.postMessage({
|
||||
t: "telemetry",
|
||||
action: telemetryAction,
|
||||
});
|
||||
sendTelemetry(telemetryAction);
|
||||
}
|
||||
setter(x);
|
||||
};
|
||||
@@ -53,3 +47,10 @@ export function useStateWithTelemetry<S>(
|
||||
}, [telemetryAction, filterTelemetryOnValue, setter]);
|
||||
return [value, setterWithTelemetry];
|
||||
}
|
||||
|
||||
export function sendTelemetry(telemetryAction: string) {
|
||||
vscode.postMessage({
|
||||
t: "telemetry",
|
||||
action: telemetryAction,
|
||||
});
|
||||
}
|
||||
|
||||
@@ -9,7 +9,7 @@ import {
|
||||
import { tryGetRemoteLocation } from "../../pure/bqrs-utils";
|
||||
import TextButton from "./TextButton";
|
||||
import { convertNonPrintableChars } from "../../text-utils";
|
||||
import { useStateWithTelemetry } from "../common/Telemetry";
|
||||
import { sendTelemetry, useStateWithTelemetry } from "../common/Telemetry";
|
||||
|
||||
const numOfResultsInContractedMode = 5;
|
||||
|
||||
@@ -59,7 +59,14 @@ const Cell = ({ value, fileLinkPrefix, sourceLocationPrefix }: CellProps) => {
|
||||
);
|
||||
const safeLabel = convertNonPrintableChars(value.label);
|
||||
if (url) {
|
||||
return <VSCodeLink href={url}>{safeLabel}</VSCodeLink>;
|
||||
return (
|
||||
<VSCodeLink
|
||||
onClick={() => sendTelemetry("raw-results-link")}
|
||||
href={url}
|
||||
>
|
||||
{safeLabel}
|
||||
</VSCodeLink>
|
||||
);
|
||||
} else {
|
||||
return <span>{safeLabel}</span>;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user