Skip to content

Commit e8ce2c4

Browse files
authored
Merge pull request #388 from convertcom/main-convert
Main convert
2 parents dc6a9cb + 4354f91 commit e8ce2c4

2 files changed

Lines changed: 29 additions & 48 deletions

File tree

packages/types/src/config/types.gen.ts

Lines changed: 9 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -31,44 +31,6 @@ export enum ConfigAudienceTypes {
3131
TRANSIENT = 'transient'
3232
}
3333

34-
/**
35-
* Account billing status
36-
*/
37-
export type PlanStatus = 'paid' | 'trial' | 'trialExpired' | 'canceled' | 'paused';
38-
39-
/**
40-
* Account billing status
41-
*/
42-
export const PlanStatus = {
43-
PAID: 'paid',
44-
TRIAL: 'trial',
45-
TRIAL_EXPIRED: 'trialExpired',
46-
CANCELED: 'canceled',
47-
PAUSED: 'paused'
48-
} as const;
49-
50-
/**
51-
* The Convert product line this billing plan pertains to.
52-
* - `experiences`: Relates to A/B testing, MVT, Split URL, and personalization features.
53-
* - `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."
54-
* - `addons`: Relates to add-on products that extend the core platform capabilities.
55-
*
56-
*/
57-
export type Products = 'experiences' | 'deploy' | 'addons';
58-
59-
/**
60-
* The Convert product line this billing plan pertains to.
61-
* - `experiences`: Relates to A/B testing, MVT, Split URL, and personalization features.
62-
* - `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."
63-
* - `addons`: Relates to add-on products that extend the core platform capabilities.
64-
*
65-
*/
66-
export const Products = {
67-
EXPERIENCES: 'experiences',
68-
DEPLOY: 'deploy',
69-
ADDONS: 'addons'
70-
} as const;
71-
7234
export type PageNumber = {
7335
/**
7436
* The page number for paginated results. For example, if `results_per_page` is 30, `page: 2` will retrieve items 31-60.
@@ -1916,14 +1878,14 @@ export type ConfigGoalBase = {
19161878
/**
19171879
* List of goal types to be returned
19181880
*/
1919-
type?: Array<GoalTypes>;
1881+
type?: GoalTypes;
19201882
rules?: ((RuleObject) | null);
19211883
};
19221884

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

19251887
export type DomInteractionGoal = ConfigGoalBase & {
1926-
type?: 'dom_interaction';
1888+
type?: GoalTypes.DOM_INTERACTION;
19271889
settings?: DomInteractionGoalSettings;
19281890
};
19291891

@@ -1932,7 +1894,7 @@ export enum type11 {
19321894
}
19331895

19341896
export type ScrollPercentageGoal = ConfigGoalBase & {
1935-
type?: 'scroll_percentage';
1897+
type?: GoalTypes.SCROLL_PERCENTAGE;
19361898
settings?: ScrollPercentageGoalSettings;
19371899
};
19381900

@@ -1941,7 +1903,7 @@ export enum type12 {
19411903
}
19421904

19431905
export type RevenueGoal = ConfigGoalBase & {
1944-
type?: 'revenue';
1906+
type?: GoalTypes.REVENUE;
19451907
settings?: RevenueGoalSettings;
19461908
};
19471909

@@ -1950,7 +1912,7 @@ export enum type13 {
19501912
}
19511913

19521914
export type NoSettingsGoal = ConfigGoalBase & {
1953-
type?: 'advanced' | 'visits_page' | 'code_trigger';
1915+
type?: GoalTypes.ADVANCED | 'visits_page' | GoalTypes.CODE_TRIGGER;
19541916
};
19551917

19561918
export enum type14 {
@@ -2115,15 +2077,15 @@ export type LocationTriggerBase = {
21152077
};
21162078

21172079
export type LocationTriggerUponRun = LocationTriggerBase & {
2118-
type?: 'upon_run';
2080+
type?: LocationTriggerTypes.UPON_RUN;
21192081
};
21202082

21212083
export enum type19 {
21222084
UPON_RUN = 'upon_run'
21232085
}
21242086

21252087
export type LocationTriggerManual = LocationTriggerBase & {
2126-
type?: 'manual';
2088+
type?: LocationTriggerTypes.MANUAL;
21272089
};
21282090

21292091
export enum type20 {
@@ -2146,7 +2108,7 @@ export enum LocationDomTriggerEvents {
21462108
}
21472109

21482110
export type LocationTriggerDomElement = LocationTriggerBase & {
2149-
type?: 'dom_element';
2111+
type?: LocationTriggerTypes.DOM_ELEMENT;
21502112
/**
21512113
* Describes html selector
21522114
*/
@@ -2162,7 +2124,7 @@ export enum type21 {
21622124
}
21632125

21642126
export type LocationTriggerCallback = LocationTriggerBase & {
2165-
type?: 'callback';
2127+
type?: LocationTriggerTypes.CALLBACK;
21662128
/**
21672129
* Describes the js callback that will be executed in order to fire the experience.
21682130
*

packages/utils/src/http-client.ts

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,12 @@ import {ERROR_MESSAGES, MESSAGES} from '@convertcom/js-sdk-enums';
99
import type {RequestOptions} from 'https';
1010
import {objectNotEmpty} from './object-utils';
1111

12+
/**
13+
* Server-side User-Agent advertised by the SDK so the metrics-endpoint
14+
* bot filter recognises Convert traffic via its `isConvertAgentUA` bypass.
15+
*/
16+
const CONVERT_AGENT_USER_AGENT = 'ConvertAgent/1.0';
17+
1218
export type HttpMethod =
1319
| 'GET'
1420
| 'DELETE'
@@ -204,6 +210,16 @@ export const HttpClient = {
204210
keepalive: true // to allow the request to complete even if the page unloads
205211
};
206212
if (config?.headers) options.headers = config.headers;
213+
// Always announce as Convert SDK traffic on server-side so the
214+
// metrics-endpoint bot filter recognises us via its
215+
// `isConvertAgentUA` bypass. Skip in browser — browsers strip
216+
// User-Agent per the W3C forbidden-header list, and a browser's
217+
// natural UA does not trigger isbot.
218+
if (runtimeResult.runtime !== 'browser') {
219+
if (!options.headers) options.headers = {};
220+
(options.headers as Record<string, string>)['User-Agent'] =
221+
CONVERT_AGENT_USER_AGENT;
222+
}
207223
if (config?.data && supportsRequestBody(method)) {
208224
options.body = JSON.stringify(config.data);
209225
}
@@ -317,8 +333,11 @@ export const HttpClient = {
317333
? JSON.stringify(config.data)
318334
: null;
319335
if (config?.headers) options.headers = config.headers;
336+
// See note in the fetch branch above. old-nodejs is always
337+
// server-side, so the UA announcement always applies.
338+
if (!options.headers) options.headers = {};
339+
options.headers['User-Agent'] = CONVERT_AGENT_USER_AGENT;
320340
if (postData) {
321-
if (!options.headers) options.headers = {};
322341
options.headers['Content-Length'] = Buffer.byteLength(postData);
323342
}
324343
const req = client.request(options, (res) => {

0 commit comments

Comments
 (0)