Skip to content

Commit

Permalink
* Fixed that user-info was not showing up in sentry error sends. (app…
Browse files Browse the repository at this point in the history
…arently the "auth" key on the context-object is reserved or something; so now putting the data under "user" key)

* Removed map-view data from sentry error sends. (was meant to help with debugging, but perhaps too sensitive in some cases)
  • Loading branch information
Venryx committed Feb 25, 2024
1 parent 8d00f88 commit 5d7a331
Showing 1 changed file with 16 additions and 30 deletions.
46 changes: 16 additions & 30 deletions Packages/client/Source/Utils/AutoRuns/AddUserInfoToRavenContext.ts
Original file line number Diff line number Diff line change
@@ -1,39 +1,25 @@
import {autorun} from "web-vcore/nm/mobx.js";
import {GetOpenMapID} from "Store/main";
import {GetMapView} from "Store/main/maps/mapViews/$mapView.js";
import {Me} from "dm_common";
import {Clone} from "web-vcore/nm/js-vextensions.js";
import Raven from "web-vcore/nm/raven-js";
import {Me} from "dm_common";
import {AutoRun_HandleBail} from "./@Helpers.js";

let lastUser;
let lastContextData; // only gets updated when one of the above components change
AutoRun_HandleBail(()=>{
// edit: something used to be here?
let lastAuth;
let lastMapView;
let lastContextData; // only gets updated when one of the above components change
AutoRun_HandleBail(()=>{
// const auth = GetAuth();
//const auth = GetAuth_Raw();
const auth = Me();
const mapView = GetOpenMapID() ? GetMapView(GetOpenMapID()) : null;
const user = Me();

let newContextData;
const ExtendNewContextData = newData=>{
if (newContextData == null) newContextData = Clone(lastContextData || {});
newContextData.Extend(newData);
};
// if (auth != lastAuth) ExtendNewContextData({ auth: auth ? auth.IncludeKeys('id', 'displayName') : null });
//if (auth != lastAuth) ExtendNewContextData({auth: auth ? auth.IncludeKeys("uid", "displayName", "email", "photoURL") : null});
if (auth != lastAuth) ExtendNewContextData({auth: auth ? auth.IncludeKeys("id", "displayName", /*"email",*/ "photoURL") : null});
if (mapView != lastMapView) ExtendNewContextData({mapView});
let newContextData;
const ExtendNewContextData = newData=>{
if (newContextData == null) newContextData = Clone(lastContextData || {});
Object.assign(newContextData, newData);
};
if (user != lastUser) ExtendNewContextData({user});

if (newContextData != null) {
// Log('Setting user-context: ', newContextData);
Raven.setUserContext(newContextData);
lastContextData = newContextData;
}
if (newContextData != null) {
//console.log("Setting context data: ", newContextData);
Raven.setUserContext(newContextData);
lastContextData = newContextData;
}

lastAuth = auth;
lastMapView = mapView;
});
lastUser = user;
}, {name: "AddUserInfoToRavenContext"});

0 comments on commit 5d7a331

Please sign in to comment.