240 lines
9.5 KiB
JavaScript
240 lines
9.5 KiB
JavaScript
// Metro module 1087 (f1088).
|
|
import { defineIntegration, spanToJSON, SEMANTIC_ATTRIBUTE_SENTRY_OP, SEMANTIC_ATTRIBUTE_URL_FULL, SEMANTIC_ATTRIBUTE_HTTP_REQUEST_METHOD, isString, stringMatchesSomePattern } from "./Module817";
|
|
import { SENTRY_XHR_DATA_KEY, getBodyString, getFetchRequestArgBody } from "./Module1033";
|
|
let isStandardRequest, isPersistedRequest, getGraphQLRequestPayload;
|
|
const _getGraphQLOperation = function _getGraphQLOperation(graphQLRequestPayload) {
|
|
let r30;
|
|
let r1 = typeof graphQLRequestPayload === "object";
|
|
let r0 = (typeof graphQLRequestPayload === "object" ? graphQLRequestPayload !== null : r1) && typeof graphQLRequestPayload.operationName === "string";
|
|
if (r0) {
|
|
const extensions = graphQLRequestPayload.extensions;
|
|
r0 = typeof extensions === "object" ? extensions !== null : typeof extensions === "object";
|
|
}
|
|
if (r0) {
|
|
const persistedQuery = graphQLRequestPayload.extensions.persistedQuery;
|
|
r0 = typeof persistedQuery === "object" ? persistedQuery !== null : typeof persistedQuery === "object";
|
|
}
|
|
if (r0) {
|
|
r0 = typeof graphQLRequestPayload.extensions.persistedQuery.sha256Hash === "string";
|
|
}
|
|
if (r0) {
|
|
r0 = typeof graphQLRequestPayload.extensions.persistedQuery.version === "number";
|
|
}
|
|
if (r0) {
|
|
return `persisted ${graphQLRequestPayload.operationName}`;
|
|
}
|
|
if (typeof graphQLRequestPayload === "object") {
|
|
r1 = graphQLRequestPayload !== null;
|
|
}
|
|
if (r1) {
|
|
r1 = typeof graphQLRequestPayload.query === "string";
|
|
}
|
|
if (r1) {
|
|
const { query, operationName } = graphQLRequestPayload;
|
|
const r8 = query.match(/^(?:\s*)(query|mutation|subscription)(?:\s*)(\w+)(?:\s*)[{(]/);
|
|
if (r8) {
|
|
r30 = {
|
|
operationType: r8[1],
|
|
operationName: r8[2]
|
|
};
|
|
} else {
|
|
const r29 = query.match(/^(?:\s*)(query|mutation|subscription)(?:\s*)[{(]/);
|
|
r30 = r29 ? {
|
|
operationType: r29[1],
|
|
operationName: void 0
|
|
} : {
|
|
operationType: void 0,
|
|
operationName: void 0
|
|
};
|
|
}
|
|
const { operationName: operationName2 = operationName, operationType } = r30;
|
|
const concat = HermesInternal.concat;
|
|
return operationName2 ? concat.call("", operationType, " ", operationName2) : concat.call("", operationType);
|
|
}
|
|
return "unknown";
|
|
};
|
|
isStandardRequest = function isStandardRequest(a0) {
|
|
return (typeof a0 === "object" ? a0 !== null : typeof a0 === "object") && typeof a0.query === "string";
|
|
};
|
|
isPersistedRequest = function isPersistedRequest(a0) {
|
|
let r0 = (typeof a0 === "object" ? a0 !== null : typeof a0 === "object") && typeof a0.operationName === "string";
|
|
if (r0) {
|
|
const extensions = a0.extensions;
|
|
r0 = typeof extensions === "object" ? extensions !== null : typeof extensions === "object";
|
|
}
|
|
if (r0) {
|
|
const persistedQuery = a0.extensions.persistedQuery;
|
|
r0 = typeof persistedQuery === "object" ? persistedQuery !== null : typeof persistedQuery === "object";
|
|
}
|
|
if (r0) {
|
|
r0 = typeof a0.extensions.persistedQuery.sha256Hash === "string";
|
|
}
|
|
if (r0) {
|
|
r0 = typeof a0.extensions.persistedQuery.version === "number";
|
|
}
|
|
return r0;
|
|
};
|
|
getGraphQLRequestPayload = function getGraphQLRequestPayload(a0) {
|
|
let r14;
|
|
L4: {
|
|
try {
|
|
const r7 = JSON.parse(a0);
|
|
if (!isStandardRequest(r7)) {
|
|
const isPersistedRequest2 = isPersistedRequest(r7);
|
|
r14 = void 0;
|
|
if (!isPersistedRequest2) {
|
|
break L4;
|
|
}
|
|
}
|
|
r14 = r7;
|
|
} catch ($e) {
|
|
return void 0;
|
|
}
|
|
}
|
|
return r14;
|
|
};
|
|
Object.defineProperty(exports, Symbol.toStringTag, {
|
|
value: "Module"
|
|
});
|
|
const r20 = defineIntegration((c12718_0) => ({
|
|
name: "GraphQLClient",
|
|
setup: (a0) => {
|
|
let c24045_0;
|
|
let c24044_0 = c12718_0;
|
|
a0.on("beforeOutgoingRequestSpan", (a0, a1) => {
|
|
let r59;
|
|
const r24 = spanToJSON(a0).data || {};
|
|
if (r24[SEMANTIC_ATTRIBUTE_SENTRY_OP] === "http.client") {
|
|
const r14 = r24[SEMANTIC_ATTRIBUTE_URL_FULL] || r24["http.url"];
|
|
const r13 = r24[SEMANTIC_ATTRIBUTE_HTTP_REQUEST_METHOD] || r24["http.method"];
|
|
if (isString(r14) && isString(r13)) {
|
|
const r49 = stringMatchesSomePattern(r14, c24044_0.endpoints);
|
|
if ("xhr" in a1) {
|
|
const r64 = a1.xhr[SENTRY_XHR_DATA_KEY];
|
|
r59 = r64 && getBodyString(r64.body)[0];
|
|
} else {
|
|
r59 = getBodyString(getFetchRequestArgBody(a1.input))[0];
|
|
}
|
|
if (r49 && r59) {
|
|
const graphQLRequestPayload = getGraphQLRequestPayload(r59);
|
|
if (graphQLRequestPayload) {
|
|
a0.updateName(`${r13} ${r14} (${_getGraphQLOperation(graphQLRequestPayload)})`);
|
|
let r80 = typeof graphQLRequestPayload === "object";
|
|
if ((typeof graphQLRequestPayload === "object" ? graphQLRequestPayload !== null : r80) && typeof graphQLRequestPayload.query === "string") {
|
|
a0.setAttribute("graphql.document", graphQLRequestPayload.query);
|
|
}
|
|
if (typeof graphQLRequestPayload === "object") {
|
|
r80 = graphQLRequestPayload !== null;
|
|
}
|
|
if (r80) {
|
|
r80 = typeof graphQLRequestPayload.operationName === "string";
|
|
}
|
|
if (r80) {
|
|
const extensions = graphQLRequestPayload.extensions;
|
|
r80 = typeof extensions === "object" ? extensions !== null : typeof extensions === "object";
|
|
}
|
|
if (r80) {
|
|
const persistedQuery = graphQLRequestPayload.extensions.persistedQuery;
|
|
r80 = typeof persistedQuery === "object" ? persistedQuery !== null : typeof persistedQuery === "object";
|
|
}
|
|
if (r80) {
|
|
r80 = typeof graphQLRequestPayload.extensions.persistedQuery.sha256Hash === "string";
|
|
}
|
|
if (r80) {
|
|
r80 = typeof graphQLRequestPayload.extensions.persistedQuery.version === "number";
|
|
}
|
|
if (r80) {
|
|
a0.setAttribute("graphql.persisted_query.hash.sha256", graphQLRequestPayload.extensions.persistedQuery.sha256Hash);
|
|
a0.setAttribute("graphql.persisted_query.version", graphQLRequestPayload.extensions.persistedQuery.version);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
});
|
|
c24045_0 = c12718_0;
|
|
a0.on("beforeOutgoingRequestBreadcrumb", (a0, a1) => {
|
|
let r34;
|
|
L39: {
|
|
const { category, type, data } = a0;
|
|
if (type === "http") {
|
|
if (category !== "fetch" && category !== "xhr") {
|
|
break L39;
|
|
}
|
|
const r22 = stringMatchesSomePattern(data?.url, c24045_0.endpoints);
|
|
if ("xhr" in a1) {
|
|
const r39 = a1.xhr[SENTRY_XHR_DATA_KEY];
|
|
r34 = r39 && getBodyString(r39.body)[0];
|
|
} else {
|
|
r34 = getBodyString(getFetchRequestArgBody(a1.input))[0];
|
|
}
|
|
if (r22 && data && r34) {
|
|
const graphQLRequestPayload = getGraphQLRequestPayload(r34);
|
|
if (!data.graphql && graphQLRequestPayload) {
|
|
data["graphql.operation"] = _getGraphQLOperation(graphQLRequestPayload);
|
|
let r51 = typeof graphQLRequestPayload === "object";
|
|
if ((typeof graphQLRequestPayload === "object" ? graphQLRequestPayload !== null : r51) && typeof graphQLRequestPayload.query === "string") {
|
|
data["graphql.document"] = graphQLRequestPayload.query;
|
|
}
|
|
if (typeof graphQLRequestPayload === "object") {
|
|
r51 = graphQLRequestPayload !== null;
|
|
}
|
|
if (r51) {
|
|
r51 = typeof graphQLRequestPayload.operationName === "string";
|
|
}
|
|
if (r51) {
|
|
const extensions = graphQLRequestPayload.extensions;
|
|
r51 = typeof extensions === "object" ? extensions !== null : typeof extensions === "object";
|
|
}
|
|
if (r51) {
|
|
const persistedQuery = graphQLRequestPayload.extensions.persistedQuery;
|
|
r51 = typeof persistedQuery === "object" ? persistedQuery !== null : typeof persistedQuery === "object";
|
|
}
|
|
if (r51) {
|
|
r51 = typeof graphQLRequestPayload.extensions.persistedQuery.sha256Hash === "string";
|
|
}
|
|
if (r51) {
|
|
r51 = typeof graphQLRequestPayload.extensions.persistedQuery.version === "number";
|
|
}
|
|
if (r51) {
|
|
data["graphql.persisted_query.hash.sha256"] = graphQLRequestPayload.extensions.persistedQuery.sha256Hash;
|
|
data["graphql.persisted_query.version"] = graphQLRequestPayload.extensions.persistedQuery.version;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
});
|
|
}
|
|
}));
|
|
export { _getGraphQLOperation };
|
|
export { getGraphQLRequestPayload };
|
|
export function getRequestPayloadXhrOrFetch(a0) {
|
|
let r16;
|
|
if ("xhr" in a0) {
|
|
const r24 = a0.xhr[SENTRY_XHR_DATA_KEY];
|
|
r16 = r24 && getBodyString(r24.body)[0];
|
|
} else {
|
|
r16 = getBodyString(getFetchRequestArgBody(a0.input))[0];
|
|
}
|
|
return r16;
|
|
}
|
|
export { r20 as graphqlClientIntegration };
|
|
export function parseGraphQLQuery(a0) {
|
|
const r4 = a0.match(/^(?:\s*)(query|mutation|subscription)(?:\s*)(\w+)(?:\s*)[{(]/);
|
|
if (r4) {
|
|
return {
|
|
operationType: r4[1],
|
|
operationName: r4[2]
|
|
};
|
|
}
|
|
const r6 = a0.match(/^(?:\s*)(query|mutation|subscription)(?:\s*)[{(]/);
|
|
return r6 ? {
|
|
operationType: r6[1],
|
|
operationName: void 0
|
|
} : {
|
|
operationType: void 0,
|
|
operationName: void 0
|
|
};
|
|
}
|