Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion packages/pieces/community/common/package.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"name": "@activepieces/pieces-common",
"version": "0.11.1",
"version": "0.11.2",
"type": "commonjs"
}
7 changes: 7 additions & 0 deletions packages/pieces/community/common/src/lib/helpers/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -273,6 +273,11 @@ i.e ${getBaseUrlForDescription(baseUrl, auth)}/resource or /resource`,
required: false,
...(props?.timeout ?? {}),
}),
followRedirects: Property.Checkbox({
displayName: 'Follow redirects',
required: false,
defaultValue: true,
}),
...extraProps,
},

Expand All @@ -287,6 +292,7 @@ i.e ${getBaseUrlForDescription(baseUrl, auth)}/resource or /resource`,
failsafe,
timeout,
response_is_binary,
followRedirects,
} = context.propsValue;
assertNotNullOrUndefined(method, 'Method');
assertNotNullOrUndefined(url, 'URL');
Expand Down Expand Up @@ -317,6 +323,7 @@ i.e ${getBaseUrlForDescription(baseUrl, auth)}/resource or /resource`,
...((queryParams as QueryParams) ?? {}),
},
timeout: timeout ? timeout * 1000 : 0,
followRedirects,
};

// Set response type to arraybuffer if binary response is expected
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,12 @@ export class AxiosHttpClient extends BaseHttpClient {
try {
const axiosInstance = axiosClient || axios;
process.env['NODE_TLS_REJECT_UNAUTHORIZED'] = '0';
const { urlWithoutQueryParams, queryParams: urlQueryParams } = this.getUrl(request);
const { urlWithoutQueryParams, queryParams: urlQueryParams } =
this.getUrl(request);
const headers = this.getHeaders(request);
const axiosRequestMethod = this.getAxiosRequestMethod(request.method);
const timeout = request.timeout ? request.timeout : 0;
const queryParams = request.queryParams || {}
const queryParams = request.queryParams || {};
const responseType = request.responseType || 'json';

for (const [key, value] of Object.entries(queryParams)) {
Expand All @@ -44,14 +45,22 @@ export class AxiosHttpClient extends BaseHttpClient {
data: request.body,
timeout,
responseType,
maxRedirects: (request.followRedirects ?? true) ? undefined : 0,
validateStatus: !(request.followRedirects ?? true)
? (status) => status >= 200 && status < 400
: undefined,
};

if (request.retries && request.retries > 0) {
axiosRetry(axiosInstance, {
retries: request.retries,
retryDelay: axiosRetry.exponentialDelay,
retryCondition: (error) => {
return axiosRetry.isNetworkOrIdempotentRequestError(error) || (error.response && error.response.status >= 500) || false;
return (
axiosRetry.isNetworkOrIdempotentRequestError(error) ||
(error.response && error.response.status >= 500) ||
false
);
},
});
}
Expand All @@ -65,7 +74,7 @@ export class AxiosHttpClient extends BaseHttpClient {
};
} catch (e) {
if (axios.isAxiosError(e)) {
const httpError = new HttpError(request.body, e);
const httpError = new HttpError(request.body, e);
console.error(
'[HttpClient#(sanitized error message)] Request failed:',
httpError
Expand All @@ -76,7 +85,6 @@ export class AxiosHttpClient extends BaseHttpClient {
}
}


private getAxiosRequestMethod(httpMethod: HttpMethod): string {
return httpMethod.toString();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,5 @@ export type HttpRequest<RequestBody extends HttpRequestBody = any> = {
timeout?: number;
retries?: number;
responseType?: 'arraybuffer' | 'json' | 'blob' | 'text';
followRedirects?: boolean;
};
2 changes: 1 addition & 1 deletion packages/pieces/community/http/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@activepieces/piece-http",
"version": "0.11.0",
"version": "0.11.1",
"dependencies": {
"https-proxy-agent": "7.0.4"
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -238,6 +238,11 @@ export const httpSendRequestAction = createAction({
displayName: 'Timeout(in seconds)',
required: false,
}),
followRedirects: Property.Checkbox({
displayName: 'Follow redirects',
required: false,
defaultValue: true,
}),
failureMode: Property.StaticDropdown({
displayName: 'On Failure',
required: false,
Expand Down Expand Up @@ -273,6 +278,7 @@ export const httpSendRequestAction = createAction({
use_proxy,
authType,
authFields,
followRedirects,
} = context.propsValue;

assertNotNullOrUndefined(method, 'Method');
Expand All @@ -284,6 +290,7 @@ export const httpSendRequestAction = createAction({
headers: headers as HttpHeaders,
queryParams: queryParams as QueryParams,
timeout: timeout ? timeout * 1000 : 0,
followRedirects,
};

switch (authType) {
Expand Down
6 changes: 6 additions & 0 deletions packages/react-ui/src/app/routes/templates/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,11 @@ import { Button } from '@/components/ui/button';
import { SidebarTrigger } from '@/components/ui/sidebar-shadcn';
import { flowHooks } from '@/features/flows/lib/flow-hooks';
import { templatesHooks } from '@/features/templates/hooks/templates-hook';
import { templatesTelemetryApi } from '@/features/templates/lib/templates-telemetry-api';
import { platformHooks } from '@/hooks/platform-hooks';
import {
Template,
TemplateTelemetryEventType,
TemplateType,
UncategorizedFolderId,
} from '@activepieces/shared';
Expand Down Expand Up @@ -41,6 +43,10 @@ const TemplatesPage = () => {

const handleTemplateSelect = (template: Template) => {
navigate(`/templates/${template.id}`);
templatesTelemetryApi.sendEvent({
eventType: TemplateTelemetryEventType.VIEW,
templateId: template.id,
});
};

const templatesByCategory = useMemo(() => {
Expand Down
Loading