forked from MapComplete/MapComplete
Fix: fix error reporting
This commit is contained in:
parent
7f5544c1e5
commit
913add4295
5 changed files with 48 additions and 43 deletions
|
@ -54,7 +54,7 @@ export class Changes {
|
|||
featureSwitchIsTesting?: Store<boolean>
|
||||
}
|
||||
osmConnection: OsmConnection
|
||||
reportError?: (error: string) => void
|
||||
reportError?: ((message: string | Error | XMLHttpRequest, extramessage?: string) => void),
|
||||
featureProperties?: FeaturePropertiesStore
|
||||
historicalUserLocations?: FeatureSource<Feature<Point, GeoLocationPointProperties>>
|
||||
allElements?: IndexedFeatureSource
|
||||
|
@ -75,7 +75,7 @@ export class Changes {
|
|||
}
|
||||
this.state = state
|
||||
this.backend = state.osmConnection.Backend()
|
||||
this._reportError = state.reportError
|
||||
this._reportError = (msg, err) => state.reportError(msg, err)
|
||||
this._changesetHandler = new ChangesetHandler(
|
||||
state.featureSwitches?.featureSwitchIsTesting ?? new ImmutableStore(false),
|
||||
state.osmConnection,
|
||||
|
@ -669,19 +669,24 @@ export class Changes {
|
|||
const createdIds = new Set(
|
||||
pending.filter((cd) => cd.changes !== undefined).map((cd) => cd.id)
|
||||
)
|
||||
pending.forEach((c) => {
|
||||
if (c.id < 0) {
|
||||
if (createdIds.has(c.id)) {
|
||||
for (const c of pending) {
|
||||
let id = c.id
|
||||
const newId = this._changesetHandler._remappings.get(c.type + "/" + c.id)
|
||||
if (newId) {
|
||||
id = Number(newId.split("/")[1])
|
||||
}
|
||||
if (id < 0) {
|
||||
if (createdIds.has(id)) {
|
||||
toUpload.push(c)
|
||||
} else {
|
||||
this._reportError(
|
||||
`Got an orphaned change. The 'creation'-change description for ${c.type}/${c.id} got lost. Permanently dropping this change:` +
|
||||
`Got an orphaned change. The 'creation'-change description for ${c.type}/${id} got lost. Permanently dropping this change:` +
|
||||
JSON.stringify(c)
|
||||
)
|
||||
}
|
||||
return
|
||||
continue
|
||||
}
|
||||
const matchFound = !!objects.find((o) => o.id === c.id && o.type === c.type)
|
||||
const matchFound = !!objects.find((o) => o.id === id && o.type === c.type)
|
||||
if (matchFound) {
|
||||
toUpload.push(c)
|
||||
} else {
|
||||
|
@ -689,12 +694,12 @@ export class Changes {
|
|||
"Refusing change about " +
|
||||
c.type +
|
||||
"/" +
|
||||
c.id +
|
||||
id +
|
||||
" as not in the objects. No internet?"
|
||||
)
|
||||
refused.push(c)
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
return { refused, toUpload }
|
||||
}
|
||||
|
|
|
@ -40,7 +40,8 @@ export class ChangesetHandler {
|
|||
private readonly backend: string
|
||||
|
||||
/**
|
||||
* Contains previously rewritten IDs
|
||||
* Contains previously rewritten IDs, e.g. {"node/-1" --> "node/123456"}
|
||||
*
|
||||
* @private
|
||||
*/
|
||||
public readonly _remappings = new Map<string, string>()
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
import { Changes } from "../../Logic/Osm/Changes"
|
||||
import { NewGeometryFromChangesFeatureSource } from "../../Logic/FeatureSource/Sources/NewGeometryFromChangesFeatureSource"
|
||||
import {
|
||||
NewGeometryFromChangesFeatureSource
|
||||
} from "../../Logic/FeatureSource/Sources/NewGeometryFromChangesFeatureSource"
|
||||
import { WithLayoutSourceState } from "./WithLayoutSourceState"
|
||||
import ThemeConfig from "../ThemeConfig/ThemeConfig"
|
||||
import { Utils } from "../../Utils"
|
||||
|
@ -18,9 +20,7 @@ import { Map as MlMap } from "maplibre-gl"
|
|||
import FilteringFeatureSource from "../../Logic/FeatureSource/Sources/FilteringFeatureSource"
|
||||
import ShowDataLayer from "../../UI/Map/ShowDataLayer"
|
||||
import SelectedElementTagsUpdater from "../../Logic/Actors/SelectedElementTagsUpdater"
|
||||
import NoElementsInViewDetector, {
|
||||
FeatureViewState,
|
||||
} from "../../Logic/Actors/NoElementsInViewDetector"
|
||||
import NoElementsInViewDetector, { FeatureViewState } from "../../Logic/Actors/NoElementsInViewDetector"
|
||||
|
||||
export class WithChangesState extends WithLayoutSourceState {
|
||||
readonly changes: Changes
|
||||
|
@ -43,7 +43,7 @@ export class WithChangesState extends WithLayoutSourceState {
|
|||
osmConnection: this.osmConnection,
|
||||
featureProperties: this.featureProperties,
|
||||
historicalUserLocations: this.historicalUserLocations,
|
||||
reportError: this.reportError,
|
||||
reportError: (err, msg) => this.reportError(err, msg)
|
||||
},
|
||||
theme?.isLeftRightSensitive() ?? false
|
||||
)
|
||||
|
@ -104,16 +104,6 @@ export class WithChangesState extends WithLayoutSourceState {
|
|||
return
|
||||
}
|
||||
const isTesting = this.featureSwitchIsTesting?.data
|
||||
console.log(
|
||||
isTesting
|
||||
? ">>> _Not_ reporting error to report server as testmode is on"
|
||||
: ">>> Reporting error to",
|
||||
Constants.ErrorReportServer,
|
||||
message
|
||||
)
|
||||
if (isTesting) {
|
||||
return
|
||||
}
|
||||
|
||||
if ("" + message === "[object XMLHttpRequest]") {
|
||||
const req = <XMLHttpRequest>message
|
||||
|
@ -137,25 +127,35 @@ export class WithChangesState extends WithLayoutSourceState {
|
|||
}
|
||||
|
||||
const stacktrace: string = new Error().stack
|
||||
|
||||
try {
|
||||
const err = {
|
||||
stacktrace,
|
||||
message: "" + message,
|
||||
theme: this.theme?.id,
|
||||
version: Constants.vNumber,
|
||||
language: this.userRelatedState.language.data,
|
||||
username: this.osmConnection.userDetails.data?.name,
|
||||
userid: this.osmConnection.userDetails.data?.uid,
|
||||
pendingChanges: this.changes.pendingChanges.data,
|
||||
previousChanges: this.changes.allChanges.data,
|
||||
changeRewrites: Utils.MapToObj(this.changes._changesetHandler._remappings)
|
||||
}
|
||||
console.trace(
|
||||
isTesting
|
||||
? ">>> _Not_ reporting error to report server as testmode is on"
|
||||
: ">>> Reporting error to",
|
||||
Constants.ErrorReportServer,
|
||||
message, err
|
||||
)
|
||||
if (isTesting) {
|
||||
return
|
||||
}
|
||||
await fetch(Constants.ErrorReportServer, {
|
||||
method: "POST",
|
||||
body: JSON.stringify({
|
||||
stacktrace,
|
||||
message: "" + message,
|
||||
theme: this.theme.id,
|
||||
version: Constants.vNumber,
|
||||
language: this.userRelatedState.language.data,
|
||||
username: this.osmConnection.userDetails.data?.name,
|
||||
userid: this.osmConnection.userDetails.data?.uid,
|
||||
pendingChanges: this.changes.pendingChanges.data,
|
||||
previousChanges: this.changes.allChanges.data,
|
||||
changeRewrites: Utils.MapToObj(this.changes._changesetHandler._remappings),
|
||||
}),
|
||||
body: JSON.stringify(err)
|
||||
})
|
||||
} catch (e) {
|
||||
console.error("Could not upload an error report")
|
||||
console.error("Could not upload an error report", e)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -29,7 +29,7 @@ export class WithImageState extends WithGuiState implements SpecialVisualization
|
|||
this.osmConnection,
|
||||
this.changes,
|
||||
this.geolocation.geolocationState.currentGPSLocation,
|
||||
this.reportError
|
||||
(err, msg) => this.reportError(err, msg)
|
||||
)
|
||||
const longAgo = new Date()
|
||||
longAgo.setTime(new Date().getTime() - 5 * 365 * 24 * 60 * 60 * 1000)
|
||||
|
|
|
@ -3,7 +3,7 @@ import {
|
|||
DataDrivenPropertyValueSpecification,
|
||||
LayerSpecification,
|
||||
Map as MlMap,
|
||||
SymbolLayerSpecification,
|
||||
SymbolLayerSpecification
|
||||
} from "maplibre-gl"
|
||||
import Locale from "../i18n/Locale"
|
||||
import { Utils } from "../../Utils"
|
||||
|
@ -1752,7 +1752,6 @@ export class ProtomapsLanguageSupport {
|
|||
}
|
||||
const newExpressionF = ProtomapsLanguageSupport.expressions[layer.id]
|
||||
if (!newExpressionF) {
|
||||
console.log(">>> No function found for", layer.id)
|
||||
return
|
||||
}
|
||||
const newExpression = newExpressionF(language)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue