Skip to content

Commit

Permalink
Swap from Microanalytics to Beam. (Still privacy-focussed, better fre…
Browse files Browse the repository at this point in the history
…e tier.)
  • Loading branch information
holly-cummins committed Sep 13, 2023
1 parent c6d9e1d commit 723e830
Show file tree
Hide file tree
Showing 11 changed files with 52 additions and 49 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/build_and_publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ jobs:
ALGOLIA_SEARCH_ONLY_API_KEY: ${{ secrets.ALGOLIA_SEARCH_ONLY_API_KEY }}
ALGOLIA_ADMIN_API_KEY: ${{ secrets.ALGOLIA_ADMIN_API_KEY }}
ALGOLIA_INDEX_NAME: ${{ secrets.ALGOLIA_INDEX_NAME }}
MICROANALYTICS_ID: ${{secrets.MICROANALYTICS_ID}} || "none"
BEAM_ID: ${{secrets.BEAM_ID}}
BEARER_TOKEN: ${{ secrets.BEARER_TOKEN }}
NODE_ENV: production
GATSBY_ACTIVE_ENV: production
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ Create an `.env` file like below in the root folder. Change `...` placeholders w
<br />By default, your `.env` file will be ignored by git. Remove `.env` from `.gitignore` in order to be able to push the file to your repository.

```text
MICROANALYTICS_ID=...
CLICKY_ID=...
ALGOLIA_APP_ID=...
ALGOLIA_SEARCH_ONLY_API_KEY=...
ALGOLIA_ADMIN_API_KEY=...
Expand Down
4 changes: 4 additions & 0 deletions content/posts/2021-11-15--tech-stack/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -86,3 +86,7 @@ The [platform code](https://github.com/holly-cummins/gatsby-platform/) for this
Most of the personalisation is in the `content` folder, but there are a few bits and pieces elsewhere, like `avatar.jpg` and `src/images/jpg`.

The content itself is not open source.

## Updates

Since writing this blog, I've swapped out Microanalytics for Beam Analytics (Microanalytics got rid of their free tier, and a paid solution like Mamoto was overkill).
4 changes: 2 additions & 2 deletions gatsby-config.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,9 @@ module.exports = {
},
plugins: [
{
resolve: "microanalytics",
resolve: `gatsby-plugin-beam-analytics`,
options: {
id: process.env.MICROANALYTICS_ID
dataToken: process.env.BEAM_ID
}
},
`gatsby-plugin-styled-jsx`, // the plugin's code is inserted directly to gatsby-node.js and gatsby-ssr.js files
Expand Down
26 changes: 13 additions & 13 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

14 changes: 14 additions & 0 deletions plugins/gatsby-plugin-beam-analytics/gatsby-node.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
exports.pluginOptionsSchema = ({ Joi }) => {
return Joi.object({
dataToken: Joi.string()
.optional()
.description(
`The data token from the beamanalytics.io onboarding. (If missing, analytics will not be shared.)`
)
});
};

// Log out information after a build is done
exports.onPostBuild = ({ reporter }) => {
reporter.info(`beamanalytics.io tags have been added.`);
};
14 changes: 14 additions & 0 deletions plugins/gatsby-plugin-beam-analytics/gatsby-ssr.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
const React = require("react");

exports.onRenderBody = ({ setHeadComponents }, pluginOptions) => {
if (pluginOptions.dataToken && process.env.NODE_ENV === "production") {
setHeadComponents([
<script
key="beam"
src="https://beamanalytics.b-cdn.net/beam.min.js"
data-token={pluginOptions.dataToken}
async
></script>
]);
}
};
3 changes: 3 additions & 0 deletions plugins/gatsby-plugin-beam-analytics/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"name": "gatsby-plugin-beam-analytics"
}
12 changes: 0 additions & 12 deletions plugins/microanalytics/gatsby-node.js

This file was deleted.

17 changes: 0 additions & 17 deletions plugins/microanalytics/gatsby-ssr.js

This file was deleted.

3 changes: 0 additions & 3 deletions plugins/microanalytics/package.json

This file was deleted.

0 comments on commit 723e830

Please sign in to comment.