CardinalPath/gas — Issue #16: Change plugins API to avoid conflicts with default functions
Author: eduardocereto
Created: 2012-02-28 01:53:26+00:00
State: open
Labels: feature

I feel that I don't get the API right. We have 2 problems with the current API.

- For functions that are gas specific we don't clearly indicate that GAS is handling that call instead of ga.js. eg: (_trackOutboundLinks can be added in the future by ga.js and then we have a problem.)
- For functions that are not gas specific we change the behaviour but that is not explicit on the API. eg: (_addDomainName is both a GAS and gaq function. We alter it behaviour and GAS may or may not push that into gaq).

So I'd like to prupose a different API, to make it clear what GAS is doing and what is it most likely not touching while sending to ga.js

I first started thinking about it while planning to implement social trackings. Following the consistency with current API `_trackOutboundLinks`, `_trackDownloads` the most logic choice would be `_trackSocial`, but that already exists on ga.js.

So instead of using track Social I have a couple of choices:

- `_gasSocial`. It's nice because it's namespaced, so we'll never have a clash with g.js functions again. The bad aspect of it is that _gas becomes redundant when you look at the whole call. `_gas.push(['_gasSocial']);`
- `_setAutoTrackSocial`, This is more consistent with ga api but we might have problems in the future as well. There an undocumented function incide ga/js called `_setAutoTrackOutbound`, I expect that in the future it might replace our `_trackOutbound` , and that in the future ga.js might have more functions like that.

So my opinion is that we should rename all our plugins for v1.6 keeping backward compatibility. Possibly removing the deprecated names on v2.0.

- `_trackOutboundLinks` -> `_gasOutboundLinks`
- `_trackDownloads` -> `_gasDownloads`
- `_trackForms` -> `_gasForms`
- `_trackVimeo` -> `_gasVimeo`
- ...