Skip to content

Emit created/deleted activities for setup experience scripts - #49639

Merged
juan-fdz-hawa merged 1 commit into
mainfrom
16774-setup-experience-script-operations-bypass-activity-audit-logging
Jul 23, 2026
Merged

Emit created/deleted activities for setup experience scripts#49639
juan-fdz-hawa merged 1 commit into
mainfrom
16774-setup-experience-script-operations-bypass-activity-audit-logging

Conversation

@juan-fdz-hawa

@juan-fdz-hawa juan-fdz-hawa commented Jul 21, 2026

Copy link
Copy Markdown
Contributor

Setup experience script add/replace/delete now record activities (API and GitOps), skipping no-op re-submissions.

Related issue: Resolves #

Checklist for submitter

If some of the following don't apply, delete the relevant line.

  • Changes file added for user-visible changes in changes/, orbit/changes/ or ee/fleetd-chrome/changes.
    See Changes files for more information.

Testing

  • Added/updated automated tests
  • QA'd all new/changed functionality manually

Summary by CodeRabbit

  • New Features
    • Added audit-log entries when setup experience scripts are added, updated, or deleted.
    • Audit details now include the script name and associated fleet, with support for unassigned scripts.
    • Reapplying an unchanged script or deleting a nonexistent script no longer creates duplicate audit entries.
    • Added activity feed labels and messages for setup experience script changes.
  • Bug Fixes
    • Script updates now correctly replace changed content while avoiding unnecessary writes for identical content.

@codecov

codecov Bot commented Jul 21, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 81.81818% with 12 lines in your changes missing coverage. Please review.
✅ Project coverage is 67.90%. Comparing base (e14ef67) to head (ffcfa7f).
⚠️ Report is 17 commits behind head on main.

Files with missing lines Patch % Lines
ee/server/service/setup_experience.go 78.37% 4 Missing and 4 partials ⚠️
...vityFeed/GlobalActivityItem/GlobalActivityItem.tsx 75.00% 2 Missing and 2 partials ⚠️
Additional details and impacted files
@@           Coverage Diff            @@
##             main   #49639    +/-   ##
========================================
  Coverage   67.90%   67.90%            
========================================
  Files        3889     3889            
  Lines      248409   248468    +59     
  Branches    13059    13226   +167     
========================================
+ Hits       168671   168712    +41     
- Misses      64530    64539     +9     
- Partials    15208    15217     +9     
Flag Coverage Δ
backend 69.28% <84.00%> (-0.01%) ⬇️
frontend 60.39% <75.00%> (+<0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@coderabbitai

coderabbitai Bot commented Jul 21, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 13c4e697-4b1a-44ae-822e-e78032e37eb4

📥 Commits

Reviewing files that changed from the base of the PR and between 6602c42bcb04eb149bad35c4bc0f7dbc43cc7f6b and ffcfa7f.

⛔ Files ignored due to path filters (1)
  • docs/Contributing/reference/audit-logs.md is excluded by !**/*.md
📒 Files selected for processing (21)
  • changes/16774-setup-experience-script-activities
  • cmd/fleetctl/fleetctl/gitops_test.go
  • cmd/fleetctl/fleetctl/testdata/gitops/no-team.yml
  • cmd/fleetctl/fleetctl/testing_utils/testing_utils.go
  • ee/server/service/setup_experience.go
  • ee/server/service/setup_experience_test.go
  • frontend/interfaces/activity.ts
  • frontend/pages/DashboardPage/cards/ActivityFeed/GlobalActivityItem/GlobalActivityItem.tests.tsx
  • frontend/pages/DashboardPage/cards/ActivityFeed/GlobalActivityItem/GlobalActivityItem.tsx
  • server/datastore/mysql/activities_test.go
  • server/datastore/mysql/custom_host_vitals_test.go
  • server/datastore/mysql/hosts_test.go
  • server/datastore/mysql/microsoft_mdm_test.go
  • server/datastore/mysql/setup_experience.go
  • server/datastore/mysql/setup_experience_test.go
  • server/fleet/activities.go
  • server/fleet/datastore.go
  • server/mock/datastore_mock.go
  • server/service/integration_mdm_setup_experience_test.go
  • server/service/setup_experience_test.go
  • tools/dibble/pkg/seed/activities.go
🚧 Files skipped from review as they are similar to previous changes (19)
  • frontend/pages/DashboardPage/cards/ActivityFeed/GlobalActivityItem/GlobalActivityItem.tests.tsx
  • changes/16774-setup-experience-script-activities
  • cmd/fleetctl/fleetctl/testdata/gitops/no-team.yml
  • server/service/setup_experience_test.go
  • frontend/pages/DashboardPage/cards/ActivityFeed/GlobalActivityItem/GlobalActivityItem.tsx
  • server/datastore/mysql/activities_test.go
  • cmd/fleetctl/fleetctl/gitops_test.go
  • server/fleet/datastore.go
  • server/datastore/mysql/custom_host_vitals_test.go
  • server/datastore/mysql/setup_experience.go
  • cmd/fleetctl/fleetctl/testing_utils/testing_utils.go
  • server/fleet/activities.go
  • ee/server/service/setup_experience_test.go
  • server/mock/datastore_mock.go
  • tools/dibble/pkg/seed/activities.go
  • ee/server/service/setup_experience.go
  • server/service/integration_mdm_setup_experience_test.go
  • server/datastore/mysql/hosts_test.go
  • server/datastore/mysql/setup_experience_test.go

Walkthrough

Adds audit activities for setup experience script creation, replacement, and deletion. The datastore now reports whether setting a script changed persisted content, allowing the service to suppress duplicate creation events and repeated deletion events. Activity payloads include optional fleet metadata and script names. The frontend adds activity types, filter labels, rendering templates, and tests. GitOps and datastore mocks and tests are updated for the new contract.

Possibly related PRs

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 8.33% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly summarizes the main change: emitting created/deleted activities for setup experience scripts.
Description check ✅ Passed The description follows the template and covers the summary, changes file, and testing, with only a placeholder related issue left incomplete.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch 16774-setup-experience-script-operations-bypass-activity-audit-logging

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🧹 Nitpick comments (1)
frontend/interfaces/activity.ts (1)

579-582: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value

Fix formatting issue flagged by Prettier.

The static analysis tool flagged a formatting issue here. Consider keeping the keys and values on the same line to comply with the project's Prettier configuration.

💅 Proposed fix
-  [ActivityType.CreatedSetupExperienceScript]:
-    "Added setup experience script",
-  [ActivityType.DeletedSetupExperienceScript]:
-    "Deleted setup experience script",
+  [ActivityType.CreatedSetupExperienceScript]: "Added setup experience script",
+  [ActivityType.DeletedSetupExperienceScript]: "Deleted setup experience script",
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@frontend/interfaces/activity.ts` around lines 579 - 582, Update the
ActivityType.CreatedSetupExperienceScript and
ActivityType.DeletedSetupExperienceScript entries to keep each key and string
value on a single line, matching the project’s Prettier formatting.

Source: Linters/SAST tools

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@ee/server/service/setup_experience.go`:
- Around line 209-217: Move the setupExperienceTeamName call and its error
return before DeleteSetupExperienceScript in the surrounding setup-experience
operation. Ensure teamName is successfully fetched before any script deletion
occurs, while preserving the existing error handling and subsequent deletion
flow.

---

Nitpick comments:
In `@frontend/interfaces/activity.ts`:
- Around line 579-582: Update the ActivityType.CreatedSetupExperienceScript and
ActivityType.DeletedSetupExperienceScript entries to keep each key and string
value on a single line, matching the project’s Prettier formatting.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 43bd11e8-cf95-4cbf-8361-2d1cbf9d0c4e

📥 Commits

Reviewing files that changed from the base of the PR and between bd8f1e8 and 3c66e2d6624ac83f2ea4abdf68ef5b187651c247.

⛔ Files ignored due to path filters (1)
  • docs/Contributing/reference/audit-logs.md is excluded by !**/*.md
📒 Files selected for processing (20)
  • changes/16774-setup-experience-script-activities
  • cmd/fleetctl/fleetctl/gitops_test.go
  • cmd/fleetctl/fleetctl/testing_utils/testing_utils.go
  • ee/server/service/setup_experience.go
  • ee/server/service/setup_experience_test.go
  • frontend/interfaces/activity.ts
  • frontend/pages/DashboardPage/cards/ActivityFeed/GlobalActivityItem/GlobalActivityItem.tests.tsx
  • frontend/pages/DashboardPage/cards/ActivityFeed/GlobalActivityItem/GlobalActivityItem.tsx
  • server/datastore/mysql/activities_test.go
  • server/datastore/mysql/custom_host_vitals_test.go
  • server/datastore/mysql/hosts_test.go
  • server/datastore/mysql/microsoft_mdm_test.go
  • server/datastore/mysql/setup_experience.go
  • server/datastore/mysql/setup_experience_test.go
  • server/fleet/activities.go
  • server/fleet/datastore.go
  • server/mock/datastore_mock.go
  • server/service/integration_mdm_setup_experience_test.go
  • server/service/setup_experience_test.go
  • tools/dibble/pkg/seed/activities.go

Comment thread ee/server/service/setup_experience.go Outdated
@juan-fdz-hawa
juan-fdz-hawa force-pushed the 16774-setup-experience-script-operations-bypass-activity-audit-logging branch from 3c66e2d to 8ee3433 Compare July 21, 2026 13:24
@juan-fdz-hawa
juan-fdz-hawa force-pushed the 16774-setup-experience-script-operations-bypass-activity-audit-logging branch from 8f9906f to 6602c42 Compare July 21, 2026 14:30
Setup experience script add/replace/delete now record activities (API and
GitOps), skipping no-op re-submissions.
@juan-fdz-hawa
juan-fdz-hawa force-pushed the 16774-setup-experience-script-operations-bypass-activity-audit-logging branch from 6602c42 to ffcfa7f Compare July 21, 2026 14:48
@juan-fdz-hawa
juan-fdz-hawa merged commit fbccb8c into main Jul 23, 2026
65 of 67 checks passed
@juan-fdz-hawa
juan-fdz-hawa deleted the 16774-setup-experience-script-operations-bypass-activity-audit-logging branch July 23, 2026 10:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants