For what interval of $a$ is $\int_0^{\frac\pi2}\frac{\cos a\sin x}{1+\sin a\sin x}dx =a\csc a-\frac\pi2\tan \frac a2$ valid? In my previous Question [1], @Quanto has defined
$$J(a) = \int_0^{\frac\pi2}\ln(1+\sin a\sin x)\,dx$$
and stated
$$J'(a)
=\int_0^{\frac\pi2}\frac{\cos a\sin x}{1+\sin a\sin x}\,dx
=a\csc a-\frac\pi2\tan \frac a2
$$
But, I was wondering if this is valid $\forall a\in \Bbb R-{{n\pi}}$.
Using Desmos, it seems that this is valid for $a\in \Big(-\frac{3\pi}{2},\frac{\pi}{2}\Big)$. Is there any explanation can we offer?
On desmos, I run $a$ from $-1000$ to $1000$ and I see that the the Integral $\Big(J'(a)\Big)$ achieves value only from $-\pi$ to $\pi$.
 A: Note
\begin{align}
I=\int_0^{\frac\pi2}\frac{\cos a\sin x}{1+\sin a\sin x}dx
= \cot a\left( \frac\pi2 - \int_0^{\frac\pi2}\frac{1}{1+\sin a\sin x}dx\right)\tag1\\
\end{align}
With $\cos x= \frac{1-\tan^2\frac x2}{1+\tan^2\frac x2}$
\begin{align}& \int_0^{\frac\pi2}\frac{1}{1+\sin a\sin x}dx 
=\int_0^{\frac\pi2}\frac{1}{1+\sin a\cos x}dx \\
= &\>2\int_0^{\frac\pi2}\frac{d(\tan\frac x2)}{(1-\sin a)\tan^2\frac x2+(1+\sin a)}\\
= &\>2\sec a \tan^{-1}\left(\tan(\frac\pi4 -\frac a2)\right) 
=\>\sec a \>\left(\frac\pi2 -a \right)\tag2\\
\end{align}
where the last step requires $\frac\pi4 -\frac a2\in (-\frac\pi2,\frac\pi2)$, or $a\in ( - \frac\pi2, \frac{3\pi}2)$.
Substitute (2) into (1) to arrive at
$$I=a\csc a-\frac\pi2\tan \frac a2$$
A: Using the tangent half-angle substitution,
$$\int\frac{\cos (a)\sin (x)}{1+\sin (a)\sin (x)}dx=x \cot (a)+2 \csc (a) \tan ^{-1}\Bigg[\cos \left(\frac{a-x}{2}\right) \csc
   \left(\frac{a+x}{2}\right)\Bigg]$$
$$\int_0^{\frac\pi2}\frac{\cos (a)\sin (x)}{1+\sin (a)\sin (x)}dx=\frac{1}{2} \pi  \cot \left(\frac{a}{2}\right)-2 \csc (a) \tan ^{-1}\Big[\cot
   \left(\frac{a}{2}\right)\Big]$$
Being lazy, I asked a CAS for restrictions and it gave
$$\Re\left(\cos ^{-1}(\csc (a))\right)\geq \pi \lor \Re\left(\sin ^{-1}(\csc
   (a))\right)>0\lor \sin ^{-1}(\csc (a))\notin \mathbb{R}$$
