It's not clear if you are purchasing the Alaska Airlines ticket together with your international flight - and the situation is very different depending on whether you are.
To answer your main question, 4 hours is plenty of time to make your way from an International arrival to a domestic connection at SFO. Given check-in (and bag drop) cut-off deadlines that still gives you around 3+ hours, which is plenty of time. SFO is a relatively easy airport to get around, and although delays at immigration can occur, they would not cause you to miss a connecting flight 4 hours later.
Of course, that presumes your inbound flight is on-time. If it is delayed by more than an hour, especially if more than 2 hours, then things will get more complex.
If you have purchased your flights together, and the inbound is delayed, then it is the airlines responsibility to move you to a later flight if you don't make your connection. So if your flights are booked together, 4 hours is still plenty as you can rely on them rebooking you if needed.
If you are NOT booking the two flights together, then the best advice I can give is to NOT fly Alaska Airlines, but instead look at flying United Airlines. United have what is called a "flat tire" policy, which means that if you arrive at the airport late - such as if your inbound flight was delayed - then they will make every effort to move you to a later flight free of charge. Alaska do not have such a policy, and you will likely be forced to either buy a new ticket, or pay a change fee on your existing ticket.