@@ -25,11 +25,7 @@ public static async Task<ApiResult> GroupIdentifyAsync(
2525 StringOrValue < int > key ,
2626 string name ,
2727 Dictionary < string , object > ? properties )
28- {
29- properties ??= new Dictionary < string , object > ( ) ;
30- properties [ "name" ] = name ;
31- return await NotNull ( client ) . GroupIdentifyAsync ( type , key , properties , CancellationToken . None ) ;
32- }
28+ => await client . GroupIdentifyAsync ( type , key , name , properties , CancellationToken . None ) ;
3329
3430 /// <summary>
3531 /// Sets a groups properties, which allows asking questions like "Who are the most active companies"
@@ -49,11 +45,7 @@ public static async Task<ApiResult> GroupIdentifyAsync(
4945 StringOrValue < int > key ,
5046 string name ,
5147 Dictionary < string , object > ? properties )
52- {
53- properties ??= new Dictionary < string , object > ( ) ;
54- properties [ "name" ] = name ;
55- return await NotNull ( client ) . GroupIdentifyAsync ( distinctId , type , key , properties , CancellationToken . None ) ;
56- }
48+ => await client . GroupIdentifyAsync ( distinctId , type , key , name , properties , CancellationToken . None ) ;
5749
5850 /// <summary>
5951 /// Sets a groups properties, which allows asking questions like "Who are the most active companies"
@@ -73,11 +65,7 @@ public static async Task<ApiResult> GroupIdentifyAsync(
7365 string name ,
7466 Dictionary < string , object > ? properties ,
7567 CancellationToken cancellationToken )
76- {
77- properties ??= new Dictionary < string , object > ( ) ;
78- properties [ "name" ] = name ;
79- return await NotNull ( client ) . GroupIdentifyAsync ( type , key , properties , cancellationToken ) ;
80- }
68+ => await GroupIdentifyWithNameAsync ( NotNull ( client ) , distinctId : null , type , key , name , properties , cancellationToken ) ;
8169
8270 /// <summary>
8371 /// Sets a groups properties, which allows asking questions like "Who are the most active companies"
@@ -99,11 +87,7 @@ public static async Task<ApiResult> GroupIdentifyAsync(
9987 string name ,
10088 Dictionary < string , object > ? properties ,
10189 CancellationToken cancellationToken )
102- {
103- properties ??= new Dictionary < string , object > ( ) ;
104- properties [ "name" ] = name ;
105- return await NotNull ( client ) . GroupIdentifyAsync ( distinctId , type , key , properties , cancellationToken ) ;
106- }
90+ => await GroupIdentifyWithNameAsync ( NotNull ( client ) , distinctId , type , key , name , properties , cancellationToken ) ;
10791
10892 /// <summary>
10993 /// Sets a groups properties, which allows asking questions like "Who are the most active companies"
@@ -147,4 +131,21 @@ public static async Task<ApiResult> GroupIdentifyAsync(
147131 key ,
148132 name ,
149133 properties : new Dictionary < string , object > ( ) ) ;
150- }
134+
135+ static async Task < ApiResult > GroupIdentifyWithNameAsync (
136+ IPostHogClient client ,
137+ string ? distinctId ,
138+ string type ,
139+ StringOrValue < int > key ,
140+ string name ,
141+ Dictionary < string , object > ? properties ,
142+ CancellationToken cancellationToken )
143+ {
144+ properties ??= new Dictionary < string , object > ( ) ;
145+ properties [ "name" ] = name ;
146+
147+ return distinctId is null
148+ ? await client . GroupIdentifyAsync ( type , key , properties , cancellationToken )
149+ : await client . GroupIdentifyAsync ( distinctId , type , key , properties , cancellationToken ) ;
150+ }
151+ }
0 commit comments