fix: snippet usage analytics (#7946)

This commit is contained in:
arunvjn 2021-09-30 09:01:50 +05:30 committed by GitHub
parent d9d6d00106
commit 964d58747a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 9 additions and 5 deletions

View File

@ -302,7 +302,8 @@ export default function SnippetDescription({ item }: { item: Snippet }) {
),
},
];
if (template && args && args.length > 0) {
const replaceableArgs = (args || []).filter((arg) => !arg.placeholder);
if (template && replaceableArgs && replaceableArgs.length > 0) {
tabs.push({
key: "Customize",
title: "Customize",
@ -319,7 +320,7 @@ export default function SnippetDescription({ item }: { item: Snippet }) {
</div>
</div>
<div className="snippet-group">
{args.map((arg: SnippetArgument) => (
{replaceableArgs.map((arg: SnippetArgument) => (
<div
className="argument"
key={arg.name}

View File

@ -176,7 +176,7 @@ function GlobalSearch() {
const setCategory = useCallback(
(category: SearchCategory) => {
if (isSnippet(category)) {
AnalyticsUtil.logEvent("SNIPPET_CATEGORY_CLICK");
AnalyticsUtil.logEvent("SNIPPET_LOOKUP");
}
dispatch(setGlobalSearchFilterContext({ category: category }));
},

View File

@ -103,8 +103,10 @@ export const getSnippetFilterLabel = (state: AppState, label: string) => {
};
export type SnippetArgument = {
identifier: string;
name: string;
type: ValidationTypes;
placeholder?: boolean;
};
export type SearchCategory = {

View File

@ -887,7 +887,8 @@ function* executeCommandSaga(actionPayload: ReduxAction<SlashCommandPayload>) {
: SnippetAction.COPY, //Set insertSnippet to true only if values
}),
);
const effectRaceResult = yield race({
AnalyticsUtil.logEvent("SNIPPET_LOOKUP");
const effectRaceResult: { failure: any; success: any } = yield race({
failure: take(ReduxActionTypes.CANCEL_SNIPPET),
success: take(ReduxActionTypes.INSERT_SNIPPET),
});

View File

@ -172,7 +172,7 @@ export type EventName =
| "SNIPPET_EXECUTE"
| "SNIPPET_FILTER"
| "SNIPPET_COPIED"
| "SNIPPET_CATEGORY_CLICK"
| "SNIPPET_LOOKUP"
| "SIGNPOSTING_SKIP"
| "SIGNPOSTING_CREATE_DATASOURCE_CLICK"
| "SIGNPOSTING_CREATE_QUERY_CLICK"