Skip to content
This repository has been archived by the owner on Oct 3, 2024. It is now read-only.

Commit

Permalink
Verify host update with tests
Browse files Browse the repository at this point in the history
  • Loading branch information
davesee committed Oct 12, 2022
1 parent dc938b8 commit abc6c45
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 9 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
node_modules
dist
dist
.env
2 changes: 1 addition & 1 deletion package-lock.json

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

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "azure-log-analytics-data-collector",
"version": "2.2.9",
"version": "2.2.10",
"description": "Node.js wrapper for Azure Log Analytics data collector API",
"main": "./dist/index.js",
"exports": "./dist/index.js",
Expand Down Expand Up @@ -49,4 +49,4 @@
"dependencies": {
"node-fetch": "^2.6.7"
}
}
}
4 changes: 2 additions & 2 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ export class DataCollectorClient {
constructor(
private readonly workspaceId: string,
private readonly sharedKey: string,
private readonly host: string
private readonly host: string | undefined
) { }

/**
Expand Down Expand Up @@ -56,7 +56,7 @@ export class DataCollectorClient {
headers["time-generated-field"] = timeGenerated;
}

const hostUrl = (this.host === null || this.host.trim() === "") ? "ods.opinsights.azure.com" : "${this.host}";
const hostUrl = (this.host === null || this.host === undefined) ? "ods.opinsights.azure.com" : this.host;
const url = `https://${this.workspaceId}.${hostUrl}/api/logs?api-version=${API_VERSION}`;

const res = await fetch(url, {
Expand Down
6 changes: 3 additions & 3 deletions test/index.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@ import { DataCollectorClient } from "../src";
describe("The data collector client", () => {
const { LOG_ANALYTICS_HOST, LOG_ANALYTICS_AGENT_KEY, LOG_ANALYTICS_WORKSPACE_ID } = process.env;

if (!LOG_ANALYTICS_HOST || !LOG_ANALYTICS_AGENT_KEY || !LOG_ANALYTICS_WORKSPACE_ID) {
if (!LOG_ANALYTICS_AGENT_KEY || !LOG_ANALYTICS_WORKSPACE_ID) {
throw new Error(
"LOG_ANALYTICS_HOST, LOG_ANALYTICS_AGENT_KEY and LOG_ANALYTICS_WORKSPACE_ID are required"
"LOG_ANALYTICS_AGENT_KEY and LOG_ANALYTICS_WORKSPACE_ID are required"
);
}
const client = new DataCollectorClient(
Expand Down Expand Up @@ -54,7 +54,7 @@ describe("The data collector client", () => {
const client = new DataCollectorClient(
LOG_ANALYTICS_WORKSPACE_ID,
"X" + LOG_ANALYTICS_AGENT_KEY,
"x" + LOG_ANALYTICS_HOST
LOG_ANALYTICS_HOST
);
const res = await client.send("MyLogs", [
{
Expand Down

0 comments on commit abc6c45

Please sign in to comment.