Skip to content

Commit

Permalink
fix: address comments
Browse files Browse the repository at this point in the history
  • Loading branch information
marco-ippolito committed Nov 22, 2024
1 parent 93d867d commit cbda681
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 7 deletions.
9 changes: 8 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,14 @@ hdcli tracker run

```bash
# Send information about your project manifest files
hdcli report ingestion
hdcli report generate
```

It is possible to change the server to which the report is sent by setting the `HD_REPORT_URL` environment variable.

```bash
# Send information about your project manifest files
NES_REPORT_URL="https://example.com/graphql" hdcli report generate
```

## Tutorials
Expand Down
6 changes: 3 additions & 3 deletions libs/report/ingestion/src/lib/ingestion.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@ import { findManifestFile, getClientToken, sendManifest } from './send-manifest'
import { type Options } from './types';

export const reportIngestionCommand: CommandModule<object, Options> = {
command: 'ingestion',
command: 'generate',
describe: 'send manifest files information',
aliases: ['ingest', 'i'],
aliases: ['gen', 'g'],
builder: {
consent: {
describe: 'Agree to understanding that sensitive data may be outputted',
describe: 'I understand that sensitive data may be uploaded to the server',
required: false,
default: false,
boolean: true,
Expand Down
17 changes: 14 additions & 3 deletions libs/report/ingestion/src/lib/send-manifest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,23 +4,33 @@ import { TELEMETRY_INITIALIZE_MUTATION, TELEMETRY_REPORT_MUTATION } from './quer
import { type JSONValue } from './types';
import { promptToProceedUploadFile } from './prompts';

const NES_REPORT_URL = process.env['NES_REPORT_URL'] || 'https://api.nes.herodevs.com/graphql';

const client = new ApolloClient({
cache: new InMemoryCache(),
uri: 'https://api.nes.herodevs.com/graphql',
uri: NES_REPORT_URL,
});

// I don't think this is the right key please change it :)
const MANIFEST_TELEMETRY_KEY = 'd7:diagnostics:report';
const MANIFEST_TELEMETRY_KEY = 'ingest:project:report';

// This is the list of files that we are going to look for
const MANIFEST_FILES = [{ name: 'package.json' }];

const MAX_FILE_SIZE = 5e6; // 5MB

function getUserAgent() {
return `hdcli/${process.env['npm_package_version'] ?? 'unknown'}`;
}

export async function initializeTelemetry(clientName: string) {
return client.mutate({
mutation: TELEMETRY_INITIALIZE_MUTATION,
variables: { clientName },
context: {
headers: {
'User-Agent': getUserAgent(),
},
},
});
}

Expand All @@ -36,6 +46,7 @@ export async function sendTelemetryReport(
context: {
headers: {
'x-nes-telrep': oid,
'User-Agent': getUserAgent(),
},
},
});
Expand Down

0 comments on commit cbda681

Please sign in to comment.