Skip to content

Commit fcc82ea

Browse files
committed
create a plugin to inject heap tracking js client-side
1 parent f3ea582 commit fcc82ea

File tree

6 files changed

+37
-56
lines changed

6 files changed

+37
-56
lines changed

docs/get-started.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@ This tutorial will teach you:
1010
- How to create application configurations
1111
- How to open a port and direct traffic to an application
1212

13-
<figure class="video_container">
14-
<iframe width="560" height="315" src="https://www.youtube.com/embed/fzig4AvMr74" frameborder="0" allowfullscreen="true"> </iframe>
13+
<figure className="video_container">
14+
<iframe width="560" height="315" src="https://www.youtube.com/embed/fzig4AvMr74" frameBorder="0" allowFullScreen={true}> </iframe>
1515
</figure>
1616

1717
## Step 1: Create Application

docs/guide-config.md

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,10 @@ title: Add Env Variables & Configs
44

55
A well designed application is likely to have configurations which vary between deployments. Kubernetes makes it easy to override the configurations specified in images.
66

7-
<figure class="video_container">
8-
<iframe width="560" height="315" src="https://www.youtube.com/embed/bMwc6XPtM3c" frameborder="0" allowfullscreen="true"> </iframe>
7+
<figure className="video_container">
8+
<iframe width="560" height="315" src="https://www.youtube.com/embed/bMwc6XPtM3c" frameBorder="0" allowFullScreen={true}> </iframe>
99
</figure>
1010

11-
1211
## Example Container Setup
1312

1413
Let's go through an example of configuring Redis. Our goal is to change the `maxmemory` parameter. (Imagine that you need a larger amount of memory for production vs dev)

docs/guide-logs.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22
title: View Container Logs
33
---
44

5-
<figure class="video_container">
6-
<iframe width="560" height="315" src="https://www.youtube.com/embed/zMzWkzxIKlo" frameborder="0" allowfullscreen="true"> </iframe>
5+
<figure className="video_container">
6+
<iframe width="560" height="315" src="https://www.youtube.com/embed/zMzWkzxIKlo" frameBorder="0" allowFullScreen={true}> </iframe>
77
</figure>
88

99
Sometimes its useful to view the log output of a particular container. Kalm provides a view to quickly view logs in the web:

docusaurus.config.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77

88
// See https://docusaurus.io/docs/site-config for all the possible
99
// site configuration options.
10+
const path = require("path");
1011

1112
const siteConfig = {
1213
title: "Kalm", // Title for your website.
@@ -15,10 +16,9 @@ const siteConfig = {
1516
// Used for publishing and more
1617
projectName: "kalm",
1718
organizationName: "kalmhq",
18-
1919
/* path to images for header/footer */
2020
favicon: "img/kalm-logo-blue.svg",
21-
21+
plugins: [path.resolve(__dirname, "heap-plugin")],
2222
themeConfig: {
2323
algolia: {
2424
apiKey: "d589acaac8cdb8ae96fca3f78c600ae4",

heap-plugin/index.js

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
module.exports = function (context, options) {
2+
// ...
3+
return {
4+
name: "heap-plugin",
5+
async loadContent() {
6+
/* ... */
7+
console.log("HEAP plugin load content");
8+
},
9+
async contentLoaded({ content, actions }) {
10+
console.log("HEAP plugin content loaded");
11+
},
12+
/* other lifecycle API */
13+
injectHtmlTags() {
14+
let heapId = process.env.HEAP_ID;
15+
console.log({ heapId });
16+
return {
17+
headTags: [
18+
{
19+
tagName: "script",
20+
innerHTML: `
21+
window.heap=window.heap||[],heap.load=function(e,t){window.heap.appid=e,window.heap.config=t=t||{};var r=document.createElement("script");r.type="text/javascript",r.async=!0,r.src="https://cdn.heapanalytics.com/js/heap-"+e+".js";var a=document.getElementsByTagName("script")[0];a.parentNode.insertBefore(r,a);for(var n=function(e){return function(){heap.push([e].concat(Array.prototype.slice.call(arguments,0)))}},p=["addEventProperties","addUserProperties","clearEventProperties","identify","resetIdentity","removeEventProperty","setEventProperties","track","unsetEventProperty"],o=0;o<p.length;o++)heap[p[o]]=n(p[o])};
22+
heap.load("${heapId}");
23+
`,
24+
},
25+
],
26+
};
27+
},
28+
};
29+
};

static/js/code-block-buttons.js

Lines changed: 0 additions & 47 deletions
This file was deleted.

0 commit comments

Comments
 (0)