You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The other way is to drop down lower and use `Segment.Http``send` and `batch` directly. This will require first creating a `client` with `Segment.Http.client/1`/`Segment.Http.client/2`
The library has a number of configuration options you can use to overwrite default values and behaviours
125
+
126
+
*`config :segment, :sender_impl` Allows selection of a sender implementation. At the moment this defaults to `Segment.Analytics.Batcher` which will send all events in batch. Change this value to `Segment.Analytics.Sender` to have all messages sent immediately (asyncronously)
127
+
*`config :segment, :max_batch_size` The maximum batch size of messages that will be sent to Segment at one time. Default value is 100.
128
+
*`config :segment, :batch_every_ms` The time (in ms) between every batch request. Default value is 2000 (2 seconds)
129
+
*`config :segment, :retry_attempts` The number of times to retry sending against the segment API. Default value is 3
130
+
*`config :segment, :retry_expiry` The maximum time (in ms) spent retrying. Default value is 10000 (10 seconds)
131
+
*`config :segment, :retry_start` The time (in ms) to start the first retry. Default value is 100
132
+
*`config :segment, :send_to_http` If set to `false`, the libray will override the Tesla Adapter implementation to only log segment calls to `debug` but not make any actual API calls. This can be useful if you want to switch off Segment for test or dev. Default value is true
133
+
*`config :segment, :tesla, :adapter` This config option allows for overriding the HTTP Adapter for Tesla (which the library defaults to Hackney).This can be useful if you prefer something else, or want to mock the adapter for testing.
134
+
135
+
## Usage in Phoenix
136
+
137
+
This is how I add to a Phoenix project (may not be your preferred way)
138
+
139
+
1. Add the following to deps section of your mix.exs: `{:segment, "~> 0.2.0"}`
140
+
and then `mix deps.get`
141
+
2. Add a config variable for your write_key (you may want to make this load from ENV)
142
+
ie.
143
+
```elixir
144
+
config :segment,
145
+
write_key:"2iFFnRsCfi"
146
+
```
147
+
3. Start the Segment GenServer in the supervised children list. In `application.ex` add to the children list:
There are not many tests at the moment. But you can run a live test on your segment
125
-
account by running.
154
+
There are not many tests at the moment. if you want to run live tests on your account you need to change the config in `test.exs` to `config :segment, :send_to_http, true` and then provide your key as an environment variable.
0 commit comments