Skip to content

Commit

Permalink
Remove "was this page useful" mechanism (analytics) (#579)
Browse files Browse the repository at this point in the history
Qiskit documentation now lives in docs.quantum.ibm.com and has its own
analytics mechanism.

The Qiskit Ecosystem projects will be migrating to GitHub pages.
Qiskit/ecosystem#578. Given that, I doubt
we'll want to commit to still maintaining this analytics mechanism.
Maintenance is more than only the code: it also means committing to
helping projects access the dashboard.

Instead, keep this Sphinx theme as simple as possible to make it more
sustainable. Projects highly interested in analytics could always add
the functionality their own way.
  • Loading branch information
Eric-Arellano authored Dec 1, 2023
1 parent 339be24 commit 11eb12c
Show file tree
Hide file tree
Showing 14 changed files with 4 additions and 201 deletions.
2 changes: 1 addition & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ The docs will rebuild every time you run `npm run test-qiskit` and `npm run test

First, get the `snapshot_results` folder, either by downloading it from CI or by running the tests locally. Then:

1. Find the "actual" snapshot for the failing test, such as `footer-includes-page-analytics-1-actual.png`.
1. Find the "actual" snapshot for the failing test, such as `api-docs-class-page-1-actual.png`.
2. Copy that snapshot into the folder `tests/js/qiskit.test.js-snapshots` or `tests/js/ecosystem.test.js-snapshots`, depending on which theme failed. Rename the `-actual.png` file ending to be `-linux.png` and overwrite the prior file.

### How to add a new snapshot
Expand Down
16 changes: 0 additions & 16 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -116,22 +116,6 @@ The `qiskit_sphinx_theme` extension defines the below custom directives for you
![](tests/js/qiskit.test.js-snapshots/custom-directives-1-linux.png)
![](tests/js/qiskit.test.js-snapshots/custom-directives-2-linux.png)

## Enable Qiskit.org Analytics

Qiskit.org uses Segment Analytics to collect information on traffic to sites under the qiskit.org domain. This is not enabled by default but if you would like to enable it you can add a `analytics_enabled` variable to the `html_context` object in your `conf.py`. Setting this to `True` will enable analytics for your site once it is deployed to `qiskit.org/`.

```python
html_context = {
'analytics_enabled': True
}
```

By enabling analytics we will be able to collect information on number of visits to each documentation page. It will also trigger the addition of a `Was this page helpful?` component at the bottom of each documentation page, so users will be able to provide yes/no feedback for each page.

![](tests/js/qiskit.test.js-snapshots/footer-includes-page-analytics-1-linux.png)

If you do not enable analytics, no data will be collected and the `Was this page helpful?` component will not show.

## Add an announcement banner to all pages

> :warning: **Note:** This feature is currently only available for the Qiskit theme, it is not yet available in the Ecosystem theme
Expand Down
5 changes: 0 additions & 5 deletions example_docs/docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,14 +75,9 @@
}

html_context = {
# Add "Was this page useful?" to the footer.
"analytics_enabled": True,
# Users of the theme can set prior version numbers. They'll
# show up in the sidebar under the "Previous Versions" section.
"version_list": [0.1, 0.2, 0.3],
# This allows docs authors to have folders that can be
# closed and opened in the left sidebar.
"expandable_sidebar": True,
# Users of the theme can set the text and optional url for an announcement banner
"theme_announcement": "🎉 Custom announcement text!",
"announcement_url_text": "Check it out",
Expand Down
42 changes: 0 additions & 42 deletions src/qiskit_sphinx_theme/assets/styles/_footer.scss

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
@import "colors";
@import "custom-directives";
@import "drop-shadows";
@import "footer";
@import "icons";
@import "layout";
@import "left-sidebar";
Expand Down
12 changes: 3 additions & 9 deletions src/qiskit_sphinx_theme/ecosystem/page.html
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
{#-
This file is vendored from Furo (created by Pradyun Gedam) and used under the MIT license.

When adding custom Qiskit code, surround it with `QISKIT CHANGE: start` and
`QISKIT CHANGE: end` Jinja-style comments.

We also vendor this file in the Qiskit theme. When making changes, check if `theme/page.html`
should have it too.
No changes should be made to it. This file is only to overwrite the changes made
in the Qiskit theme. Once that theme is deleted, this file should be deleted so
that we can go back to using the default file from Furo.
-#}

{% extends "base.html" %}
Expand Down Expand Up @@ -104,10 +102,6 @@
<footer>
{% block footer %}

{#- QISKIT CHANGE: start. -#}
{% include "custom_templates/footer_analytics.html" %}
{#- QISKIT CHANGE: end. -#}

<div class="related-pages">
{% if next -%}
<a class="next-page" href="{{ next.link }}">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,63 +22,3 @@
-#}
<link href="https://fonts.googleapis.com/css2?family=IBM+Plex+Mono:wght@400;600&family=IBM+Plex+Sans:ital,wght@0,400;0,600;1,400;1,600&display=swap" rel="stylesheet">
<script src="{{ pathto('_static/js/web-components/top-nav-bar.js', 1) }}"></script>

{%- if analytics_enabled %}
<script>
(function () {
window._analytics = {
segment_key: 'ffdYLviQze3kzomaINXNk6NwpY9LlXcw',
coremetrics: false,
optimizely: false,
googleAddServices: false,
fullStory: false,
autoPageEventSpa: false,
autoFormEvents: false,
autoPageView: false
}

window.digitalData = {
page: {
pageInfo: {
productTitle: 'IBM Q Experience',
analytics: {
category: 'Qiskit.org'
}
}
}
}
}());
</script>
<script src="https://cloud.ibm.com/analytics/build/bluemix-analytics.min.js"></script>
<script>
(function () {
'use strict'

if (!window.bluemixAnalytics || !window.digitalData) { return }

const category = window.digitalData.page.pageInfo.analytics.category
const productTitle = window.digitalData.page.pageInfo.productTitle
const routeName = 'documentation'

window.bluemixAnalytics.pageEvent(category, routeName, {
navigationType: 'pushState',
productTitle: productTitle,
title: document.title
})

window.trackCta = (action) => {
if (!window.bluemixAnalytics || !window.digitalData) { return }

const category = window.digitalData.page.pageInfo.analytics.category
const productTitle = window.digitalData.page.pageInfo.productTitle

window.bluemixAnalytics.trackEvent('CTA Clicked', {
productTitle,
category,
CTA: action
})
}

}());
</script>
{%- endif -%}

This file was deleted.

4 changes: 0 additions & 4 deletions src/qiskit_sphinx_theme/theme/qiskit-sphinx-theme/page.html
Original file line number Diff line number Diff line change
Expand Up @@ -122,10 +122,6 @@
<footer>
{% block footer %}

{#- QISKIT CHANGE: start. -#}
{% include "custom_templates/footer_analytics.html" %}
{#- QISKIT CHANGE: end. -#}

<div class="related-pages">
{% if next -%}
<a class="next-page" href="{{ next.link }}">
Expand Down
10 changes: 0 additions & 10 deletions tests/js/ecosystem.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -107,14 +107,4 @@ test.describe("colors can be changed", () => {
const translations = page.locator("div.qiskit-translations-container");
await expect(translations).toHaveScreenshot();
});

test("footer", async ({ page }) => {
await page.goto("");

const yesOption = page.locator("div.qiskit-analytics-container a").first();
await yesOption.hover();

const footer = page.locator("footer");
await expect(footer).toHaveScreenshot();
});
});
Binary file not shown.
25 changes: 0 additions & 25 deletions tests/js/qiskit.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -170,31 +170,6 @@ test.describe("api docs", () => {
});
});

test.describe("footer", () => {
test("includes page analytics", async ({ page }) => {
await page.goto("");
const footer = page.locator("footer");
await expect(footer).toHaveScreenshot();
});

test("says 'thank you' when analytics clicked", async ({ page }) => {
await page.goto("");
const yesOption = page.locator("div.qiskit-analytics-container a").first();

// First, check that we change the color of the buttons when hovering.
await yesOption.hover();
const backgroundColor = await yesOption.evaluate(
(node) => getComputedStyle(node).backgroundColor,
);
expect(backgroundColor).toEqual("rgb(105, 41, 196)");

// Then, check the screenshot when clicking.
await yesOption.click();
const analytics = page.locator("div.qiskit-analytics-container");
await expect(analytics).toHaveScreenshot();
});
});

test("tables align with qiskit.org", async ({ page }) => {
await page.goto("sphinx_guide/tables.html");
await hideTopNavBar(page);
Expand Down
Binary file not shown.
Binary file not shown.

0 comments on commit 11eb12c

Please sign in to comment.