Skip to content

Commit 00c7c92

Browse files
authored
fix(content-health-monitor): setup instructions (#271)
* Update instructions to clarify it is intended for content owners * Update setup instructions, GUID error instructions * Extend update-manifest command to auto-include all images, then update the manifest file * Add browser address bar image to instructions * Update manifest * Update image and manifest
1 parent 54b4a47 commit 00c7c92

File tree

7 files changed

+44
-33
lines changed

7 files changed

+44
-33
lines changed

extensions/content-health-monitor/Makefile

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,9 @@ clean:
4949
.PHONY: update-manifest
5050
update-manifest:
5151
cp manifest.json manifest.old.json
52-
uv run rsconnect write-manifest quarto content-health-monitor.qmd content_health_utils.py images/refresh-report.png images/settings-gear-icon.png --overwrite
52+
$(eval IMAGE_FILES := $(shell find images -type f | tr '\n' ' '))
53+
@echo "Including image files: $(IMAGE_FILES)"
54+
uv run rsconnect write-manifest quarto content-health-monitor.qmd content_health_utils.py $(IMAGE_FILES) --overwrite
5355
jq -n --slurpfile old manifest.old.json --slurpfile new manifest.json \
5456
'{"version": $$new[0].version, "locale": $$new[0].locale, "metadata": $$new[0].metadata, "extension": $$old[0].extension, "environment": $$old[0].environment} * ($$new[0] | del(.version, .locale, .metadata))' \
5557
> manifest.merged.json

extensions/content-health-monitor/content-health-monitor.qmd

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -93,10 +93,12 @@ if not state.show_instructions:
9393
# ------ DISPLAY SECTION ------ #
9494
# Create the about content text
9595
about_content = f"""<div>
96+
This report is intended to monitor content that you own. If you share this report with someone else it may not function properly.<br><br>
97+
9698
This report uses <b>{current_user_name}</b>'s API key to monitor a single piece of content. It checks whether the content is
9799
reachable, but does not verify that it runs without errors.<br><br>
98-
When scheduled to run regularly, the report will send an email alert
99-
if the content becomes unreachable.
100+
101+
When scheduled to run regularly, the report will send an email alert if the content becomes unreachable.
100102
To learn more about scheduling reports in Connect, see the
101103
<a href="https://docs.posit.co/connect/user/scheduling/index.html" target="_blank">Scheduling documentation</a>.
102104
</div>"""

extensions/content-health-monitor/content_health_utils.py

Lines changed: 25 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -68,30 +68,32 @@ def get_env_var(var_name, state, description=""):
6868
# Detailed instructions for MONITORED_CONTENT
6969
else:
7070
one_tab = "&nbsp;&nbsp;&nbsp;&nbsp;" # For indentation in HTML
71-
two_tabs = f"{one_tab}{one_tab}" # For deeper indentation
7271
instruction = (
7372
f"To monitor a piece of content you must configure the <code>{var_name}</code> environment variable.<br><br>"
7473

75-
f"<b>Step 1:</b> Locate the content you want to monitor in a new browser tab or window<br>"
76-
f"{one_tab}<b>Option A:</b> Copy the GUID from the Content Settings panel<br>"
77-
f"{two_tabs}• Click the <b>gear icon</b> in the top right toolbar to open <b>Content Settings</b><br>"
78-
f'{two_tabs}<img src="images/settings-gear-icon.png" alt="Settings gear icon location" '
79-
f'style="max-width: 80%; margin: 10px 0; border: 1px solid #ddd;"><br>'
80-
f"{two_tabs}• Select the <b>Info</b> tab<br>"
81-
f"{two_tabs}• Scroll to the bottom and click the <b>copy</b> button next to the GUID<br>"
82-
f"{one_tab}<b>Option B:</b> Copy the full URL from your browser<br>"
83-
f"{two_tabs}• If the address bar contains a GUID (ex: 1d97c1ff-e56c-4074-906f-cb3557685b75), "
84-
f"you can simply copy the entire URL<br><br>"
74+
f"<h2>Step 1: Find the content to be monitored</h2>"
75+
f"{one_tab}• In a separate tab, open the content you wish to monitor<br>"
76+
f"{one_tab}• In the browser address bar, copy the entire address (URL)<br><br>"
77+
f"{one_tab}<img src=\"images/address-bar.png\" alt=\"Browser address bar\" style=\"max-width: 50%; margin: 10px 0 10px 0; border: 1px solid #ddd;\"><br>"
8578

86-
f"<b>Step 2:</b> Return to this report to set the environment variable<br>"
87-
f"{one_tab}• Click the <b>gear icon</b> to open <b>Content Settings</b><br>"
88-
f"{one_tab}• Select the <b>Vars</b> tab<br>"
89-
f"{one_tab}• Add a new variable named <code>{var_name}</code><br>"
90-
f"{one_tab}• Paste the GUID you copied into the value field<br>"
91-
f"{one_tab}• Click <b>Add Variable</b> and then <b>Save</b> to save it<br><br>"
79+
f"<h2>Step 2: Configure this report</h2>"
80+
f"{one_tab}• Return to this report<br>"
81+
f"{one_tab}• Click the <b>gear icon</b> at the top right of the screen to open <b>Content Settings</b><br>"
82+
f"{one_tab}<img src=\"images/settings-gear-icon.png\" alt=\"Content Settings button\" style=\"max-width: 30%; margin: 10px 0 10px 0; border: 1px solid #ddd;\"><br>"
83+
f"{one_tab}• Click the <b>Vars</b> tab<br>"
84+
f"{one_tab}• In the <b>Name</b> field enter <code>{var_name}</code><br>"
85+
f"{one_tab}• In the <b>Value</b> field paste the full address you copied in the previous step<br>"
86+
f"{one_tab}• It should look like the example below<br>"
87+
f"{one_tab}<img src=\"images/vars.png\" alt=\"Environment Variables tab\" style=\"max-width: 30%; margin: 10px 0 10px 0; border: 1px solid #ddd;\"><br>"
88+
f"{one_tab}• Click <b>Add Variable</b><br>"
89+
f"{one_tab}• Click <b>Save</b> at the top of the screen to save your changes<br><br>"
9290

93-
f"<b>Step 3:</b> Click <b>Refresh Report</b> in the top right to to run a health check against the content specified in the new variable<br>"
94-
f'<img src="images/refresh-report.png" alt="Refresh report button" style="max-width: 80%; margin: 10px 0; border: 1px solid #ddd;"><br><br>'
91+
f"<h2>Step 3: Run the report to execute the health check</h2>"
92+
f"{one_tab}• Click the <b>Refresh Report</b> button at the top right to run a health check against the monitored content<br>"
93+
f"{one_tab}• The health check will run and report the status<br>"
94+
f"{one_tab}• If the content is healthy, you will see a <b>PASS</b> status, otherwise you will see a <b>FAIL</b> status<br>"
95+
f"{one_tab}• If you see a <b>FAIL</b> status, click the <b>View Logs</b> link to see more details about the failure<br>"
96+
f"{one_tab}<img src=\"images/refresh-report.png\" alt=\"Refresh report button\" style=\"max-width: 30%; margin: 10px 0 10px 0; border: 1px solid #ddd;\"><br><br>"
9597

9698
)
9799

@@ -150,7 +152,8 @@ def extract_guid(input_string):
150152
f"The URL provided in <code>MONITORED_CONTENT</code> does not contain a valid GUID. "
151153
f"The URL should contain a GUID like: <code>1d97c1ff-e56c-4074-906f-cb3557685b75</code><br><br>"
152154
f"The URL provided is: <a href=\"{input_string}\" target=\"_blank\" rel=\"noopener noreferrer\">{input_string}</a><br><br>"
153-
f"Please update your environment variable with a valid GUID or a URL containing a GUID."
155+
f"Please update your environment variable with a valid a URL containing a GUID.<br><br>"
156+
f"Or copy the GUID from the bottom of the Info tab. See the <a href=\"https://docs.posit.co/connect/user/content-settings/\" target=\"_blank\" rel=\"noopener noreferrer\">Connect Content Settings User Guide</a> instructions for more information.<br><br>"
154157
)
155158
return input_string, error_message
156159

@@ -159,7 +162,8 @@ def extract_guid(input_string):
159162
f"The value provided in <code>MONITORED_CONTENT</code> is not a valid GUID. "
160163
f"A valid GUID looks like: <code>1d97c1ff-e56c-4074-906f-cb3557685b75</code><br><br>"
161164
f"The provided value was: <code>{input_string}</code><br><br>"
162-
f"Please update your environment variable with a valid GUID or a URL containing a GUID."
165+
f"Please update your environment variable with a valid GUID or a URL containing a GUID.<br><br>"
166+
f"The GUID can be found at the bottom of the Info tab. See the <a href=\"https://docs.posit.co/connect/user/content-settings/\" target=\"_blank\" rel=\"noopener noreferrer\">Connect Content Settings User Guide</a> instructions for more information.<br><br>"
163167
)
164168
return input_string, error_message
165169

@@ -408,9 +412,6 @@ def create_instructions_box(instructions_html_content):
408412
<div style="{CSS_BOX_STYLE.format(border=warning['border'], background=neutral['background'])}">
409413
<div style="{CSS_HEADER_STYLE}; color: #f0ad4e;">⚙️ Setup Required</div>
410414
{instructions_html_content}
411-
<div style="{CSS_FOOTER_STYLE}">
412-
See Posit Connect documentation for <a href='https://docs.posit.co/connect/user/content-settings/#content-vars' target='_blank'>Vars (environment variables)</a>
413-
</div>
414415
</div>
415416
"""
416417

50.7 KB
Loading
25.9 KB
Loading

extensions/content-health-monitor/manifest.json

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232
"version": "3.11.7",
3333
"package_manager": {
3434
"name": "pip",
35-
"version": "24.2",
35+
"version": "25.1.1",
3636
"package_file": "requirements.txt"
3737
}
3838
},
@@ -41,16 +41,22 @@
4141
"checksum": "5f89d52674b219c0b0ed85f1a5785641"
4242
},
4343
"content-health-monitor.qmd": {
44-
"checksum": "f3cb8562a07f411da78748d107ffeb3e"
44+
"checksum": "d108f54df865a66e2ac54a7fb3ac9772"
4545
},
4646
"content_health_utils.py": {
47-
"checksum": "0ce8c4e2191fc4763492c5498626912f"
47+
"checksum": "5b7c8db239c4b9e0782060b1172b2456"
4848
},
49-
"images/refresh-report.png": {
50-
"checksum": "e5680e6188eb8d659e4313cb89d0be3b"
49+
"images/vars.png": {
50+
"checksum": "9840b32e4adec7d5a3c70bb3373a63bb"
5151
},
5252
"images/settings-gear-icon.png": {
5353
"checksum": "e2bc43263eb8a9179b6e0e5ab3e22450"
54+
},
55+
"images/address-bar.png": {
56+
"checksum": "993cc8f97996c68f30527abbcc63cf3c"
57+
},
58+
"images/refresh-report.png": {
59+
"checksum": "e5680e6188eb8d659e4313cb89d0be3b"
5460
}
5561
}
5662
}

extensions/content-health-monitor/test_content_health_utils.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -293,7 +293,7 @@ def test_extract_guid_with_url_no_guid(self):
293293
assert "The URL provided in <code>MONITORED_CONTENT</code> does not contain a valid GUID" in error_message
294294
assert "The URL should contain a GUID like: <code>1d97c1ff-e56c-4074-906f-cb3557685b75</code>" in error_message
295295
assert f"<a href=\"{input_string}\" target=\"_blank\" rel=\"noopener noreferrer\">" in error_message
296-
assert "Please update your environment variable with a valid GUID or a URL containing a GUID" in error_message
296+
assert "Please update your environment variable with a valid a URL containing a GUID" in error_message
297297

298298
def test_extract_guid_with_plain_text(self):
299299
"""Test extract_guid with plain text that is not a URL and does not contain a GUID"""

0 commit comments

Comments
 (0)