cupcake/raven-go — pull request #13 by tylrtrmbl (2013-12-30 01:38:02+00:00)
Title: Merge tags according to spec

Fixes cupcake/raven-go#6

Example tags from spec:

> ```go
> {
> "tags": [
> ["foo", "bar"],
> ["foo", "baz"]
> ],
> }
> ```

One potentially controversial implementation decision I made was keeping tag specifications dictionaries; this does seem to be [on spec](http://sentry.readthedocs.org/en/latest/developer/client/index.html#client-usage-end-user) though:

> Additionally, you should provide methods (depending on the platform) which allow for capturing of a basic message and an exception-type:
>
> ```
> RavenClient::captureMessage(string $message)
> RavenClient::captureException(exception $exception)
> ```
>
> The above methods should also allow optional arguments (or a __*map*__ of arguments).

(My emphasis)

Another is that I've taken tags out of `packet.Init` world. It was awkward that it did tag merging, since I had to do my own tag merging outside of `packet.Init` anyway. Before:

```go
// Merge client tags and capture tags
tags := make(map[string]string, len(client.Tags)+len(captureTags))
for tag, value := range client.Tags {
tags[tag] = value
}
for tag, value := range captureTags {
tags[tag] = value
}

...

err := packet.Init(projectID, tags)
if err != nil {
ch <- err
return
}
```

After:

```go
// Merge capture tags and client tags
packet.MergeTags(captureTags)
packet.MergeTags(client.Tags)

...

err := packet.Init(projectID)
if err != nil {
ch <- err
return
}
```

I tried to make the tests right.

Let me know what you think! Thanks.