Skip to content

Commit

Permalink
fix(frontend): snowplow environment specific URL setting through Cadd… (
Browse files Browse the repository at this point in the history
  • Loading branch information
sukanya-rath authored May 1, 2024
1 parent 28228f9 commit 94a9f3b
Show file tree
Hide file tree
Showing 9 changed files with 16 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,8 @@ spec:
value: http://{{ .Release.Name }}-backend
- name: LOG_LEVEL
value: {{ .Values.env.logLevel }}
- name: SNOWPLOW_URL
value: {{ .Values.env.snowplowUrl }}
ports:
- name: http
containerPort: {{ .Values.service.targetPort }}
Expand Down
1 change: 1 addition & 0 deletions charts/fin-pay-transparency/values-prod.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,7 @@ frontend:
memory: 50Mi
env:
logLevel: info
snowplowUrl: spt.apps.gov.bc.ca
autoscaling:
enabled: true
minReplicas: 3
Expand Down
1 change: 1 addition & 0 deletions charts/fin-pay-transparency/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,7 @@ frontend:
memory: 50Mi
env:
logLevel: info
snowplowUrl: spm.apps.gov.bc.ca
autoscaling:
enabled: true
minReplicas: 3
Expand Down
2 changes: 1 addition & 1 deletion frontend/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,4 @@ local.*
/blob-report/
/playwright/
.env.playwright
user.json
user.json
8 changes: 7 additions & 1 deletion frontend/Caddyfile
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,17 @@
}
level {$LOG_LEVEL}
}
handle /env.js {
header {
Content-Type text/javascript
}
respond `window.config = {"SNOWPLOW_URL":"{$SNOWPLOW_URL}"};`
}
root * /app/dist
encode zstd gzip
file_server
@spa_router {
not path /api/*
not path /api/* /env.js
file {
try_files {path} /index.html
}
Expand Down
1 change: 0 additions & 1 deletion frontend/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
# Build static files
FROM node:lts-alpine AS build

WORKDIR /app
COPY . .
RUN npm ci --ignore-scripts && \
Expand Down
3 changes: 2 additions & 1 deletion frontend/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,16 @@
<link rel="apple-touch-icon" href="bcid-apple-touch-icon.png">
<link rel="preload" href="https://fonts.googleapis.com/css?family=Material+Icons" as="style">
<link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Material+Icons">
<script type="text/javascript" src="/env.js"></script>
<title>FIN Pay Transparency</title>
</head>

<body>
<noscript>
<strong>Please enable JavaScript to continue.</strong>
</noscript>
<script src="/snowplow.js"></script>
<div id="app"></div>
<script src="/snowplow.js"></script>
<script type="module" src="/src/main.js"></script>
<!-- built files will be auto injected -->
</body>
Expand Down
2 changes: 1 addition & 1 deletion frontend/public/snowplow.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
p.GlobalSnowplowNamespace.push(i);p[i]=function(){(p[i].q=p[i].q||[]).push(arguments)
};p[i].q=p[i].q||[];n=l.createElement(o);g=l.getElementsByTagName(o)[0];n.async=1;
n.src=w;g.parentNode.insertBefore(n,g)}}(window,document,"script","https://www2.gov.bc.ca/StaticWebResources/static/sp/sp-2-14-0.js","snowplow"));
window.snowplow('newTracker','rt','spm.apps.gov.bc.ca', {
window.snowplow('newTracker','rt',window.config.SNOWPLOW_URL, {
appId: 'Snowplow_standalone',
cookieLifetime: 86400 * 548,
platform: 'web',
Expand Down
1 change: 1 addition & 0 deletions frontend/src/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import 'viewerjs/dist/viewer.css';
import component from 'v-viewer';
import VueDOMPurifyHTML from 'vue-dompurify-html';


const myCustomLightTheme = {
dark: false,
colors: {
Expand Down

0 comments on commit 94a9f3b

Please sign in to comment.