Don't call posthog before its initialised
This commit is contained in:
		
					parent
					
						
							
								0dcaa90650
							
						
					
				
			
			
				commit
				
					
						5e4aa53997
					
				
			
		
					 2 changed files with 6 additions and 1 deletions
				
			
		| 
						 | 
					@ -343,7 +343,8 @@ export const ClientProvider: FC<Props> = ({ children }) => {
 | 
				
			||||||
    window.matrixclient = client;
 | 
					    window.matrixclient = client;
 | 
				
			||||||
    window.isPasswordlessUser = isPasswordlessUser;
 | 
					    window.isPasswordlessUser = isPasswordlessUser;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    PosthogAnalytics.instance.onLoginStatusChanged();
 | 
					    if (PosthogAnalytics.hasInstance())
 | 
				
			||||||
 | 
					      PosthogAnalytics.instance.onLoginStatusChanged();
 | 
				
			||||||
  }, [client, isPasswordlessUser]);
 | 
					  }, [client, isPasswordlessUser]);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  if (error) {
 | 
					  if (error) {
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -102,6 +102,10 @@ export class PosthogAnalytics {
 | 
				
			||||||
  private platformSuperProperties = {};
 | 
					  private platformSuperProperties = {};
 | 
				
			||||||
  private registrationType: RegistrationType = RegistrationType.Guest;
 | 
					  private registrationType: RegistrationType = RegistrationType.Guest;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  public static hasInstance(): boolean {
 | 
				
			||||||
 | 
					    return Boolean(this.internalInstance);
 | 
				
			||||||
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  public static get instance(): PosthogAnalytics {
 | 
					  public static get instance(): PosthogAnalytics {
 | 
				
			||||||
    if (!this.internalInstance) {
 | 
					    if (!this.internalInstance) {
 | 
				
			||||||
      this.internalInstance = new PosthogAnalytics(posthog);
 | 
					      this.internalInstance = new PosthogAnalytics(posthog);
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue