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
If you’re using a different library, follow the steps below to migrate to the[Analytics-CSharp library](/docs/connections/sources/catalog/libraries/server/csharp/).
6
+
If you’re currently using Analytics.NET or Analytics.Xamarin to send data to Segment, please follow the steps below to migrate to the[Analytics-CSharp library](/docs/connections/sources/catalog/libraries/server/csharp/).
7
+
8
+
You can update to Analytics-CSharp in 3 easy steps
9
+
1. Bundle Analytics-CSharp into your app (and remove your previous SDK)
10
+
2. Change the namespaces
11
+
3. Advanced: Run Analytics in Synchronous Mode
7
12
8
13
9
14
##Start the Migration
@@ -61,78 +66,13 @@ If you’re using a different library, follow the steps below to migrate to the
61
66
62
67
<br> Before:
63
68
```c#
64
-
Analytics.Initialize("YOUR_WRITE_KEY", new Config().SetAsync(false));
69
+
Analytics.Client.Page(null, "Login", new Properties(), new Options()
70
+
.SetAnonymousId("some-id"));
65
71
```
66
72
67
73
ThenewSDK by default, generates an AnonymousIDfor youif you never call`analytics.Identify`.If you've called `Identify` and want to go back to anonymous, try:
68
74
69
75
<br> After:
70
76
```c#
71
77
analytics.Reset();
72
-
```
73
-
74
-
3. Change your nested properties settings.
75
-
76
-
<br> Before:
77
-
```c#
78
-
Analytics.Client.Identify("hj2kf92ds212", new Traits() {
79
-
{ "email", "tom@example.com" },
80
-
{ "name", "Tom Smykowski" },
81
-
{ "address", new Dict() {
82
-
{ "street", "123 Fake Street" },
83
-
{ "city", "Boston" }
84
-
}}
85
-
});
86
-
```
87
-
88
-
<br> After:
89
-
```c#
90
-
// compatbile with the old way
91
-
analytics.Identify("hj2kf92ds212", new JsonObject()
92
-
{
93
-
{ "email", "tom@example.com" },
94
-
{ "name", "Tom Smykowski" },
95
-
{ "address", new JsonObject() {
96
-
{ "street", "123 Fake Street" },
97
-
{ "city", "Boston" }
98
-
}}
99
-
});
100
-
```
101
-
102
-
The new SDK internally implements a flexible JSON builder (Serialization.NET), that allows you build a complex JSON payload: