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>
|
featureSwitchIsTesting?: Store<boolean>
|
||||||
}
|
}
|
||||||
osmConnection: OsmConnection
|
osmConnection: OsmConnection
|
||||||
reportError?: (error: string) => void
|
reportError?: ((message: string | Error | XMLHttpRequest, extramessage?: string) => void),
|
||||||
featureProperties?: FeaturePropertiesStore
|
featureProperties?: FeaturePropertiesStore
|
||||||
historicalUserLocations?: FeatureSource<Feature<Point, GeoLocationPointProperties>>
|
historicalUserLocations?: FeatureSource<Feature<Point, GeoLocationPointProperties>>
|
||||||
allElements?: IndexedFeatureSource
|
allElements?: IndexedFeatureSource
|
||||||
|
@ -75,7 +75,7 @@ export class Changes {
|
||||||
}
|
}
|
||||||
this.state = state
|
this.state = state
|
||||||
this.backend = state.osmConnection.Backend()
|
this.backend = state.osmConnection.Backend()
|
||||||
this._reportError = state.reportError
|
this._reportError = (msg, err) => state.reportError(msg, err)
|
||||||
this._changesetHandler = new ChangesetHandler(
|
this._changesetHandler = new ChangesetHandler(
|
||||||
state.featureSwitches?.featureSwitchIsTesting ?? new ImmutableStore(false),
|
state.featureSwitches?.featureSwitchIsTesting ?? new ImmutableStore(false),
|
||||||
state.osmConnection,
|
state.osmConnection,
|
||||||
|
@ -669,19 +669,24 @@ export class Changes {
|
||||||
const createdIds = new Set(
|
const createdIds = new Set(
|
||||||
pending.filter((cd) => cd.changes !== undefined).map((cd) => cd.id)
|
pending.filter((cd) => cd.changes !== undefined).map((cd) => cd.id)
|
||||||
)
|
)
|
||||||
pending.forEach((c) => {
|
for (const c of pending) {
|
||||||
if (c.id < 0) {
|
let id = c.id
|
||||||
if (createdIds.has(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)
|
toUpload.push(c)
|
||||||
} else {
|
} else {
|
||||||
this._reportError(
|
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)
|
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) {
|
if (matchFound) {
|
||||||
toUpload.push(c)
|
toUpload.push(c)
|
||||||
} else {
|
} else {
|
||||||
|
@ -689,12 +694,12 @@ export class Changes {
|
||||||
"Refusing change about " +
|
"Refusing change about " +
|
||||||
c.type +
|
c.type +
|
||||||
"/" +
|
"/" +
|
||||||
c.id +
|
id +
|
||||||
" as not in the objects. No internet?"
|
" as not in the objects. No internet?"
|
||||||
)
|
)
|
||||||
refused.push(c)
|
refused.push(c)
|
||||||
}
|
}
|
||||||
})
|
}
|
||||||
|
|
||||||
return { refused, toUpload }
|
return { refused, toUpload }
|
||||||
}
|
}
|
||||||
|
|
|
@ -40,7 +40,8 @@ export class ChangesetHandler {
|
||||||
private readonly backend: string
|
private readonly backend: string
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Contains previously rewritten IDs
|
* Contains previously rewritten IDs, e.g. {"node/-1" --> "node/123456"}
|
||||||
|
*
|
||||||
* @private
|
* @private
|
||||||
*/
|
*/
|
||||||
public readonly _remappings = new Map<string, string>()
|
public readonly _remappings = new Map<string, string>()
|
||||||
|
|
|
@ -1,5 +1,7 @@
|
||||||
import { Changes } from "../../Logic/Osm/Changes"
|
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 { WithLayoutSourceState } from "./WithLayoutSourceState"
|
||||||
import ThemeConfig from "../ThemeConfig/ThemeConfig"
|
import ThemeConfig from "../ThemeConfig/ThemeConfig"
|
||||||
import { Utils } from "../../Utils"
|
import { Utils } from "../../Utils"
|
||||||
|
@ -18,9 +20,7 @@ import { Map as MlMap } from "maplibre-gl"
|
||||||
import FilteringFeatureSource from "../../Logic/FeatureSource/Sources/FilteringFeatureSource"
|
import FilteringFeatureSource from "../../Logic/FeatureSource/Sources/FilteringFeatureSource"
|
||||||
import ShowDataLayer from "../../UI/Map/ShowDataLayer"
|
import ShowDataLayer from "../../UI/Map/ShowDataLayer"
|
||||||
import SelectedElementTagsUpdater from "../../Logic/Actors/SelectedElementTagsUpdater"
|
import SelectedElementTagsUpdater from "../../Logic/Actors/SelectedElementTagsUpdater"
|
||||||
import NoElementsInViewDetector, {
|
import NoElementsInViewDetector, { FeatureViewState } from "../../Logic/Actors/NoElementsInViewDetector"
|
||||||
FeatureViewState,
|
|
||||||
} from "../../Logic/Actors/NoElementsInViewDetector"
|
|
||||||
|
|
||||||
export class WithChangesState extends WithLayoutSourceState {
|
export class WithChangesState extends WithLayoutSourceState {
|
||||||
readonly changes: Changes
|
readonly changes: Changes
|
||||||
|
@ -43,7 +43,7 @@ export class WithChangesState extends WithLayoutSourceState {
|
||||||
osmConnection: this.osmConnection,
|
osmConnection: this.osmConnection,
|
||||||
featureProperties: this.featureProperties,
|
featureProperties: this.featureProperties,
|
||||||
historicalUserLocations: this.historicalUserLocations,
|
historicalUserLocations: this.historicalUserLocations,
|
||||||
reportError: this.reportError,
|
reportError: (err, msg) => this.reportError(err, msg)
|
||||||
},
|
},
|
||||||
theme?.isLeftRightSensitive() ?? false
|
theme?.isLeftRightSensitive() ?? false
|
||||||
)
|
)
|
||||||
|
@ -104,16 +104,6 @@ export class WithChangesState extends WithLayoutSourceState {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
const isTesting = this.featureSwitchIsTesting?.data
|
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]") {
|
if ("" + message === "[object XMLHttpRequest]") {
|
||||||
const req = <XMLHttpRequest>message
|
const req = <XMLHttpRequest>message
|
||||||
|
@ -137,25 +127,35 @@ export class WithChangesState extends WithLayoutSourceState {
|
||||||
}
|
}
|
||||||
|
|
||||||
const stacktrace: string = new Error().stack
|
const stacktrace: string = new Error().stack
|
||||||
|
|
||||||
try {
|
try {
|
||||||
await fetch(Constants.ErrorReportServer, {
|
const err = {
|
||||||
method: "POST",
|
|
||||||
body: JSON.stringify({
|
|
||||||
stacktrace,
|
stacktrace,
|
||||||
message: "" + message,
|
message: "" + message,
|
||||||
theme: this.theme.id,
|
theme: this.theme?.id,
|
||||||
version: Constants.vNumber,
|
version: Constants.vNumber,
|
||||||
language: this.userRelatedState.language.data,
|
language: this.userRelatedState.language.data,
|
||||||
username: this.osmConnection.userDetails.data?.name,
|
username: this.osmConnection.userDetails.data?.name,
|
||||||
userid: this.osmConnection.userDetails.data?.uid,
|
userid: this.osmConnection.userDetails.data?.uid,
|
||||||
pendingChanges: this.changes.pendingChanges.data,
|
pendingChanges: this.changes.pendingChanges.data,
|
||||||
previousChanges: this.changes.allChanges.data,
|
previousChanges: this.changes.allChanges.data,
|
||||||
changeRewrites: Utils.MapToObj(this.changes._changesetHandler._remappings),
|
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(err)
|
||||||
})
|
})
|
||||||
} catch (e) {
|
} 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.osmConnection,
|
||||||
this.changes,
|
this.changes,
|
||||||
this.geolocation.geolocationState.currentGPSLocation,
|
this.geolocation.geolocationState.currentGPSLocation,
|
||||||
this.reportError
|
(err, msg) => this.reportError(err, msg)
|
||||||
)
|
)
|
||||||
const longAgo = new Date()
|
const longAgo = new Date()
|
||||||
longAgo.setTime(new Date().getTime() - 5 * 365 * 24 * 60 * 60 * 1000)
|
longAgo.setTime(new Date().getTime() - 5 * 365 * 24 * 60 * 60 * 1000)
|
||||||
|
|
|
@ -3,7 +3,7 @@ import {
|
||||||
DataDrivenPropertyValueSpecification,
|
DataDrivenPropertyValueSpecification,
|
||||||
LayerSpecification,
|
LayerSpecification,
|
||||||
Map as MlMap,
|
Map as MlMap,
|
||||||
SymbolLayerSpecification,
|
SymbolLayerSpecification
|
||||||
} from "maplibre-gl"
|
} from "maplibre-gl"
|
||||||
import Locale from "../i18n/Locale"
|
import Locale from "../i18n/Locale"
|
||||||
import { Utils } from "../../Utils"
|
import { Utils } from "../../Utils"
|
||||||
|
@ -1752,7 +1752,6 @@ export class ProtomapsLanguageSupport {
|
||||||
}
|
}
|
||||||
const newExpressionF = ProtomapsLanguageSupport.expressions[layer.id]
|
const newExpressionF = ProtomapsLanguageSupport.expressions[layer.id]
|
||||||
if (!newExpressionF) {
|
if (!newExpressionF) {
|
||||||
console.log(">>> No function found for", layer.id)
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
const newExpression = newExpressionF(language)
|
const newExpression = newExpressionF(language)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue