Skip to content

Commit ac1c066

Browse files
feat(core): make context id factory getter configurable
1 parent d0bb082 commit ac1c066

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

packages/core/helpers/context-id-factory.ts

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,16 +27,19 @@ export class ContextIdFactory {
2727
*/
2828
public static getByRequest<T extends Record<any, any> = any>(
2929
request: T,
30+
propsToInspect: string[] = ['raw'],
3031
): ContextId {
3132
if (!request) {
32-
return createContextId();
33+
return ContextIdFactory.create();
3334
}
3435
if (request[REQUEST_CONTEXT_ID as any]) {
3536
return request[REQUEST_CONTEXT_ID as any];
3637
}
37-
if (request.raw && request.raw[REQUEST_CONTEXT_ID]) {
38-
return request.raw[REQUEST_CONTEXT_ID];
38+
for (const key of propsToInspect) {
39+
if (request[key]?.[REQUEST_CONTEXT_ID]) {
40+
return request[key][REQUEST_CONTEXT_ID];
41+
}
3942
}
40-
return createContextId();
43+
return ContextIdFactory.create();
4144
}
4245
}

0 commit comments

Comments
 (0)