Concept:
For integrals involving exponentials, substitution simplifies the expression considerably.
Step 1: Use substitution \(e^x=t\).
Let
\[
e^x=t
\]
Then,
\[
e^{2x}=t^2
\]
and
\[
dx=\frac{dt}{t}
\]
Thus,
\[
I=\int \frac{t^2-1}{t^2+t+1}\cdot \frac{dt}{t}
\]
Factor numerator:
\[
t^2-1=(t-1)(t+1)
\]
So,
\[
I=\int \frac{(t-1)(t+1)}{t(t^2+t+1)}dt
\]
Using partial fractions,
\[
\frac{t^2-1}{t(t^2+t+1)}
=
-\frac1t+\frac{2t+1}{t^2+t+1}
\]
Hence,
\[
I=\int -\frac1t\,dt+\int \frac{2t+1}{t^2+t+1}\,dt
\]
Step 2: Integrate each term.
\[
\int -\frac1t\,dt=-\log|t|
\]
and
\[
\int \frac{2t+1}{t^2+t+1}dt
=
\log(t^2+t+1)
\]
Therefore,
\[
I=
\log(t^2+t+1)-\log t+c
\]
Substituting \(t=e^x\),
\[
I=
\log(e^{2x}+e^x+1)-x+c
\]
Hence the answer is
\[
\boxed{
\log(e^{2x}+e^x+1)-x+c
}
\]