The integral is $$\int \frac{\mathrm{d}x}{\sin^2 x+\sin x+1}$$
Consider $$\int \frac{\mathrm{d}x}{ax^2+bx+c}$$ There are a total of three cases, depending on the discriminant of $ax^2+bx+c$. Two of which are shown here (#1).
The third one, i.e. when $\Delta=0$, simply means evaluating $$\frac{1}{a}\int \frac{\mathrm{d}x}{\big(x+\frac{b}{2a}\big)^2} $$
For the first two cases, you can see different substitutions are used so as to prevent $i$ from appearing in the answer, hence resulting in an $\arctan$ function and a $\ln$ function respectively. The discrepancy arises when we change $+(4ac-b^2)$ to $-(b^2-4ac)$.
In general, is it possible to evaluate $$\int \frac{\mathrm{d}x}{a\sin^2 x+b\sin x+c}$$ such that the result does not contain complex numbers when $\Delta_{\sin x}<0$?
The only approach I can think of when $\Delta_{\sin x}>0$ is by partial fraction decomposition, which differs from the method of substitution used above.