Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(frontend): snowplow environment specific URL setting through Cadd… #455

Merged
merged 9 commits into from
May 1, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading