Update riveted.js with support for multiple simultaneous trackers #32
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
The previous version supports multi-tracker setups with the
gaTrackerargument, which specifies a single tracker to which Riveted events will be sent. This is a bummer if you want several trackers to all receive the Riveted events so that they match (and since the data is useful everywhere).This patch adds support for sending events to several trackers:
gaTrackernow allows both the old string format for a single tracker and array format to pass several trackersuniversalSendCommandswitches to arrayuniversalSeldCommandsso it can contain commands for multiple trackersinitnow processesgaTrackerbased on whether it's an array, (build commands for each tracker in the array), a string (build the single command for that tracker) or empty (build a command for the default tracker).sendUserTimingandsendEventnow loop through the commands inuniversalSendCommandsarray to send events for each registered trackerNote that it also adds references to
defaulttracker, which is a string used to indicate the main tracker that doesn't require a prefix forgasend commands. If you pass in multiple trackers via an array ingaTrackerthen you would usedefaultto indicate that prefix-less tracker. We also made sure that if you pass indefaultas a string for a single tracker what happens is what you'd expect: The code for the prefix-less tracker is used.As far as we know this update is back-compatible with previous versions. If
gaTrackeris empty or a string with a single tracker, Riveted will work the same as before!Thanks for considering this PR! If it can't be merged, I hope it can help someone else having the same problem as us (wanting Riveted on both of our trackers).