fix Discord invite page crashing in browser version
This commit is contained in:
parent
2f786a2ee5
commit
4c7e8cd4cb
1 changed files with 34 additions and 1 deletions
|
|
@ -21,6 +21,7 @@ import { Devs } from "@utils/constants";
|
||||||
import { Logger } from "@utils/Logger";
|
import { Logger } from "@utils/Logger";
|
||||||
import definePlugin, { OptionType, StartAt } from "@utils/types";
|
import definePlugin, { OptionType, StartAt } from "@utils/types";
|
||||||
import { WebpackRequire } from "@vencord/discord-types/webpack";
|
import { WebpackRequire } from "@vencord/discord-types/webpack";
|
||||||
|
import { Flux, FluxDispatcher } from "@webpack/common";
|
||||||
|
|
||||||
const settings = definePluginSettings({
|
const settings = definePluginSettings({
|
||||||
disableAnalytics: {
|
disableAnalytics: {
|
||||||
|
|
@ -45,7 +46,7 @@ export default definePlugin({
|
||||||
predicate: () => settings.store.disableAnalytics,
|
predicate: () => settings.store.disableAnalytics,
|
||||||
replacement: {
|
replacement: {
|
||||||
match: /\(0,\i\.analyticsTrackingStoreMaker\)/,
|
match: /\(0,\i\.analyticsTrackingStoreMaker\)/,
|
||||||
replace: "(()=>{})",
|
replace: "$self.analyticsTrackingStoreMaker",
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
|
@ -140,5 +141,37 @@ export default definePlugin({
|
||||||
Reflect.deleteProperty(window, "DiscordSentry");
|
Reflect.deleteProperty(window, "DiscordSentry");
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
},
|
||||||
|
|
||||||
|
analyticsTrackingStoreMaker() {
|
||||||
|
class AnalyticsTrackingStoreStub extends Flux.Store {
|
||||||
|
static displayName = "AnalyticsTrackingStore";
|
||||||
|
|
||||||
|
requestDrain() { }
|
||||||
|
|
||||||
|
async submitEventsImmediately() {
|
||||||
|
// This is supposed to return a Discord rest response but we can't know what the correct shape would be, because
|
||||||
|
// 1. It's not used anywhere
|
||||||
|
// 2. It takes a dynamic url
|
||||||
|
// Instead we throw an error with the same structure as a Discord rest error which they probably should handle gracefully.
|
||||||
|
// Discord also throws a plain object instead of Error class
|
||||||
|
|
||||||
|
throw {
|
||||||
|
ok: false,
|
||||||
|
status: 500,
|
||||||
|
body: {
|
||||||
|
message: "Analytics tracking is disabled by NoTrack",
|
||||||
|
code: 0
|
||||||
|
},
|
||||||
|
headers: {},
|
||||||
|
text: JSON.stringify({
|
||||||
|
message: "Analytics tracking is disabled by NoTrack",
|
||||||
|
code: 0
|
||||||
|
})
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return new AnalyticsTrackingStoreStub(FluxDispatcher);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue