//native
type Pinterest = {
token: string;
};
/**
* Receives batched logs from integration applications.
* This endpoint receives batched logs from integration applications on partner platforms.
Note: If you're interested in joining the beta, please reach out to your Pinterest account manager.
*/
export async function main(
auth: Pinterest,
body: {
logs: {
client_timestamp: number;
event_type: "APP" | "API";
log_level: "INFO" | "WARN" | "ERROR";
external_business_id?: string;
advertiser_id?: string;
merchant_id?: string;
tag_id?: string;
feed_profile_id?: string;
message?: string;
app_version_number?: string;
platform_version_number?: string;
error?: {
cause?: string;
column_number?: number;
file_name?: string;
line_number?: number;
message?: string;
message_detail?: string;
name?: string;
number?: number;
stack_trace?: string;
};
request?: {
method:
| "GET"
| "HEAD"
| "POST"
| "PUT"
| "DELETE"
| "CONNECT"
| "OPTIONS"
| "TRACE"
| "PATCH";
host: string;
path: string;
request_headers?: {};
response_headers?: {};
response_status_code?: number;
};
}[];
},
) {
const url = new URL(`https://api.pinterest.com/v5/integrations/logs`);
const response = await fetch(url, {
method: "POST",
headers: {
"Content-Type": "application/json",
Authorization: "Bearer " + auth.token,
},
body: JSON.stringify(body),
});
if (!response.ok) {
const text = await response.text();
throw new Error(`${response.status} ${text}`);
}
return await response.json();
}
Submitted by hugo697 536 days ago