mirror of
https://github.com/formbricks/formbricks.git
synced 2026-01-05 21:32:02 -06:00
fix: posthog free limit reporting (#2026)
This commit is contained in:
@@ -96,7 +96,7 @@ export async function GET(
|
||||
person = await createPerson(environmentId, userId);
|
||||
}
|
||||
} else {
|
||||
sendFreeLimitReachedEventToPosthogBiWeekly(environmentId, "userTargeting");
|
||||
await sendFreeLimitReachedEventToPosthogBiWeekly(environmentId, "userTargeting");
|
||||
const errorMessage = `Monthly Active Users limit in the current plan is reached in ${environmentId}`;
|
||||
if (!person) {
|
||||
// if it's a new person and MAU limit is reached, throw an error
|
||||
@@ -110,7 +110,7 @@ export async function GET(
|
||||
}
|
||||
}
|
||||
if (isInAppSurveyLimitReached) {
|
||||
sendFreeLimitReachedEventToPosthogBiWeekly(environmentId, "inAppSurvey");
|
||||
await sendFreeLimitReachedEventToPosthogBiWeekly(environmentId, "inAppSurvey");
|
||||
}
|
||||
|
||||
const [surveys, noCodeActionClasses, product] = await Promise.all([
|
||||
|
||||
@@ -6,19 +6,19 @@ import { getTeamDetails } from "@formbricks/lib/teamDetail/service";
|
||||
export const sendFreeLimitReachedEventToPosthogBiWeekly = async (
|
||||
environmentId: string,
|
||||
plan: "inAppSurvey" | "userTargeting"
|
||||
) => {
|
||||
await unstable_cache(
|
||||
): Promise<string> =>
|
||||
unstable_cache(
|
||||
async () => {
|
||||
const teamDetails = await getTeamDetails(environmentId);
|
||||
if (teamDetails?.teamOwnerId) {
|
||||
return await capturePosthogEvent(teamDetails.teamOwnerId, "free limit reached", teamDetails.teamId, {
|
||||
await capturePosthogEvent(teamDetails.teamOwnerId, "free limit reached", teamDetails.teamId, {
|
||||
plan,
|
||||
});
|
||||
}
|
||||
return "success";
|
||||
},
|
||||
[`posthog-${plan}-limitReached-${environmentId}`],
|
||||
{
|
||||
revalidate: 60 * 60 * 24 * 15, // 15 days
|
||||
}
|
||||
)();
|
||||
};
|
||||
|
||||
@@ -58,7 +58,7 @@ export async function GET(
|
||||
isInAppSurveyLimitReached =
|
||||
!hasInAppSurveySubscription && currentResponseCount >= PRICING_APPSURVEYS_FREE_RESPONSES;
|
||||
if (isInAppSurveyLimitReached) {
|
||||
sendFreeLimitReachedEventToPosthogBiWeekly(environmentId, "inAppSurvey");
|
||||
await sendFreeLimitReachedEventToPosthogBiWeekly(environmentId, "inAppSurvey");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user