Skip to content

feat: add X-Client headers to datasource methods#1419

Merged
ckbedwell merged 3 commits into
mainfrom
feat/terraform-headers
Nov 11, 2025
Merged

feat: add X-Client headers to datasource methods#1419
ckbedwell merged 3 commits into
mainfrom
feat/terraform-headers

Conversation

@ckbedwell

@ckbedwell ckbedwell commented Nov 6, 2025

Copy link
Copy Markdown
Contributor

Closes: #1212

Problem

Customers may be managing their resources outside of the Synthetic Monitoring application but we have no way to identify what these are.

Solution

The API now accepts two headers: X-Client-ID and X-Client-Version which indicate where the interaction with the API came from. Our Terraform provider has been sending these headers for a while now and this PR adds the same headers with the Synthetic Monitoring app's values.

The long-term goal here is to add a feature which identifies how resources are managed so customers can easily find the source of truth for managing them, as well as blocking interactions -- such as checks which are managed by Terraform can't be updated in the app.

Additional context

I found this ticket was a good excuse to add tests to our datasource module as I can easily see this regressing as we work on the datasource methods further.

@ckbedwell ckbedwell requested a review from The-9880 November 6, 2025 11:35
@ckbedwell ckbedwell requested a review from a team as a code owner November 6, 2025 11:35
@ckbedwell ckbedwell requested a review from w1kman November 6, 2025 11:35
@github-actions

github-actions Bot commented Nov 6, 2025

Copy link
Copy Markdown

Script size changes

Name +/- Main This PR Outcome
[502.js] = 1,732.65 kB 1,732.65 kB
[935.js] = 953.37 kB 953.37 kB
[datasource/module.js] -0.78% 24.72 kB 24.53 kB
[692.js] = 20.10 kB 20.10 kB
[663.js] = 5.84 kB 5.84 kB
[module.js] = 4.92 kB 4.92 kB

Totals

Name +/- Main This PR Outcome
[Scripts] = 2,741.59 kB 2,741.40 kB
[Non-script Assets] = 2,618.12 kB 2,618.12 kB
[All] = 5,359.72 kB 5,359.53 kB

Generated by 🚫 dangerJS against abb0ba8

@The-9880 The-9880 left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Are you intentionally not adding the headers to GET endpoints?

e.g. listProbes, listChecks, getCheck? Otherwise, LGTM

@ckbedwell ckbedwell changed the title feat: add headers to datasource methods feat: add X-Client headers to datasource methods Nov 7, 2025
@ckbedwell ckbedwell force-pushed the feat/terraform-headers branch from 48d576d to abb0ba8 Compare November 7, 2025 10:27
@ckbedwell ckbedwell requested a review from The-9880 November 7, 2025 10:31
@ckbedwell

Copy link
Copy Markdown
Contributor Author

Are you intentionally not adding the headers to GET endpoints?

e.g. listProbes, listChecks, getCheck? Otherwise, LGTM

Added them now! It made the code much cleaner as I just put it on our fetchAPI wrapper method.

Comment on lines -308 to -309
async getCheck(checkId: number) {
return this.fetchAPI<Check>(`${this.instanceSettings.url}/sm/check/${checkId}`);

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

I guess removing this is fine because it seems unused, I was kind of confused by it. Do we always just call listChecks then?

I refreshed individual check pages and that seems to be the case.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Yeah, we might use it at some point and if so I'll then add it back in but right now we just get everything. There's quite a few features where we don't have a dedicated API endpoint to do something so we always revert to using the listChecks method and parse the response ourselves. (e.g. what checks are using what probes, common labels, etc.)

@ckbedwell ckbedwell added the feature A feature added to the application. label Nov 10, 2025
@ckbedwell ckbedwell merged commit 7212d24 into main Nov 11, 2025
23 checks passed
@ckbedwell ckbedwell deleted the feat/terraform-headers branch November 11, 2025 11:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

feature A feature added to the application.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Start reporting X-Client-ID/X-Client-Version

2 participants