angulartics2
angulartics2 copied to clipboard
GA Mutates properties object
For support questions, please consider using Gitter - Chat
I'm submitting a ...
-
[x] bug report
-
[ ] feature request
-
[ ] question about the decisions made in the repository
-
What is the expected behavior?
const input = { id: 1 };
this.angulartics.eventTrack.next({
action: 'sell',
properties: input,
});
console.log(input); // { id: 1 }
this.apollo.mutate({ mutation, variables: { input } })
- What is the motivation / use case for changing the behavior?
Using angulartics shouldn't unexpected mutate the properties you pass in. I'm using GraphQL and was passing in my mutation input directly and now I get this error:
Variable "$input" got invalid value { id: "Qm94OjIw", action: "sell", category: "Event" }; Field "category" is not defined by type PurchaseBoxInput.
It's mutating the original object unexpectedly. Obviously I can get around it by { ...input }
but nobody expects a tracking lib to mutate the original object
https://github.com/angulartics/angulartics2/blob/6e5c886ee8c28b778ee4c03bd1dd955cc8bda8a1/src/lib/providers/ga/ga.ts#L97