All files / app/service bugs.ts

17.24% Statements 5/29
100% Branches 0/0
0% Functions 0/3
17.24% Lines 5/29

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68            89x   89x   88x                                             88x                                     88x                              
import { BugReportFormData } from "components/Navigation/ReportDialog";
import {
  GeolocationClickInfoReq,
  GeolocationSearchInfoReq,
  ReportBugReq,
  ScreenResolution,
} from "proto/bugs_pb";
 
import client from "./client";
 
export async function reportBug({
  description,
  results,
  subject,
}: BugReportFormData) {
  const req = new ReportBugReq();
 
  const screenResolution = new ScreenResolution();
  screenResolution.setWidth(window.innerWidth);
  screenResolution.setHeight(window.innerHeight);
 
  req.setSubject(subject);
  req.setDescription(description);
  req.setResults(results);
  req.setFrontendVersion(process.env.NEXT_PUBLIC_VERSION);
  req.setUserAgent(navigator.userAgent);
  req.setScreenResolution(screenResolution);
  req.setPage(window.location.href);
 
  const res = await client.bugs.reportBug(req);
  return res.toObject();
}
 
export async function geolocationSearchInfo({
  searchString,
  nominatimResultJson,
  formattedResultJson,
  durationMs,
}: {
  searchString: string;
  nominatimResultJson: string;
  formattedResultJson: string;
  durationMs: number;
}) {
  const req = new GeolocationSearchInfoReq();
  req.setSearchString(searchString);
  req.setNominatimResultJson(nominatimResultJson);
  req.setFormattedResultJson(formattedResultJson);
  req.setDurationMs(durationMs);
  await client.bugs.geolocationSearchInfo(req);
}
 
export async function geolocationClickInfo({
  context,
  formattedResultJson,
  searchChoiceJson,
}: {
  context: string;
  formattedResultJson: string;
  searchChoiceJson: string;
}) {
  const req = new GeolocationClickInfoReq();
  req.setContext(context);
  req.setFormattedResultJson(formattedResultJson);
  req.setSearchChoiceJson(searchChoiceJson);
  await client.bugs.geolocationClickInfo(req);
}