Skip to content

Update Serving API - from backend PR #5294 - #315

Merged
abbaseya merged 1 commit into
main-convertfrom
api-serving-update-5294
Oct 30, 2025
Merged

Update Serving API - from backend PR #5294#315
abbaseya merged 1 commit into
main-convertfrom
api-serving-update-5294

Conversation

@clllaur

@clllaur clllaur commented Jul 11, 2025

Copy link
Copy Markdown
Contributor

Updating TS Serving API after the latest changes from backend repo,
PR #5294

@clllaur
clllaur requested a review from a team July 11, 2025 22:59

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Summary of Changes

Hello @clllaur, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request updates the TypeScript API definitions, specifically within packages/types/src/config/types.gen.ts, to synchronize with recent changes in the backend. The primary focus is on expanding the API's capabilities related to audience targeting and visitor data retrieval, alongside some general type clean-up and documentation improvements.

Highlights

  • New Rule Types for Audience Targeting: Introduced VisitorIdMatchRule and GroupIdMatchRule types, along with their corresponding rule_type constants. These new rules are integrated into RuleElementNoUrl and a newly added RuleElementAudience type, enabling more granular audience targeting based on visitor and group identifiers.
  • Structured Audience Rule Definitions: Added the RuleObjectAudience type, which provides a structured way to define complex logical rules for audience matching, leveraging the new RuleElementAudience type for its elements.
  • New Type for Uploaded File Data: Introduced the UploadedFileData type to represent uploaded file objects. This type includes properties for the file's storage key, original name, and a read-only URL for access.
  • Clarification on Global JavaScript Behavior: Updated the JSDoc comment for the global_javascript property within ConfigProject to clarify its behavior. It now explicitly states that this code will be combined with environment-specific global JavaScript by appending it with a newline character when an environment is specified in the request.
  • API Endpoints for Visitor Data Retrieval: Implemented new API endpoints (/visitor-data/{account_id}/{project_id} and /visitor-data/{sdk_key}) to allow for the retrieval of visitor-specific data. Corresponding request types (GetVisitorDataData, GetVisitorDataBySdkKeyData) and a shared response type (VisitorDataResponseData) have also been added.
  • Project Configuration Type Refinement: Removed the environments property from the ConfigProject type, streamlining the project configuration definition.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point in your pull request via creating an issue comment (i.e. comment on the pull request page) using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in issue comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist is currently in preview and may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments to provide feedback.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

The pull request updates the TypeScript Serving API types, introducing new rules, data structures, and API endpoints. There are areas for improvement regarding naming conventions, code duplication, and documentation clarity, which could impact the long-term maintainability and usability of the SDK types. I've provided specific suggestions to address these points.

Comment thread packages/types/src/config/types.gen.ts Outdated
Comment on lines +679 to +696
export type rule_type = 'visitor_id';

export const rule_type = {
VISITOR_ID: 'visitor_id'
} as const;

export type GroupIdMatchRule = BaseRuleWithStringValue & {
rule_type: 'group_id';
matching?: (BaseMatch & {
match_type?: TextMatchingOptions;
});
};

export type rule_type2 = 'group_id';

export const rule_type2 = {
GROUP_ID: 'group_id'
} as const;

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

high

The names rule_type and rule_type2 are not descriptive and could lead to confusion. rule_type2 in particular is a poor name that suggests it's a temporary or automatically generated name, which harms code clarity and maintainability. Additionally, exporting a type and a constant with the same name (rule_type) is valid in TypeScript but can be confusing. Refactor these to use more descriptive and distinct names.

export type VisitorIdRuleType = 'visitor_id';

export const VisitorIdRule = {
    VISITOR_ID: 'visitor_id'
} as const;

export type GroupIdRuleType = 'group_id';

export const GroupIdRule = {
    GROUP_ID: 'group_id'
} as const;

Comment thread packages/types/src/config/types.gen.ts Outdated

export type RuleElement = GenericTextMatchRule | GenericNumericMatchRule | GenericBoolMatchRule | GenericTextKeyValueMatchRule | GenericNumericKeyValueMatchRule | GenericBoolKeyValueMatchRule | CookieMatchRule | CountryMatchRule | LanguageMatchRule | GoalTriggeredMatchRule | SegmentBucketedMatchRule | DayOfWeekMatchRule | HourOfDayMatchRule | MinuteOfHourMatchRule | BrowserNameMatchRule | OsMatchRule | WeatherConditionMatchRule | VisitorTypeMatchRule | JsConditionMatchRule;

export type RuleElementAudience = GenericTextMatchRule | GenericNumericMatchRule | GenericBoolMatchRule | GenericTextKeyValueMatchRule | GenericNumericKeyValueMatchRule | GenericBoolKeyValueMatchRule | CookieMatchRule | CountryMatchRule | LanguageMatchRule | GoalTriggeredMatchRule | SegmentBucketedMatchRule | DayOfWeekMatchRule | HourOfDayMatchRule | MinuteOfHourMatchRule | BrowserNameMatchRule | OsMatchRule | WeatherConditionMatchRule | VisitorTypeMatchRule | JsConditionMatchRule | VisitorIdMatchRule | GroupIdMatchRule;

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The type RuleElementAudience is identical to RuleElementNoUrl defined on line 698. To avoid code duplication and improve maintainability, define RuleElementAudience as a type alias for RuleElementNoUrl.

export type RuleElementAudience = RuleElementNoUrl;

Comment on lines +780 to +798
/**
* This one describes a logical rule that is being used inside the app for triggering goals, matching audiences etc
*/
export type RuleObjectAudience = {
/**
* This describes an outer set of blocks which are evaluated using OR's between them
*/
OR?: Array<{
/**
* This describes a colections of logical blocks which are evaluated using AND's between them
*/
AND?: Array<{
/**
* This describes a colections of logical blocks which are evaluated using OR's between them
*/
OR_WHEN?: Array<RuleElementAudience>;
}>;
}>;
} | null;

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

This type RuleObjectAudience is structurally identical to RuleObjectNoUrl. Assuming RuleElementAudience is aliased to RuleElementNoUrl as suggested in another comment, this type also becomes a duplicate and can be simplified to an alias. The JSDoc comment "This one describes..." is a bit informal. Rephrase it to be more direct, for example: "Describes a logical rule...".

/**
 * Describes a logical rule that is being used inside the app for triggering goals, matching audiences etc
 */
export type RuleObjectAudience = RuleObjectNoUrl;

Comment on lines +1028 to +1030
/**
* File Object
*/

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The JSDoc comment "File Object" is not very descriptive. Expand it to explain what this object represents for better clarity.

/**
 * Represents data for a file that has been uploaded.
 */

Comment thread packages/types/src/config/types.gen.ts Outdated
/**
* Select specific fields to be returned
*/
fields?: Array<(string)>;

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

For defining an array of strings, the string[] syntax is more idiomatic and concise in TypeScript than Array<(string)>. Use it here for better readability.

    fields?: string[];

Comment thread packages/types/src/config/types.gen.ts Outdated
/**
* Select specific fields to be returned
*/
fields?: Array<(string)>;

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

For defining an array of strings, the string[] syntax is more idiomatic and concise in TypeScript than Array<(string)>.

    fields?: string[];

Comment on lines +2956 to +2959
/**
* Object consumed by SDKs
*
*/

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The JSDoc comment "Object consumed by SDKs" is a bit generic. Make it more specific to the response for better documentation.

                /**
                 * Successful response containing the visitor data.
                 */

Comment on lines +2972 to +2975
/**
* Object consumed by SDKs
*
*/

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The JSDoc comment "Object consumed by SDKs" is a bit generic. Make it more specific to the response for better documentation.

                /**
                 * Successful response containing the visitor data.
                 */

@clllaur
clllaur force-pushed the api-serving-update-5294 branch 2 times, most recently from 412c2b2 to 831216e Compare July 16, 2025 11:29
@clllaur
clllaur force-pushed the api-serving-update-5294 branch 4 times, most recently from 6bcba8b to ec63810 Compare July 28, 2025 22:00
@clllaur
clllaur force-pushed the api-serving-update-5294 branch 7 times, most recently from ac2f7c8 to c64384e Compare August 5, 2025 12:21
@clllaur
clllaur force-pushed the api-serving-update-5294 branch from c64384e to 7791d1d Compare August 20, 2025 01:01
@clllaur
clllaur force-pushed the api-serving-update-5294 branch from 7791d1d to 2901299 Compare September 5, 2025 16:11
@clllaur
clllaur force-pushed the api-serving-update-5294 branch 2 times, most recently from 8aca3d2 to 0f1d8ea Compare September 16, 2025 20:22
@abbaseya abbaseya closed this Sep 26, 2025
@abbaseya abbaseya reopened this Sep 26, 2025
@clllaur
clllaur force-pushed the api-serving-update-5294 branch from 0f1d8ea to c363a57 Compare September 26, 2025 15:38
@sonarqubecloud

Copy link
Copy Markdown

@abbaseya
abbaseya merged commit 93e4347 into main-convert Oct 30, 2025
5 checks passed
@abbaseya
abbaseya deleted the api-serving-update-5294 branch October 30, 2025 11:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants