feat: add analytics logging while hoppscotch requests are fired
This commit is contained in:
@@ -121,6 +121,7 @@
|
|||||||
<script>
|
<script>
|
||||||
import Paho from "paho-mqtt"
|
import Paho from "paho-mqtt"
|
||||||
import debounce from "~/helpers/utils/debounce"
|
import debounce from "~/helpers/utils/debounce"
|
||||||
|
import { logHoppRequestRunToAnalytics } from "~/helpers/fb/analytics"
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
data() {
|
data() {
|
||||||
@@ -191,6 +192,10 @@ export default {
|
|||||||
})
|
})
|
||||||
this.client.onConnectionLost = this.onConnectionLost
|
this.client.onConnectionLost = this.onConnectionLost
|
||||||
this.client.onMessageArrived = this.onMessageArrived
|
this.client.onMessageArrived = this.onMessageArrived
|
||||||
|
|
||||||
|
logHoppRequestRunToAnalytics({
|
||||||
|
platform: "mqtt",
|
||||||
|
})
|
||||||
},
|
},
|
||||||
onConnectionFailure() {
|
onConnectionFailure() {
|
||||||
this.connectionState = false
|
this.connectionState = false
|
||||||
|
|||||||
@@ -141,6 +141,7 @@
|
|||||||
import { io as Client } from "socket.io-client"
|
import { io as Client } from "socket.io-client"
|
||||||
import wildcard from "socketio-wildcard"
|
import wildcard from "socketio-wildcard"
|
||||||
import debounce from "~/helpers/utils/debounce"
|
import debounce from "~/helpers/utils/debounce"
|
||||||
|
import { logHoppRequestRunToAnalytics } from "~/helpers/fb/analytics"
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
data() {
|
data() {
|
||||||
@@ -262,6 +263,10 @@ export default {
|
|||||||
icon: "error",
|
icon: "error",
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
logHoppRequestRunToAnalytics({
|
||||||
|
platform: "socketio",
|
||||||
|
})
|
||||||
},
|
},
|
||||||
disconnect() {
|
disconnect() {
|
||||||
this.io.close()
|
this.io.close()
|
||||||
|
|||||||
@@ -48,6 +48,7 @@
|
|||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
|
import { logHoppRequestRunToAnalytics } from "~/helpers/fb/analytics"
|
||||||
import debounce from "~/helpers/utils/debounce"
|
import debounce from "~/helpers/utils/debounce"
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
@@ -158,6 +159,10 @@ export default {
|
|||||||
},
|
},
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|
||||||
|
logHoppRequestRunToAnalytics({
|
||||||
|
platform: "mqtt",
|
||||||
|
})
|
||||||
},
|
},
|
||||||
handleSSEError(error) {
|
handleSSEError(error) {
|
||||||
this.stop()
|
this.stop()
|
||||||
|
|||||||
@@ -159,6 +159,7 @@
|
|||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
|
import { logHoppRequestRunToAnalytics } from "~/helpers/fb/analytics"
|
||||||
import debounce from "~/helpers/utils/debounce"
|
import debounce from "~/helpers/utils/debounce"
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
@@ -273,6 +274,10 @@ export default {
|
|||||||
icon: "error",
|
icon: "error",
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
logHoppRequestRunToAnalytics({
|
||||||
|
platform: "wss",
|
||||||
|
})
|
||||||
},
|
},
|
||||||
disconnect() {
|
disconnect() {
|
||||||
if (this.socket) {
|
if (this.socket) {
|
||||||
|
|||||||
@@ -13,6 +13,13 @@ type SettingsCustomDimensions = {
|
|||||||
syncHistory: boolean
|
syncHistory: boolean
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type HoppRequestEvent =
|
||||||
|
| {
|
||||||
|
platform: "rest" | "graphql-query" | "graphql-schema"
|
||||||
|
strategy: "normal" | "proxy" | "extension"
|
||||||
|
}
|
||||||
|
| { platform: "wss" | "sse" | "socketio" | "mqtt" }
|
||||||
|
|
||||||
export function initAnalytics() {
|
export function initAnalytics() {
|
||||||
analytics = firebase.app().analytics()
|
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)
|
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) =>
|
export const sendNetworkRequest = (req) =>
|
||||||
runAppropriateStrategy(req).finally(() => window.$nuxt.$loading.finish())
|
runAppropriateStrategy(req).finally(() => window.$nuxt.$loading.finish())
|
||||||
|
|||||||
@@ -485,9 +485,10 @@
|
|||||||
import * as gql from "graphql"
|
import * as gql from "graphql"
|
||||||
import { commonHeaders } from "~/helpers/headers"
|
import { commonHeaders } from "~/helpers/headers"
|
||||||
import { getPlatformSpecialKey } from "~/helpers/platformutils"
|
import { getPlatformSpecialKey } from "~/helpers/platformutils"
|
||||||
import { sendNetworkRequest } from "~/helpers/network"
|
import { getCurrentStrategyID, sendNetworkRequest } from "~/helpers/network"
|
||||||
import { getSettingSubject } from "~/newstore/settings"
|
import { getSettingSubject } from "~/newstore/settings"
|
||||||
import { addGraphqlHistoryEntry } from "~/newstore/history"
|
import { addGraphqlHistoryEntry } from "~/newstore/history"
|
||||||
|
import { logHoppRequestRunToAnalytics } from "~/helpers/fb/analytics"
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
beforeRouteLeave(_to, _from, next) {
|
beforeRouteLeave(_to, _from, next) {
|
||||||
@@ -849,6 +850,11 @@ export default {
|
|||||||
})
|
})
|
||||||
console.log("Error", error)
|
console.log("Error", error)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
logHoppRequestRunToAnalytics({
|
||||||
|
platform: "graphql-query",
|
||||||
|
strategy: getCurrentStrategyID(),
|
||||||
|
})
|
||||||
},
|
},
|
||||||
|
|
||||||
// NOTE : schema required here is the GQL Schema document object, not the schema string
|
// NOTE : schema required here is the GQL Schema document object, not the schema string
|
||||||
@@ -918,6 +924,11 @@ export default {
|
|||||||
await this.getSchema()
|
await this.getSchema()
|
||||||
|
|
||||||
this.pollSchema()
|
this.pollSchema()
|
||||||
|
|
||||||
|
logHoppRequestRunToAnalytics({
|
||||||
|
platform: "graphql-schema",
|
||||||
|
strategy: getCurrentStrategyID(),
|
||||||
|
})
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
async pollSchema() {
|
async pollSchema() {
|
||||||
|
|||||||
@@ -766,7 +766,11 @@ import getEnvironmentVariablesFromScript from "~/helpers/preRequest"
|
|||||||
import runTestScriptWithVariables from "~/helpers/postwomanTesting"
|
import runTestScriptWithVariables from "~/helpers/postwomanTesting"
|
||||||
import parseTemplateString from "~/helpers/templating"
|
import parseTemplateString from "~/helpers/templating"
|
||||||
import { tokenRequest, oauthRedirect } from "~/helpers/oauth"
|
import { tokenRequest, oauthRedirect } from "~/helpers/oauth"
|
||||||
import { cancelRunningRequest, sendNetworkRequest } from "~/helpers/network"
|
import {
|
||||||
|
cancelRunningRequest,
|
||||||
|
getCurrentStrategyID,
|
||||||
|
sendNetworkRequest,
|
||||||
|
} from "~/helpers/network"
|
||||||
import {
|
import {
|
||||||
hasPathParams,
|
hasPathParams,
|
||||||
addPathParamsToVariables,
|
addPathParamsToVariables,
|
||||||
@@ -782,6 +786,7 @@ import { generateCodeWithGenerator } from "~/helpers/codegen/codegen"
|
|||||||
import { getSettingSubject, applySetting } from "~/newstore/settings"
|
import { getSettingSubject, applySetting } from "~/newstore/settings"
|
||||||
import { addRESTHistoryEntry } from "~/newstore/history"
|
import { addRESTHistoryEntry } from "~/newstore/history"
|
||||||
import clone from "lodash/clone"
|
import clone from "lodash/clone"
|
||||||
|
import { logHoppRequestRunToAnalytics } from "~/helpers/fb/analytics"
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
data() {
|
data() {
|
||||||
@@ -1642,6 +1647,11 @@ export default {
|
|||||||
response: syntheticResponse,
|
response: syntheticResponse,
|
||||||
})
|
})
|
||||||
this.testReports = testResults
|
this.testReports = testResults
|
||||||
|
|
||||||
|
logHoppRequestRunToAnalytics({
|
||||||
|
platform: "rest",
|
||||||
|
strategy: getCurrentStrategyID(),
|
||||||
|
})
|
||||||
},
|
},
|
||||||
getQueryStringFromPath() {
|
getQueryStringFromPath() {
|
||||||
const pathParsed = url.parse(this.uri)
|
const pathParsed = url.parse(this.uri)
|
||||||
|
|||||||
Reference in New Issue
Block a user