Skip to content

Commit 052ce35

Browse files
author
Calvin Allen
committed
NR-381373
- Trying to add an actual exception to the front-end - Add sourcemap upload step to docker build, but only when API_KEY is present, so it won't do it on a normal build, only a publish
1 parent 89bc57b commit 052ce35

File tree

3 files changed

+44
-13
lines changed

3 files changed

+44
-13
lines changed

.github/workflows/publish_image.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ jobs:
5050
FOSSA_API_KEY=${{ secrets.FOSSA_API_KEY }}
5151
NEW_RELIC_METADATA_COMMIT=${{ github.sha }}
5252
NEW_RELIC_METADATA_RELEASE_TAG=${{ github.ref_name }}
53+
NEW_RELIC_API_KEY=${{ secrets.NEW_RELIC_API_KEY }}
5354
5455
- name: Generate artifact attestation
5556
uses: actions/attest-build-provenance@v1

Dockerfile

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,13 +30,15 @@ ARG BROWSER_TRUST_KEY
3030
ARG BROWSER_AGENT_ID
3131
ARG BROWSER_APPLICATION_ID
3232
ARG FOSSA_API_KEY
33+
ARG NEW_RELIC_API_KEY
3334

3435
ENV BROWSER_LICENSE_KEY=$BROWSER_LICENSE_KEY
3536
ENV BROWSER_ACCOUNT_ID=$BROWSER_ACCOUNT_ID
3637
ENV BROWSER_TRUST_KEY=$BROWSER_TRUST_KEY
3738
ENV BROWSER_AGENT_ID=$BROWSER_AGENT_ID
3839
ENV BROWSER_APPLICATION_ID=$BROWSER_APPLICATION_ID
3940
ENV FOSSA_API_KEY=$FOSSA_API_KEY
41+
ENV NEW_RELIC_API_KEY=$NEW_RELIC_API_KEY
4042

4143
RUN --mount=type=cache,target=/root/.gradle ./gradlew downloadNewRelicAgent --console=plain --info --no-daemon --no-watch-fs
4244
RUN --mount=type=cache,target=/root/.gradle ./gradlew build --console=plain --info --no-daemon --no-watch-fs
@@ -52,6 +54,16 @@ RUN if [ -z "$FOSSA_API_KEY" ] ; then \
5254
fossa analyze; \
5355
fi
5456

57+
RUN if [ -z "$NEW_RELIC_API_KEY" ] ; then \
58+
echo --SKIPPING SOURCE MAP UPLOAD ; \
59+
else \
60+
filename=$(ls /src/client/dist/assets/*.js | grep -v '.map.js' | xargs -n 1 basename) && \
61+
curl -H "Api-Key: $NEW_RELIC_API_KEY" \
62+
-F "sourcemap=/src/client/dist/assets/$filename.map" \
63+
-F "javascriptUrl=https://petclinic-demogorgon.staging-service.nr-ops.net/react/assets/$filename" \
64+
https://sourcemaps.service.newrelic.com/v2/applications/$BROWSER_APPLICATION_ID/sourcemaps ;\
65+
fi
66+
5567
FROM base AS final
5668
WORKDIR /app
5769
COPY --from=build /src/build/libs/petclinic-backend-1.0.0.jar .

client/src/pages/Error.tsx

Lines changed: 31 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,38 @@
11
import pets from '/src/assets/images/pets.png';
22

3+
const mapping = new Map<number, string>([
4+
[1,"Dogs"],
5+
[2,"Cats"],
6+
[3,"Horses"],
7+
[4,"Iguanas"],
8+
[5,"Goblin Sharks"]
9+
])
10+
311
export const Error = () => {
12+
const renderListItem = (index: number) => {
13+
const item = mapping.get(index);
414

15+
if(!item){
16+
// @ts-ignore
17+
throw new Error(`No mapping found for index: ${index}`);
18+
}
519

6-
const numbers = [0,1,2];
7-
const theNumber = numbers[10];
20+
return (
21+
<li>{item}</li>
22+
)
23+
}
824

9-
return (
10-
<>
11-
<div className="row">
12-
<div className="col-md-12">
13-
<img className="img-responsive" src={pets} />
14-
</div>
15-
</div>
16-
<h2>Something happened...</h2>
17-
<h3>{theNumber}</h3>
18-
</>
19-
);
25+
return (
26+
<>
27+
<div className="row">
28+
<div className="col-md-12">
29+
<img className="img-responsive" src={pets} />
30+
</div>
31+
</div>
32+
<h3>We currently work with the following animal species:</h3>
33+
<ol>
34+
{[1,2,3,4,5,6].map(i => renderListItem(i))}
35+
</ol>
36+
</>
37+
);
2038
};

0 commit comments

Comments
 (0)