I’m not sure what your question is. The GraphObject.click event handler is passed two arguments. The second argument is that GraphObject on which the event handler was defined. So:
$(go.Shape, "Circle",
{ . . .,
portId: . . .,
click: function(e, shape) {
console.log("clicked port: " + shape.portId);
}
})