Skip to content

[NO-REF] - update PIA module with API and A/B test parameters - #484

Open
vladconstructor wants to merge 4 commits into
Constructor-io:masterfrom
vladconstructor:NO-REF/update-pia-module-with-arbitrary-parameters
Open

[NO-REF] - update PIA module with API and A/B test parameters#484
vladconstructor wants to merge 4 commits into
Constructor-io:masterfrom
vladconstructor:NO-REF/update-pia-module-with-arbitrary-parameters

Conversation

@vladconstructor

Copy link
Copy Markdown
Contributor

No description provided.

@vladconstructor
vladconstructor requested a review from a team as a code owner August 20, 2026 14:11
Copilot AI lite review requested due to automatic review settings August 20, 2026 14:11

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

This PR updates the Product Insights Agent (PIA) client to support additional request/query parameters used for experiments and response formatting, and aligns the public TypeScript types and module tests with the new capabilities.

Changes:

  • Add support in PIA URL construction for testCells (as ef-* query params) and additional request parameters: features, feature_variants, pre_filter_expression, guard, and fmt_options.
  • Extend pia.d.ts parameter types via a shared PiaBaseParameters and add typing for preFilterExpression and fmtOptions.
  • Add/extend PIA module specs to cover newly supported parameters.

Reviewed changes

Copilot reviewed 2 out of 3 changed files in this pull request and generated 3 comments.

File Description
src/types/pia.d.ts Extends PIA parameter typings (base params + new fields like preFilterExpression / fmtOptions).
src/modules/pia.js Adds query param wiring for experiments (testCells) and new PIA request parameters.
spec/src/modules/pia.js Adds tests for the new query parameter behaviors (needs stronger assertions/coverage).
Suppressed comments (1)

spec/src/modules/pia.js:332

  • For parity with other tests in this file, the new features test should assert the parsed value (not just the key), and fmtOptions behavior is currently untested despite being added to the request builder.
    it('Should pass features as query parameters when provided', function () {
      this.timeout(10000);
      const features = { pia_v2: true };
      const { agent: { pia } } = new ConstructorIO({
        apiKey: piaApiKey,

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread spec/src/modules/pia.js Outdated
return pia.getSuggestedQuestions(validItemId, { featureVariants }).then(() => {
const requestedUrlParams = helpers.extractUrlParamsFromFetch(fetchSpy);

expect(requestedUrlParams).to.have.property('feature_variants');
Comment thread spec/src/modules/pia.js
Comment on lines +176 to +189
it('Should pass pre_filter_expression as a query parameter when provided', () => {
const preFilterExpression = { brand: 'apple' };
const { agent: { pia } } = new ConstructorIO({
apiKey: piaApiKey,
fetch: fetchSpy,
});

return pia.getSuggestedQuestions(validItemId, { preFilterExpression }).then(() => {
const requestedUrlParams = helpers.extractUrlParamsFromFetch(fetchSpy);

expect(requestedUrlParams).to.have.property('pre_filter_expression');
});
});

Comment thread spec/src/modules/pia.js Outdated
return pia.getSuggestedQuestions(validItemId, { features }).then(() => {
const requestedUrlParams = helpers.extractUrlParamsFromFetch(fetchSpy);

expect(requestedUrlParams).to.have.property('features');
@vladconstructor vladconstructor changed the title [NO-REF] - update PIA module with test parameters [NO-REF] - update PIA module with API and A/B test parameters Aug 21, 2026
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