|
1 | 1 | import { createSlice } from '@reduxjs/toolkit'
|
2 | 2 | import { cloneDeep } from 'lodash'
|
3 | 3 | import axios, { CancelTokenSource } from 'axios'
|
| 4 | +import * as jsonpath from 'jsonpath' |
4 | 5 |
|
5 | 6 | import { ApiEndpoints } from 'uiSrc/constants'
|
6 | 7 | import { apiService } from 'uiSrc/services'
|
@@ -183,17 +184,23 @@ export function setReJSONDataAction(
|
183 | 184 | )
|
184 | 185 |
|
185 | 186 | if (isStatusSuccessful(status)) {
|
186 |
| - sendEventTelemetry({ |
187 |
| - event: getBasedOnViewTypeEvent( |
188 |
| - state.browser.keys?.viewType, |
189 |
| - TelemetryEvent.BROWSER_KEY_VALUE_EDITED, |
190 |
| - TelemetryEvent.TREE_VIEW_KEY_VALUE_EDITED |
191 |
| - ), |
192 |
| - eventData: { |
193 |
| - databaseId: state.connections.instances?.connectedInstance?.id, |
194 |
| - keyLevel: getJsonPathLevel(path), |
195 |
| - } |
196 |
| - }) |
| 187 | + try { |
| 188 | + const isEditMode = jsonpath.query(state.browser.rejson?.data?.data, `$..${path}`).length > 0 |
| 189 | + sendEventTelemetry({ |
| 190 | + event: getBasedOnViewTypeEvent( |
| 191 | + state.browser.keys?.viewType, |
| 192 | + TelemetryEvent[`BROWSER_JSON_PROPERTY_${isEditMode ? 'EDITED' : 'ADDED'}`], |
| 193 | + TelemetryEvent[`TREE_VIEW_JSON_PROPERTY_${isEditMode ? 'EDITED' : 'ADDED'}`], |
| 194 | + ), |
| 195 | + eventData: { |
| 196 | + databaseId: state.connections.instances?.connectedInstance?.id, |
| 197 | + keyLevel: getJsonPathLevel(path), |
| 198 | + } |
| 199 | + }) |
| 200 | + } catch (error) { |
| 201 | + // console.log(error) |
| 202 | + } |
| 203 | + |
197 | 204 | dispatch(setReJSONDataSuccess())
|
198 | 205 | dispatch<any>(fetchReJSON(key, '.'))
|
199 | 206 | dispatch<any>(refreshKeyInfoAction(key))
|
@@ -236,7 +243,7 @@ export function appendReJSONArrayItemAction(
|
236 | 243 | sendEventTelemetry({
|
237 | 244 | event: getBasedOnViewTypeEvent(
|
238 | 245 | state.browser.keys?.viewType,
|
239 |
| - TelemetryEvent.BROWSER_KEY_VALUE_ADDED, |
| 246 | + TelemetryEvent.BROWSER_JSON_PROPERTY_ADDED, |
240 | 247 | TelemetryEvent.TREE_VIEW_JSON_PROPERTY_ADDED
|
241 | 248 | ),
|
242 | 249 | eventData: {
|
|
0 commit comments