@@ -14,7 +14,7 @@ import { initLoggerSink } from './workflow/logger';
1414import { Runtime } from './runtime' ;
1515import { InjectedSinks } from './sinks' ;
1616import { MiB } from './utils' ;
17- import { defaultWorkflowInterceptorModules , WorkflowBundleWithSourceMap } from './workflow/bundler' ;
17+ import { WorkflowBundleWithSourceMap } from './workflow/bundler' ;
1818
1919export type { WebpackConfiguration } ;
2020
@@ -417,6 +417,9 @@ export interface WorkerOptions {
417417
418418 * When using {@link workflowBundle}, these Workflow interceptors (`WorkerInterceptors.workflowModules`) are not used.
419419 * Instead, provide them via {@link BundleOptions.workflowInterceptorModules} when calling {@link bundleWorkflowCode}.
420+ *
421+ * Before v1.9.0, calling `appendDefaultInterceptors()` was required when registering custom interceptors in order to
422+ * preserve SDK's logging interceptors. This is no longer the case.
420423 */
421424 interceptors ?: WorkerInterceptors ;
422425
@@ -622,27 +625,25 @@ export function defaultSinks(logger?: Logger): InjectedSinks<LoggerSinks> {
622625 * Appends the default Worker logging interceptors to given interceptor arrays.
623626 *
624627 * @param logger a {@link Logger} - defaults to the {@link Runtime} singleton logger.
628+ *
629+ * @deprecated Calling `appendDefaultInterceptors()` is no longer required. To configure a custom logger, set the
630+ * {@see Runtime.logger} property instead.
625631 */
626632export function appendDefaultInterceptors (
627633 interceptors : WorkerInterceptors ,
628634 logger ?: Logger | undefined
629- ) : Required < WorkerInterceptors > {
630- // FIXME: Don't worry for this function being unclean, this code will be optimized in the next PR.
635+ ) : WorkerInterceptors {
636+ if ( ! logger || logger === Runtime . instance ( ) . logger ) return interceptors ;
631637
632- // eslint-disable-next-line deprecation/deprecation
633- let activityInbound = interceptors . activityInbound ?? [ ] ;
634- if ( logger && logger !== Runtime . instance ( ) . logger ) {
635- activityInbound = [
638+ return {
639+ activityInbound : [
636640 // eslint-disable-next-line deprecation/deprecation
637641 ( ctx ) => new ActivityInboundLogInterceptor ( ctx , logger ) ,
638- ...activityInbound ,
639- ] ;
640- }
641-
642- return {
643- activityInbound,
644- activity : interceptors . activity ?? [ ] ,
645- workflowModules : [ ...( interceptors . workflowModules ?? [ ] ) , ...defaultWorkflowInterceptorModules ] ,
642+ // eslint-disable-next-line deprecation/deprecation
643+ ...( interceptors . activityInbound ?? [ ] ) ,
644+ ] ,
645+ activity : interceptors . activity ,
646+ workflowModules : interceptors . workflowModules ,
646647 } ;
647648}
648649
@@ -703,7 +704,12 @@ export function addDefaultWorkerOptions(options: WorkerOptions): WorkerOptionsWi
703704 showStackTraceSources : showStackTraceSources ?? false ,
704705 reuseV8Context : reuseV8Context ?? false ,
705706 debugMode : debugMode ?? false ,
706- interceptors : appendDefaultInterceptors ( interceptors ?? { } ) ,
707+ interceptors : {
708+ activity : interceptors ?. activity ?? [ ] ,
709+ // eslint-disable-next-line deprecation/deprecation
710+ activityInbound : interceptors ?. activityInbound ?? [ ] ,
711+ workflowModules : interceptors ?. workflowModules ?? [ ] ,
712+ } ,
707713 nonStickyToStickyPollRatio : nonStickyToStickyPollRatio ?? 0.2 ,
708714 sinks : {
709715 ...initLoggerSink ( Runtime . instance ( ) . logger ) ,
0 commit comments