Skip to content

Commit

Permalink
fix(logging): return necessary values (#2870)
Browse files Browse the repository at this point in the history
  • Loading branch information
rxri authored Feb 28, 2024
1 parent c20c485 commit 34b89f5
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 7 deletions.
8 changes: 5 additions & 3 deletions jsHelper/spicetifyWrapper.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
window.Spicetify = {
get CosmosAsync() {
return Spicetify.Player.origin?._cosmos;
},
Player: {
addEventListener: (type, callback) => {
if (!(type in Spicetify.Player.eventListeners)) {
Expand Down Expand Up @@ -390,6 +387,11 @@ window.Spicetify = {
};

Spicetify.Player.origin._cosmos = new Proxy(Spicetify.Player.origin._cosmos, handler);
Object.defineProperty(Spicetify, "CosmosAsync", {
get: () => {
return Spicetify.Player.origin?._cosmos;
}
});
})();

(function waitForPlatform() {
Expand Down
14 changes: 10 additions & 4 deletions src/preprocess/preprocess.go
Original file line number Diff line number Diff line change
Expand Up @@ -324,10 +324,10 @@ func disableLogging(input string) string {
return fmt.Sprintf("%sreturn;", submatches[0])
})
utils.Replace(&input, `key:"logInteraction",value:function\([\w,]+\)\{`, func(submatches ...string) string {
return fmt.Sprintf("%sreturn{interactionId:null,pageInstanceId:null};", submatches[0])
return fmt.Sprintf("%sreturn {interactionId:null,pageInstanceId:null};", submatches[0])
})
utils.Replace(&input, `key:"logNonAuthInteraction",value:function\([\w,]+\)\{`, func(submatches ...string) string {
return fmt.Sprintf("%sreturn{interactionId:null,pageInstanceId:null};", submatches[0])
return fmt.Sprintf("%sreturn {interactionId:null,pageInstanceId:null};", submatches[0])
})
utils.Replace(&input, `key:"logImpression",value:function\([\w,]+\)\{`, func(submatches ...string) string {
return fmt.Sprintf("%sreturn;", submatches[0])
Expand All @@ -354,11 +354,14 @@ func disableLogging(input string) string {
return fmt.Sprintf("%s{return;}%s", submatches[1], submatches[2])
})
utils.Replace(&input, `key:"lastFlush",value:function\(\)\{`, func(submatches ...string) string {
return fmt.Sprintf("%sreturn;", submatches[0])
return fmt.Sprintf("%sreturn Promise.resolve({fired:true});", submatches[0])
})
utils.Replace(&input, `key:"addItemInEventsStorage",value:function\([^)]*\)\s*\{`, func(submatches ...string) string {
return fmt.Sprintf("%sreturn;", submatches[0])
})
utils.Replace(&input, `key:"createLoggingParams",value:function\([^)]*\)\s*\{`, func(submatches ...string) string {
return fmt.Sprintf("%sreturn {interactionIds:null,pageInstanceIds:null};", submatches[0])
})

utils.Replace(&input, `registerEventListeners\([^)]*\)\s*\{`, func(submatches ...string) string {
return fmt.Sprintf("%sreturn;", submatches[0])
Expand All @@ -385,11 +388,14 @@ func disableLogging(input string) string {
return fmt.Sprintf("%sreturn;", submatches[0])
})
utils.Replace(&input, `lastFlush\([^)]*\)\s*\{`, func(submatches ...string) string {
return fmt.Sprintf("%sreturn;", submatches[0])
return fmt.Sprintf("%sreturn Promise.resolve({fired:true});", submatches[0])
})
utils.Replace(&input, `addItemInEventsStorage\([^)]*\)\s*\{`, func(submatches ...string) string {
return fmt.Sprintf("%sreturn;", submatches[0])
})
utils.Replace(&input, `createLoggingParams\([^)]*\)\s*\{`, func(submatches ...string) string {
return fmt.Sprintf("%sreturn {interactionIds:null,pageInstanceIds:null};", submatches[0])
})

return input
}
Expand Down

0 comments on commit 34b89f5

Please sign in to comment.