I don’t think you can replace the optical sensor since most mouses have it soldered on the mainboard.
open