|
9 | 9 |
|
10 | 10 | public class Amplitude {
|
11 | 11 | private static readonly string UnityLibraryName = "amplitude-unity";
|
12 |
| - private static readonly string UnityLibraryVersion = "2.5.1"; |
| 12 | + private static readonly string UnityLibraryVersion = "2.6.0"; |
13 | 13 |
|
14 | 14 | private static Dictionary<string, Amplitude> instances;
|
15 | 15 | private static readonly object instanceLock = new object();
|
@@ -40,6 +40,10 @@ public class Amplitude {
|
40 | 40 | [DllImport ("__Internal")]
|
41 | 41 | private static extern void _Amplitude_setUserProperties(string instanceName, string propertiesJson);
|
42 | 42 | [DllImport ("__Internal")]
|
| 43 | + private static extern void _Amplitude_setGroup(string instanceName, string groupType, string groupName); |
| 44 | + [DllImport ("__Internal")] |
| 45 | + private static extern void _Amplitude_setGroupWithStringArray(string instanceName, string groupType, string[] groupName, int length); |
| 46 | + [DllImport ("__Internal")] |
43 | 47 | private static extern void _Amplitude_setOptOut(string instanceName, bool enabled);
|
44 | 48 | [DllImport ("__Internal")]
|
45 | 49 | private static extern void _Amplitude_setMinTimeBetweenSessionsMillis(string instanceName, long minTimeBetweenSessionsMillis);
|
@@ -568,6 +572,52 @@ public void setUserProperties(IDictionary<string, object> properties) {
|
568 | 572 | #endif
|
569 | 573 | }
|
570 | 574 |
|
| 575 | + /// <summary> |
| 576 | + /// Adds a user to a group or groups. You need to specify a groupType and groupName(s). |
| 577 | + /// For example you can group people by their organization. In that case groupType is "orgId", and groupName would be the actual ID(s). groupName can be a string or an array of strings to indicate a user in multiple groups. |
| 578 | + /// You can also call setGroup multiple times with different groupTypes to track multiple types of groups (up to 5 per app). |
| 579 | + /// **Note:** this will also set groupType: groupName as a user property. |
| 580 | + /// </summary> |
| 581 | + /// <param name="groupType"You need to specify a group type (for example orgId).</param> |
| 582 | + /// <param name="groupName"The value for the group name, can be a string. (for example for groupType orgId, the groupName would be the actual id number, like 15).</param> |
| 583 | + public void setGroup(string groupType, string groupName) { |
| 584 | + Log (string.Format("C# setGroup")); |
| 585 | +#if (UNITY_IPHONE || UNITY_TVOS) |
| 586 | + if (Application.platform == RuntimePlatform.IPhonePlayer || Application.platform == RuntimePlatform.tvOS) { |
| 587 | + _Amplitude_setGroup(instanceName, groupType, groupName); |
| 588 | + } |
| 589 | +#endif |
| 590 | + |
| 591 | +#if UNITY_ANDROID |
| 592 | + if (Application.platform == RuntimePlatform.Android) { |
| 593 | + pluginClass.CallStatic("setGroup", instanceName, groupType, groupName); |
| 594 | + } |
| 595 | +#endif |
| 596 | + } |
| 597 | + |
| 598 | + /// <summary> |
| 599 | + /// Adds a user to a group or groups. You need to specify a groupType and groupName(s). |
| 600 | + /// For example you can group people by their organization. In that case groupType is "orgId", and groupName would be the actual ID(s). groupName can be a string or an array of strings to indicate a user in multiple groups. |
| 601 | + /// You can also call setGroup multiple times with different groupTypes to track multiple types of groups (up to 5 per app). |
| 602 | + /// **Note:** this will also set groupType: groupName as a user property. |
| 603 | + /// </summary> |
| 604 | + /// <param name="groupType"You need to specify a group type (for example sports).</param> |
| 605 | + /// <param name="groupName"The value for the group name, can be an array of strings. (for example for groupType orgId, the groupName would be array of sport, like [soccer, tennis]).</param> |
| 606 | + public void setGroup(string groupType, string[] groupName) { |
| 607 | + Log (string.Format("C# setGroup")); |
| 608 | +#if (UNITY_IPHONE || UNITY_TVOS) |
| 609 | + if (Application.platform == RuntimePlatform.IPhonePlayer || Application.platform == RuntimePlatform.tvOS) { |
| 610 | + _Amplitude_setGroupWithStringArray(instanceName, groupType, groupName, groupName.Length); |
| 611 | + } |
| 612 | +#endif |
| 613 | + |
| 614 | +#if UNITY_ANDROID |
| 615 | + if (Application.platform == RuntimePlatform.Android) { |
| 616 | + pluginClass.CallStatic("setGroup", instanceName, groupType, groupName); |
| 617 | + } |
| 618 | +#endif |
| 619 | + } |
| 620 | + |
571 | 621 | /// <summary>
|
572 | 622 | /// Enables tracking opt out.
|
573 | 623 | /// If the user wants to opt out of all tracking, use this method to enable opt out for them.
|
|
0 commit comments