This is an end stop axis sensor used in the Flashforge brand series of 3D printers. As the use of these are mixed and matched between each variety of 3D printer, with different ones for different axes, it’s best to physically match the end stop you’re looking to replace with the version from the picture below.