feat: add analytics logging while hoppscotch requests are fired
This commit is contained in:
@@ -13,6 +13,13 @@ type SettingsCustomDimensions = {
|
||||
syncHistory: boolean
|
||||
}
|
||||
|
||||
type HoppRequestEvent =
|
||||
| {
|
||||
platform: "rest" | "graphql-query" | "graphql-schema"
|
||||
strategy: "normal" | "proxy" | "extension"
|
||||
}
|
||||
| { platform: "wss" | "sse" | "socketio" | "mqtt" }
|
||||
|
||||
export function initAnalytics() {
|
||||
analytics = firebase.app().analytics()
|
||||
|
||||
@@ -46,3 +53,7 @@ function initSettingsListeners() {
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
export function logHoppRequestRunToAnalytics(ev: HoppRequestEvent) {
|
||||
analytics.logEvent("hopp-request", ev)
|
||||
}
|
||||
|
||||
@@ -25,5 +25,21 @@ const runAppropriateStrategy = (req) => {
|
||||
return AxiosStrategy(req)
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns an identifier for how a request will be ran
|
||||
* if the system is asked to fire a request
|
||||
*
|
||||
* @returns {"normal" | "extension" | "proxy"}
|
||||
*/
|
||||
export function getCurrentStrategyID() {
|
||||
if (isExtensionsAllowed() && hasExtensionInstalled()) {
|
||||
return "extension"
|
||||
} else if (settingsStore.value.PROXY_ENABLED) {
|
||||
return "proxy"
|
||||
} else {
|
||||
return "normal"
|
||||
}
|
||||
}
|
||||
|
||||
export const sendNetworkRequest = (req) =>
|
||||
runAppropriateStrategy(req).finally(() => window.$nuxt.$loading.finish())
|
||||
|
||||
Reference in New Issue
Block a user