@oneuptime/common 7.0.5098 → 8.0.5124

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -504,105 +504,122 @@ ${createdItem.description?.trim() || "No description provided."}
504
504
  feedInfoInMarkdown += `\n\n`;
505
505
  }
506
506
 
507
- // Parallelize operations that don't depend on each other
508
- const parallelOperations: Array<Promise<any>> = [];
509
-
510
- // 1. Essential monitor status operation (must complete first)
511
- await this.changeMonitorStatus(
512
- createdItem.projectId,
513
- [createdItem.id],
514
- createdItem.currentMonitorStatusId,
515
- false, // notifyOwners = false
516
- "This status was created when the monitor was created.",
517
- undefined,
518
- onCreate.createBy.props,
519
- );
520
-
521
- // 2. Start core operations in parallel that can run asynchronously (excluding workspace operations)
522
-
523
- // Add default probes if needed (can be slow with many probes)
524
- if (
525
- createdItem.monitorType &&
526
- MonitorTypeHelper.isProbableMonitor(createdItem.monitorType)
527
- ) {
528
- parallelOperations.push(
529
- this.addDefaultProbesToMonitor(
530
- createdItem.projectId,
531
- createdItem.id,
532
- ).catch((error: Error) => {
533
- logger.error("Error in adding default probes");
534
- logger.error(error);
535
- // Don't fail monitor creation due to probe creation issues
536
- }),
537
- );
538
- }
539
-
540
- // Billing operations
541
- if (IsBillingEnabled) {
542
- parallelOperations.push(
543
- ActiveMonitoringMeteredPlan.reportQuantityToBillingProvider(
544
- createdItem.projectId,
545
- ).catch((error: Error) => {
546
- logger.error("Error in billing operations");
547
- logger.error(error);
548
- // Don't fail monitor creation due to billing issues
549
- }),
550
- );
551
- }
552
-
553
- // Owner operations
554
- if (
555
- onCreate.createBy.miscDataProps &&
556
- (onCreate.createBy.miscDataProps["ownerTeams"] ||
557
- onCreate.createBy.miscDataProps["ownerUsers"])
558
- ) {
559
- parallelOperations.push(
560
- this.addOwners(
561
- createdItem.projectId,
562
- createdItem.id,
563
- (onCreate.createBy.miscDataProps["ownerUsers"] as Array<ObjectID>) ||
564
- [],
565
- (onCreate.createBy.miscDataProps["ownerTeams"] as Array<ObjectID>) ||
566
- [],
567
- false,
568
- onCreate.createBy.props,
569
- ).catch((error: Error) => {
570
- logger.error("Error in adding owners");
571
- logger.error(error);
572
- // Don't fail monitor creation due to owner issues
573
- }),
574
- );
575
- }
576
-
577
- // Probe status refresh (can be expensive with many probes)
578
- parallelOperations.push(
579
- this.refreshMonitorProbeStatus(createdItem.id).catch((error: Error) => {
580
- logger.error("Error in refreshing probe status");
581
- logger.error(error);
582
- // Don't fail monitor creation due to probe status issues
583
- }),
584
- );
585
-
586
- // Wait for core operations to complete, then handle workspace operations
587
- Promise.allSettled(parallelOperations)
588
- .then(() => {
589
- // Handle workspace operations after core operations complete
590
- // Run workspace operations in background without blocking response
591
- this.handleWorkspaceOperationsAsync({
592
- projectId: createdItem.projectId!,
593
- monitorId: createdItem.id!,
594
- monitorName: createdItem.name!,
595
- feedInfoInMarkdown,
596
- createdByUserId,
597
- }).catch((error: Error) => {
598
- logger.error("Error in workspace operations");
599
- logger.error(error);
600
- // Don't fail monitor creation due to workspace issues
601
- });
507
+ // Execute operations sequentially with error handling (workspace first)
508
+ Promise.resolve()
509
+ .then(async () => {
510
+ try {
511
+ return await this.handleWorkspaceOperationsAsync({
512
+ projectId: createdItem.projectId!,
513
+ monitorId: createdItem.id!,
514
+ monitorName: createdItem.name!,
515
+ feedInfoInMarkdown,
516
+ createdByUserId,
517
+ });
518
+ } catch (error) {
519
+ logger.error(
520
+ "Workspace operations failed in MonitorService.onCreateSuccess",
521
+ );
522
+ logger.error(error as Error);
523
+ return Promise.resolve();
524
+ }
525
+ })
526
+ .then(async () => {
527
+ try {
528
+ return await this.changeMonitorStatus(
529
+ createdItem.projectId!,
530
+ [createdItem.id!],
531
+ createdItem.currentMonitorStatusId!,
532
+ false, // notifyOwners = false
533
+ "This status was created when the monitor was created.",
534
+ undefined,
535
+ onCreate.createBy.props,
536
+ );
537
+ } catch (error) {
538
+ logger.error(
539
+ "Change monitor status failed in MonitorService.onCreateSuccess",
540
+ );
541
+ logger.error(error as Error);
542
+ return Promise.resolve();
543
+ }
544
+ })
545
+ .then(async () => {
546
+ try {
547
+ if (
548
+ createdItem.monitorType &&
549
+ MonitorTypeHelper.isProbableMonitor(createdItem.monitorType)
550
+ ) {
551
+ return await this.addDefaultProbesToMonitor(
552
+ createdItem.projectId!,
553
+ createdItem.id!,
554
+ );
555
+ }
556
+ return Promise.resolve();
557
+ } catch (error) {
558
+ logger.error(
559
+ "Add default probes failed in MonitorService.onCreateSuccess",
560
+ );
561
+ logger.error(error as Error);
562
+ return Promise.resolve();
563
+ }
564
+ })
565
+ .then(async () => {
566
+ try {
567
+ if (IsBillingEnabled) {
568
+ return await ActiveMonitoringMeteredPlan.reportQuantityToBillingProvider(
569
+ createdItem.projectId!,
570
+ );
571
+ }
572
+ return Promise.resolve();
573
+ } catch (error) {
574
+ logger.error(
575
+ "Billing operations failed in MonitorService.onCreateSuccess",
576
+ );
577
+ logger.error(error as Error);
578
+ return Promise.resolve();
579
+ }
580
+ })
581
+ .then(async () => {
582
+ try {
583
+ if (
584
+ onCreate.createBy.miscDataProps &&
585
+ (onCreate.createBy.miscDataProps["ownerTeams"] ||
586
+ onCreate.createBy.miscDataProps["ownerUsers"])
587
+ ) {
588
+ return await this.addOwners(
589
+ createdItem.projectId!,
590
+ createdItem.id!,
591
+ (onCreate.createBy.miscDataProps[
592
+ "ownerUsers"
593
+ ] as Array<ObjectID>) || [],
594
+ (onCreate.createBy.miscDataProps[
595
+ "ownerTeams"
596
+ ] as Array<ObjectID>) || [],
597
+ false,
598
+ onCreate.createBy.props,
599
+ );
600
+ }
601
+ return Promise.resolve();
602
+ } catch (error) {
603
+ logger.error("Add owners failed in MonitorService.onCreateSuccess");
604
+ logger.error(error as Error);
605
+ return Promise.resolve();
606
+ }
607
+ })
608
+ .then(async () => {
609
+ try {
610
+ return await this.refreshMonitorProbeStatus(createdItem.id!);
611
+ } catch (error) {
612
+ logger.error(
613
+ "Refresh probe status failed in MonitorService.onCreateSuccess",
614
+ );
615
+ logger.error(error as Error);
616
+ return Promise.resolve();
617
+ }
602
618
  })
603
619
  .catch((error: Error) => {
604
- logger.error("Error in parallel monitor creation operations");
605
- logger.error(error);
620
+ logger.error(
621
+ `Critical error in MonitorService sequential operations: ${error}`,
622
+ );
606
623
  });
607
624
 
608
625
  return createdItem;
@@ -610,6 +610,12 @@ ${resourcesAffected ? `**Resources Affected:** ${resourcesAffected}` : ""}
610
610
  labels: {
611
611
  name: true,
612
612
  },
613
+ createdByUserId: true,
614
+ createdByUser: {
615
+ _id: true,
616
+ name: true,
617
+ email: true,
618
+ },
613
619
  },
614
620
  props: {
615
621
  isRoot: true,
@@ -620,71 +626,80 @@ ${resourcesAffected ? `**Resources Affected:** ${resourcesAffected}` : ""}
620
626
  throw new BadDataException("Scheduled Maintenance not found");
621
627
  }
622
628
 
623
- // Execute core operations in parallel first
624
- const coreOperations: Array<Promise<any>> = [];
625
-
626
- // Create feed item asynchronously
627
- coreOperations.push(
628
- this.createScheduledMaintenanceFeedAsync(
629
- scheduledMaintenance,
630
- createdItem,
631
- ),
632
- );
633
-
634
- // Create state timeline asynchronously
635
- coreOperations.push(
636
- this.createScheduledMaintenanceStateTimelineAsync(createdItem),
637
- );
638
-
639
- // Handle owner assignment asynchronously
640
- if (
641
- createdItem.projectId &&
642
- createdItem.id &&
643
- onCreate.createBy.miscDataProps &&
644
- (onCreate.createBy.miscDataProps["ownerTeams"] ||
645
- onCreate.createBy.miscDataProps["ownerUsers"])
646
- ) {
647
- coreOperations.push(
648
- this.addOwners(
649
- createdItem.projectId!,
650
- createdItem.id!,
651
- (onCreate.createBy.miscDataProps["ownerUsers"] as Array<ObjectID>) ||
652
- [],
653
- (onCreate.createBy.miscDataProps["ownerTeams"] as Array<ObjectID>) ||
654
- [],
655
- false,
656
- onCreate.createBy.props,
657
- ),
658
- );
659
- }
660
-
661
- // Execute core operations in parallel with error handling
662
- Promise.allSettled(coreOperations)
663
- .then((coreResults: any[]) => {
664
- // Log any errors from core operations
665
- coreResults.forEach((result: any, index: number) => {
666
- if (result.status === "rejected") {
667
- logger.error(
668
- `Core operation ${index} failed in ScheduledMaintenanceService.onCreateSuccess: ${result.reason}`,
629
+ // Execute operations sequentially with error handling
630
+ Promise.resolve()
631
+ .then(async () => {
632
+ try {
633
+ if (createdItem.projectId && createdItem.id) {
634
+ return await this.handleScheduledMaintenanceWorkspaceOperationsAsync(
635
+ createdItem,
669
636
  );
670
637
  }
671
- });
672
-
673
- // Handle workspace operations after core operations complete
674
- if (createdItem.projectId && createdItem.id) {
675
- // Run workspace operations in background without blocking response
676
- this.handleScheduledMaintenanceWorkspaceOperationsAsync(
638
+ return Promise.resolve();
639
+ } catch (error) {
640
+ logger.error(
641
+ `Workspace operations failed in ScheduledMaintenanceService.onCreateSuccess: ${error}`,
642
+ );
643
+ return Promise.resolve();
644
+ }
645
+ })
646
+ .then(async () => {
647
+ try {
648
+ return await this.createScheduledMaintenanceFeedAsync(
649
+ scheduledMaintenance,
650
+ );
651
+ } catch (error) {
652
+ logger.error(
653
+ `Create scheduled maintenance feed failed in ScheduledMaintenanceService.onCreateSuccess: ${error}`,
654
+ );
655
+ return Promise.resolve();
656
+ }
657
+ })
658
+ .then(async () => {
659
+ try {
660
+ return await this.createScheduledMaintenanceStateTimelineAsync(
677
661
  createdItem,
678
- ).catch((error: Error) => {
679
- logger.error(
680
- `Workspace operations failed in ScheduledMaintenanceService.onCreateSuccess: ${error}`,
662
+ );
663
+ } catch (error) {
664
+ logger.error(
665
+ `Create scheduled maintenance state timeline failed in ScheduledMaintenanceService.onCreateSuccess: ${error}`,
666
+ );
667
+ return Promise.resolve();
668
+ }
669
+ })
670
+ .then(async () => {
671
+ try {
672
+ if (
673
+ createdItem.projectId &&
674
+ createdItem.id &&
675
+ onCreate.createBy.miscDataProps &&
676
+ (onCreate.createBy.miscDataProps["ownerTeams"] ||
677
+ onCreate.createBy.miscDataProps["ownerUsers"])
678
+ ) {
679
+ return await this.addOwners(
680
+ createdItem.projectId!,
681
+ createdItem.id!,
682
+ (onCreate.createBy.miscDataProps[
683
+ "ownerUsers"
684
+ ] as Array<ObjectID>) || [],
685
+ (onCreate.createBy.miscDataProps[
686
+ "ownerTeams"
687
+ ] as Array<ObjectID>) || [],
688
+ false,
689
+ onCreate.createBy.props,
681
690
  );
682
- });
691
+ }
692
+ return Promise.resolve();
693
+ } catch (error) {
694
+ logger.error(
695
+ `Add owners failed in ScheduledMaintenanceService.onCreateSuccess: ${error}`,
696
+ );
697
+ return Promise.resolve();
683
698
  }
684
699
  })
685
700
  .catch((error: Error) => {
686
701
  logger.error(
687
- `Critical error in ScheduledMaintenanceService core operations: ${error}`,
702
+ `Critical error in ScheduledMaintenanceService sequential operations: ${error}`,
688
703
  );
689
704
  });
690
705
 
@@ -738,17 +753,17 @@ ${resourcesAffected ? `**Resources Affected:** ${resourcesAffected}` : ""}
738
753
  @CaptureSpan()
739
754
  private async createScheduledMaintenanceFeedAsync(
740
755
  scheduledMaintenance: Model,
741
- createdItem: Model,
742
756
  ): Promise<void> {
743
757
  try {
744
758
  const createdByUserId: ObjectID | undefined | null =
745
- createdItem.createdByUserId || createdItem.createdByUser?.id;
759
+ scheduledMaintenance.createdByUserId ||
760
+ scheduledMaintenance.createdByUser?.id;
746
761
 
747
- let feedInfoInMarkdown: string = `#### 🕒 Scheduled Maintenance ${createdItem.scheduledMaintenanceNumber?.toString()} Created:
762
+ let feedInfoInMarkdown: string = `#### 🕒 Scheduled Maintenance ${scheduledMaintenance.scheduledMaintenanceNumber?.toString()} Created:
748
763
 
749
- **${createdItem.title || "No title provided."}**:
764
+ **${scheduledMaintenance.title || "No title provided."}**:
750
765
 
751
- ${createdItem.description || "No description provided."}
766
+ ${scheduledMaintenance.description || "No description provided."}
752
767
 
753
768
  `;
754
769
 
@@ -772,7 +787,7 @@ ${createdItem.description || "No description provided."}
772
787
  feedInfoInMarkdown += `🌎 **Resources Affected**:\n`;
773
788
 
774
789
  for (const monitor of scheduledMaintenance.monitors) {
775
- feedInfoInMarkdown += `- [${monitor.name}](${(await MonitorService.getMonitorLinkInDashboard(createdItem.projectId!, monitor.id!)).toString()})\n`;
790
+ feedInfoInMarkdown += `- [${monitor.name}](${(await MonitorService.getMonitorLinkInDashboard(scheduledMaintenance.projectId!, monitor.id!)).toString()})\n`;
776
791
  }
777
792
 
778
793
  feedInfoInMarkdown += `\n\n`;
@@ -781,14 +796,14 @@ ${createdItem.description || "No description provided."}
781
796
  const scheduledMaintenanceCreateMessageBlocks: Array<MessageBlocksByWorkspaceType> =
782
797
  await ScheduledMaintenanceWorkspaceMessages.getScheduledMaintenanceCreateMessageBlocks(
783
798
  {
784
- scheduledMaintenanceId: createdItem.id!,
785
- projectId: createdItem.projectId!,
799
+ scheduledMaintenanceId: scheduledMaintenance.id!,
800
+ projectId: scheduledMaintenance.projectId!,
786
801
  },
787
802
  );
788
803
 
789
804
  await ScheduledMaintenanceFeedService.createScheduledMaintenanceFeedItem({
790
- scheduledMaintenanceId: createdItem.id!,
791
- projectId: createdItem.projectId!,
805
+ scheduledMaintenanceId: scheduledMaintenance.id!,
806
+ projectId: scheduledMaintenance.projectId!,
792
807
  scheduledMaintenanceFeedEventType:
793
808
  ScheduledMaintenanceFeedEventType.ScheduledMaintenanceCreated,
794
809
  displayColor: Red500,
@@ -611,6 +611,9 @@ export class Service extends DatabaseService<WorkspaceNotificationRule> {
611
611
  notificationFor: NotificationFor;
612
612
  workspaceType: WorkspaceType;
613
613
  }): Promise<Array<WorkspaceChannel>> {
614
+ logger.debug("getWorkspaceChannelsByNotificationFor called with data:");
615
+ logger.debug(JSON.stringify(data, null, 2));
616
+
614
617
  let monitorChannels: Array<WorkspaceChannel> = [];
615
618
 
616
619
  if (data.notificationFor.monitorId) {
@@ -654,6 +657,10 @@ export class Service extends DatabaseService<WorkspaceNotificationRule> {
654
657
  },
655
658
  );
656
659
  }
660
+
661
+ logger.debug("Workspace channels found:");
662
+ logger.debug(monitorChannels);
663
+
657
664
  return monitorChannels;
658
665
  }
659
666
 
@@ -758,112 +765,132 @@ export class Service extends DatabaseService<WorkspaceNotificationRule> {
758
765
  }): Promise<{
759
766
  channelsCreated: Array<NotificationRuleWorkspaceChannel>;
760
767
  } | null> {
761
- logger.debug(
762
- "WorkspaceNotificationRuleService.createInviteAndPostToChannelsBasedOnRules",
763
- );
764
- logger.debug(data);
768
+ try {
769
+ logger.debug(
770
+ "WorkspaceNotificationRuleService.createInviteAndPostToChannelsBasedOnRules",
771
+ );
772
+ logger.debug(data);
765
773
 
766
- const channelsCreated: Array<NotificationRuleWorkspaceChannel> = [];
774
+ const channelsCreated: Array<NotificationRuleWorkspaceChannel> = [];
767
775
 
768
- const projectAuths: Array<WorkspaceProjectAuthToken> =
769
- await WorkspaceProjectAuthTokenService.getProjectAuths({
770
- projectId: data.projectId,
771
- });
772
-
773
- logger.debug("projectAuths");
774
- logger.debug(projectAuths);
776
+ const projectAuths: Array<WorkspaceProjectAuthToken> =
777
+ await WorkspaceProjectAuthTokenService.getProjectAuths({
778
+ projectId: data.projectId,
779
+ });
775
780
 
776
- if (!projectAuths || projectAuths.length === 0) {
777
- // do nothing.
778
- return null;
779
- }
781
+ logger.debug("projectAuths");
782
+ logger.debug(projectAuths);
780
783
 
781
- for (const projectAuth of projectAuths) {
782
- if (!projectAuth.authToken) {
783
- continue;
784
+ if (!projectAuths || projectAuths.length === 0) {
785
+ // do nothing.
786
+ return null;
784
787
  }
785
788
 
786
- if (!projectAuth.workspaceType) {
787
- continue;
788
- }
789
+ for (const projectAuth of projectAuths) {
790
+ try {
791
+ if (!projectAuth.authToken) {
792
+ continue;
793
+ }
789
794
 
790
- const authToken: string = projectAuth.authToken;
791
- const workspaceType: WorkspaceType = projectAuth.workspaceType;
795
+ if (!projectAuth.workspaceType) {
796
+ continue;
797
+ }
792
798
 
793
- const notificationRules: Array<WorkspaceNotificationRule> =
794
- await this.getMatchingNotificationRules({
795
- projectId: data.projectId,
796
- workspaceType: workspaceType,
797
- notificationRuleEventType: data.notificationRuleEventType,
798
- notificationFor: data.notificationFor,
799
- });
799
+ const authToken: string = projectAuth.authToken;
800
+ const workspaceType: WorkspaceType = projectAuth.workspaceType;
800
801
 
801
- logger.debug("notificationRules");
802
- logger.debug(notificationRules);
802
+ const notificationRules: Array<WorkspaceNotificationRule> =
803
+ await this.getMatchingNotificationRules({
804
+ projectId: data.projectId,
805
+ workspaceType: workspaceType,
806
+ notificationRuleEventType: data.notificationRuleEventType,
807
+ notificationFor: data.notificationFor,
808
+ });
803
809
 
804
- if (!notificationRules || notificationRules.length === 0) {
805
- return null;
806
- }
810
+ logger.debug("notificationRules");
811
+ logger.debug(notificationRules);
807
812
 
808
- logger.debug("Creating channels based on rules");
809
- const createdWorkspaceChannels: Array<NotificationRuleWorkspaceChannel> =
810
- await this.createChannelsBasedOnRules({
811
- projectId: data.projectId,
812
- projectOrUserAuthTokenForWorkspace: authToken,
813
- workspaceType: workspaceType,
814
- notificationRules: notificationRules,
815
- channelNameSiffix: data.channelNameSiffix,
816
- notificationEventType: data.notificationRuleEventType,
817
- notificationFor: data.notificationFor,
818
- });
813
+ if (!notificationRules || notificationRules.length === 0) {
814
+ return null;
815
+ }
819
816
 
820
- logger.debug("createdWorkspaceChannels");
821
- logger.debug(createdWorkspaceChannels);
817
+ logger.debug("Creating channels based on rules");
818
+ const createdWorkspaceChannels: Array<NotificationRuleWorkspaceChannel> =
819
+ await this.createChannelsBasedOnRules({
820
+ projectId: data.projectId,
821
+ projectOrUserAuthTokenForWorkspace: authToken,
822
+ workspaceType: workspaceType,
823
+ notificationRules: notificationRules,
824
+ channelNameSiffix: data.channelNameSiffix,
825
+ notificationEventType: data.notificationRuleEventType,
826
+ notificationFor: data.notificationFor,
827
+ });
822
828
 
823
- logger.debug("Inviting users and teams to channels based on rules");
824
- await this.inviteUsersAndTeamsToChannelsBasedOnRules({
825
- projectId: data.projectId,
826
- projectAuth: projectAuth,
827
- workspaceType: workspaceType,
828
- notificationRules: notificationRules,
829
- notificationChannels: createdWorkspaceChannels,
830
- });
829
+ logger.debug("createdWorkspaceChannels");
830
+ logger.debug(createdWorkspaceChannels);
831
831
 
832
- logger.debug("Getting existing channel names from notification rules");
833
- const existingChannelNames: Array<string> =
834
- this.getExistingChannelNamesFromNotificationRules({
835
- notificationRules: notificationRules.map(
836
- (rule: WorkspaceNotificationRule) => {
837
- return rule.notificationRule as BaseNotificationRule;
838
- },
839
- ),
840
- }) || [];
832
+ logger.debug("Inviting users and teams to channels based on rules");
833
+ await this.inviteUsersAndTeamsToChannelsBasedOnRules({
834
+ projectId: data.projectId,
835
+ projectAuth: projectAuth,
836
+ workspaceType: workspaceType,
837
+ notificationRules: notificationRules,
838
+ notificationChannels: createdWorkspaceChannels,
839
+ });
841
840
 
842
- logger.debug("Existing channel names:");
843
- logger.debug(existingChannelNames);
841
+ logger.debug(
842
+ "Getting existing channel names from notification rules",
843
+ );
844
+ const existingChannelNames: Array<string> =
845
+ this.getExistingChannelNamesFromNotificationRules({
846
+ notificationRules: notificationRules.map(
847
+ (rule: WorkspaceNotificationRule) => {
848
+ return rule.notificationRule as BaseNotificationRule;
849
+ },
850
+ ),
851
+ }) || [];
844
852
 
845
- logger.debug("Adding created channel names to existing channel names");
846
- for (const channel of createdWorkspaceChannels) {
847
- if (!existingChannelNames.includes(channel.name)) {
848
- existingChannelNames.push(channel.name);
849
- }
850
- }
853
+ logger.debug("Existing channel names:");
854
+ logger.debug(existingChannelNames);
851
855
 
852
- logger.debug("Final list of channel names to post messages to:");
853
- logger.debug(existingChannelNames);
856
+ logger.debug(
857
+ "Adding created channel names to existing channel names",
858
+ );
859
+ for (const channel of createdWorkspaceChannels) {
860
+ if (!existingChannelNames.includes(channel.name)) {
861
+ existingChannelNames.push(channel.name);
862
+ }
863
+ }
854
864
 
855
- logger.debug("Posting messages to workspace channels");
865
+ logger.debug("Final list of channel names to post messages to:");
866
+ logger.debug(existingChannelNames);
856
867
 
857
- logger.debug("Channels created:");
858
- logger.debug(createdWorkspaceChannels);
868
+ logger.debug("Posting messages to workspace channels");
859
869
 
860
- channelsCreated.push(...createdWorkspaceChannels);
861
- }
870
+ logger.debug("Channels created:");
871
+ logger.debug(createdWorkspaceChannels);
862
872
 
863
- logger.debug("Returning created channels");
864
- return {
865
- channelsCreated: channelsCreated,
866
- };
873
+ channelsCreated.push(...createdWorkspaceChannels);
874
+ } catch (err) {
875
+ logger.error(
876
+ "Error in creating channels and inviting users to channels for workspace type " +
877
+ projectAuth.workspaceType,
878
+ );
879
+ logger.error(err);
880
+ }
881
+ }
882
+
883
+ logger.debug("Returning created channels");
884
+ return {
885
+ channelsCreated: channelsCreated,
886
+ };
887
+ } catch (err) {
888
+ logger.error(
889
+ "Error in createChannelsAndInviteUsersToChannelsBasedOnRules:",
890
+ );
891
+ logger.error(err);
892
+ return null;
893
+ }
867
894
  }
868
895
 
869
896
  @CaptureSpan()