Merge pull request #19788 from overleaf/mj-cite-key-search-ref-providers

[web] Add ref provider info to cite-key-search event

GitOrigin-RevId: 1f3828e3f5305f06190332b637860fde606f7484
This commit is contained in:
Mathias Jakobsen 2024-08-06 09:28:15 +01:00 committed by Copybot
parent d2289379cd
commit 7aaa78e635

View file

@ -30,6 +30,7 @@ import {
import { snippet } from './completions/data/environments'
import { syntaxTree } from '@codemirror/language'
import { sendMBSampled } from '@/infrastructure/event-tracking'
import getMeta from '@/utils/meta'
function blankCompletions(): Completions {
return {
@ -242,6 +243,7 @@ const debouncedCounter = (
const CITE_ANALYTICS_REPORT_TIMEOUT = 4000
const analyticsSourceBuilder = (debounceTimes: number[]) => {
const user = getMeta('ol-user')
let timeoutId = 0
const counters = debounceTimes.map(debounceTime => {
if (debounceTime >= CITE_ANALYTICS_REPORT_TIMEOUT) {
@ -265,7 +267,12 @@ const analyticsSourceBuilder = (debounceTimes: number[]) => {
clearTimeout(timeoutId)
}
timeoutId = window.setTimeout(() => {
const result: Record<string, number> = {}
const result: Record<string, number | boolean | undefined> = {
mendeley: Boolean(
user?.features?.mendeley && user?.refProviders?.mendeley
),
zotero: Boolean(user?.features?.zotero && user?.refProviders?.zotero),
}
counters.forEach(debouncedCounter => {
result[`${debouncedCounter.debounceTime}ms`] = debouncedCounter.counter
})