|
| 1 | +const { Worker, isMainThread } = require('worker_threads'); |
1 | 2 | const readline = require('readline-sync');
|
2 |
| -let appInsights = require("applicationinsights"); |
3 |
| -let connectionString = 'InstrumentationKey=c764f176-19a5-4949-825d-9f30db2f14e8;IngestionEndpoint=https://germanywestcentral-1.in.applicationinsights.azure.com'; |
4 |
| - |
5 |
| -class questions { |
6 |
| - constructor () { |
7 |
| - this.askAge = this.askAge.bind(this) |
8 |
| - } |
9 |
| - |
10 |
| - askAge() { |
11 |
| - var age = readline.question("What is your age? "); |
12 |
| - client.trackEvent({name: "age entered", properties: {age: age}}); |
13 |
| - } |
| 3 | + |
| 4 | +let telemetryWorker = new Worker("./TelemetryClient/telemetryClient2.js"); |
| 5 | +telemetryWorker.postMessage({eventName: 'Application started', properties: {Technology: 'Node.js5'}}); |
| 6 | + |
| 7 | +var name = readline.question("What is your name? "); |
| 8 | +telemetryWorker.postMessage({eventName: 'Name entered', properties: {Name: name}}); |
| 9 | + |
| 10 | +var age = readline.question("What is your age? "); |
| 11 | +telemetryWorker.postMessage({eventName: 'Age entered', properties: {Age: age}}); |
| 12 | + |
| 13 | +//client.trackEvent({name: "name entered", properties: {name: name}}); |
| 14 | +//client.flush({callback: this.askAge}); |
| 15 | + |
| 16 | +// class questions { |
| 17 | +// constructor () { |
| 18 | +// this.askAge = this.askAge.bind(this) |
| 19 | +// } |
| 20 | + |
| 21 | +// askAge() { |
| 22 | +// var age = readline.question("What is your age? "); |
| 23 | +// client.trackEvent({name: "age entered", properties: {age: age}}); |
| 24 | +// } |
| 25 | + |
| 26 | +// askName() { |
| 27 | +// var name = readline.question("What is your name? "); |
| 28 | +// client.trackEvent({name: "name entered", properties: {name: name}}); |
| 29 | +// client.flush({callback: this.askAge}); |
| 30 | +// } |
| 31 | + |
| 32 | +// } |
| 33 | + |
| 34 | +// let q = new questions() |
| 35 | + |
| 36 | +// appInsights.setup(connectionString).setAutoCollectConsole(true).start(); |
| 37 | +// let client = appInsights.defaultClient; |
| 38 | +// client.trackEvent({name: "my custom event", properties: {myProp: "custom property value 2"}}); |
| 39 | + |
| 40 | +// client.flush({callback: q.askName()}); |
| 41 | + |
| 42 | + |
| 43 | + |
| 44 | + |
| 45 | + |
| 46 | + |
| 47 | + |
| 48 | + |
| 49 | + |
| 50 | +// const readline = require('readline-sync'); |
| 51 | +// let appInsights = require("applicationinsights"); |
| 52 | +// let connectionString = 'InstrumentationKey=c764f176-19a5-4949-825d-9f30db2f14e8;IngestionEndpoint=https://germanywestcentral-1.in.applicationinsights.azure.com'; |
| 53 | + |
| 54 | +// class questions { |
| 55 | +// constructor () { |
| 56 | +// this.askAge = this.askAge.bind(this) |
| 57 | +// } |
| 58 | + |
| 59 | +// askAge() { |
| 60 | +// var age = readline.question("What is your age? "); |
| 61 | +// client.trackEvent({name: "age entered", properties: {age: age}}); |
| 62 | +// } |
14 | 63 |
|
15 |
| - askName() { |
16 |
| - var name = readline.question("What is your name? "); |
17 |
| - client.trackEvent({name: "name entered", properties: {name: name}}); |
18 |
| - client.flush({callback: this.askAge}); |
19 |
| - } |
| 64 | +// askName() { |
| 65 | +// var name = readline.question("What is your name? "); |
| 66 | +// client.trackEvent({name: "name entered", properties: {name: name}}); |
| 67 | +// client.flush({callback: this.askAge}); |
| 68 | +// } |
20 | 69 |
|
21 |
| -} |
| 70 | +// } |
22 | 71 |
|
23 |
| -let q = new questions() |
| 72 | +// let q = new questions() |
24 | 73 |
|
25 |
| -appInsights.setup(connectionString).setAutoCollectConsole(true).start(); |
26 |
| -let client = appInsights.defaultClient; |
27 |
| -client.trackEvent({name: "my custom event", properties: {myProp: "custom property value 2"}}); |
| 74 | +// appInsights.setup(connectionString).setAutoCollectConsole(true).start(); |
| 75 | +// let client = appInsights.defaultClient; |
| 76 | +// client.trackEvent({name: "my custom event", properties: {myProp: "custom property value 2"}}); |
28 | 77 |
|
29 |
| -client.flush({callback: q.askName()}); |
| 78 | +// client.flush({callback: q.askName()}); |
0 commit comments