Skip to content

Commit

Permalink
updated @microsoft/applicationinsights-web to v3.3.0 from v3.0.7 and …
Browse files Browse the repository at this point in the history
…added tracking to Muse recordings
  • Loading branch information
TemitopeAsama committed Aug 1, 2024
1 parent d239f4d commit be7bfab
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 2 deletions.
2 changes: 1 addition & 1 deletion frontend/package-lock.json

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

2 changes: 1 addition & 1 deletion frontend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
"@hookform/resolvers": "^3.1.1",
"@magic-sdk/admin": "^2.0.0",
"@microsoft/applicationinsights-react-js": "^17.3.0",
"@microsoft/applicationinsights-web": "^3.3.0",
"@microsoft/applicationinsights-web": "^3.0.7",
"@neurosity/pipes": "^5.2.1",
"@neurosity/sdk": "^6.5.9",
"@radix-ui/react-accordion": "^1.1.2",
Expand Down
18 changes: 18 additions & 0 deletions frontend/src/services/integrations/muse.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import dayjs from "dayjs";
import { downloadDataAsZip, getCSVFile, writeToLocalStorage } from "../storage.service";
import { createHash } from "crypto";
import { getFileHash, signData } from "../signer.service";
import { appInsights } from "~/utils/appInsights";

export const MUSE_SAMPLING_RATE = 256;
export const MUSE_CHANNELS = ["TP9", "AF7", "AF8", "TP10"];
Expand Down Expand Up @@ -172,10 +173,20 @@ export class MuseEEGService {
this.recordingStartTimestamp = dayjs().valueOf();
this.recordingStatus = "started";
this.museClient.start();

appInsights.trackEvent({ name: 'start_muse_recording_init', properties: {
device: this.museClient.deviceInfo,
timeStamp: this.recordingStartTimestamp,
status: this.recordingStatus
}})
}

async stopRecording(withDownload = false, signDataset = false) {
this.museClient.pause();
appInsights.trackEvent({ name: 'stop_muse_recording_init', properties: {
device: this.museClient.deviceInfo,
timeStamp: this.recordingStartTimestamp,
}})
// prepare files for download
const datasetExport: DatasetExport = {
fileNames: [`rawBrainwaves_${this.recordingStartTimestamp}.csv`, `events_${this.recordingStartTimestamp}.csv`],
Expand Down Expand Up @@ -210,6 +221,11 @@ export class MuseEEGService {
}

try {
appInsights.trackEvent({ name: 'download_muse_recording_data', properties: {
device: this.museClient.deviceInfo,
timeStamp: this.recordingStartTimestamp,
status: this.recordingStatus
}})
if (withDownload) {
await downloadDataAsZip(datasetExport, `fusionDataExport`, dayjs.unix(this.recordingStartTimestamp));
} else {
Expand All @@ -226,6 +242,8 @@ export class MuseEEGService {
this.accelerometerSeries = [];
this.recordingStartTimestamp = 0;
this.recordingStatus = "stopped";

appInsights.trackEvent({ name: 'stop_muse_recording_completed'})
}
}
}
5 changes: 5 additions & 0 deletions frontend/src/services/integrations/neurosity.service.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,13 @@
import { Neurosity, WebBluetoothTransport } from "@neurosity/sdk";
import { Epoch, PSD } from "@neurosity/sdk/dist/esm/types/brainwaves";
import axios from "axios";
import dayjs from "dayjs";
// eslint-disable-next-line import/no-extraneous-dependencies
import { takeWhile } from "rxjs";
import * as path from "path";
import * as Papa from "papaparse";
import { promises as fsPromises } from "fs";
import JSZip, { JSZipFileOptions } from "jszip";
import { DatasetExport, EventData, IExperiment } from "~/@types";
import { downloadDataAsZip } from "../storage.service";
import { channel } from "diagnostics_channel";
Expand Down

0 comments on commit be7bfab

Please sign in to comment.