From 964d58747a869ed896217c2ab3368610822b208b Mon Sep 17 00:00:00 2001
From: arunvjn <32433245+arunvjn@users.noreply.github.com>
Date: Thu, 30 Sep 2021 09:01:50 +0530
Subject: [PATCH] fix: snippet usage analytics (#7946)
---
.../editorComponents/GlobalSearch/SnippetsDescription.tsx | 5 +++--
.../src/components/editorComponents/GlobalSearch/index.tsx | 2 +-
.../src/components/editorComponents/GlobalSearch/utils.tsx | 2 ++
app/client/src/sagas/ActionSagas.ts | 3 ++-
app/client/src/utils/AnalyticsUtil.tsx | 2 +-
5 files changed, 9 insertions(+), 5 deletions(-)
diff --git a/app/client/src/components/editorComponents/GlobalSearch/SnippetsDescription.tsx b/app/client/src/components/editorComponents/GlobalSearch/SnippetsDescription.tsx
index 1c35274d3c..abe5cc1b51 100644
--- a/app/client/src/components/editorComponents/GlobalSearch/SnippetsDescription.tsx
+++ b/app/client/src/components/editorComponents/GlobalSearch/SnippetsDescription.tsx
@@ -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 }) {
- {args.map((arg: SnippetArgument) => (
+ {replaceableArgs.map((arg: SnippetArgument) => (
{
if (isSnippet(category)) {
- AnalyticsUtil.logEvent("SNIPPET_CATEGORY_CLICK");
+ AnalyticsUtil.logEvent("SNIPPET_LOOKUP");
}
dispatch(setGlobalSearchFilterContext({ category: category }));
},
diff --git a/app/client/src/components/editorComponents/GlobalSearch/utils.tsx b/app/client/src/components/editorComponents/GlobalSearch/utils.tsx
index 4cdb1e2c39..fafd0c2949 100644
--- a/app/client/src/components/editorComponents/GlobalSearch/utils.tsx
+++ b/app/client/src/components/editorComponents/GlobalSearch/utils.tsx
@@ -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 = {
diff --git a/app/client/src/sagas/ActionSagas.ts b/app/client/src/sagas/ActionSagas.ts
index 24d54d578c..26504f187f 100644
--- a/app/client/src/sagas/ActionSagas.ts
+++ b/app/client/src/sagas/ActionSagas.ts
@@ -887,7 +887,8 @@ function* executeCommandSaga(actionPayload: ReduxAction) {
: 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),
});
diff --git a/app/client/src/utils/AnalyticsUtil.tsx b/app/client/src/utils/AnalyticsUtil.tsx
index 91fad978e3..a064aa7c44 100644
--- a/app/client/src/utils/AnalyticsUtil.tsx
+++ b/app/client/src/utils/AnalyticsUtil.tsx
@@ -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"