Skip to content

Instantly share code, notes, and snippets.

@NedyUdombat
Created December 22, 2023 12:24
Show Gist options
  • Save NedyUdombat/f3b3d2c508577e0c3ceb019339746287 to your computer and use it in GitHub Desktop.
Save NedyUdombat/f3b3d2c508577e0c3ceb019339746287 to your computer and use it in GitHub Desktop.
import { PostHog } from 'posthog-node';
const posthogClient = new PostHog(process.env.POSTHOG_API_KEY, {
host: process.env.POSTHOG_API_HOST,
});
const group = async (
userId: string,
groupId: string,
{
company_name,
company_status,
company_seats_count,
company_users_count,
subscription_plan_name,
subscription_plan_value,
subscription_plan_type,
is_company_paid,
company_id,
company_amount_of_teams,
company_number_of_pods,
company_number_of_templates,
company_owner_email,
company_owner_name,
subscription_has_discount,
subscription_discount_amount,
}: {
company_name: string;
company_status: string;
company_seats_count: number;
company_users_count: number;
subscription_plan_name: string;
subscription_plan_value: number;
subscription_plan_type: string;
is_company_paid: boolean;
company_id: string;
company_amount_of_teams: number;
company_number_of_pods: number;
company_number_of_templates: number;
company_owner_email: string;
company_owner_name: string;
subscription_has_discount: boolean;
subscription_discount_amount: number;
},
) => {
posthogClient.groupIdentify({
groupType: 'company',
groupKey: groupId ? groupId : company_id,
properties: {
name: company_name,
company_name,
company_status,
company_seats_count,
company_users_count,
subscription_plan_name,
subscription_plan_value,
subscription_plan_type,
is_company_paid,
company_id,
company_amount_of_teams,
company_number_of_pods,
company_number_of_templates,
company_owner_email,
company_owner_name,
subscription_has_discount,
subscription_discount_amount,
},
});
};
export { group };
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment