Skip to content

Commit

Permalink
give hashes prefixes, disable source maps
Browse files Browse the repository at this point in the history
  • Loading branch information
grahamc committed Mar 13, 2024
1 parent ded2327 commit fee480e
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 21 deletions.
20 changes: 9 additions & 11 deletions dist/index.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion dist/index.js.map

This file was deleted.

1 change: 0 additions & 1 deletion dist/sourcemap-register.cjs

This file was deleted.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
"build": "tsc",
"format": "prettier --write '**/*.ts'",
"lint": "eslint src/**/*.ts",
"package": "ncc build --source-map --license licenses.txt",
"package": "ncc build --license licenses.txt",
"all": "npm run build && npm run format && npm run lint && npm run package"
},
"repository": {
Expand Down
17 changes: 10 additions & 7 deletions src/correlation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,30 +14,30 @@ export function identify(): AnonymizedCorrelationHashes {
const ident = {
correlation_source: "github-actions",

repository: hashEnvironmentVariables([
repository: hashEnvironmentVariables("GHR", [
"GITHUB_SERVER_URL",
"GITHUB_REPOSITORY_OWNER",
"GITHUB_REPOSITORY_OWNER_ID",
"GITHUB_REPOSITORY",
"GITHUB_REPOSITORY_ID",
]),
workflow: hashEnvironmentVariables([
workflow: hashEnvironmentVariables("GHW", [
"GITHUB_SERVER_URL",
"GITHUB_REPOSITORY_OWNER",
"GITHUB_REPOSITORY_OWNER_ID",
"GITHUB_REPOSITORY",
"GITHUB_REPOSITORY_ID",
"GITHUB_WORKFLOW",
]),
run: hashEnvironmentVariables([
run: hashEnvironmentVariables("GHWR", [
"GITHUB_SERVER_URL",
"GITHUB_REPOSITORY_OWNER",
"GITHUB_REPOSITORY_OWNER_ID",
"GITHUB_REPOSITORY",
"GITHUB_REPOSITORY_ID",
"GITHUB_RUN_ID",
]),
run_differentiator: hashEnvironmentVariables([
run_differentiator: hashEnvironmentVariables("GHWA", [
"GITHUB_SERVER_URL",
"GITHUB_REPOSITORY_OWNER",
"GITHUB_REPOSITORY_OWNER_ID",
Expand All @@ -49,7 +49,7 @@ export function identify(): AnonymizedCorrelationHashes {
]),
groups: {
ci: "github-actions",
github_organization: hashEnvironmentVariables([
github_organization: hashEnvironmentVariables("GHO", [
"GITHUB_SERVER_URL",
"GITHUB_REPOSITORY_OWNER",
"GITHUB_REPOSITORY_OWNER_ID",
Expand All @@ -63,7 +63,10 @@ export function identify(): AnonymizedCorrelationHashes {
return ident;
}

function hashEnvironmentVariables(variables: string[]): undefined | string {
function hashEnvironmentVariables(
prefix: string,
variables: string[],
): undefined | string {
const hash = createHash("sha256");

for (const varName of variables) {
Expand All @@ -79,5 +82,5 @@ function hashEnvironmentVariables(variables: string[]): undefined | string {
}
}

return hash.digest("hex");
return `${prefix}-${hash.digest("hex")}`;
}

0 comments on commit fee480e

Please sign in to comment.