p. 464 Top of Calculus: Early Transcendentals (6 edn 2007) doesn't explain the discovery of this trick (in this question's title), that thus feels clairvoyant.
I understand, but ask not about, other less tricky methods to calculate $\int \sec x \,dx $.