forked from segmentio/Analytics.NET
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathOptions.cs
More file actions
77 lines (69 loc) · 2.38 KB
/
Options.cs
File metadata and controls
77 lines (69 loc) · 2.38 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
using System;
using Segment.Model;
namespace Segment.Model
{
public class Options
{
public string AnonymousId { get; private set; }
public Dict Integrations { get; private set; }
public DateTime? Timestamp { get; private set; }
public Context Context { get; private set; }
/// <summary>
/// Options object that allows the specification of a timestamp,
/// an anonymousId, a context, or target integrations.
/// </summary>
public Options ()
{
this.Integrations = new Dict ();
this.Context = new Context ();
}
/// <summary>
/// Sets the anonymousId of the user. This is typically a cookie session id that identifies
/// a visitor before they have logged in.
/// </summary>
/// <returns>This Options object for chaining.</returns>
/// <param name="anonymousId">The visitor's anonymousId.</param>
public Options SetAnonymousId (string anonymousId)
{
this.AnonymousId = anonymousId;
return this;
}
/// <summary>
/// Sets the timestamp of when an analytics call occurred. The timestamp is primarily used for
/// historical imports or if this event happened in the past. The timestamp is not required,
/// and if it's not provided, our servers will timestamp the call as if it just happened.
/// </summary>
/// <returns>This Options object for chaining.</returns>
/// <param name="timestamp">The call's timestamp.</param>
public Options SetTimestamp (DateTime? timestamp)
{
this.Timestamp = timestamp;
return this;
}
/// <summary>
/// Sets the context of this analytics call. Context contains information about the environment
/// such as the app, the user agent, ip, etc ..
/// </summary>
/// <returns>This Options object for chaining.</returns>
/// <param name="context">The visitor's context.</param>
public Options SetContext (Context context)
{
this.Context = context;
return this;
}
/// <summary>
/// Determines which integrations this messages goes to.
/// new Options()
/// .Integration("All", false)
/// .Integration("Mixpanel", true)
/// will send a message to only Mixpanel.
/// </summary>
/// <param name="integration">The integration name.</param>
/// <param name="enabled">If set to <c>true</c>, then the integration is enabled.</param>
public Options SetIntegration (string integration, bool enabled)
{
this.Integrations.Add (integration, enabled);
return this;
}
}
}