@intlayer/backend-contract 9.7.2 → 9.8.0-canary.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/analytics.cjs +59 -0
- package/dist/cjs/analytics.cjs.map +1 -1
- package/dist/cjs/analyticsReport.cjs +301 -0
- package/dist/cjs/analyticsReport.cjs.map +1 -0
- package/dist/cjs/project.cjs.map +1 -1
- package/dist/esm/analytics.mjs +35 -1
- package/dist/esm/analytics.mjs.map +1 -1
- package/dist/esm/analyticsReport.mjs +276 -0
- package/dist/esm/analyticsReport.mjs.map +1 -0
- package/dist/esm/project.mjs.map +1 -1
- package/dist/types/analytics.d.ts +284 -1
- package/dist/types/analytics.d.ts.map +1 -1
- package/dist/types/analyticsReport.d.ts +294 -0
- package/dist/types/analyticsReport.d.ts.map +1 -0
- package/dist/types/project.d.ts +5 -0
- package/dist/types/project.d.ts.map +1 -1
- package/package.json +2 -2
package/dist/cjs/project.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"project.cjs","names":["typedStringSchema","z","typedValueSchema","dateTimeSchema","objectIdSchema","defineRouteGroup","defineRoute","paginationQueryShape","repeatableQueryValueSchema","paginatedResponseSchema","responseDataSchema"],"sources":["../../src/project.ts"],"sourcesContent":["import type { Locale } from '@intlayer/types/allLocales';\nimport type { AiConfig, URLType } from '@intlayer/types/config';\nimport { z } from 'zod/mini';\nimport {\n dateTimeSchema,\n objectIdSchema,\n paginationQueryShape,\n repeatableQueryValueSchema,\n typedStringSchema,\n typedValueSchema,\n} from './common';\nimport {\n defineRoute,\n defineRouteGroup,\n type RouteBody,\n type RouteBodyInput,\n type RouteParams,\n type RouteQuerystring,\n} from './defineRoute';\nimport {\n type PaginatedResponse,\n paginatedResponseSchema,\n type ResponseData,\n responseDataSchema,\n} from './responseData';\n\n/** Locale code (ex: `en`, `fr-CA`). */\nexport const localeSchema = typedStringSchema<Locale>();\n\n/** Project AI settings: the Intlayer AI config plus the masked key state. */\nexport type ProjectConfigAI = Partial<AiConfig> & {\n /** Masked API key (`sk-proj-****abcd`), never the real one. */\n apiKey?: string;\n apiKeyConfigured?: boolean;\n};\n\n/**\n * Project-level overrides of the Intlayer configuration. Loose objects: the\n * CLI pushes whole config sections, unknown keys must reach the service.\n */\nexport const projectConfigurationSchema = z.looseObject({\n internationalization: z.optional(\n z.looseObject({\n locales: z.optional(z.array(localeSchema)),\n defaultLocale: z.optional(localeSchema),\n })\n ),\n editor: z.optional(\n z.looseObject({\n applicationURL: z.optional(typedStringSchema<URLType>()),\n cmsURL: z.optional(typedStringSchema<URLType>()),\n })\n ),\n ai: z.optional(typedValueSchema<ProjectConfigAI>()),\n});\n\n/** Generic build webhook (Vercel, Netlify, custom). */\nexport const webhookSchema = z.looseObject({\n id: z.optional(z.string()),\n name: z.string(),\n url: z.string(),\n enabled: z.optional(z.boolean()),\n /** Optional signature secret. */\n secret: z.optional(z.string()),\n});\n\n/** Build triggers: git provider pipeline + generic webhooks. */\nexport const projectCISchema = z.object({\n autoTriggerBuilds: z.optional(z.boolean()),\n /** Commit CMS edits of `hybrid` dictionaries back to their source file. */\n autoCommitDictionaries: z.optional(z.boolean()),\n webhooks: z.optional(z.array(webhookSchema)),\n});\n\n/** Git provider of a connected repository. */\nexport const repositoryProviderSchema = z.enum([\n 'github',\n 'gitlab',\n 'bitbucket',\n 'codeberg',\n 'gitee',\n]);\n\nconst baseRepositoryShape = {\n owner: z.string(),\n repository: z.string(),\n branch: z.string(),\n url: z.string(),\n configFilePath: z.string(),\n};\n\n/**\n * Git repository connected to a project. The repo-scoped token never leaves\n * the server.\n */\nexport const repositoryConnectionSchema = z.discriminatedUnion('provider', [\n z.looseObject({\n provider: z.literal('github'),\n ...baseRepositoryShape,\n installationId: z.optional(z.number()),\n }),\n z.looseObject({\n provider: z.literal('gitlab'),\n ...baseRepositoryShape,\n projectId: z.optional(z.number()),\n /** Custom GitLab instance URL (ex: https://gitlab.company.com). */\n instanceUrl: z.optional(z.string()),\n }),\n z.looseObject({\n provider: z.literal('bitbucket'),\n ...baseRepositoryShape,\n workspace: z.string(),\n }),\n z.looseObject({ provider: z.literal('codeberg'), ...baseRepositoryShape }),\n z.looseObject({ provider: z.literal('gitee'), ...baseRepositoryShape }),\n]);\n\n/** null = unrestricted, [] = no access, array = allowed ids (null = production). */\nconst allowedEnvironmentIdsSchema = z.nullable(z.array(z.nullable(z.string())));\n/** null = unrestricted, [] = no access, array = allowed locales. */\nconst allowedLocalesSchema = z.nullable(z.array(localeSchema));\n\n/** Project environment (production is injected when none is the default). */\nexport const environmentSchema = z.looseObject({\n id: z.string(),\n name: z.string(),\n isDefault: z.boolean(),\n configuration: z.optional(projectConfigurationSchema),\n createdAt: z.optional(dateTimeSchema),\n updatedAt: z.optional(dateTimeSchema),\n});\n\n/** Granular per-member access, overlaid on the member's role. */\nexport const projectMemberGranularAccessSchema = z.object({\n userId: z.string(),\n allowedEnvironmentIds: allowedEnvironmentIdsSchema,\n allowedLocales: allowedLocalesSchema,\n});\n\n/** Access key (OAuth2 client credentials). Live bearer tokens are never sent. */\nexport const accessKeySchema = z.looseObject({\n id: z.string(),\n name: z.string(),\n clientId: z.string(),\n /** Shown to project members (dashboard copy, CLI login). */\n clientSecret: z.string(),\n grants: z.array(z.string()),\n userId: z.string(),\n expiresAt: z.optional(z.nullable(dateTimeSchema)),\n allowedEnvironmentIds: z.optional(allowedEnvironmentIdsSchema),\n allowedLocales: z.optional(allowedLocalesSchema),\n createdAt: dateTimeSchema,\n updatedAt: dateTimeSchema,\n});\n\n/** Project as returned by the API. */\nexport const projectSchema = z.looseObject({\n id: z.string(),\n organizationId: z.string(),\n name: z.string(),\n membersIds: z.array(z.string()),\n adminsIds: z.array(z.string()),\n viewersIds: z.optional(z.array(z.string())),\n memberAccess: z.optional(z.array(projectMemberGranularAccessSchema)),\n creatorId: z.string(),\n configuration: z.optional(projectConfigurationSchema),\n repository: z.optional(z.nullable(repositoryConnectionSchema)),\n webhooks: z.optional(projectCISchema),\n autoFill: z.optional(z.boolean()),\n /** Screenshot of the application URL, generated automatically. */\n imageUrl: z.optional(z.string()),\n environments: z.optional(z.array(environmentSchema)),\n oAuth2Access: z.array(accessKeySchema),\n createdAt: dateTimeSchema,\n updatedAt: dateTimeSchema,\n});\n\n/** Translation health of one locale of a project. */\nexport const localeInsightSchema = z.object({\n locale: localeSchema,\n isDefault: z.boolean(),\n translatedKeys: z.number(),\n totalKeys: z.number(),\n missingKeys: z.number(),\n /** Ratio in the `[0, 1]` range. */\n completionRate: z.number(),\n});\n\n/** Project-wide localization insights shown on the dashboard overview. */\nexport const projectInsightsSchema = z.object({\n projectId: z.string(),\n /** Unix epoch (ms) at which the snapshot was computed. */\n generatedAt: z.number(),\n defaultLocale: z.nullable(localeSchema),\n localeCount: z.number(),\n dictionaryCount: z.number(),\n keyCount: z.number(),\n translationUnitCount: z.number(),\n translatedUnitCount: z.number(),\n overallCompletionRate: z.number(),\n fullyTranslatedLocaleCount: z.number(),\n dictionariesWithMissingTranslations: z.number(),\n missingTranslationCount: z.number(),\n localeInsights: z.array(localeInsightSchema),\n recentlyUpdated: z.array(\n z.object({ key: z.string(), updatedAt: z.number() })\n ),\n lastUpdatedAt: z.nullable(z.number()),\n memberCount: z.number(),\n adminCount: z.number(),\n environmentCount: z.number(),\n autoFill: z.boolean(),\n aiConfigured: z.boolean(),\n repositoryProvider: z.nullable(repositoryProviderSchema),\n applicationURL: z.nullable(z.string()),\n});\n\n/** CI configuration file status of the connected repository. */\nexport const ciStatusSchema = z.object({\n exists: z.boolean(),\n content: z.string(),\n path: z.string(),\n fileUrl: z.optional(z.string()),\n allowAutoPush: z.boolean(),\n});\n\nconst projectIdParamsSchema = z.object({ projectId: objectIdSchema });\nconst clientIdBodySchema = z.object({ clientId: z.string() });\n\nconst ciTargetResultSchema = z.object({\n target: z.string(),\n success: z.boolean(),\n message: z.optional(z.string()),\n});\n\n/** REST contract of the `/api/project` routes. */\nexport const projectContract = defineRouteGroup({\n prefix: '/api/project',\n tag: 'Project',\n routes: {\n getProjects: defineRoute({\n method: 'GET',\n path: '/',\n summary: 'List the projects visible to the session',\n schemas: {\n querystring: z.looseObject({\n ...paginationQueryShape,\n ids: z.optional(repeatableQueryValueSchema),\n name: z.optional(z.string()),\n search: z.optional(z.string()),\n organizationId: z.optional(z.string()),\n membersIds: z.optional(repeatableQueryValueSchema),\n sortBy: z.optional(z.string()),\n sortOrder: z.optional(z.string()),\n /** Admin only: list projects of every organization. */\n fetchAll: z.optional(z.enum(['true', 'false'])),\n }),\n response: { 200: paginatedResponseSchema(projectSchema) },\n },\n }),\n getProjectInsights: defineRoute({\n method: 'GET',\n path: '/insights',\n summary: 'Localization insights of the selected project',\n schemas: {\n response: { 200: responseDataSchema(projectInsightsSchema) },\n },\n }),\n addProject: defineRoute({\n method: 'POST',\n path: '/',\n summary: 'Create a project in the selected organization',\n schemas: {\n body: z.looseObject({ name: z.string().check(z.minLength(1)) }),\n response: { 200: responseDataSchema(projectSchema) },\n },\n }),\n updateProject: defineRoute({\n method: 'PUT',\n path: '/',\n summary: 'Update the selected project',\n schemas: {\n /**\n * Allow-list: membership and ownership fields (`adminsIds`,\n * `membersIds`, `viewersIds`, `creatorId`, `memberAccess`,\n * `environments`) are stripped, they only change through their\n * dedicated endpoints and the invariants those enforce.\n */\n body: z.object({\n name: z.optional(z.string().check(z.minLength(1))),\n configuration: z.optional(projectConfigurationSchema),\n autoFill: z.optional(z.boolean()),\n webhooks: z.optional(projectCISchema),\n /** `null` disconnects the repository. */\n repository: z.optional(z.nullable(repositoryConnectionSchema)),\n }),\n response: { 200: responseDataSchema(projectSchema) },\n },\n }),\n updateProjectMembers: defineRoute({\n method: 'PUT',\n path: '/members',\n summary: 'Replace the members of the selected project',\n schemas: {\n body: z.object({\n membersIds: z.optional(\n z.array(\n z.object({\n userId: objectIdSchema,\n isAdmin: z.optional(z.boolean()),\n })\n )\n ),\n }),\n response: { 200: responseDataSchema(projectSchema) },\n },\n }),\n pushProjectConfiguration: defineRoute({\n method: 'PUT',\n path: '/configuration',\n summary: 'Push the local Intlayer configuration to the project',\n schemas: {\n body: projectConfigurationSchema,\n response: { 200: responseDataSchema(projectConfigurationSchema) },\n },\n }),\n deleteProject: defineRoute({\n method: 'DELETE',\n path: '/',\n summary: 'Delete the selected project',\n schemas: {\n response: { 200: responseDataSchema(projectSchema) },\n },\n }),\n selectProject: defineRoute({\n method: 'PUT',\n path: '/:projectId',\n summary: 'Select a project for the current session',\n schemas: {\n params: projectIdParamsSchema,\n response: { 200: responseDataSchema(projectSchema) },\n },\n }),\n unselectProject: defineRoute({\n method: 'POST',\n path: '/logout',\n summary: 'Unselect the project of the current session',\n schemas: {\n response: { 200: responseDataSchema(z.null()) },\n },\n }),\n addNewAccessKey: defineRoute({\n method: 'POST',\n path: '/access_key',\n summary: 'Create an access key for the selected project',\n schemas: {\n body: z.object({\n name: z.string().check(z.minLength(1)),\n grants: z.array(z.string()),\n /** ISO date-time, parsed to a `Date`; omitted for a key that never expires. */\n expiresAt: z.optional(\n z.pipe(\n z.iso.datetime(),\n z.transform((value) => new Date(value))\n )\n ),\n allowedEnvironmentIds: z.optional(allowedEnvironmentIdsSchema),\n allowedLocales: z.optional(allowedLocalesSchema),\n }),\n response: { 200: responseDataSchema(accessKeySchema) },\n },\n }),\n refreshAccessKey: defineRoute({\n method: 'PATCH',\n path: '/access_key',\n summary: 'Regenerate the secret of an access key',\n schemas: {\n body: clientIdBodySchema,\n response: { 200: responseDataSchema(accessKeySchema) },\n },\n }),\n deleteAccessKey: defineRoute({\n method: 'DELETE',\n path: '/access_key',\n summary: 'Delete an access key',\n schemas: {\n body: clientIdBodySchema,\n response: { 200: responseDataSchema(z.null()) },\n },\n }),\n triggerBuild: defineRoute({\n method: 'POST',\n path: '/build',\n summary: 'Trigger the CI pipelines and webhooks of the project',\n schemas: {\n response: {\n 200: responseDataSchema(\n z.object({ results: z.array(ciTargetResultSchema) })\n ),\n },\n },\n }),\n triggerWebhook: defineRoute({\n method: 'POST',\n path: '/webhook',\n summary: 'Trigger a single project webhook',\n schemas: {\n body: z.object({ webhookIndex: z.int().check(z.gte(0)) }),\n response: { 200: responseDataSchema(ciTargetResultSchema) },\n },\n }),\n getCIConfiguration: defineRoute({\n method: 'GET',\n path: '/ci',\n summary: 'CI configuration status of the connected repository',\n schemas: {\n response: { 200: responseDataSchema(ciStatusSchema) },\n },\n }),\n pushCIConfiguration: defineRoute({\n method: 'POST',\n path: '/ci',\n summary: 'Commit the CI configuration file to the repository',\n schemas: {\n response: {\n 200: responseDataSchema(z.object({ success: z.boolean() })),\n },\n },\n }),\n deleteProjectByIdAdmin: defineRoute({\n method: 'DELETE',\n path: '/:projectId/admin',\n summary: 'Admin only: delete any project',\n schemas: {\n params: projectIdParamsSchema,\n response: { 200: responseDataSchema(projectSchema) },\n },\n }),\n updateMemberAccess: defineRoute({\n method: 'PUT',\n path: '/member/:userId/access',\n summary: 'Restrict the environments and locales of a project member',\n schemas: {\n params: z.object({ userId: objectIdSchema }),\n body: z.object({\n allowedEnvironmentIds: allowedEnvironmentIdsSchema,\n allowedLocales: allowedLocalesSchema,\n }),\n response: {\n 200: responseDataSchema(projectMemberGranularAccessSchema),\n },\n },\n }),\n },\n});\n\n/** Route definitions of the `/api/project` group, by name. */\nexport type ProjectRoutes = (typeof projectContract)['routes'];\n\n// Entity types\nexport type ProjectConfiguration = z.output<typeof projectConfigurationSchema>;\nexport type Webhook = z.output<typeof webhookSchema>;\nexport type ProjectConfigCI = z.output<typeof projectCISchema>;\nexport type RepositoryProvider = z.output<typeof repositoryProviderSchema>;\nexport type RepositoryConnection = z.output<typeof repositoryConnectionSchema>;\nexport type EnvironmentAPI = z.output<typeof environmentSchema>;\nexport type ProjectMemberGranularAccessAPI = z.output<\n typeof projectMemberGranularAccessSchema\n>;\nexport type OAuth2AccessAPI = z.output<typeof accessKeySchema>;\nexport type ProjectAPI = z.output<typeof projectSchema>;\nexport type ProjectInsights = z.output<typeof projectInsightsSchema>;\nexport type CIStatus = z.output<typeof ciStatusSchema>;\n\n// Request / response types\nexport type GetProjectsParams = RouteQuerystring<ProjectRoutes['getProjects']>;\nexport type GetProjectsResult = PaginatedResponse<ProjectAPI>;\nexport type GetProjectInsightsResult = ResponseData<ProjectInsights>;\nexport type AddProjectBody = RouteBodyInput<ProjectRoutes['addProject']>;\nexport type AddProjectResult = ResponseData<ProjectAPI>;\nexport type UpdateProjectBody = RouteBodyInput<ProjectRoutes['updateProject']>;\nexport type UpdateProjectResult = ResponseData<ProjectAPI>;\nexport type UpdateProjectMembersBody = RouteBodyInput<\n ProjectRoutes['updateProjectMembers']\n>;\nexport type UpdateProjectMembersResult = ResponseData<ProjectAPI>;\nexport type PushProjectConfigurationBody = RouteBodyInput<\n ProjectRoutes['pushProjectConfiguration']\n>;\nexport type PushProjectConfigurationResult = ResponseData<ProjectConfiguration>;\nexport type DeleteProjectResult = ResponseData<ProjectAPI>;\nexport type SelectProjectParam = RouteParams<ProjectRoutes['selectProject']>;\nexport type SelectProjectResult = ResponseData<ProjectAPI>;\nexport type UnselectProjectResult = ResponseData<null>;\n/** `expiresAt` also accepts a `Date`: JSON serializes it to an ISO string. */\nexport type AddNewAccessKeyBody = Omit<\n RouteBodyInput<ProjectRoutes['addNewAccessKey']>,\n 'expiresAt'\n> & { expiresAt?: Date | string };\nexport type AddNewAccessKeyResponse = ResponseData<OAuth2AccessAPI>;\nexport type RefreshAccessKeyBody = RouteBody<ProjectRoutes['refreshAccessKey']>;\nexport type RefreshAccessKeyResponse = ResponseData<OAuth2AccessAPI>;\nexport type DeleteAccessKeyBody = RouteBody<ProjectRoutes['deleteAccessKey']>;\nexport type DeleteAccessKeyResponse = ResponseData<null>;\nexport type TriggerBuildResult = ResponseData<{\n results: z.output<typeof ciTargetResultSchema>[];\n}>;\nexport type TriggerWebhookBody = RouteBody<ProjectRoutes['triggerWebhook']>;\nexport type TriggerWebhookResult = ResponseData<\n z.output<typeof ciTargetResultSchema>\n>;\nexport type GetCIConfigurationResult = ResponseData<CIStatus>;\nexport type PushCIConfigurationResult = ResponseData<{ success: boolean }>;\nexport type DeleteProjectByIdAdminResult = ResponseData<ProjectAPI>;\nexport type UpdateMemberAccessParams = RouteParams<\n ProjectRoutes['updateMemberAccess']\n>;\nexport type UpdateMemberAccessBody = RouteBodyInput<\n ProjectRoutes['updateMemberAccess']\n>;\nexport type UpdateMemberAccessResult =\n ResponseData<ProjectMemberGranularAccessAPI>;\n"],"mappings":";;;;;;;;AA2BA,MAAa,eAAeA,iCAA0B;;;;;AAatD,MAAa,6BAA6BC,WAAE,YAAY;CACtD,sBAAsBA,WAAE,SACtBA,WAAE,YAAY;EACZ,SAASA,WAAE,SAASA,WAAE,MAAM,YAAY,CAAC;EACzC,eAAeA,WAAE,SAAS,YAAY;CACxC,CAAC,CACH;CACA,QAAQA,WAAE,SACRA,WAAE,YAAY;EACZ,gBAAgBA,WAAE,SAASD,iCAA2B,CAAC;EACvD,QAAQC,WAAE,SAASD,iCAA2B,CAAC;CACjD,CAAC,CACH;CACA,IAAIC,WAAE,SAASC,gCAAkC,CAAC;AACpD,CAAC;;AAGD,MAAa,gBAAgBD,WAAE,YAAY;CACzC,IAAIA,WAAE,SAASA,WAAE,OAAO,CAAC;CACzB,MAAMA,WAAE,OAAO;CACf,KAAKA,WAAE,OAAO;CACd,SAASA,WAAE,SAASA,WAAE,QAAQ,CAAC;;CAE/B,QAAQA,WAAE,SAASA,WAAE,OAAO,CAAC;AAC/B,CAAC;;AAGD,MAAa,kBAAkBA,WAAE,OAAO;CACtC,mBAAmBA,WAAE,SAASA,WAAE,QAAQ,CAAC;;CAEzC,wBAAwBA,WAAE,SAASA,WAAE,QAAQ,CAAC;CAC9C,UAAUA,WAAE,SAASA,WAAE,MAAM,aAAa,CAAC;AAC7C,CAAC;;AAGD,MAAa,2BAA2BA,WAAE,KAAK;CAC7C;CACA;CACA;CACA;CACA;AACF,CAAC;AAED,MAAM,sBAAsB;CAC1B,OAAOA,WAAE,O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,CAAC;EACD,wBAAwBK,gCAAY;GAClC,QAAQ;GACR,MAAM;GACN,SAAS;GACT,SAAS;IACP,QAAQ;IACR,UAAU,EAAE,KAAKI,wCAAmB,aAAa,EAAE;GACrD;EACF,CAAC;EACD,oBAAoBJ,gCAAY;GAC9B,QAAQ;GACR,MAAM;GACN,SAAS;GACT,SAAS;IACP,QAAQL,WAAE,OAAO,EAAE,QAAQG,8BAAe,CAAC;IAC3C,MAAMH,WAAE,OAAO;KACb,uBAAuB;KACvB,gBAAgB;IAClB,CAAC;IACD,UAAU,EACR,KAAKS,wCAAmB,iCAAiC,EAC3D;GACF;EACF,CAAC;CACH;AACF,CAAC"}
|
|
1
|
+
{"version":3,"file":"project.cjs","names":["typedStringSchema","z","typedValueSchema","dateTimeSchema","objectIdSchema","defineRouteGroup","defineRoute","paginationQueryShape","repeatableQueryValueSchema","paginatedResponseSchema","responseDataSchema"],"sources":["../../src/project.ts"],"sourcesContent":["import type { Locale } from '@intlayer/types/allLocales';\nimport type { AiConfig, URLType } from '@intlayer/types/config';\nimport { z } from 'zod/mini';\nimport {\n dateTimeSchema,\n objectIdSchema,\n paginationQueryShape,\n repeatableQueryValueSchema,\n typedStringSchema,\n typedValueSchema,\n} from './common';\nimport {\n defineRoute,\n defineRouteGroup,\n type RouteBody,\n type RouteBodyInput,\n type RouteParams,\n type RouteQuerystring,\n} from './defineRoute';\nimport {\n type PaginatedResponse,\n paginatedResponseSchema,\n type ResponseData,\n responseDataSchema,\n} from './responseData';\n\n/** Locale code (ex: `en`, `fr-CA`). */\nexport const localeSchema = typedStringSchema<Locale>();\n\n/** Project AI settings: the Intlayer AI config plus the masked key state. */\nexport type ProjectConfigAI = Partial<AiConfig> & {\n /** Masked API key (`sk-proj-****abcd`), never the real one. */\n apiKey?: string;\n apiKeyConfigured?: boolean;\n /**\n * `false` runs AI calls on the plan credits instead of the own key.\n * Missing means enabled.\n */\n isOwnAPIKeyEnabled?: boolean;\n};\n\n/**\n * Project-level overrides of the Intlayer configuration. Loose objects: the\n * CLI pushes whole config sections, unknown keys must reach the service.\n */\nexport const projectConfigurationSchema = z.looseObject({\n internationalization: z.optional(\n z.looseObject({\n locales: z.optional(z.array(localeSchema)),\n defaultLocale: z.optional(localeSchema),\n })\n ),\n editor: z.optional(\n z.looseObject({\n applicationURL: z.optional(typedStringSchema<URLType>()),\n cmsURL: z.optional(typedStringSchema<URLType>()),\n })\n ),\n ai: z.optional(typedValueSchema<ProjectConfigAI>()),\n});\n\n/** Generic build webhook (Vercel, Netlify, custom). */\nexport const webhookSchema = z.looseObject({\n id: z.optional(z.string()),\n name: z.string(),\n url: z.string(),\n enabled: z.optional(z.boolean()),\n /** Optional signature secret. */\n secret: z.optional(z.string()),\n});\n\n/** Build triggers: git provider pipeline + generic webhooks. */\nexport const projectCISchema = z.object({\n autoTriggerBuilds: z.optional(z.boolean()),\n /** Commit CMS edits of `hybrid` dictionaries back to their source file. */\n autoCommitDictionaries: z.optional(z.boolean()),\n webhooks: z.optional(z.array(webhookSchema)),\n});\n\n/** Git provider of a connected repository. */\nexport const repositoryProviderSchema = z.enum([\n 'github',\n 'gitlab',\n 'bitbucket',\n 'codeberg',\n 'gitee',\n]);\n\nconst baseRepositoryShape = {\n owner: z.string(),\n repository: z.string(),\n branch: z.string(),\n url: z.string(),\n configFilePath: z.string(),\n};\n\n/**\n * Git repository connected to a project. The repo-scoped token never leaves\n * the server.\n */\nexport const repositoryConnectionSchema = z.discriminatedUnion('provider', [\n z.looseObject({\n provider: z.literal('github'),\n ...baseRepositoryShape,\n installationId: z.optional(z.number()),\n }),\n z.looseObject({\n provider: z.literal('gitlab'),\n ...baseRepositoryShape,\n projectId: z.optional(z.number()),\n /** Custom GitLab instance URL (ex: https://gitlab.company.com). */\n instanceUrl: z.optional(z.string()),\n }),\n z.looseObject({\n provider: z.literal('bitbucket'),\n ...baseRepositoryShape,\n workspace: z.string(),\n }),\n z.looseObject({ provider: z.literal('codeberg'), ...baseRepositoryShape }),\n z.looseObject({ provider: z.literal('gitee'), ...baseRepositoryShape }),\n]);\n\n/** null = unrestricted, [] = no access, array = allowed ids (null = production). */\nconst allowedEnvironmentIdsSchema = z.nullable(z.array(z.nullable(z.string())));\n/** null = unrestricted, [] = no access, array = allowed locales. */\nconst allowedLocalesSchema = z.nullable(z.array(localeSchema));\n\n/** Project environment (production is injected when none is the default). */\nexport const environmentSchema = z.looseObject({\n id: z.string(),\n name: z.string(),\n isDefault: z.boolean(),\n configuration: z.optional(projectConfigurationSchema),\n createdAt: z.optional(dateTimeSchema),\n updatedAt: z.optional(dateTimeSchema),\n});\n\n/** Granular per-member access, overlaid on the member's role. */\nexport const projectMemberGranularAccessSchema = z.object({\n userId: z.string(),\n allowedEnvironmentIds: allowedEnvironmentIdsSchema,\n allowedLocales: allowedLocalesSchema,\n});\n\n/** Access key (OAuth2 client credentials). Live bearer tokens are never sent. */\nexport const accessKeySchema = z.looseObject({\n id: z.string(),\n name: z.string(),\n clientId: z.string(),\n /** Shown to project members (dashboard copy, CLI login). */\n clientSecret: z.string(),\n grants: z.array(z.string()),\n userId: z.string(),\n expiresAt: z.optional(z.nullable(dateTimeSchema)),\n allowedEnvironmentIds: z.optional(allowedEnvironmentIdsSchema),\n allowedLocales: z.optional(allowedLocalesSchema),\n createdAt: dateTimeSchema,\n updatedAt: dateTimeSchema,\n});\n\n/** Project as returned by the API. */\nexport const projectSchema = z.looseObject({\n id: z.string(),\n organizationId: z.string(),\n name: z.string(),\n membersIds: z.array(z.string()),\n adminsIds: z.array(z.string()),\n viewersIds: z.optional(z.array(z.string())),\n memberAccess: z.optional(z.array(projectMemberGranularAccessSchema)),\n creatorId: z.string(),\n configuration: z.optional(projectConfigurationSchema),\n repository: z.optional(z.nullable(repositoryConnectionSchema)),\n webhooks: z.optional(projectCISchema),\n autoFill: z.optional(z.boolean()),\n /** Screenshot of the application URL, generated automatically. */\n imageUrl: z.optional(z.string()),\n environments: z.optional(z.array(environmentSchema)),\n oAuth2Access: z.array(accessKeySchema),\n createdAt: dateTimeSchema,\n updatedAt: dateTimeSchema,\n});\n\n/** Translation health of one locale of a project. */\nexport const localeInsightSchema = z.object({\n locale: localeSchema,\n isDefault: z.boolean(),\n translatedKeys: z.number(),\n totalKeys: z.number(),\n missingKeys: z.number(),\n /** Ratio in the `[0, 1]` range. */\n completionRate: z.number(),\n});\n\n/** Project-wide localization insights shown on the dashboard overview. */\nexport const projectInsightsSchema = z.object({\n projectId: z.string(),\n /** Unix epoch (ms) at which the snapshot was computed. */\n generatedAt: z.number(),\n defaultLocale: z.nullable(localeSchema),\n localeCount: z.number(),\n dictionaryCount: z.number(),\n keyCount: z.number(),\n translationUnitCount: z.number(),\n translatedUnitCount: z.number(),\n overallCompletionRate: z.number(),\n fullyTranslatedLocaleCount: z.number(),\n dictionariesWithMissingTranslations: z.number(),\n missingTranslationCount: z.number(),\n localeInsights: z.array(localeInsightSchema),\n recentlyUpdated: z.array(\n z.object({ key: z.string(), updatedAt: z.number() })\n ),\n lastUpdatedAt: z.nullable(z.number()),\n memberCount: z.number(),\n adminCount: z.number(),\n environmentCount: z.number(),\n autoFill: z.boolean(),\n aiConfigured: z.boolean(),\n repositoryProvider: z.nullable(repositoryProviderSchema),\n applicationURL: z.nullable(z.string()),\n});\n\n/** CI configuration file status of the connected repository. */\nexport const ciStatusSchema = z.object({\n exists: z.boolean(),\n content: z.string(),\n path: z.string(),\n fileUrl: z.optional(z.string()),\n allowAutoPush: z.boolean(),\n});\n\nconst projectIdParamsSchema = z.object({ projectId: objectIdSchema });\nconst clientIdBodySchema = z.object({ clientId: z.string() });\n\nconst ciTargetResultSchema = z.object({\n target: z.string(),\n success: z.boolean(),\n message: z.optional(z.string()),\n});\n\n/** REST contract of the `/api/project` routes. */\nexport const projectContract = defineRouteGroup({\n prefix: '/api/project',\n tag: 'Project',\n routes: {\n getProjects: defineRoute({\n method: 'GET',\n path: '/',\n summary: 'List the projects visible to the session',\n schemas: {\n querystring: z.looseObject({\n ...paginationQueryShape,\n ids: z.optional(repeatableQueryValueSchema),\n name: z.optional(z.string()),\n search: z.optional(z.string()),\n organizationId: z.optional(z.string()),\n membersIds: z.optional(repeatableQueryValueSchema),\n sortBy: z.optional(z.string()),\n sortOrder: z.optional(z.string()),\n /** Admin only: list projects of every organization. */\n fetchAll: z.optional(z.enum(['true', 'false'])),\n }),\n response: { 200: paginatedResponseSchema(projectSchema) },\n },\n }),\n getProjectInsights: defineRoute({\n method: 'GET',\n path: '/insights',\n summary: 'Localization insights of the selected project',\n schemas: {\n response: { 200: responseDataSchema(projectInsightsSchema) },\n },\n }),\n addProject: defineRoute({\n method: 'POST',\n path: '/',\n summary: 'Create a project in the selected organization',\n schemas: {\n body: z.looseObject({ name: z.string().check(z.minLength(1)) }),\n response: { 200: responseDataSchema(projectSchema) },\n },\n }),\n updateProject: defineRoute({\n method: 'PUT',\n path: '/',\n summary: 'Update the selected project',\n schemas: {\n /**\n * Allow-list: membership and ownership fields (`adminsIds`,\n * `membersIds`, `viewersIds`, `creatorId`, `memberAccess`,\n * `environments`) are stripped, they only change through their\n * dedicated endpoints and the invariants those enforce.\n */\n body: z.object({\n name: z.optional(z.string().check(z.minLength(1))),\n configuration: z.optional(projectConfigurationSchema),\n autoFill: z.optional(z.boolean()),\n webhooks: z.optional(projectCISchema),\n /** `null` disconnects the repository. */\n repository: z.optional(z.nullable(repositoryConnectionSchema)),\n }),\n response: { 200: responseDataSchema(projectSchema) },\n },\n }),\n updateProjectMembers: defineRoute({\n method: 'PUT',\n path: '/members',\n summary: 'Replace the members of the selected project',\n schemas: {\n body: z.object({\n membersIds: z.optional(\n z.array(\n z.object({\n userId: objectIdSchema,\n isAdmin: z.optional(z.boolean()),\n })\n )\n ),\n }),\n response: { 200: responseDataSchema(projectSchema) },\n },\n }),\n pushProjectConfiguration: defineRoute({\n method: 'PUT',\n path: '/configuration',\n summary: 'Push the local Intlayer configuration to the project',\n schemas: {\n body: projectConfigurationSchema,\n response: { 200: responseDataSchema(projectConfigurationSchema) },\n },\n }),\n deleteProject: defineRoute({\n method: 'DELETE',\n path: '/',\n summary: 'Delete the selected project',\n schemas: {\n response: { 200: responseDataSchema(projectSchema) },\n },\n }),\n selectProject: defineRoute({\n method: 'PUT',\n path: '/:projectId',\n summary: 'Select a project for the current session',\n schemas: {\n params: projectIdParamsSchema,\n response: { 200: responseDataSchema(projectSchema) },\n },\n }),\n unselectProject: defineRoute({\n method: 'POST',\n path: '/logout',\n summary: 'Unselect the project of the current session',\n schemas: {\n response: { 200: responseDataSchema(z.null()) },\n },\n }),\n addNewAccessKey: defineRoute({\n method: 'POST',\n path: '/access_key',\n summary: 'Create an access key for the selected project',\n schemas: {\n body: z.object({\n name: z.string().check(z.minLength(1)),\n grants: z.array(z.string()),\n /** ISO date-time, parsed to a `Date`; omitted for a key that never expires. */\n expiresAt: z.optional(\n z.pipe(\n z.iso.datetime(),\n z.transform((value) => new Date(value))\n )\n ),\n allowedEnvironmentIds: z.optional(allowedEnvironmentIdsSchema),\n allowedLocales: z.optional(allowedLocalesSchema),\n }),\n response: { 200: responseDataSchema(accessKeySchema) },\n },\n }),\n refreshAccessKey: defineRoute({\n method: 'PATCH',\n path: '/access_key',\n summary: 'Regenerate the secret of an access key',\n schemas: {\n body: clientIdBodySchema,\n response: { 200: responseDataSchema(accessKeySchema) },\n },\n }),\n deleteAccessKey: defineRoute({\n method: 'DELETE',\n path: '/access_key',\n summary: 'Delete an access key',\n schemas: {\n body: clientIdBodySchema,\n response: { 200: responseDataSchema(z.null()) },\n },\n }),\n triggerBuild: defineRoute({\n method: 'POST',\n path: '/build',\n summary: 'Trigger the CI pipelines and webhooks of the project',\n schemas: {\n response: {\n 200: responseDataSchema(\n z.object({ results: z.array(ciTargetResultSchema) })\n ),\n },\n },\n }),\n triggerWebhook: defineRoute({\n method: 'POST',\n path: '/webhook',\n summary: 'Trigger a single project webhook',\n schemas: {\n body: z.object({ webhookIndex: z.int().check(z.gte(0)) }),\n response: { 200: responseDataSchema(ciTargetResultSchema) },\n },\n }),\n getCIConfiguration: defineRoute({\n method: 'GET',\n path: '/ci',\n summary: 'CI configuration status of the connected repository',\n schemas: {\n response: { 200: responseDataSchema(ciStatusSchema) },\n },\n }),\n pushCIConfiguration: defineRoute({\n method: 'POST',\n path: '/ci',\n summary: 'Commit the CI configuration file to the repository',\n schemas: {\n response: {\n 200: responseDataSchema(z.object({ success: z.boolean() })),\n },\n },\n }),\n deleteProjectByIdAdmin: defineRoute({\n method: 'DELETE',\n path: '/:projectId/admin',\n summary: 'Admin only: delete any project',\n schemas: {\n params: projectIdParamsSchema,\n response: { 200: responseDataSchema(projectSchema) },\n },\n }),\n updateMemberAccess: defineRoute({\n method: 'PUT',\n path: '/member/:userId/access',\n summary: 'Restrict the environments and locales of a project member',\n schemas: {\n params: z.object({ userId: objectIdSchema }),\n body: z.object({\n allowedEnvironmentIds: allowedEnvironmentIdsSchema,\n allowedLocales: allowedLocalesSchema,\n }),\n response: {\n 200: responseDataSchema(projectMemberGranularAccessSchema),\n },\n },\n }),\n },\n});\n\n/** Route definitions of the `/api/project` group, by name. */\nexport type ProjectRoutes = (typeof projectContract)['routes'];\n\n// Entity types\nexport type ProjectConfiguration = z.output<typeof projectConfigurationSchema>;\nexport type Webhook = z.output<typeof webhookSchema>;\nexport type ProjectConfigCI = z.output<typeof projectCISchema>;\nexport type RepositoryProvider = z.output<typeof repositoryProviderSchema>;\nexport type RepositoryConnection = z.output<typeof repositoryConnectionSchema>;\nexport type EnvironmentAPI = z.output<typeof environmentSchema>;\nexport type ProjectMemberGranularAccessAPI = z.output<\n typeof projectMemberGranularAccessSchema\n>;\nexport type OAuth2AccessAPI = z.output<typeof accessKeySchema>;\nexport type ProjectAPI = z.output<typeof projectSchema>;\nexport type ProjectInsights = z.output<typeof projectInsightsSchema>;\nexport type CIStatus = z.output<typeof ciStatusSchema>;\n\n// Request / response types\nexport type GetProjectsParams = RouteQuerystring<ProjectRoutes['getProjects']>;\nexport type GetProjectsResult = PaginatedResponse<ProjectAPI>;\nexport type GetProjectInsightsResult = ResponseData<ProjectInsights>;\nexport type AddProjectBody = RouteBodyInput<ProjectRoutes['addProject']>;\nexport type AddProjectResult = ResponseData<ProjectAPI>;\nexport type UpdateProjectBody = RouteBodyInput<ProjectRoutes['updateProject']>;\nexport type UpdateProjectResult = ResponseData<ProjectAPI>;\nexport type UpdateProjectMembersBody = RouteBodyInput<\n ProjectRoutes['updateProjectMembers']\n>;\nexport type UpdateProjectMembersResult = ResponseData<ProjectAPI>;\nexport type PushProjectConfigurationBody = RouteBodyInput<\n ProjectRoutes['pushProjectConfiguration']\n>;\nexport type PushProjectConfigurationResult = ResponseData<ProjectConfiguration>;\nexport type DeleteProjectResult = ResponseData<ProjectAPI>;\nexport type SelectProjectParam = RouteParams<ProjectRoutes['selectProject']>;\nexport type SelectProjectResult = ResponseData<ProjectAPI>;\nexport type UnselectProjectResult = ResponseData<null>;\n/** `expiresAt` also accepts a `Date`: JSON serializes it to an ISO string. */\nexport type AddNewAccessKeyBody = Omit<\n RouteBodyInput<ProjectRoutes['addNewAccessKey']>,\n 'expiresAt'\n> & { expiresAt?: Date | string };\nexport type AddNewAccessKeyResponse = ResponseData<OAuth2AccessAPI>;\nexport type RefreshAccessKeyBody = RouteBody<ProjectRoutes['refreshAccessKey']>;\nexport type RefreshAccessKeyResponse = ResponseData<OAuth2AccessAPI>;\nexport type DeleteAccessKeyBody = RouteBody<ProjectRoutes['deleteAccessKey']>;\nexport type DeleteAccessKeyResponse = ResponseData<null>;\nexport type TriggerBuildResult = ResponseData<{\n results: z.output<typeof ciTargetResultSchema>[];\n}>;\nexport type TriggerWebhookBody = RouteBody<ProjectRoutes['triggerWebhook']>;\nexport type TriggerWebhookResult = ResponseData<\n z.output<typeof ciTargetResultSchema>\n>;\nexport type GetCIConfigurationResult = ResponseData<CIStatus>;\nexport type PushCIConfigurationResult = ResponseData<{ success: boolean }>;\nexport type DeleteProjectByIdAdminResult = ResponseData<ProjectAPI>;\nexport type UpdateMemberAccessParams = RouteParams<\n ProjectRoutes['updateMemberAccess']\n>;\nexport type UpdateMemberAccessBody = RouteBodyInput<\n ProjectRoutes['updateMemberAccess']\n>;\nexport type UpdateMemberAccessResult =\n ResponseData<ProjectMemberGranularAccessAPI>;\n"],"mappings":";;;;;;;;AA2BA,MAAa,eAAeA,iCAA0B;;;;;AAkBtD,MAAa,6BAA6BC,WAAE,YAAY;CACtD,sBAAsBA,WAAE,SACtBA,WAAE,YAAY;EACZ,SAASA,WAAE,SAASA,WAAE,MAAM,YAAY,CAAC;EACzC,eAAeA,WAAE,SAAS,YAAY;CACxC,CAAC,CACH;CACA,QAAQA,WAAE,SACRA,WAAE,YAAY;EACZ,gBAAgBA,WAAE,SAASD,iCAA2B,CAAC;EACvD,QAAQC,WAAE,SAASD,iCAA2B,CAAC;CACjD,CAAC,CACH;CACA,IAAIC,WAAE,SAASC,gCAAkC,CAAC;AACpD,CAAC;;AAGD,MAAa,gBAAgBD,WAAE,YAAY;CACzC,IAAIA,WAAE,SAASA,WAAE,OAAO,CAAC;CACzB,MAAMA,WAAE,OAAO;CACf,KAAKA,WAAE,OAAO;CACd,SAASA,WAAE,SAASA,WAAE,QAAQ,CAAC;;CAE/B,QAAQA,WAAE,SAASA,WAAE,OAAO,CAAC;AAC/B,CAAC;;AAGD,MAAa,kBAAkBA,WAAE,OAAO;CACtC,mBAAmBA,WAAE,SAASA,WAAE,QAAQ,CAAC;;CAEzC,wBAAwBA,WAAE,SAASA,WAAE,QAAQ,CAAC;CAC9C,UAAUA,WAAE,SAASA,WAAE,MAAM,aAAa,CAAC;AAC7C,CAAC;;AAGD,MAAa,2BAA2BA,WAAE,KAAK;CAC7C;CACA;CACA;CACA;CACA;AACF,CAAC;AAED,MAAM,sBAAsB;CAC1B,OAAOA,WAAE,OAAO;CAChB,YAAYA,WAAE,OAAO;CACrB,QAAQA,WAAE,OAAO;CACjB,KAAKA,WAAE,OAAO;CACd,gBAAgBA,WAAE,OAAO;AAC3B;;;;;AAMA,MAAa,6BAA6BA,WAAE,mB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ACD,oBAAoBJ,gCAAY;GAC9B,QAAQ;GACR,MAAM;GACN,SAAS;GACT,SAAS;IACP,QAAQL,WAAE,OAAO,EAAE,QAAQG,8BAAe,CAAC;IAC3C,MAAMH,WAAE,OAAO;KACb,uBAAuB;KACvB,gBAAgB;IAClB,CAAC;IACD,UAAU,EACR,KAAKS,wCAAmB,iCAAiC,EAC3D;GACF;EACF,CAAC;CACH;AACF,CAAC"}
|
package/dist/esm/analytics.mjs
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { ANALYTICS_ACTIVE_USERS_RETENTION_DAYS, ANALYTICS_ANNOTATION_TYPES, ANALYTICS_DIMENSION_DESCRIPTIONS, ANALYTICS_METRIC_DESCRIPTIONS, ANALYTICS_METRIC_DIMENSIONS, ANALYTICS_REALTIME_DIMENSIONS, ANALYTICS_REALTIME_MAX_MINUTES, ANALYTICS_REALTIME_METRICS, ANALYTICS_REPORT_DEFAULT_LIMIT, ANALYTICS_REPORT_DIMENSIONS, ANALYTICS_REPORT_MAX_DATE_RANGES, ANALYTICS_REPORT_MAX_LIMIT, ANALYTICS_REPORT_METRICS, ANALYTICS_TIME_DIMENSIONS, analyticsAnnotationSchema, analyticsAnnotationsQuerySchema, analyticsDateRangeSchema, analyticsDimensionFilterSchema, analyticsMetricFilterSchema, analyticsOrderBySchema, analyticsRealtimeReportRequestSchema, analyticsReportRequestSchema, analyticsReportRowSchema, analyticsReportSchema, analyticsSchemaInfoSchema } from "./analyticsReport.mjs";
|
|
1
2
|
import { defineRoute, defineRouteGroup } from "./defineRoute.mjs";
|
|
2
3
|
import { responseDataSchema } from "./responseData.mjs";
|
|
3
4
|
import { z } from "zod/mini";
|
|
@@ -255,6 +256,39 @@ const analyticsContract = defineRouteGroup({
|
|
|
255
256
|
response: { 200: responseDataSchema(experimentResultSchema) }
|
|
256
257
|
}
|
|
257
258
|
}),
|
|
259
|
+
getAnalyticsSchema: defineRoute({
|
|
260
|
+
method: "GET",
|
|
261
|
+
path: "/schema",
|
|
262
|
+
summary: "Report dimensions, metrics, their compatibility, retention and experiments",
|
|
263
|
+
schemas: { response: { 200: responseDataSchema(analyticsSchemaInfoSchema) } }
|
|
264
|
+
}),
|
|
265
|
+
runAnalyticsReport: defineRoute({
|
|
266
|
+
method: "POST",
|
|
267
|
+
path: "/report",
|
|
268
|
+
summary: "Aggregated report: metrics broken down by dimensions over date ranges",
|
|
269
|
+
schemas: {
|
|
270
|
+
body: analyticsReportRequestSchema,
|
|
271
|
+
response: { 200: responseDataSchema(analyticsReportSchema) }
|
|
272
|
+
}
|
|
273
|
+
}),
|
|
274
|
+
runAnalyticsRealtimeReport: defineRoute({
|
|
275
|
+
method: "POST",
|
|
276
|
+
path: "/realtime-report",
|
|
277
|
+
summary: "Aggregated activity of the last minutes (up to one hour)",
|
|
278
|
+
schemas: {
|
|
279
|
+
body: analyticsRealtimeReportRequestSchema,
|
|
280
|
+
response: { 200: responseDataSchema(analyticsReportSchema) }
|
|
281
|
+
}
|
|
282
|
+
}),
|
|
283
|
+
getAnalyticsAnnotations: defineRoute({
|
|
284
|
+
method: "GET",
|
|
285
|
+
path: "/annotations",
|
|
286
|
+
summary: "Dated content and traffic events (dictionary edits, repo syncs, new locales, experiments)",
|
|
287
|
+
schemas: {
|
|
288
|
+
querystring: analyticsAnnotationsQuerySchema,
|
|
289
|
+
response: { 200: responseDataSchema(z.array(analyticsAnnotationSchema)) }
|
|
290
|
+
}
|
|
291
|
+
}),
|
|
258
292
|
getPageMetadata: defineRoute({
|
|
259
293
|
method: "GET",
|
|
260
294
|
path: "/page-metadata",
|
|
@@ -267,5 +301,5 @@ const analyticsContract = defineRouteGroup({
|
|
|
267
301
|
}
|
|
268
302
|
});
|
|
269
303
|
|
|
270
|
-
export { PAGE_FLOW_ENTRANCE, analyticsContract, analyticsEventTypeSchema, audienceGranularitySchema, audienceRangeSchema, audienceSeriesPointSchema, audienceStatsSchema, incomingAnalyticsEventSchema, liveVisitorFlowSchema, liveVisitorFlowStepSchema, liveVisitorSchema, pageFlowLinkSchema, pageFlowNodeSchema, pageFlowSchema };
|
|
304
|
+
export { ANALYTICS_ACTIVE_USERS_RETENTION_DAYS, ANALYTICS_ANNOTATION_TYPES, ANALYTICS_DIMENSION_DESCRIPTIONS, ANALYTICS_METRIC_DESCRIPTIONS, ANALYTICS_METRIC_DIMENSIONS, ANALYTICS_REALTIME_DIMENSIONS, ANALYTICS_REALTIME_MAX_MINUTES, ANALYTICS_REALTIME_METRICS, ANALYTICS_REPORT_DEFAULT_LIMIT, ANALYTICS_REPORT_DIMENSIONS, ANALYTICS_REPORT_MAX_DATE_RANGES, ANALYTICS_REPORT_MAX_LIMIT, ANALYTICS_REPORT_METRICS, ANALYTICS_TIME_DIMENSIONS, PAGE_FLOW_ENTRANCE, analyticsAnnotationSchema, analyticsAnnotationsQuerySchema, analyticsContract, analyticsDateRangeSchema, analyticsDimensionFilterSchema, analyticsEventTypeSchema, analyticsMetricFilterSchema, analyticsOrderBySchema, analyticsRealtimeReportRequestSchema, analyticsReportRequestSchema, analyticsReportRowSchema, analyticsReportSchema, analyticsSchemaInfoSchema, audienceGranularitySchema, audienceRangeSchema, audienceSeriesPointSchema, audienceStatsSchema, incomingAnalyticsEventSchema, liveVisitorFlowSchema, liveVisitorFlowStepSchema, liveVisitorSchema, pageFlowLinkSchema, pageFlowNodeSchema, pageFlowSchema };
|
|
271
305
|
//# sourceMappingURL=analytics.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"analytics.mjs","names":[],"sources":["../../src/analytics.ts"],"sourcesContent":["import { z } from 'zod/mini';\nimport {\n defineRoute,\n defineRouteGroup,\n type RouteBodyInput,\n} from './defineRoute';\nimport { type ResponseData, responseDataSchema } from './responseData';\n\n/** Kind of analytics event sent by the SDK. */\nexport const analyticsEventTypeSchema = z.enum([\n 'page_view',\n 'content_exposure',\n 'conversion',\n]);\n\n/** One event as sent by the SDK (batched). */\nexport const incomingAnalyticsEventSchema = z.looseObject({\n type: analyticsEventTypeSchema,\n /** Client timestamp (epoch ms). */\n t: z.number(),\n locale: z.string(),\n url: z.string(),\n ref: z.optional(z.string()),\n dictionaryKey: z.optional(z.string()),\n keyPath: z.optional(z.string()),\n nodeType: z.optional(z.string()),\n variant: z.optional(z.string()),\n count: z.optional(z.number()),\n experimentKey: z.optional(z.string()),\n goal: z.optional(z.string()),\n value: z.optional(z.number()),\n});\n\n/**\n * Time windows of the audience report. `live` covers the sessions active in the\n * last 30 minutes, bucketed per minute.\n */\nexport const audienceRangeSchema = z.enum([\n 'live',\n '1h',\n '24h',\n '7d',\n '30d',\n '90d',\n '6mo',\n '1y',\n '3y',\n]);\n\nexport const audienceGranularitySchema = z.enum([\n 'minute',\n 'hour',\n 'day',\n 'week',\n 'month',\n]);\n\nexport const audienceSeriesPointSchema = z.object({\n /** ISO bucket start. */\n bucket: z.string(),\n users: z.number(),\n views: z.number(),\n});\n\nconst audienceBreakdownRowSchema = z.object({\n key: z.string(),\n users: z.number(),\n views: z.number(),\n});\n\n/** A session active in the `live` window, placed on the map. */\nexport const liveVisitorSchema = z.object({\n /** Opaque, non-reversible visitor id (prefix of the hashed session). */\n visitorId: z.string(),\n /** ISO country code, `ZZ` when unknown. */\n country: z.string(),\n /** City reported by the CDN, when available. */\n city: z.optional(z.string()),\n /** City-level latitude (rounded to ~1 km), when available. */\n latitude: z.optional(z.number()),\n /** City-level longitude (rounded to ~1 km), when available. */\n longitude: z.optional(z.number()),\n /** Locale the visitor is browsing in. */\n locale: z.optional(z.string()),\n /** Page of the visitor's latest activity. */\n currentUrl: z.string(),\n /** Pages the visitor was active on during the window. */\n pageCount: z.number(),\n /** Page views during the window. */\n views: z.number(),\n /** ISO date of the visitor's first activity in the window. */\n firstSeenAt: z.string(),\n /** ISO date of the visitor's latest activity. */\n lastSeenAt: z.string(),\n /** Minutes (`YYYY-MM-DDTHH:mm`, UTC) the visitor was active in, oldest first. */\n activeMinutes: z.array(z.string()),\n});\n\n/** One step of a live visitor's journey, oldest first. */\nexport const liveVisitorFlowStepSchema = z.object({\n url: z.string(),\n locale: z.optional(z.string()),\n /** ISO date the visitor reached the page. */\n firstSeenAt: z.string(),\n /** ISO date of the visitor's latest activity on the page. */\n lastSeenAt: z.string(),\n views: z.number(),\n});\n\n/**\n * Page journey of one live visitor over the `live` window. `visitor` is `null`\n * once the session has left the window (not an error: it simply went quiet).\n */\nexport const liveVisitorFlowSchema = z.object({\n visitor: z.nullable(liveVisitorSchema),\n steps: z.array(liveVisitorFlowStepSchema),\n});\n\n/**\n * Pseudo-page a session starts from. Used as the flow's starting page, the\n * next step lists the landing pages.\n */\nexport const PAGE_FLOW_ENTRANCE = '(entrance)';\n\n/** One page of a flow step; `url` is `null` for the \"other pages\" bucket. */\nexport const pageFlowNodeSchema = z.object({\n url: z.nullable(z.string()),\n /** Average navigations reaching this page at this step. */\n value: z.number(),\n /** Part of `value` that left the site from this page (`null` if unknown). */\n exits: z.nullable(z.number()),\n});\n\n/** Average navigations from a page of one step to a page of the next. */\nexport const pageFlowLinkSchema = z.object({\n /** Step of the source page; the target is on `fromStep + 1`. */\n fromStep: z.number(),\n fromUrl: z.nullable(z.string()),\n toUrl: z.nullable(z.string()),\n value: z.number(),\n});\n\n/** Averaged navigation flow starting from one page. */\nexport const pageFlowSchema = z.object({\n startUrl: z.string(),\n range: audienceRangeSchema,\n /** Pages per step, the starting page alone on step 0. */\n steps: z.array(z.array(pageFlowNodeSchema)),\n links: z.array(pageFlowLinkSchema),\n});\n\nexport const audienceStatsSchema = z.object({\n usersToday: z.number(),\n usersLast7Days: z.number(),\n usersInRange: z.number(),\n viewsInRange: z.number(),\n range: audienceRangeSchema,\n rangeHours: z.number(),\n granularity: audienceGranularitySchema,\n series: z.array(audienceSeriesPointSchema),\n byLocale: z.array(audienceBreakdownRowSchema),\n byCountry: z.array(audienceBreakdownRowSchema),\n byPage: z.array(audienceBreakdownRowSchema),\n /** Active sessions with their location — `live` range only. */\n liveVisitors: z.optional(z.array(liveVisitorSchema)),\n /** First UTC day with collected data (`YYYY-MM-DD`), `null` before any. */\n dataSince: z.nullable(z.string()),\n});\n\nconst analyticsOverviewRowSchema = z.object({\n url: z.string(),\n locale: z.string(),\n views: z.number(),\n});\n\nconst contentStatRowSchema = z.object({\n dictionaryKey: z.string(),\n keyPath: z.string(),\n locale: z.string(),\n exposures: z.number(),\n});\n\nconst experimentResultSchema = z.object({\n experimentKey: z.string(),\n variants: z.array(\n z.object({\n variant: z.string(),\n exposures: z.number(),\n conversions: z.number(),\n conversionRate: z.number(),\n })\n ),\n pValue: z.nullable(z.number()),\n winner: z.nullable(z.string()),\n});\n\nconst pageMetadataSchema = z.object({\n title: z.optional(z.string()),\n description: z.optional(z.string()),\n});\n\n/** REST contract of the `/api/analytics` routes. */\nexport const analyticsContract = defineRouteGroup({\n prefix: '/api/analytics',\n tag: 'Analytics',\n routes: {\n ingestAnalyticsEvents: defineRoute({\n method: 'POST',\n path: '/events',\n summary: 'Ingest SDK events (public browser token, rate limited)',\n schemas: {\n /** Sent as `text/plain` JSON by `navigator.sendBeacon`. */\n body: z.looseObject({\n /** Token from `POST /api/public/token` (`analytics:ingest`). */\n token: z.optional(z.string()),\n /** @deprecated Superseded by `token`; still accepted. */\n clientId: z.optional(z.string()),\n sessionId: z.string(),\n sdkVersion: z.string(),\n events: z.array(incomingAnalyticsEventSchema),\n }),\n response: {\n 200: responseDataSchema(z.object({ accepted: z.number() })),\n },\n },\n }),\n getAnalyticsOverview: defineRoute({\n method: 'GET',\n path: '/overview',\n summary: 'Page views per page and locale',\n schemas: {\n response: {\n 200: responseDataSchema(z.array(analyticsOverviewRowSchema)),\n },\n },\n }),\n getAnalyticsAudience: defineRoute({\n method: 'GET',\n path: '/audience',\n summary: 'Audience report over a time window',\n schemas: {\n querystring: z.object({\n range: z.optional(z.string()),\n /** Legacy: converted to the closest range. */\n days: z.optional(z.string()),\n }),\n response: { 200: responseDataSchema(audienceStatsSchema) },\n },\n }),\n getLiveVisitorFlow: defineRoute({\n method: 'GET',\n path: '/audience/live/visitors/:visitorId',\n summary: 'Page journey of a visitor active in the last 30 minutes',\n schemas: {\n params: z.object({\n visitorId: z.string().check(z.regex(/^[a-f0-9]{16}$/)),\n }),\n response: { 200: responseDataSchema(liveVisitorFlowSchema) },\n },\n }),\n getPageFlow: defineRoute({\n method: 'GET',\n path: '/page-flow',\n summary: 'Average page-to-page navigation flow from a starting page',\n schemas: {\n querystring: z.object({\n range: z.optional(z.string()),\n /** Starting page pathname; defaults to `/`. */\n startUrl: z.optional(z.string()),\n }),\n response: { 200: responseDataSchema(pageFlowSchema) },\n },\n }),\n getContentStats: defineRoute({\n method: 'GET',\n path: '/content-stats',\n summary: 'Content exposures per dictionary key path and locale',\n schemas: {\n response: { 200: responseDataSchema(z.array(contentStatRowSchema)) },\n },\n }),\n getExperimentResults: defineRoute({\n method: 'GET',\n path: '/experiments/:experimentKey',\n summary: 'A/B test results of an experiment',\n schemas: {\n params: z.object({ experimentKey: z.string().check(z.minLength(1)) }),\n response: { 200: responseDataSchema(experimentResultSchema) },\n },\n }),\n getPageMetadata: defineRoute({\n method: 'GET',\n path: '/page-metadata',\n summary: 'Title and description of a page of the project',\n schemas: {\n querystring: z.object({ url: z.optional(z.string()) }),\n response: { 200: responseDataSchema(pageMetadataSchema) },\n },\n }),\n },\n});\n\n/** Route definitions of the `/api/analytics` group, by name. */\nexport type AnalyticsRoutes = (typeof analyticsContract)['routes'];\n\nexport type AnalyticsEventType = z.output<typeof analyticsEventTypeSchema>;\nexport type IncomingAnalyticsEvent = z.output<\n typeof incomingAnalyticsEventSchema\n>;\nexport type AudienceRange = z.output<typeof audienceRangeSchema>;\nexport type AudienceGranularity = z.output<typeof audienceGranularitySchema>;\nexport type AudienceSeriesPoint = z.output<typeof audienceSeriesPointSchema>;\nexport type AudienceBreakdownRow = z.output<typeof audienceBreakdownRowSchema>;\nexport type AudienceStats = z.output<typeof audienceStatsSchema>;\nexport type LiveVisitor = z.output<typeof liveVisitorSchema>;\nexport type LiveVisitorFlowStep = z.output<typeof liveVisitorFlowStepSchema>;\nexport type LiveVisitorFlow = z.output<typeof liveVisitorFlowSchema>;\nexport type PageFlowNode = z.output<typeof pageFlowNodeSchema>;\nexport type PageFlowLink = z.output<typeof pageFlowLinkSchema>;\nexport type PageFlow = z.output<typeof pageFlowSchema>;\nexport type AnalyticsOverviewRow = z.output<typeof analyticsOverviewRowSchema>;\nexport type ContentStatRow = z.output<typeof contentStatRowSchema>;\nexport type ExperimentResult = z.output<typeof experimentResultSchema>;\nexport type PageMetadata = z.output<typeof pageMetadataSchema>;\n\nexport type IngestAnalyticsBody = RouteBodyInput<\n AnalyticsRoutes['ingestAnalyticsEvents']\n>;\nexport type IngestAnalyticsResult = ResponseData<{ accepted: number }>;\nexport type GetAnalyticsOverviewResult = ResponseData<AnalyticsOverviewRow[]>;\nexport type GetContentStatsResult = ResponseData<ContentStatRow[]>;\nexport type GetExperimentResultsResult = ResponseData<ExperimentResult>;\nexport type GetAudienceResult = ResponseData<AudienceStats>;\nexport type GetLiveVisitorFlowResult = ResponseData<LiveVisitorFlow>;\nexport type GetPageFlowResult = ResponseData<PageFlow>;\nexport type GetPageMetadataResult = ResponseData<PageMetadata>;\n"],"mappings":";;;;;;AASA,MAAa,2BAA2B,EAAE,KAAK;CAC7C;CACA;CACA;AACF,CAAC;;AAGD,MAAa,+BAA+B,EAAE,YAAY;CACxD,MAAM;;CAEN,GAAG,EAAE,OAAO;CACZ,QAAQ,EAAE,OAAO;CACjB,KAAK,EAAE,OAAO;CACd,KAAK,EAAE,SAAS,EAAE,OAAO,CAAC;CAC1B,eAAe,EAAE,SAAS,EAAE,OAAO,CAAC;CACpC,SAAS,EAAE,SAAS,EAAE,OAAO,CAAC;CAC9B,UAAU,EAAE,SAAS,EAAE,OAAO,CAAC;CAC/B,SAAS,EAAE,SAAS,EAAE,OAAO,CAAC;CAC9B,OAAO,EAAE,SAAS,EAAE,OAAO,CAAC;CAC5B,eAAe,EAAE,SAAS,EAAE,OAAO,C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AAE,KAAK,mBAAmB,mBAAmB,EAAE;GAC3D;EACF,CAAC;EACD,oBAAoB,YAAY;GAC9B,QAAQ;GACR,MAAM;GACN,SAAS;GACT,SAAS;IACP,QAAQ,EAAE,OAAO,EACf,WAAW,EAAE,OAAO,CAAC,CAAC,MAAM,EAAE,MAAM,gBAAgB,CAAC,EACvD,CAAC;IACD,UAAU,EAAE,KAAK,mBAAmB,qBAAqB,EAAE;GAC7D;EACF,CAAC;EACD,aAAa,YAAY;GACvB,QAAQ;GACR,MAAM;GACN,SAAS;GACT,SAAS;IACP,aAAa,EAAE,OAAO;KACpB,OAAO,EAAE,SAAS,EAAE,OAAO,CAAC;;KAE5B,UAAU,EAAE,SAAS,EAAE,OAAO,CAAC;IACjC,CAAC;IACD,UAAU,EAAE,KAAK,mBAAmB,cAAc,EAAE;GACtD;EACF,CAAC;EACD,iBAAiB,YAAY;GAC3B,QAAQ;GACR,MAAM;GACN,SAAS;GACT,SAAS,EACP,UAAU,EAAE,KAAK,mBAAmB,EAAE,MAAM,oBAAoB,CAAC,EAAE,EACrE;EACF,CAAC;EACD,sBAAsB,YAAY;GAChC,QAAQ;GACR,MAAM;GACN,SAAS;GACT,SAAS;IACP,QAAQ,EAAE,OAAO,EAAE,eAAe,EAAE,OAAO,CAAC,CAAC,MAAM,EAAE,UAAU,CAAC,CAAC,EAAE,CAAC;IACpE,UAAU,EAAE,KAAK,mBAAmB,sBAAsB,EAAE;GAC9D;EACF,CAAC;EACD,iBAAiB,YAAY;GAC3B,QAAQ;GACR,MAAM;GACN,SAAS;GACT,SAAS;IACP,aAAa,EAAE,OAAO,EAAE,KAAK,EAAE,SAAS,EAAE,OAAO,CAAC,EAAE,CAAC;IACrD,UAAU,EAAE,KAAK,mBAAmB,kBAAkB,EAAE;GAC1D;EACF,CAAC;CACH;AACF,CAAC"}
|
|
1
|
+
{"version":3,"file":"analytics.mjs","names":[],"sources":["../../src/analytics.ts"],"sourcesContent":["import { z } from 'zod/mini';\nimport {\n type AnalyticsAnnotation,\n type AnalyticsReport,\n type AnalyticsSchemaInfo,\n analyticsAnnotationSchema,\n analyticsAnnotationsQuerySchema,\n analyticsRealtimeReportRequestSchema,\n analyticsReportRequestSchema,\n analyticsReportSchema,\n analyticsSchemaInfoSchema,\n} from './analyticsReport';\nimport {\n defineRoute,\n defineRouteGroup,\n type RouteBodyInput,\n} from './defineRoute';\nimport { type ResponseData, responseDataSchema } from './responseData';\n\nexport * from './analyticsReport';\n\n/** Kind of analytics event sent by the SDK. */\nexport const analyticsEventTypeSchema = z.enum([\n 'page_view',\n 'content_exposure',\n 'conversion',\n]);\n\n/** One event as sent by the SDK (batched). */\nexport const incomingAnalyticsEventSchema = z.looseObject({\n type: analyticsEventTypeSchema,\n /** Client timestamp (epoch ms). */\n t: z.number(),\n locale: z.string(),\n url: z.string(),\n ref: z.optional(z.string()),\n dictionaryKey: z.optional(z.string()),\n keyPath: z.optional(z.string()),\n nodeType: z.optional(z.string()),\n variant: z.optional(z.string()),\n count: z.optional(z.number()),\n experimentKey: z.optional(z.string()),\n goal: z.optional(z.string()),\n value: z.optional(z.number()),\n});\n\n/**\n * Time windows of the audience report. `live` covers the sessions active in the\n * last 30 minutes, bucketed per minute.\n */\nexport const audienceRangeSchema = z.enum([\n 'live',\n '1h',\n '24h',\n '7d',\n '30d',\n '90d',\n '6mo',\n '1y',\n '3y',\n]);\n\nexport const audienceGranularitySchema = z.enum([\n 'minute',\n 'hour',\n 'day',\n 'week',\n 'month',\n]);\n\nexport const audienceSeriesPointSchema = z.object({\n /** ISO bucket start. */\n bucket: z.string(),\n users: z.number(),\n views: z.number(),\n});\n\nconst audienceBreakdownRowSchema = z.object({\n key: z.string(),\n users: z.number(),\n views: z.number(),\n});\n\n/** A session active in the `live` window, placed on the map. */\nexport const liveVisitorSchema = z.object({\n /** Opaque, non-reversible visitor id (prefix of the hashed session). */\n visitorId: z.string(),\n /** ISO country code, `ZZ` when unknown. */\n country: z.string(),\n /** City reported by the CDN, when available. */\n city: z.optional(z.string()),\n /** City-level latitude (rounded to ~1 km), when available. */\n latitude: z.optional(z.number()),\n /** City-level longitude (rounded to ~1 km), when available. */\n longitude: z.optional(z.number()),\n /** Locale the visitor is browsing in. */\n locale: z.optional(z.string()),\n /** Page of the visitor's latest activity. */\n currentUrl: z.string(),\n /** Pages the visitor was active on during the window. */\n pageCount: z.number(),\n /** Page views during the window. */\n views: z.number(),\n /** ISO date of the visitor's first activity in the window. */\n firstSeenAt: z.string(),\n /** ISO date of the visitor's latest activity. */\n lastSeenAt: z.string(),\n /** Minutes (`YYYY-MM-DDTHH:mm`, UTC) the visitor was active in, oldest first. */\n activeMinutes: z.array(z.string()),\n});\n\n/** One step of a live visitor's journey, oldest first. */\nexport const liveVisitorFlowStepSchema = z.object({\n url: z.string(),\n locale: z.optional(z.string()),\n /** ISO date the visitor reached the page. */\n firstSeenAt: z.string(),\n /** ISO date of the visitor's latest activity on the page. */\n lastSeenAt: z.string(),\n views: z.number(),\n});\n\n/**\n * Page journey of one live visitor over the `live` window. `visitor` is `null`\n * once the session has left the window (not an error: it simply went quiet).\n */\nexport const liveVisitorFlowSchema = z.object({\n visitor: z.nullable(liveVisitorSchema),\n steps: z.array(liveVisitorFlowStepSchema),\n});\n\n/**\n * Pseudo-page a session starts from. Used as the flow's starting page, the\n * next step lists the landing pages.\n */\nexport const PAGE_FLOW_ENTRANCE = '(entrance)';\n\n/** One page of a flow step; `url` is `null` for the \"other pages\" bucket. */\nexport const pageFlowNodeSchema = z.object({\n url: z.nullable(z.string()),\n /** Average navigations reaching this page at this step. */\n value: z.number(),\n /** Part of `value` that left the site from this page (`null` if unknown). */\n exits: z.nullable(z.number()),\n});\n\n/** Average navigations from a page of one step to a page of the next. */\nexport const pageFlowLinkSchema = z.object({\n /** Step of the source page; the target is on `fromStep + 1`. */\n fromStep: z.number(),\n fromUrl: z.nullable(z.string()),\n toUrl: z.nullable(z.string()),\n value: z.number(),\n});\n\n/** Averaged navigation flow starting from one page. */\nexport const pageFlowSchema = z.object({\n startUrl: z.string(),\n range: audienceRangeSchema,\n /** Pages per step, the starting page alone on step 0. */\n steps: z.array(z.array(pageFlowNodeSchema)),\n links: z.array(pageFlowLinkSchema),\n});\n\nexport const audienceStatsSchema = z.object({\n usersToday: z.number(),\n usersLast7Days: z.number(),\n usersInRange: z.number(),\n viewsInRange: z.number(),\n range: audienceRangeSchema,\n rangeHours: z.number(),\n granularity: audienceGranularitySchema,\n series: z.array(audienceSeriesPointSchema),\n byLocale: z.array(audienceBreakdownRowSchema),\n byCountry: z.array(audienceBreakdownRowSchema),\n byPage: z.array(audienceBreakdownRowSchema),\n /** Active sessions with their location — `live` range only. */\n liveVisitors: z.optional(z.array(liveVisitorSchema)),\n /** First UTC day with collected data (`YYYY-MM-DD`), `null` before any. */\n dataSince: z.nullable(z.string()),\n});\n\nconst analyticsOverviewRowSchema = z.object({\n url: z.string(),\n locale: z.string(),\n views: z.number(),\n});\n\nconst contentStatRowSchema = z.object({\n dictionaryKey: z.string(),\n keyPath: z.string(),\n locale: z.string(),\n exposures: z.number(),\n});\n\nconst experimentResultSchema = z.object({\n experimentKey: z.string(),\n variants: z.array(\n z.object({\n variant: z.string(),\n exposures: z.number(),\n conversions: z.number(),\n conversionRate: z.number(),\n })\n ),\n pValue: z.nullable(z.number()),\n winner: z.nullable(z.string()),\n});\n\nconst pageMetadataSchema = z.object({\n title: z.optional(z.string()),\n description: z.optional(z.string()),\n});\n\n/** REST contract of the `/api/analytics` routes. */\nexport const analyticsContract = defineRouteGroup({\n prefix: '/api/analytics',\n tag: 'Analytics',\n routes: {\n ingestAnalyticsEvents: defineRoute({\n method: 'POST',\n path: '/events',\n summary: 'Ingest SDK events (public browser token, rate limited)',\n schemas: {\n /** Sent as `text/plain` JSON by `navigator.sendBeacon`. */\n body: z.looseObject({\n /** Token from `POST /api/public/token` (`analytics:ingest`). */\n token: z.optional(z.string()),\n /** @deprecated Superseded by `token`; still accepted. */\n clientId: z.optional(z.string()),\n sessionId: z.string(),\n sdkVersion: z.string(),\n events: z.array(incomingAnalyticsEventSchema),\n }),\n response: {\n 200: responseDataSchema(z.object({ accepted: z.number() })),\n },\n },\n }),\n getAnalyticsOverview: defineRoute({\n method: 'GET',\n path: '/overview',\n summary: 'Page views per page and locale',\n schemas: {\n response: {\n 200: responseDataSchema(z.array(analyticsOverviewRowSchema)),\n },\n },\n }),\n getAnalyticsAudience: defineRoute({\n method: 'GET',\n path: '/audience',\n summary: 'Audience report over a time window',\n schemas: {\n querystring: z.object({\n range: z.optional(z.string()),\n /** Legacy: converted to the closest range. */\n days: z.optional(z.string()),\n }),\n response: { 200: responseDataSchema(audienceStatsSchema) },\n },\n }),\n getLiveVisitorFlow: defineRoute({\n method: 'GET',\n path: '/audience/live/visitors/:visitorId',\n summary: 'Page journey of a visitor active in the last 30 minutes',\n schemas: {\n params: z.object({\n visitorId: z.string().check(z.regex(/^[a-f0-9]{16}$/)),\n }),\n response: { 200: responseDataSchema(liveVisitorFlowSchema) },\n },\n }),\n getPageFlow: defineRoute({\n method: 'GET',\n path: '/page-flow',\n summary: 'Average page-to-page navigation flow from a starting page',\n schemas: {\n querystring: z.object({\n range: z.optional(z.string()),\n /** Starting page pathname; defaults to `/`. */\n startUrl: z.optional(z.string()),\n }),\n response: { 200: responseDataSchema(pageFlowSchema) },\n },\n }),\n getContentStats: defineRoute({\n method: 'GET',\n path: '/content-stats',\n summary: 'Content exposures per dictionary key path and locale',\n schemas: {\n response: { 200: responseDataSchema(z.array(contentStatRowSchema)) },\n },\n }),\n getExperimentResults: defineRoute({\n method: 'GET',\n path: '/experiments/:experimentKey',\n summary: 'A/B test results of an experiment',\n schemas: {\n params: z.object({ experimentKey: z.string().check(z.minLength(1)) }),\n response: { 200: responseDataSchema(experimentResultSchema) },\n },\n }),\n getAnalyticsSchema: defineRoute({\n method: 'GET',\n path: '/schema',\n summary:\n 'Report dimensions, metrics, their compatibility, retention and experiments',\n schemas: {\n response: { 200: responseDataSchema(analyticsSchemaInfoSchema) },\n },\n }),\n runAnalyticsReport: defineRoute({\n method: 'POST',\n path: '/report',\n summary:\n 'Aggregated report: metrics broken down by dimensions over date ranges',\n schemas: {\n body: analyticsReportRequestSchema,\n response: { 200: responseDataSchema(analyticsReportSchema) },\n },\n }),\n runAnalyticsRealtimeReport: defineRoute({\n method: 'POST',\n path: '/realtime-report',\n summary: 'Aggregated activity of the last minutes (up to one hour)',\n schemas: {\n body: analyticsRealtimeReportRequestSchema,\n response: { 200: responseDataSchema(analyticsReportSchema) },\n },\n }),\n getAnalyticsAnnotations: defineRoute({\n method: 'GET',\n path: '/annotations',\n summary:\n 'Dated content and traffic events (dictionary edits, repo syncs, new locales, experiments)',\n schemas: {\n querystring: analyticsAnnotationsQuerySchema,\n response: {\n 200: responseDataSchema(z.array(analyticsAnnotationSchema)),\n },\n },\n }),\n getPageMetadata: defineRoute({\n method: 'GET',\n path: '/page-metadata',\n summary: 'Title and description of a page of the project',\n schemas: {\n querystring: z.object({ url: z.optional(z.string()) }),\n response: { 200: responseDataSchema(pageMetadataSchema) },\n },\n }),\n },\n});\n\n/** Route definitions of the `/api/analytics` group, by name. */\nexport type AnalyticsRoutes = (typeof analyticsContract)['routes'];\n\nexport type AnalyticsEventType = z.output<typeof analyticsEventTypeSchema>;\nexport type IncomingAnalyticsEvent = z.output<\n typeof incomingAnalyticsEventSchema\n>;\nexport type AudienceRange = z.output<typeof audienceRangeSchema>;\nexport type AudienceGranularity = z.output<typeof audienceGranularitySchema>;\nexport type AudienceSeriesPoint = z.output<typeof audienceSeriesPointSchema>;\nexport type AudienceBreakdownRow = z.output<typeof audienceBreakdownRowSchema>;\nexport type AudienceStats = z.output<typeof audienceStatsSchema>;\nexport type LiveVisitor = z.output<typeof liveVisitorSchema>;\nexport type LiveVisitorFlowStep = z.output<typeof liveVisitorFlowStepSchema>;\nexport type LiveVisitorFlow = z.output<typeof liveVisitorFlowSchema>;\nexport type PageFlowNode = z.output<typeof pageFlowNodeSchema>;\nexport type PageFlowLink = z.output<typeof pageFlowLinkSchema>;\nexport type PageFlow = z.output<typeof pageFlowSchema>;\nexport type AnalyticsOverviewRow = z.output<typeof analyticsOverviewRowSchema>;\nexport type ContentStatRow = z.output<typeof contentStatRowSchema>;\nexport type ExperimentResult = z.output<typeof experimentResultSchema>;\nexport type PageMetadata = z.output<typeof pageMetadataSchema>;\n\nexport type IngestAnalyticsBody = RouteBodyInput<\n AnalyticsRoutes['ingestAnalyticsEvents']\n>;\nexport type IngestAnalyticsResult = ResponseData<{ accepted: number }>;\nexport type GetAnalyticsOverviewResult = ResponseData<AnalyticsOverviewRow[]>;\nexport type GetContentStatsResult = ResponseData<ContentStatRow[]>;\nexport type GetExperimentResultsResult = ResponseData<ExperimentResult>;\nexport type GetAudienceResult = ResponseData<AudienceStats>;\nexport type GetLiveVisitorFlowResult = ResponseData<LiveVisitorFlow>;\nexport type GetPageFlowResult = ResponseData<PageFlow>;\nexport type GetPageMetadataResult = ResponseData<PageMetadata>;\nexport type GetAnalyticsSchemaResult = ResponseData<AnalyticsSchemaInfo>;\nexport type RunAnalyticsReportResult = ResponseData<AnalyticsReport>;\nexport type GetAnalyticsAnnotationsResult = ResponseData<AnalyticsAnnotation[]>;\nexport type RunAnalyticsReportBody = RouteBodyInput<\n AnalyticsRoutes['runAnalyticsReport']\n>;\nexport type RunAnalyticsRealtimeReportBody = RouteBodyInput<\n AnalyticsRoutes['runAnalyticsRealtimeReport']\n>;\n"],"mappings":";;;;;;;AAsBA,MAAa,2BAA2B,EAAE,KAAK;CAC7C;CACA;CACA;AACF,CAAC;;AAGD,MAAa,+BAA+B,EAAE,YAAY;CACxD,MAAM;;CAEN,GAAG,EAAE,OAAO;CACZ,QAAQ,EAAE,OAAO;CACjB,KAAK,EAAE,OAAO;CACd,KAAK,EAAE,SAAS,EAAE,OAAO,CAAC;CAC1B,eAAe,EAAE,SAAS,EAAE,OAAO,CAAC;CACpC,SAAS,EAAE,SAAS,EAAE,OAAO,CAAC;CAC9B,UAAU,EAAE,SAAS,EAA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F,SAAS;IACP,MAAM;IACN,UAAU,EAAE,KAAK,mBAAmB,qBAAqB,EAAE;GAC7D;EACF,CAAC;EACD,4BAA4B,YAAY;GACtC,QAAQ;GACR,MAAM;GACN,SAAS;GACT,SAAS;IACP,MAAM;IACN,UAAU,EAAE,KAAK,mBAAmB,qBAAqB,EAAE;GAC7D;EACF,CAAC;EACD,yBAAyB,YAAY;GACnC,QAAQ;GACR,MAAM;GACN,SACE;GACF,SAAS;IACP,aAAa;IACb,UAAU,EACR,KAAK,mBAAmB,EAAE,MAAM,yBAAyB,CAAC,EAC5D;GACF;EACF,CAAC;EACD,iBAAiB,YAAY;GAC3B,QAAQ;GACR,MAAM;GACN,SAAS;GACT,SAAS;IACP,aAAa,EAAE,OAAO,EAAE,KAAK,EAAE,SAAS,EAAE,OAAO,CAAC,EAAE,CAAC;IACrD,UAAU,EAAE,KAAK,mBAAmB,kBAAkB,EAAE;GAC1D;EACF,CAAC;CACH;AACF,CAAC"}
|
|
@@ -0,0 +1,276 @@
|
|
|
1
|
+
import { z } from "zod/mini";
|
|
2
|
+
|
|
3
|
+
// src/analyticsReport.ts
|
|
4
|
+
/**
|
|
5
|
+
* Report dimensions. Time dimensions are labelled `YYYY-MM-DD` (`date`),
|
|
6
|
+
* `YYYY-Www` (`week`, ISO week) and `YYYY-MM` (`month`), all in UTC.
|
|
7
|
+
*/
|
|
8
|
+
const ANALYTICS_REPORT_DIMENSIONS = [
|
|
9
|
+
"date",
|
|
10
|
+
"week",
|
|
11
|
+
"month",
|
|
12
|
+
"locale",
|
|
13
|
+
"pagePath",
|
|
14
|
+
"country",
|
|
15
|
+
"dictionaryKey",
|
|
16
|
+
"keyPath",
|
|
17
|
+
"contentType",
|
|
18
|
+
"variant",
|
|
19
|
+
"experimentKey",
|
|
20
|
+
"goal"
|
|
21
|
+
];
|
|
22
|
+
const ANALYTICS_REPORT_METRICS = [
|
|
23
|
+
"pageViews",
|
|
24
|
+
"activeUsers",
|
|
25
|
+
"entrances",
|
|
26
|
+
"contentExposures",
|
|
27
|
+
"conversions",
|
|
28
|
+
"conversionValue"
|
|
29
|
+
];
|
|
30
|
+
/** Dimensions that bucket time; they cannot be used in dimension filters. */
|
|
31
|
+
const ANALYTICS_TIME_DIMENSIONS = [
|
|
32
|
+
"date",
|
|
33
|
+
"week",
|
|
34
|
+
"month"
|
|
35
|
+
];
|
|
36
|
+
const TIME_DIMENSIONS = ANALYTICS_TIME_DIMENSIONS;
|
|
37
|
+
/**
|
|
38
|
+
* Dimensions each metric can be broken down by. The data is stored
|
|
39
|
+
* pre-aggregated per event type, so a dimension a metric was not recorded with
|
|
40
|
+
* cannot be applied to it (ex: visitors are not attributed per page).
|
|
41
|
+
*/
|
|
42
|
+
const ANALYTICS_METRIC_DIMENSIONS = {
|
|
43
|
+
pageViews: [
|
|
44
|
+
...TIME_DIMENSIONS,
|
|
45
|
+
"locale",
|
|
46
|
+
"pagePath"
|
|
47
|
+
],
|
|
48
|
+
activeUsers: [
|
|
49
|
+
...TIME_DIMENSIONS,
|
|
50
|
+
"locale",
|
|
51
|
+
"country"
|
|
52
|
+
],
|
|
53
|
+
entrances: [...TIME_DIMENSIONS, "pagePath"],
|
|
54
|
+
contentExposures: [
|
|
55
|
+
...TIME_DIMENSIONS,
|
|
56
|
+
"locale",
|
|
57
|
+
"dictionaryKey",
|
|
58
|
+
"keyPath",
|
|
59
|
+
"contentType",
|
|
60
|
+
"variant",
|
|
61
|
+
"experimentKey"
|
|
62
|
+
],
|
|
63
|
+
conversions: [
|
|
64
|
+
...TIME_DIMENSIONS,
|
|
65
|
+
"locale",
|
|
66
|
+
"variant",
|
|
67
|
+
"experimentKey",
|
|
68
|
+
"goal"
|
|
69
|
+
],
|
|
70
|
+
conversionValue: [
|
|
71
|
+
...TIME_DIMENSIONS,
|
|
72
|
+
"locale",
|
|
73
|
+
"variant",
|
|
74
|
+
"experimentKey",
|
|
75
|
+
"goal"
|
|
76
|
+
]
|
|
77
|
+
};
|
|
78
|
+
const ANALYTICS_DIMENSION_DESCRIPTIONS = {
|
|
79
|
+
date: "UTC day, `YYYY-MM-DD`.",
|
|
80
|
+
week: "ISO week, `YYYY-Www` (weeks start on Monday, UTC).",
|
|
81
|
+
month: "Month, `YYYY-MM` (UTC).",
|
|
82
|
+
locale: "Locale the content was displayed in (ex: `fr`, `en-GB`).",
|
|
83
|
+
pagePath: "Page pathname, including any locale prefix (`/fr/pricing`). For `entrances`, the landing page.",
|
|
84
|
+
country: "ISO 3166-1 alpha-2 visitor country, `ZZ` when unknown.",
|
|
85
|
+
dictionaryKey: "Intlayer dictionary key of the displayed content.",
|
|
86
|
+
keyPath: "Path of the displayed field inside its dictionary.",
|
|
87
|
+
contentType: "Intlayer node type of the displayed field (translation, enumeration, markdown…).",
|
|
88
|
+
variant: "A/B variant shown.",
|
|
89
|
+
experimentKey: "A/B experiment key.",
|
|
90
|
+
goal: "Conversion goal name."
|
|
91
|
+
};
|
|
92
|
+
const ANALYTICS_METRIC_DESCRIPTIONS = {
|
|
93
|
+
pageViews: "Page views.",
|
|
94
|
+
activeUsers: "Distinct anonymous visitor sessions (not additive across rows: a visitor seen in two locales counts in both). Kept 400 days.",
|
|
95
|
+
entrances: "Sessions that started on the page (landing pages).",
|
|
96
|
+
contentExposures: "Times a content field was displayed.",
|
|
97
|
+
conversions: "Conversion events.",
|
|
98
|
+
conversionValue: "Sum of the numeric value attached to conversions."
|
|
99
|
+
};
|
|
100
|
+
const ANALYTICS_REALTIME_DIMENSIONS = [
|
|
101
|
+
"minute",
|
|
102
|
+
"pagePath",
|
|
103
|
+
"locale",
|
|
104
|
+
"country"
|
|
105
|
+
];
|
|
106
|
+
const ANALYTICS_REALTIME_METRICS = ["activeUsers", "pageViews"];
|
|
107
|
+
/** Retention of the realtime activity, in minutes. */
|
|
108
|
+
const ANALYTICS_REALTIME_MAX_MINUTES = 60;
|
|
109
|
+
/** Retention of the distinct visitor markers behind `activeUsers`, in days. */
|
|
110
|
+
const ANALYTICS_ACTIVE_USERS_RETENTION_DAYS = 400;
|
|
111
|
+
/** Default and maximum number of rows a report returns. */
|
|
112
|
+
const ANALYTICS_REPORT_DEFAULT_LIMIT = 100;
|
|
113
|
+
const ANALYTICS_REPORT_MAX_LIMIT = 1e4;
|
|
114
|
+
/** Maximum date ranges compared in one report. */
|
|
115
|
+
const ANALYTICS_REPORT_MAX_DATE_RANGES = 4;
|
|
116
|
+
/**
|
|
117
|
+
* Date of a report range: `YYYY-MM-DD`, `today`, `yesterday` or `NdaysAgo`
|
|
118
|
+
* (ex: `30daysAgo`). Days are UTC.
|
|
119
|
+
*/
|
|
120
|
+
const relativeDateSchema = z.string().check(z.regex(/^(\d{4}-\d{2}-\d{2}|today|yesterday|\d+daysAgo)$/, "Expected YYYY-MM-DD, today, yesterday or NdaysAgo"));
|
|
121
|
+
const analyticsDateRangeSchema = z.object({
|
|
122
|
+
startDate: relativeDateSchema,
|
|
123
|
+
endDate: relativeDateSchema,
|
|
124
|
+
/** Label of the range in the rows (`dateRange` column) when comparing. */
|
|
125
|
+
name: z.optional(z.string().check(z.maxLength(64)))
|
|
126
|
+
});
|
|
127
|
+
const dimensionFilterOperatorSchema = z.enum([
|
|
128
|
+
"exact",
|
|
129
|
+
"contains",
|
|
130
|
+
"beginsWith",
|
|
131
|
+
"endsWith",
|
|
132
|
+
"inList"
|
|
133
|
+
]);
|
|
134
|
+
const analyticsDimensionFilterSchema = z.object({
|
|
135
|
+
dimension: z.enum(ANALYTICS_REPORT_DIMENSIONS),
|
|
136
|
+
operator: dimensionFilterOperatorSchema,
|
|
137
|
+
/** Compared value (every operator but `inList`). */
|
|
138
|
+
value: z.optional(z.string().check(z.maxLength(512))),
|
|
139
|
+
/** Accepted values (`inList`). */
|
|
140
|
+
values: z.optional(z.array(z.string().check(z.maxLength(512))).check(z.maxLength(100))),
|
|
141
|
+
/** Defaults to `false`. */
|
|
142
|
+
caseSensitive: z.optional(z.boolean()),
|
|
143
|
+
/** Keeps the rows that do NOT match. */
|
|
144
|
+
not: z.optional(z.boolean())
|
|
145
|
+
});
|
|
146
|
+
const metricFilterOperatorSchema = z.enum([
|
|
147
|
+
"equal",
|
|
148
|
+
"greaterThan",
|
|
149
|
+
"greaterThanOrEqual",
|
|
150
|
+
"lessThan",
|
|
151
|
+
"lessThanOrEqual",
|
|
152
|
+
"between"
|
|
153
|
+
]);
|
|
154
|
+
const analyticsMetricFilterSchema = z.object({
|
|
155
|
+
metric: z.enum(ANALYTICS_REPORT_METRICS),
|
|
156
|
+
operator: metricFilterOperatorSchema,
|
|
157
|
+
value: z.number(),
|
|
158
|
+
/** Upper bound (inclusive) of `between`. */
|
|
159
|
+
toValue: z.optional(z.number())
|
|
160
|
+
});
|
|
161
|
+
const analyticsOrderBySchema = z.object({
|
|
162
|
+
/** A requested dimension or metric, or `dateRange`. */
|
|
163
|
+
field: z.string(),
|
|
164
|
+
/** Descending order. Defaults to `true` for metrics, `false` otherwise. */
|
|
165
|
+
desc: z.optional(z.boolean())
|
|
166
|
+
});
|
|
167
|
+
const analyticsReportRequestSchema = z.object({
|
|
168
|
+
dateRanges: z.array(analyticsDateRangeSchema).check(z.minLength(1), z.maxLength(4)),
|
|
169
|
+
dimensions: z._default(z.array(z.enum(ANALYTICS_REPORT_DIMENSIONS)).check(z.maxLength(4)), []),
|
|
170
|
+
metrics: z.array(z.enum(ANALYTICS_REPORT_METRICS)).check(z.minLength(1), z.maxLength(ANALYTICS_REPORT_METRICS.length)),
|
|
171
|
+
dimensionFilters: z.optional(z.array(analyticsDimensionFilterSchema).check(z.maxLength(10))),
|
|
172
|
+
metricFilters: z.optional(z.array(analyticsMetricFilterSchema).check(z.maxLength(10))),
|
|
173
|
+
orderBys: z.optional(z.array(analyticsOrderBySchema).check(z.maxLength(4))),
|
|
174
|
+
limit: z.optional(z.number().check(z.int(), z.minimum(1), z.maximum(ANALYTICS_REPORT_MAX_LIMIT))),
|
|
175
|
+
offset: z.optional(z.number().check(z.int(), z.minimum(0)))
|
|
176
|
+
});
|
|
177
|
+
const analyticsRealtimeReportRequestSchema = z.object({
|
|
178
|
+
dimensions: z._default(z.array(z.enum(ANALYTICS_REALTIME_DIMENSIONS)).check(z.maxLength(3)), []),
|
|
179
|
+
metrics: z.array(z.enum(ANALYTICS_REALTIME_METRICS)).check(z.minLength(1), z.maxLength(ANALYTICS_REALTIME_METRICS.length)),
|
|
180
|
+
/** Window, in minutes before now. Defaults to 30. */
|
|
181
|
+
minutesAgo: z.optional(z.number().check(z.int(), z.minimum(1), z.maximum(60))),
|
|
182
|
+
dimensionFilters: z.optional(z.array(z.object({
|
|
183
|
+
dimension: z.enum(ANALYTICS_REALTIME_DIMENSIONS),
|
|
184
|
+
operator: dimensionFilterOperatorSchema,
|
|
185
|
+
value: z.optional(z.string().check(z.maxLength(512))),
|
|
186
|
+
values: z.optional(z.array(z.string().check(z.maxLength(512))).check(z.maxLength(100))),
|
|
187
|
+
caseSensitive: z.optional(z.boolean()),
|
|
188
|
+
not: z.optional(z.boolean())
|
|
189
|
+
})).check(z.maxLength(10))),
|
|
190
|
+
limit: z.optional(z.number().check(z.int(), z.minimum(1), z.maximum(ANALYTICS_REPORT_MAX_LIMIT)))
|
|
191
|
+
});
|
|
192
|
+
/** A report row: dimension values (strings) and metric values (numbers). */
|
|
193
|
+
const analyticsReportRowSchema = z.record(z.string(), z.union([z.string(), z.number()]));
|
|
194
|
+
const analyticsReportSchema = z.object({
|
|
195
|
+
dimensions: z.array(z.string()),
|
|
196
|
+
metrics: z.array(z.string()),
|
|
197
|
+
/** Resolved ranges (absolute UTC days), in request order. */
|
|
198
|
+
dateRanges: z.array(z.object({
|
|
199
|
+
name: z.string(),
|
|
200
|
+
startDate: z.string(),
|
|
201
|
+
endDate: z.string()
|
|
202
|
+
})),
|
|
203
|
+
rows: z.array(analyticsReportRowSchema),
|
|
204
|
+
/** Rows matching the filters, before `offset` / `limit`. */
|
|
205
|
+
rowCount: z.number(),
|
|
206
|
+
/** Per date range totals, ignoring `metricFilters`. */
|
|
207
|
+
totals: z.array(analyticsReportRowSchema),
|
|
208
|
+
metadata: z.object({
|
|
209
|
+
timeZone: z.literal("UTC"),
|
|
210
|
+
/** First UTC day with collected data, `null` before any. */
|
|
211
|
+
dataSince: z.nullable(z.string()),
|
|
212
|
+
/** Rows were left out by `limit` / `offset`. */
|
|
213
|
+
truncated: z.boolean(),
|
|
214
|
+
/** Caveats the reader should know about (retention, sampling…). */
|
|
215
|
+
warnings: z.array(z.string())
|
|
216
|
+
})
|
|
217
|
+
});
|
|
218
|
+
const analyticsSchemaInfoSchema = z.object({
|
|
219
|
+
timeZone: z.literal("UTC"),
|
|
220
|
+
dataSince: z.nullable(z.string()),
|
|
221
|
+
/** Locales configured on the project. */
|
|
222
|
+
locales: z.array(z.string()),
|
|
223
|
+
retention: z.object({
|
|
224
|
+
activeUsersDays: z.number(),
|
|
225
|
+
realtimeMinutes: z.number()
|
|
226
|
+
}),
|
|
227
|
+
dimensions: z.array(z.object({
|
|
228
|
+
name: z.string(),
|
|
229
|
+
description: z.string()
|
|
230
|
+
})),
|
|
231
|
+
metrics: z.array(z.object({
|
|
232
|
+
name: z.string(),
|
|
233
|
+
description: z.string(),
|
|
234
|
+
compatibleDimensions: z.array(z.string())
|
|
235
|
+
})),
|
|
236
|
+
realtime: z.object({
|
|
237
|
+
dimensions: z.array(z.string()),
|
|
238
|
+
metrics: z.array(z.string())
|
|
239
|
+
}),
|
|
240
|
+
/** Experiments with collected data, with the goals converted on. */
|
|
241
|
+
experiments: z.array(z.object({
|
|
242
|
+
experimentKey: z.string(),
|
|
243
|
+
variants: z.array(z.string()),
|
|
244
|
+
goals: z.array(z.string()),
|
|
245
|
+
firstSeen: z.string()
|
|
246
|
+
}))
|
|
247
|
+
});
|
|
248
|
+
const ANALYTICS_ANNOTATION_TYPES = [
|
|
249
|
+
"dictionary_created",
|
|
250
|
+
"content_version_created",
|
|
251
|
+
"dictionary_updated",
|
|
252
|
+
"source_synced",
|
|
253
|
+
"locale_first_traffic",
|
|
254
|
+
"experiment_started"
|
|
255
|
+
];
|
|
256
|
+
const analyticsAnnotationSchema = z.object({
|
|
257
|
+
/** ISO date-time, or the UTC day for traffic-derived annotations. */
|
|
258
|
+
date: z.string(),
|
|
259
|
+
type: z.enum(ANALYTICS_ANNOTATION_TYPES),
|
|
260
|
+
title: z.string(),
|
|
261
|
+
dictionaryKey: z.optional(z.string()),
|
|
262
|
+
locale: z.optional(z.string()),
|
|
263
|
+
experimentKey: z.optional(z.string()),
|
|
264
|
+
/** Link to the commit / pull request (`source_synced`). */
|
|
265
|
+
url: z.optional(z.string())
|
|
266
|
+
});
|
|
267
|
+
const analyticsAnnotationsQuerySchema = z.object({
|
|
268
|
+
/** `YYYY-MM-DD`, `today`, `yesterday` or `NdaysAgo`. Defaults to 90daysAgo. */
|
|
269
|
+
startDate: z.optional(relativeDateSchema),
|
|
270
|
+
endDate: z.optional(relativeDateSchema),
|
|
271
|
+
types: z.optional(z.string()),
|
|
272
|
+
limit: z.optional(z.string())
|
|
273
|
+
});
|
|
274
|
+
|
|
275
|
+
export { ANALYTICS_ACTIVE_USERS_RETENTION_DAYS, ANALYTICS_ANNOTATION_TYPES, ANALYTICS_DIMENSION_DESCRIPTIONS, ANALYTICS_METRIC_DESCRIPTIONS, ANALYTICS_METRIC_DIMENSIONS, ANALYTICS_REALTIME_DIMENSIONS, ANALYTICS_REALTIME_MAX_MINUTES, ANALYTICS_REALTIME_METRICS, ANALYTICS_REPORT_DEFAULT_LIMIT, ANALYTICS_REPORT_DIMENSIONS, ANALYTICS_REPORT_MAX_DATE_RANGES, ANALYTICS_REPORT_MAX_LIMIT, ANALYTICS_REPORT_METRICS, ANALYTICS_TIME_DIMENSIONS, analyticsAnnotationSchema, analyticsAnnotationsQuerySchema, analyticsDateRangeSchema, analyticsDimensionFilterSchema, analyticsMetricFilterSchema, analyticsOrderBySchema, analyticsRealtimeReportRequestSchema, analyticsReportRequestSchema, analyticsReportRowSchema, analyticsReportSchema, analyticsSchemaInfoSchema };
|
|
276
|
+
//# sourceMappingURL=analyticsReport.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"analyticsReport.mjs","names":[],"sources":["../../src/analyticsReport.ts"],"sourcesContent":["import { z } from 'zod/mini';\n\n/**\n * Report dimensions. Time dimensions are labelled `YYYY-MM-DD` (`date`),\n * `YYYY-Www` (`week`, ISO week) and `YYYY-MM` (`month`), all in UTC.\n */\nexport const ANALYTICS_REPORT_DIMENSIONS = [\n 'date',\n 'week',\n 'month',\n 'locale',\n 'pagePath',\n 'country',\n 'dictionaryKey',\n 'keyPath',\n 'contentType',\n 'variant',\n 'experimentKey',\n 'goal',\n] as const;\n\nexport const ANALYTICS_REPORT_METRICS = [\n 'pageViews',\n 'activeUsers',\n 'entrances',\n 'contentExposures',\n 'conversions',\n 'conversionValue',\n] as const;\n\nexport type AnalyticsReportDimension =\n (typeof ANALYTICS_REPORT_DIMENSIONS)[number];\nexport type AnalyticsReportMetric = (typeof ANALYTICS_REPORT_METRICS)[number];\n\n/** Dimensions that bucket time; they cannot be used in dimension filters. */\nexport const ANALYTICS_TIME_DIMENSIONS = [\n 'date',\n 'week',\n 'month',\n] as const satisfies readonly AnalyticsReportDimension[];\n\nconst TIME_DIMENSIONS = ANALYTICS_TIME_DIMENSIONS;\n\n/**\n * Dimensions each metric can be broken down by. The data is stored\n * pre-aggregated per event type, so a dimension a metric was not recorded with\n * cannot be applied to it (ex: visitors are not attributed per page).\n */\nexport const ANALYTICS_METRIC_DIMENSIONS = {\n pageViews: [...TIME_DIMENSIONS, 'locale', 'pagePath'],\n activeUsers: [...TIME_DIMENSIONS, 'locale', 'country'],\n entrances: [...TIME_DIMENSIONS, 'pagePath'],\n contentExposures: [\n ...TIME_DIMENSIONS,\n 'locale',\n 'dictionaryKey',\n 'keyPath',\n 'contentType',\n 'variant',\n 'experimentKey',\n ],\n conversions: [\n ...TIME_DIMENSIONS,\n 'locale',\n 'variant',\n 'experimentKey',\n 'goal',\n ],\n conversionValue: [\n ...TIME_DIMENSIONS,\n 'locale',\n 'variant',\n 'experimentKey',\n 'goal',\n ],\n} as const satisfies Record<\n AnalyticsReportMetric,\n readonly AnalyticsReportDimension[]\n>;\n\nexport const ANALYTICS_DIMENSION_DESCRIPTIONS: Record<\n AnalyticsReportDimension,\n string\n> = {\n date: 'UTC day, `YYYY-MM-DD`.',\n week: 'ISO week, `YYYY-Www` (weeks start on Monday, UTC).',\n month: 'Month, `YYYY-MM` (UTC).',\n locale: 'Locale the content was displayed in (ex: `fr`, `en-GB`).',\n pagePath:\n 'Page pathname, including any locale prefix (`/fr/pricing`). For `entrances`, the landing page.',\n country: 'ISO 3166-1 alpha-2 visitor country, `ZZ` when unknown.',\n dictionaryKey: 'Intlayer dictionary key of the displayed content.',\n keyPath: 'Path of the displayed field inside its dictionary.',\n contentType:\n 'Intlayer node type of the displayed field (translation, enumeration, markdown…).',\n variant: 'A/B variant shown.',\n experimentKey: 'A/B experiment key.',\n goal: 'Conversion goal name.',\n};\n\nexport const ANALYTICS_METRIC_DESCRIPTIONS: Record<\n AnalyticsReportMetric,\n string\n> = {\n pageViews: 'Page views.',\n activeUsers:\n 'Distinct anonymous visitor sessions (not additive across rows: a visitor seen in two locales counts in both). Kept 400 days.',\n entrances: 'Sessions that started on the page (landing pages).',\n contentExposures: 'Times a content field was displayed.',\n conversions: 'Conversion events.',\n conversionValue: 'Sum of the numeric value attached to conversions.',\n};\n\nexport const ANALYTICS_REALTIME_DIMENSIONS = [\n 'minute',\n 'pagePath',\n 'locale',\n 'country',\n] as const;\n\nexport const ANALYTICS_REALTIME_METRICS = ['activeUsers', 'pageViews'] as const;\n\nexport type AnalyticsRealtimeDimension =\n (typeof ANALYTICS_REALTIME_DIMENSIONS)[number];\nexport type AnalyticsRealtimeMetric =\n (typeof ANALYTICS_REALTIME_METRICS)[number];\n\n/** Retention of the realtime activity, in minutes. */\nexport const ANALYTICS_REALTIME_MAX_MINUTES = 60;\n/** Retention of the distinct visitor markers behind `activeUsers`, in days. */\nexport const ANALYTICS_ACTIVE_USERS_RETENTION_DAYS = 400;\n/** Default and maximum number of rows a report returns. */\nexport const ANALYTICS_REPORT_DEFAULT_LIMIT = 100;\nexport const ANALYTICS_REPORT_MAX_LIMIT = 10_000;\n/** Maximum date ranges compared in one report. */\nexport const ANALYTICS_REPORT_MAX_DATE_RANGES = 4;\n\n/**\n * Date of a report range: `YYYY-MM-DD`, `today`, `yesterday` or `NdaysAgo`\n * (ex: `30daysAgo`). Days are UTC.\n */\nconst relativeDateSchema = z\n .string()\n .check(\n z.regex(\n /^(\\d{4}-\\d{2}-\\d{2}|today|yesterday|\\d+daysAgo)$/,\n 'Expected YYYY-MM-DD, today, yesterday or NdaysAgo'\n )\n );\n\nexport const analyticsDateRangeSchema = z.object({\n startDate: relativeDateSchema,\n endDate: relativeDateSchema,\n /** Label of the range in the rows (`dateRange` column) when comparing. */\n name: z.optional(z.string().check(z.maxLength(64))),\n});\n\nconst dimensionFilterOperatorSchema = z.enum([\n 'exact',\n 'contains',\n 'beginsWith',\n 'endsWith',\n 'inList',\n]);\n\nexport const analyticsDimensionFilterSchema = z.object({\n dimension: z.enum(ANALYTICS_REPORT_DIMENSIONS),\n operator: dimensionFilterOperatorSchema,\n /** Compared value (every operator but `inList`). */\n value: z.optional(z.string().check(z.maxLength(512))),\n /** Accepted values (`inList`). */\n values: z.optional(\n z.array(z.string().check(z.maxLength(512))).check(z.maxLength(100))\n ),\n /** Defaults to `false`. */\n caseSensitive: z.optional(z.boolean()),\n /** Keeps the rows that do NOT match. */\n not: z.optional(z.boolean()),\n});\n\nconst metricFilterOperatorSchema = z.enum([\n 'equal',\n 'greaterThan',\n 'greaterThanOrEqual',\n 'lessThan',\n 'lessThanOrEqual',\n 'between',\n]);\n\nexport const analyticsMetricFilterSchema = z.object({\n metric: z.enum(ANALYTICS_REPORT_METRICS),\n operator: metricFilterOperatorSchema,\n value: z.number(),\n /** Upper bound (inclusive) of `between`. */\n toValue: z.optional(z.number()),\n});\n\nexport const analyticsOrderBySchema = z.object({\n /** A requested dimension or metric, or `dateRange`. */\n field: z.string(),\n /** Descending order. Defaults to `true` for metrics, `false` otherwise. */\n desc: z.optional(z.boolean()),\n});\n\nexport const analyticsReportRequestSchema = z.object({\n dateRanges: z\n .array(analyticsDateRangeSchema)\n .check(z.minLength(1), z.maxLength(ANALYTICS_REPORT_MAX_DATE_RANGES)),\n dimensions: z._default(\n z.array(z.enum(ANALYTICS_REPORT_DIMENSIONS)).check(z.maxLength(4)),\n []\n ),\n metrics: z\n .array(z.enum(ANALYTICS_REPORT_METRICS))\n .check(z.minLength(1), z.maxLength(ANALYTICS_REPORT_METRICS.length)),\n dimensionFilters: z.optional(\n z.array(analyticsDimensionFilterSchema).check(z.maxLength(10))\n ),\n metricFilters: z.optional(\n z.array(analyticsMetricFilterSchema).check(z.maxLength(10))\n ),\n orderBys: z.optional(z.array(analyticsOrderBySchema).check(z.maxLength(4))),\n limit: z.optional(\n z\n .number()\n .check(z.int(), z.minimum(1), z.maximum(ANALYTICS_REPORT_MAX_LIMIT))\n ),\n offset: z.optional(z.number().check(z.int(), z.minimum(0))),\n});\n\nexport const analyticsRealtimeReportRequestSchema = z.object({\n dimensions: z._default(\n z.array(z.enum(ANALYTICS_REALTIME_DIMENSIONS)).check(z.maxLength(3)),\n []\n ),\n metrics: z\n .array(z.enum(ANALYTICS_REALTIME_METRICS))\n .check(z.minLength(1), z.maxLength(ANALYTICS_REALTIME_METRICS.length)),\n /** Window, in minutes before now. Defaults to 30. */\n minutesAgo: z.optional(\n z\n .number()\n .check(z.int(), z.minimum(1), z.maximum(ANALYTICS_REALTIME_MAX_MINUTES))\n ),\n dimensionFilters: z.optional(\n z\n .array(\n z.object({\n dimension: z.enum(ANALYTICS_REALTIME_DIMENSIONS),\n operator: dimensionFilterOperatorSchema,\n value: z.optional(z.string().check(z.maxLength(512))),\n values: z.optional(\n z.array(z.string().check(z.maxLength(512))).check(z.maxLength(100))\n ),\n caseSensitive: z.optional(z.boolean()),\n not: z.optional(z.boolean()),\n })\n )\n .check(z.maxLength(10))\n ),\n limit: z.optional(\n z\n .number()\n .check(z.int(), z.minimum(1), z.maximum(ANALYTICS_REPORT_MAX_LIMIT))\n ),\n});\n\n/** A report row: dimension values (strings) and metric values (numbers). */\nexport const analyticsReportRowSchema = z.record(\n z.string(),\n z.union([z.string(), z.number()])\n);\n\nexport const analyticsReportSchema = z.object({\n dimensions: z.array(z.string()),\n metrics: z.array(z.string()),\n /** Resolved ranges (absolute UTC days), in request order. */\n dateRanges: z.array(\n z.object({ name: z.string(), startDate: z.string(), endDate: z.string() })\n ),\n rows: z.array(analyticsReportRowSchema),\n /** Rows matching the filters, before `offset` / `limit`. */\n rowCount: z.number(),\n /** Per date range totals, ignoring `metricFilters`. */\n totals: z.array(analyticsReportRowSchema),\n metadata: z.object({\n timeZone: z.literal('UTC'),\n /** First UTC day with collected data, `null` before any. */\n dataSince: z.nullable(z.string()),\n /** Rows were left out by `limit` / `offset`. */\n truncated: z.boolean(),\n /** Caveats the reader should know about (retention, sampling…). */\n warnings: z.array(z.string()),\n }),\n});\n\nexport const analyticsSchemaInfoSchema = z.object({\n timeZone: z.literal('UTC'),\n dataSince: z.nullable(z.string()),\n /** Locales configured on the project. */\n locales: z.array(z.string()),\n retention: z.object({\n activeUsersDays: z.number(),\n realtimeMinutes: z.number(),\n }),\n dimensions: z.array(z.object({ name: z.string(), description: z.string() })),\n metrics: z.array(\n z.object({\n name: z.string(),\n description: z.string(),\n compatibleDimensions: z.array(z.string()),\n })\n ),\n realtime: z.object({\n dimensions: z.array(z.string()),\n metrics: z.array(z.string()),\n }),\n /** Experiments with collected data, with the goals converted on. */\n experiments: z.array(\n z.object({\n experimentKey: z.string(),\n variants: z.array(z.string()),\n goals: z.array(z.string()),\n firstSeen: z.string(),\n })\n ),\n});\n\nexport const ANALYTICS_ANNOTATION_TYPES = [\n 'dictionary_created',\n 'content_version_created',\n 'dictionary_updated',\n 'source_synced',\n 'locale_first_traffic',\n 'experiment_started',\n] as const;\n\nexport const analyticsAnnotationSchema = z.object({\n /** ISO date-time, or the UTC day for traffic-derived annotations. */\n date: z.string(),\n type: z.enum(ANALYTICS_ANNOTATION_TYPES),\n title: z.string(),\n dictionaryKey: z.optional(z.string()),\n locale: z.optional(z.string()),\n experimentKey: z.optional(z.string()),\n /** Link to the commit / pull request (`source_synced`). */\n url: z.optional(z.string()),\n});\n\nexport const analyticsAnnotationsQuerySchema = z.object({\n /** `YYYY-MM-DD`, `today`, `yesterday` or `NdaysAgo`. Defaults to 90daysAgo. */\n startDate: z.optional(relativeDateSchema),\n endDate: z.optional(relativeDateSchema),\n types: z.optional(z.string()),\n limit: z.optional(z.string()),\n});\n\nexport type AnalyticsDateRange = z.output<typeof analyticsDateRangeSchema>;\nexport type AnalyticsDimensionFilter = z.output<\n typeof analyticsDimensionFilterSchema\n>;\nexport type AnalyticsMetricFilter = z.output<\n typeof analyticsMetricFilterSchema\n>;\nexport type AnalyticsOrderBy = z.output<typeof analyticsOrderBySchema>;\nexport type AnalyticsReportRequest = z.input<\n typeof analyticsReportRequestSchema\n>;\nexport type AnalyticsRealtimeReportRequest = z.input<\n typeof analyticsRealtimeReportRequestSchema\n>;\nexport type AnalyticsReportRow = z.output<typeof analyticsReportRowSchema>;\nexport type AnalyticsReport = z.output<typeof analyticsReportSchema>;\nexport type AnalyticsSchemaInfo = z.output<typeof analyticsSchemaInfoSchema>;\nexport type AnalyticsAnnotationType =\n (typeof ANALYTICS_ANNOTATION_TYPES)[number];\nexport type AnalyticsAnnotation = z.output<typeof analyticsAnnotationSchema>;\nexport type AnalyticsAnnotationsQuery = z.output<\n typeof analyticsAnnotationsQuerySchema\n>;\n"],"mappings":";;;;;;;AAMA,MAAa,8BAA8B;CACzC;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;AACF;AAEA,MAAa,2BAA2B;CACtC;CACA;CACA;CACA;CACA;CACA;AACF;;AAOA,MAAa,4BAA4B;CACvC;CACA;CACA;AACF;AAEA,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