Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add impressions to metadata #1068

Merged
merged 2 commits into from
Nov 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 6 additions & 4 deletions web/api/helpers/app-store.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { getLocalisedCategory } from "@/lib/categories";
import { whitelistedAppsPermit2 } from "@/lib/constants";
import { generateExternalNullifier } from "@/lib/hashing";
import {
AppStatsItem,
AppStatsReturnType,
AppStoreFormattedFields,
AppStoreMetadataDescription,
Expand All @@ -15,9 +16,9 @@ export const formatAppMetadata = async (
locale: string = "en",
): Promise<AppStoreFormattedFields> => {
const { app, ...appMetadata } = appData;
const appStat: number =
appStats.find((stat) => stat.app_id === appMetadata.app_id)?.unique_users ??
0;
const singleAppStats: AppStatsItem | undefined = appStats.find(
(stat) => stat.app_id === appMetadata.app_id,
);

// const appRating = await getAppRating(appMetadata.app_id);

Expand Down Expand Up @@ -83,7 +84,8 @@ export const formatAppMetadata = async (
ratings_external_nullifier: generateExternalNullifier(
`${appMetadata.app_id}_app_review`,
).digest,
unique_users: appStat,
unique_users: singleAppStats?.unique_users ?? 0,
impressions: singleAppStats?.total_impressions ?? 0,
category: getLocalisedCategory(appMetadata.category, locale) ?? {
id: "other",
name: "Other",
Expand Down
2 changes: 2 additions & 0 deletions web/lib/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -232,6 +232,7 @@ export type AppStoreFormattedFields = Omit<
| "is_reviewer_world_app_approved"
> & {
app_rating: number;
impressions: number;
ratings_external_nullifier: string;
show_in_app_store: boolean;
unique_users: number;
Expand Down Expand Up @@ -259,6 +260,7 @@ export type AppStatsItem = {
unique_users: number;
last_updated_at: string;
unique_users_last_7_days: number | null;
total_impressions: number;
};

export type AppStatsReturnType = Array<AppStatsItem>;
Expand Down
2 changes: 2 additions & 0 deletions web/tests/api/v2/minikit-app-metadata.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,7 @@ const app_metadata = {
associated_domains: ["https://worldcoin.org"],
app_rating: 0,
unique_users: 0,
impressions: 0,
team_name: "test",
};

Expand Down Expand Up @@ -224,6 +225,7 @@ describe("/api/v2/minikit/app-metadata/[app_id] [success cases]", () => {
supported_languages: ["en"],
app_rating: 0,
unique_users: 0,
impressions: 0,
team_name: "test",
});
});
Expand Down
3 changes: 3 additions & 0 deletions web/tests/api/v2/public/apps/app.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@ describe("/api/public/app/[app_id]", () => {
supported_languages: ["en", "es"],
app_rating: 0,
unique_users: 0,
impressions: 0,
verification_status: "unverified",
description: {
how_it_works: "few",
Expand Down Expand Up @@ -184,6 +185,7 @@ describe("/api/public/app/[app_id]", () => {
supported_languages: ["en", "es"],
app_rating: 0,
unique_users: 0,
impressions: 0,
verification_status: "verified",
description: {
how_it_works: "few",
Expand Down Expand Up @@ -272,6 +274,7 @@ describe("/api/public/app/[app_id]", () => {
permit2_tokens: ["0x0c892815f0B058E69987920A23FBb33c834289cf"],
app_rating: 0,
unique_users: 0,
impressions: 0,
whitelisted_addresses: ["0x1234", "0x5678"],
category: { id: "social", name: "Social" },
description: {
Expand Down
4 changes: 4 additions & 0 deletions web/tests/api/v2/public/apps/apps.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -218,6 +218,7 @@ describe("/api/v2/public/apps", () => {
showcase_img_urls: ["https://cdn.test.com/1/showcase1.png"],
team_name: "Example Team",
unique_users: 0,
impressions: 0,
whitelisted_addresses: ["0x1234", "0x5678"],
app_mode: "mini-app",
category: { id: "social", name: "Social" },
Expand Down Expand Up @@ -245,6 +246,7 @@ describe("/api/v2/public/apps", () => {
category: { id: "social", name: "Social" },
whitelisted_addresses: ["0x1234", "0x5678"],
unique_users: 0,
impressions: 0,
app_mode: "external",
description: {
overview: "fwefw",
Expand Down Expand Up @@ -279,6 +281,7 @@ describe("/api/v2/public/apps", () => {
],
whitelisted_addresses: ["0x1234", "0x5678"],
unique_users: 0,
impressions: 0,
app_rating: 0,
app_mode: "mini-app",
associated_domains: ["https://worldcoin.org"],
Expand Down Expand Up @@ -386,6 +389,7 @@ describe("/api/v2/public/apps", () => {
"0x00ca597c4f12f9f85a633bb04cfdc877af7c2d91a6c1c7fe45031b495a227a58",
app_rating: 0,
unique_users: 0,
impressions: 0,
whitelisted_addresses: ["0x1234", "0x5678"],
category: { id: "social", name: "Social" },
description: {
Expand Down
Loading