Skip to content

Commit

Permalink
Merge pull request #1646 from bcgov/feature/ALCS-1890-2
Browse files Browse the repository at this point in the history
Snowplow to Main
  • Loading branch information
dhaselhan authored May 2, 2024
2 parents 1322b07 + d354fb3 commit c074ec1
Show file tree
Hide file tree
Showing 9 changed files with 50 additions and 43 deletions.
6 changes: 4 additions & 2 deletions alcs-frontend/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,16 @@ FROM node:20-alpine AS build
WORKDIR /app

# Copy package.json file
COPY package.json .
COPY package.json package-lock.json ./

# Install dependencies
RUN npm install
RUN npm ci

# Copy the source code to the /app directory
COPY . .

ENV NODE_OPTIONS="--max-old-space-size=2048"

# Build the application
RUN npm run build -- --output-path=dist --output-hashing=all

Expand Down
2 changes: 1 addition & 1 deletion alcs-frontend/nginx.conf
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ http {
add_header 'X-XSS-Protection' '1; mode=block';
add_header 'Strict-Transport-Security' 'max-age=31536000; includeSubDomains; preload';
add_header 'Cache-control' 'no-cache';
add_header 'Content-Security-Policy' "default-src 'self';img-src 'self';style-src 'unsafe-inline' 'self';connect-src $ENABLED_CONNECT_SRC; font-src 'self' https://fonts.gstatic.com https://fonts.googleapis.com; base-uri 'self'; object-src https://nrs.objectstore.gov.bc.ca; frame-src https://alcs-metabase-test.apps.silver.devops.gov.bc.ca https://alcs-metabase-prod.apps.silver.devops.gov.bc.ca https://nrs.objectstore.gov.bc.ca;";
add_header 'Content-Security-Policy' "default-src 'self'; img-src 'self'; style-src 'unsafe-inline' 'self'; connect-src $ENABLED_CONNECT_SRC; font-src 'self' https://fonts.gstatic.com https://fonts.googleapis.com; base-uri 'self'; object-src https://nrs.objectstore.gov.bc.ca; frame-src https://alcs-metabase-test.apps.silver.devops.gov.bc.ca https://alcs-metabase-prod.apps.silver.devops.gov.bc.ca https://nrs.objectstore.gov.bc.ca; script-src 'self' https://www2.gov.bc.ca";
add_header 'Permissions-Policy' 'camera=(), geolocation=(), microphone=()';
add_header 'Referrer-Policy' 'same-origin';

Expand Down
2 changes: 2 additions & 0 deletions alcs-frontend/src/app/app.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,6 @@ import { Component } from '@angular/core';
})
export class AppComponent {
title = 'alcs-frontend';

constructor() {}
}
2 changes: 2 additions & 0 deletions portal-frontend/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ RUN npm ci
# Copy the source code to the /app directory
COPY . .

ENV NODE_OPTIONS="--max-old-space-size=2048"

# Build the application
RUN npm run build -- --output-path=dist --output-hashing=all

Expand Down
2 changes: 1 addition & 1 deletion portal-frontend/nginx.conf
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ http {
add_header 'X-XSS-Protection' '1; mode=block';
add_header 'Strict-Transport-Security' 'max-age=31536000; includeSubDomains; preload';
add_header 'Cache-control' 'no-cache';
add_header 'Content-Security-Policy' "default-src 'self';img-src 'self';style-src 'unsafe-inline' 'self';connect-src $ENABLED_CONNECT_SRC; font-src 'self' https://fonts.gstatic.com https://fonts.googleapis.com; base-uri 'self'; object-src https://nrs.objectstore.gov.bc.ca; frame-src https://nrs.objectstore.gov.bc.ca;";
add_header 'Content-Security-Policy' "default-src 'self'; img-src 'self'; style-src 'unsafe-inline' 'self'; connect-src $ENABLED_CONNECT_SRC https://spm.apps.gov.bc.ca; font-src 'self' https://fonts.gstatic.com https://fonts.googleapis.com; base-uri 'self'; object-src https://nrs.objectstore.gov.bc.ca; frame-src https://nrs.objectstore.gov.bc.ca; script-src 'self' https://www2.gov.bc.ca 'sha256-evje5KswYvntfuZqc5jmvUSANhIntI7Or6vVnjxGGQE=';";
add_header 'Permissions-Policy' 'camera=(), geolocation=(), microphone=()';
add_header 'Referrer-Policy' 'same-origin';

Expand Down
1 change: 1 addition & 0 deletions portal-frontend/src/app/app.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ export class AppComponent implements OnInit {
this.router.events.subscribe((event) => {
if (event instanceof NavigationEnd) {
this.showHeaderFooter = !event.url.includes('/alcs/');
(window as any).snowplow('trackPageView');
}
});
}
Expand Down
30 changes: 30 additions & 0 deletions portal-frontend/src/assets/snowplow.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
// <!-- Snowplow starts plowing - Standalone vE.2.14.0 -->
(function(p, l, o, w, i, n, g) {
if (!p[i]) {
p.GlobalSnowplowNamespace = p.GlobalSnowplowNamespace || [];
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");
var collector = "spm.apps.gov.bc.ca";
window.snowplow("newTracker", "rt", collector, {
appId: "Snowplow_standalone",
cookieLifetime: 86400 * 548,
platform: "web",
post: true,
forceSecureTracker: true,
contexts: {
webPage: true, performanceTiming: true
}
});
window.snowplow("enableActivityTracking", 30, 30); // Ping every 30 seconds after 30 seconds
window.snowplow("enableLinkClickTracking");
// <!-- Snowplow stops plowing -->
36 changes: 1 addition & 35 deletions portal-frontend/src/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -9,41 +9,7 @@
<link href="https://fonts.googleapis.com/icon?family=Material+Icons|Material+Icons+Outlined" rel="stylesheet" />
<!-- Load environment variables -->
<script src="assets/env.js"></script>

<script>
// <!-- Snowplow starts plowing - Standalone vE.2.14.0 -->
(function(p, l, o, w, i, n, g) {
if (!p[i]) {
p.GlobalSnowplowNamespace = p.GlobalSnowplowNamespace || [];
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");
var collector = "spm.apps.gov.bc.ca";
window.snowplow("newTracker", "rt", collector, {
appId: "Snowplow_standalone",
cookieLifetime: 86400 * 548,
platform: "web",
post: true,
forceSecureTracker: true,
contexts: {
webPage: true,
performanceTiming: true
}
});
window.snowplow("enableActivityTracking", 30, 30); // Ping every 30 seconds after 30 seconds
window.snowplow("enableLinkClickTracking");
window.snowplow("trackPageView");
// <!-- Snowplow stops plowing -->
</script>
<script src="assets/snowplow.js"></script>
</head>
<body>
<app-root></app-root>
Expand Down
12 changes: 8 additions & 4 deletions services/config/default.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,9 @@
"AUTH_SERVER": "test.loginproxy.gov.bc.ca",
"AUTH_SERVER_URL": "https://test.loginproxy.gov.bc.ca/auth",
"AUTH_TOKEN_URL": "https://test.loginproxy.gov.bc.ca/auth/realms/standard/protocol/openid-connect/token",
"SCOPES": ["openid"],
"SCOPES": [
"openid"
],
"REALM": "standard"
},
"SITEMINDER": {
Expand Down Expand Up @@ -61,12 +63,14 @@
"MAX_FILE_SIZE": 104857600
},
"REDIS": {
"HOST": "localhost",
"HOST": "redis",
"PORT": "6379",
"PASSWORD": ""
"PASSWORD": "redis"
},
"EMAIL": {
"DEFAULT_ADMINS": [""]
"DEFAULT_ADMINS": [
""
]
},
"GRPC": {
"BIND_URL": "localhost:50057",
Expand Down

0 comments on commit c074ec1

Please sign in to comment.