File tree Expand file tree Collapse file tree 2 files changed +18
-0
lines changed Expand file tree Collapse file tree 2 files changed +18
-0
lines changed Original file line number Diff line number Diff line change @@ -132,16 +132,21 @@ public function post(): void
132132
133133        $ body  = array_replace_recursive (
134134            $ this  ->toArray (),
135+             ["user_data "  => $ this  ->user_id  != null  ? $ this  ->userdata ->toArray () : []], // Only accepted if user_id is passed too 
135136            ["user_properties "  => $ this  ->user_properties ],
136137            ["consent "  => $ this  ->consent ->toArray ()],
137138        );
138139
140+         if  (count ($ body ["user_data " ]) < 1 ) unset($ body ["user_data " ]);
141+         if  (count ($ body ["user_properties " ]) < 1 ) unset($ body ["user_properties " ]);
142+ 
139143        $ chunkEvents  = array_chunk ($ this  ->events , 25 );
140144
141145        if  (count ($ chunkEvents ) < 1 ) {
142146            throw  Ga4Exception::throwMissingEvents ();
143147        }
144148
149+         $ this  ->userdata ->reset ();
145150        $ this  ->user_properties  = [];
146151        $ this  ->events  = [];
147152
Original file line number Diff line number Diff line change @@ -15,6 +15,19 @@ class UserDataHelper
1515    private  ?string  $ postal_code  = null ;
1616    private  ?string  $ country  = null ;
1717
18+     public  function  reset (): void 
19+     {
20+         $ this  ->sha256_email_address  = null ;
21+         $ this  ->sha256_phone_number  = null ;
22+         $ this  ->sha256_first_name  = null ;
23+         $ this  ->sha256_last_name  = null ;
24+         $ this  ->sha256_street  = null ;
25+         $ this  ->city  = null ;
26+         $ this  ->region  = null ;
27+         $ this  ->postal_code  = null ;
28+         $ this  ->country  = null ;
29+     }
30+ 
1831    /** 
1932     * @param string $email 
2033     * @return bool 
    
 
   
 
     
   
   
          
     
  
    
     
 
    
      
     
 
     
    You can’t perform that action at this time.
  
 
    
  
     
    
      
        
     
 
       
      
     
   
 
    
    
  
 
  
 
     
    
0 commit comments