Skip to content

Commit d5600c1

Browse files
authored
Apply suggestions from code review
1 parent 2668033 commit d5600c1

File tree

1 file changed

+12
-9
lines changed
  • src/connections/sources/catalog/libraries/server/csharp

1 file changed

+12
-9
lines changed

src/connections/sources/catalog/libraries/server/csharp/index.md

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ To get started with the Analytics-CSharp library:
6767
| `analyticsErrorHandler` | The default is set to `null`. <br>This sets an error handler to handle errors happened in analytics. |
6868
| `storageProvider` | The default is set to `DefaultStorageProvider`. <br>This sets how you want your data to be stored. `DefaultStorageProvider` is used by default which stores data to local storage. `InMemoryStorageProvider` is also provided in the library. You can also write your own storage solution by implementing `IStorageProvider` and `IStorage`. |
6969
| `httpClientProvider` | The default is set to `DefaultHTTPClientProvider`. <br>This sets a http client provider for analytics use to do network activities. The default provider uses System.Net.Http for network activities. |
70-
| `flushPolicies` | Default set to `null`. <br>This set custom flush policies to tell analytics when and how to flush. By default, it converts `flushAt` and `flushInterval` to `CountFlushPolicy` and `FrequencyFlushPolicy`. If a value is given, it overwrites `flushAt` and `flushInterval`. |
70+
| `flushPolicies` | The default is set to `null`. <br>This sets custom flush policies to tell analytics when and how to flush. By default, it converts `flushAt` and `flushInterval` to `CountFlushPolicy` and `FrequencyFlushPolicy`. If a value is given, it overwrites `flushAt` and `flushInterval`. |
7171

7272
## Tracking Methods
7373

@@ -326,10 +326,13 @@ analytics.Reset()
326326
```
327327

328328

329-
## Controlling Upload With Flush Policies
330-
To more granularly control when events are uploaded you can use `FlushPolicies`. **This will override any setting on `flushAt` and `flushInterval`, but you can use `CountFlushPolicy` and `FrequencyFlushPolicy` to have the same behaviour respectively.**
329+
## Flush policies
330+
To more granularly control when events are uploaded you can use `FlushPolicies`.
331331

332-
A Flush Policy defines the strategy for deciding when to flush, this can be on an interval, on a certain time of day, after receiving a certain number of events or even after receiving a particular event. This gives you even more flexibility on when to send event to Segment.
332+
> warning ""
333+
> `FlushPolicies` overrides any setting on `flushAt` and `flushInterval`, but you can use `CountFlushPolicy` and `FrequencyFlushPolicy` to have the same behavior.
334+
335+
A Flush Policy defines the strategy for deciding when to flush. This can be on an interval, on a certain time of day, after receiving a certain number of events or even after receiving a particular event. This gives you even more flexibility on when to send an event to Segment.
333336

334337
To make use of flush policies you can set them in the configuration of the client:
335338
```csharp
@@ -345,16 +348,16 @@ To make use of flush policies you can set them in the configuration of the clien
345348

346349
That means only the first policy to reach `ShouldFlush` gets to trigger a flush at a time. In the example above either the event count gets to 5 or the timer reaches 500ms, whatever comes first will trigger a flush.
347350

348-
We have several standard FlushPolicies:
351+
Segment has several standard FlushPolicies:
349352
- `CountFlushPolicy` triggers whenever a certain number of events is reached
350353
- `FrequencyFlushPolicy` triggers on an interval of milliseconds
351354
- `StartupFlushPolicy` triggers on client startup only
352355

353356
### Adding or removing policies
354357

355-
One of the main advantages of FlushPolicies is that you can add and remove policies on the fly. This is very powerful when you want to reduce or increase the amount of flushes.
358+
One of the main advantages of FlushPolicies is that you can choose to add and remove policies. This is very powerful when you want to reduce or increase the amount of flushes.
356359

357-
For example you might want to disable flushes if you detect the user has no network:
360+
For example, you might want to disable flushes if you detect the user has no network:
358361
```csharp
359362
// listen to network changes
360363
if (noNetwork) {
@@ -369,11 +372,11 @@ For example you might want to disable flushes if you detect the user has no netw
369372
}
370373
```
371374

372-
### Creating your own flush policies
375+
### Create your own flush policies
373376

374377
You can create a custom FlushPolicy special for your application needs by implementing the `IFlushPolicy` interface. You can also extend the `FlushPolicyBase` class that already creates and handles the `shouldFlush` value reset.
375378

376-
A `FlushPolicy` only needs to implement 2 methods:
379+
A `FlushPolicy` only needs to implement two of these methods:
377380
- `Schedule`: Executed when the flush policy is enabled and added to the client. This is a good place to start background operations, make async calls, configure things before execution
378381
- `UpdateState`: Gets called on every event tracked by your client
379382
- `Unschedule`: Called when policy should stop running any scheduled flushes

0 commit comments

Comments
 (0)