85 lines
2.4 KiB
JavaScript
85 lines
2.4 KiB
JavaScript
// Metro module 915 (f916).
|
|
import { defineIntegration } from "./setupIntegration";
|
|
import { ipHeaderNames, getClientIPAddress } from "./Module916";
|
|
import { parseCookie } from "./Module917";
|
|
import { HermesBuiltin } from "../_hermes/prelude";
|
|
Object.defineProperty(exports, Symbol.toStringTag, {
|
|
value: "Module"
|
|
});
|
|
let c752_2 = {
|
|
cookies: true,
|
|
data: true,
|
|
headers: true,
|
|
query_string: true,
|
|
url: true
|
|
};
|
|
export const requestDataIntegration = defineIntegration(function(r3 = {}) {
|
|
let c12561_0 = {
|
|
...c752_2,
|
|
...r3.include
|
|
};
|
|
return {
|
|
name: "RequestData",
|
|
processEvent: (a0, a1, a2) => {
|
|
let sdkProcessingMetadata = a0.sdkProcessingMetadata;
|
|
if (sdkProcessingMetadata === void 0) {
|
|
sdkProcessingMetadata = {};
|
|
}
|
|
const { normalizedRequest, ipAddress } = sdkProcessingMetadata;
|
|
const r4 = {};
|
|
HermesBuiltin.copyDataProperties(r4, c12561_0);
|
|
let ip = c12561_0.ip;
|
|
if (ip == null) {
|
|
ip = a2.getOptions().sendDefaultPii;
|
|
}
|
|
r4.ip = ip;
|
|
if (normalizedRequest) {
|
|
const request = {
|
|
...a0.request
|
|
};
|
|
const r26 = {};
|
|
const headers = {
|
|
...normalizedRequest.headers
|
|
};
|
|
let c23902_0 = headers;
|
|
if (r4.headers) {
|
|
r26.headers = headers;
|
|
if (!r4.cookies) {
|
|
delete headers["cookie"];
|
|
}
|
|
if (!r4.ip) {
|
|
ipHeaderNames.forEach((ipHeaderName) => {
|
|
delete c23902_0[ipHeaderName];
|
|
});
|
|
}
|
|
}
|
|
r26.method = normalizedRequest.method;
|
|
if (r4.url) {
|
|
r26.url = normalizedRequest.url;
|
|
}
|
|
if (r4.cookies) {
|
|
r26.cookies = normalizedRequest.cookies || (headers.cookie ? parseCookie(headers.cookie) : void 0) || {};
|
|
}
|
|
if (r4.query_string) {
|
|
r26.query_string = normalizedRequest.query_string;
|
|
}
|
|
if (r4.data) {
|
|
r26.data = normalizedRequest.data;
|
|
}
|
|
HermesBuiltin.copyDataProperties(request, r26);
|
|
a0.request = request;
|
|
if (r4.ip) {
|
|
const ip_address = normalizedRequest.headers && getClientIPAddress(normalizedRequest.headers) || ipAddress;
|
|
if (ip_address) {
|
|
a0.user = {
|
|
...a0.user,
|
|
ip_address
|
|
};
|
|
}
|
|
}
|
|
}
|
|
return a0;
|
|
}
|
|
};
|
|
});
|