The integration of
$$\int^\pi_0 \sin(\theta) \delta(\cos\theta - 1)\, d \theta$$
can be derived by replacing $d\theta$ with $d\cos\theta$
$$\begin{align*} \int^\pi_0 \sin(\theta) \delta(\cos\theta - 1)\, d \theta &= -\int^{-1}_1 \delta(x - 1)\, dx \quad (\text{let } x = \cos\theta, dx = -\sin(\theta)\,d\theta) \\ &= \int^1_{-1} \delta(x - 1)\, dx \\ &= 1 \end{align*}$$
However, if I don't replace the base and apply the definition of Dirac delta ($\int f(x)\delta(x -a)\,dx = f(a)$)directly, the result become $0$.
$$\begin{align*} \int^\pi_0 \sin(\theta) \delta(\cos\theta - 1)\, d \theta &= \sin(0) \\ &= 0 \end{align*}$$
What is wrong with the second approach?
I have seen the other solution that replace $\delta(\cos\theta - 1)$ at Dirac delta integral of cosx
$$\begin{align*} \int^\pi_0 \sin(\theta) \delta(\cos\theta - 1)\, d \theta &= \int^\pi_0 \sin(\theta) \frac{\delta(\theta - \frac{\pi}{2})}{|-\sin\frac{\pi}{2}|}\, d \theta \\ &= \int^\pi_0 \sin(\theta) \delta(\theta - \frac{\pi}{2})\, d \theta \\ &= \sin(\frac{\pi}{2}) \\ &= 1 \end{align*}$$
Is the replacement of the Dirac delta function necessary? Why it's required and how is the replacement derived?