Skip to content
56 changes: 9 additions & 47 deletions packages/types/src/config/types.gen.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,44 +31,6 @@ export enum ConfigAudienceTypes {
TRANSIENT = 'transient'
}

/**
* Account billing status
*/
export type PlanStatus = 'paid' | 'trial' | 'trialExpired' | 'canceled' | 'paused';

/**
* Account billing status
*/
export const PlanStatus = {
PAID: 'paid',
TRIAL: 'trial',
TRIAL_EXPIRED: 'trialExpired',
CANCELED: 'canceled',
PAUSED: 'paused'
} as const;

/**
* The Convert product line this billing plan pertains to.
* - `experiences`: Relates to A/B testing, MVT, Split URL, and personalization features.
* - `deploy`: Relates to the "Deploy" feature for rolling out changes to specific audiences without A/B testing reports. Knowledge Base: "Deployments have the potential to contain small segments...and this could be interpreted by Privacy Authorities in Europe as identification of data subjects."
* - `addons`: Relates to add-on products that extend the core platform capabilities.
*
*/
export type Products = 'experiences' | 'deploy' | 'addons';

/**
* The Convert product line this billing plan pertains to.
* - `experiences`: Relates to A/B testing, MVT, Split URL, and personalization features.
* - `deploy`: Relates to the "Deploy" feature for rolling out changes to specific audiences without A/B testing reports. Knowledge Base: "Deployments have the potential to contain small segments...and this could be interpreted by Privacy Authorities in Europe as identification of data subjects."
* - `addons`: Relates to add-on products that extend the core platform capabilities.
*
*/
export const Products = {
EXPERIENCES: 'experiences',
DEPLOY: 'deploy',
ADDONS: 'addons'
} as const;

export type PageNumber = {
/**
* The page number for paginated results. For example, if `results_per_page` is 30, `page: 2` will retrieve items 31-60.
Expand Down Expand Up @@ -1916,14 +1878,14 @@ export type ConfigGoalBase = {
/**
* List of goal types to be returned
Comment thread
JosephSamirL marked this conversation as resolved.
*/
type?: Array<GoalTypes>;
type?: GoalTypes;
Comment thread
JosephSamirL marked this conversation as resolved.
rules?: ((RuleObject) | null);
};

export type ConfigGoal = DomInteractionGoal | ScrollPercentageGoal | RevenueGoal | NoSettingsGoal | GaGoal | SubmitsFormGoal | ClicksLinkGoal | ClicksElementGoal;

export type DomInteractionGoal = ConfigGoalBase & {
type?: 'dom_interaction';
type?: GoalTypes.DOM_INTERACTION;
settings?: DomInteractionGoalSettings;
};

Expand All @@ -1932,7 +1894,7 @@ export enum type11 {
}

export type ScrollPercentageGoal = ConfigGoalBase & {
type?: 'scroll_percentage';
type?: GoalTypes.SCROLL_PERCENTAGE;
settings?: ScrollPercentageGoalSettings;
};

Expand All @@ -1941,7 +1903,7 @@ export enum type12 {
}

export type RevenueGoal = ConfigGoalBase & {
type?: 'revenue';
type?: GoalTypes.REVENUE;
settings?: RevenueGoalSettings;
};

Expand All @@ -1950,7 +1912,7 @@ export enum type13 {
}

export type NoSettingsGoal = ConfigGoalBase & {
type?: 'advanced' | 'visits_page' | 'code_trigger';
type?: GoalTypes.ADVANCED | 'visits_page' | GoalTypes.CODE_TRIGGER;
Comment thread
JosephSamirL marked this conversation as resolved.
};

export enum type14 {
Expand Down Expand Up @@ -2115,15 +2077,15 @@ export type LocationTriggerBase = {
};

export type LocationTriggerUponRun = LocationTriggerBase & {
type?: 'upon_run';
type?: LocationTriggerTypes.UPON_RUN;
};

export enum type19 {
UPON_RUN = 'upon_run'
}

export type LocationTriggerManual = LocationTriggerBase & {
type?: 'manual';
type?: LocationTriggerTypes.MANUAL;
};

export enum type20 {
Expand All @@ -2146,7 +2108,7 @@ export enum LocationDomTriggerEvents {
}

export type LocationTriggerDomElement = LocationTriggerBase & {
type?: 'dom_element';
type?: LocationTriggerTypes.DOM_ELEMENT;
/**
* Describes html selector
*/
Expand All @@ -2162,7 +2124,7 @@ export enum type21 {
}

export type LocationTriggerCallback = LocationTriggerBase & {
type?: 'callback';
type?: LocationTriggerTypes.CALLBACK;
/**
* Describes the js callback that will be executed in order to fire the experience.
*
Expand Down
21 changes: 20 additions & 1 deletion packages/utils/src/http-client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,12 @@ import {ERROR_MESSAGES, MESSAGES} from '@convertcom/js-sdk-enums';
import type {RequestOptions} from 'https';
import {objectNotEmpty} from './object-utils';

/**
* Server-side User-Agent advertised by the SDK so the metrics-endpoint
* bot filter recognises Convert traffic via its `isConvertAgentUA` bypass.
*/
const CONVERT_AGENT_USER_AGENT = 'ConvertAgent/1.0';

export type HttpMethod =
| 'GET'
| 'DELETE'
Expand Down Expand Up @@ -204,6 +210,16 @@ export const HttpClient = {
keepalive: true // to allow the request to complete even if the page unloads
};
if (config?.headers) options.headers = config.headers;
Comment thread
JosephSamirL marked this conversation as resolved.
// Always announce as Convert SDK traffic on server-side so the
// metrics-endpoint bot filter recognises us via its
// `isConvertAgentUA` bypass. Skip in browser — browsers strip
// User-Agent per the W3C forbidden-header list, and a browser's
// natural UA does not trigger isbot.
if (runtimeResult.runtime !== 'browser') {
if (!options.headers) options.headers = {};
(options.headers as Record<string, string>)['User-Agent'] =
CONVERT_AGENT_USER_AGENT;
}
if (config?.data && supportsRequestBody(method)) {
options.body = JSON.stringify(config.data);
}
Expand Down Expand Up @@ -317,8 +333,11 @@ export const HttpClient = {
? JSON.stringify(config.data)
: null;
if (config?.headers) options.headers = config.headers;
Comment thread
JosephSamirL marked this conversation as resolved.
// See note in the fetch branch above. old-nodejs is always
// server-side, so the UA announcement always applies.
if (!options.headers) options.headers = {};
options.headers['User-Agent'] = CONVERT_AGENT_USER_AGENT;
if (postData) {
if (!options.headers) options.headers = {};
options.headers['Content-Length'] = Buffer.byteLength(postData);
}
const req = client.request(options, (res) => {
Expand Down
Loading