Help with understanding quaternion vs euler rotation

I’ve started to clean up my device rotation script where I read in a phones alpha, beta and gamma values and map them to a target (camera) rotation. So far It’s working well, but I’ve also wanted to integrate optional offsets for x and y rotation.

See the project here, the script in question is “deviceRotation.js” at the “main” entity.

Given a calculated quaternion (based on the device rotation) I’ve first added the x-offset using a quaternion multiplication, using the following code:

        var q3 = new pc.Quat();

This also works fine, but I then wanted to integrate the yOffset as well, using a similar approach:

        var q4 = new pc.Quat();

This creates a weird camera rotation. I kinda got the thing working, applying the yOffset after I’ve applied the quaternion to the target.;,this.yOffset,0)

But shouldn’t both versions work, asuming they do exactly the same thing?
Thanks for any heads up.