feat: add posthog student signup
This commit is contained in:
@@ -63,7 +63,7 @@ export async function getOrgTeam(orgId: string) {
|
||||
};
|
||||
}
|
||||
|
||||
export async function getOrganizations(userId: string) {
|
||||
export async function getOrganizations(userId: string, isOrgSite?: boolean, orgSiteName?: string) {
|
||||
const { data, error } = await supabase
|
||||
.from('organizationmember')
|
||||
.select(
|
||||
@@ -120,19 +120,30 @@ export async function getOrganizations(userId: string) {
|
||||
|
||||
orgs.set(orgsArray);
|
||||
|
||||
if (localStorage) {
|
||||
const lastOrgSiteName = localStorage.getItem('classroomio_org_sitename');
|
||||
// If this is a student dashboard
|
||||
if (isOrgSite && orgSiteName) {
|
||||
const orgData = orgsArray.find((org) => org.siteName === orgSiteName);
|
||||
|
||||
const lastOrg = orgsArray.find((org) => org.siteName === lastOrgSiteName);
|
||||
|
||||
if (lastOrg) {
|
||||
currentOrg.set(lastOrg);
|
||||
if (orgData) {
|
||||
currentOrg.set(orgData);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
// Check if org was last visited in localhost
|
||||
if (localStorage) {
|
||||
const lastOrgSiteName = localStorage.getItem('classroomio_org_sitename');
|
||||
|
||||
const _currentOrg = get(currentOrg);
|
||||
if (!_currentOrg.siteName) {
|
||||
currentOrg.set(orgsArray[0]);
|
||||
const lastOrg = orgsArray.find((org) => org.siteName === lastOrgSiteName);
|
||||
|
||||
if (lastOrg) {
|
||||
currentOrg.set(lastOrg);
|
||||
}
|
||||
}
|
||||
|
||||
// Default to setting the first org in the array of orgs
|
||||
const _currentOrg = get(currentOrg);
|
||||
if (!_currentOrg.siteName) {
|
||||
currentOrg.set(orgsArray[0]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,13 +1,13 @@
|
||||
import { dev } from '$app/environment';
|
||||
import posthog from 'posthog-js';
|
||||
|
||||
export const capturePosthogEvent = (event: string, properties?: Record<string, any>): void => {
|
||||
export const capturePosthogEvent = (event: string, properties?: Record<string, unknown>): void => {
|
||||
if (dev) return;
|
||||
|
||||
posthog.capture(event, properties);
|
||||
};
|
||||
|
||||
export const identifyPosthogUser = (id: string, properties?: Record<string, any>): void => {
|
||||
export const identifyPosthogUser = (id: string, properties?: Record<string, unknown>): void => {
|
||||
if (dev) return;
|
||||
|
||||
posthog.identify(id, properties);
|
||||
|
||||
Reference in New Issue
Block a user