app-usage-events-react
Advanced tools
Comparing version 1.1.4 to 1.1.5
@@ -13,22 +13,5 @@ "use strict"; | ||
exports.captureObservationEvent = void 0; | ||
const simple_in_memory_queue_1 = require("simple-in-memory-queue"); | ||
const AppUsageEvent_1 = require("../../domain/AppUsageEvent"); | ||
const getApplicationOfSession_1 = require("../session/getApplicationOfSession"); | ||
const captureAppUsageEvent_1 = require("./captureAppUsageEvent"); | ||
const observationCaptureQueue = (0, simple_in_memory_queue_1.createQueueWithResilientRemoteConsumer)({ | ||
consumer: ({ item }) => __awaiter(void 0, void 0, void 0, function* () { | ||
yield (0, captureAppUsageEvent_1.captureAppUsageEvent)({ | ||
source: AppUsageEvent_1.AppUsageEventSource.OBSERVATION, | ||
type: item.type, | ||
details: item.details, | ||
}); | ||
}), | ||
threshold: { | ||
concurrency: 1, | ||
retry: 5, | ||
pause: 10, | ||
}, | ||
delay: { | ||
retry: 300, | ||
}, | ||
}); | ||
/** | ||
@@ -48,5 +31,10 @@ * enables programmatically capturing an observation that will be emitted as an app usage event | ||
return; // do nothing on serverside, since no installation-uuid available | ||
yield observationCaptureQueue.push({ type, details }); | ||
yield (0, getApplicationOfSession_1.waitForApplicationOfSession)(); | ||
yield (0, captureAppUsageEvent_1.captureAppUsageEvent)({ | ||
source: AppUsageEvent_1.AppUsageEventSource.OBSERVATION, | ||
type, | ||
details, | ||
}); | ||
}); | ||
exports.captureObservationEvent = captureObservationEvent; | ||
//# sourceMappingURL=captureObservationEvent.js.map |
import { AppUsageApplication } from '../../domain/AppUsageApplication'; | ||
export declare const setApplicationOfSession: (set: AppUsageApplication) => AppUsageApplication; | ||
export declare const getApplicationOfSession: () => AppUsageApplication; | ||
export declare const sleep: (ms: number) => Promise<unknown>; | ||
export declare const waitForApplicationOfSession: () => Promise<AppUsageApplication>; |
"use strict"; | ||
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { | ||
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } | ||
return new (P || (P = Promise))(function (resolve, reject) { | ||
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } | ||
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } | ||
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } | ||
step((generator = generator.apply(thisArg, _arguments || [])).next()); | ||
}); | ||
}; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.getApplicationOfSession = exports.setApplicationOfSession = void 0; | ||
exports.waitForApplicationOfSession = exports.sleep = exports.getApplicationOfSession = exports.setApplicationOfSession = void 0; | ||
// track the application in memory | ||
@@ -14,2 +23,13 @@ let application = null; | ||
exports.getApplicationOfSession = getApplicationOfSession; | ||
const sleep = (ms) => new Promise((resolve) => setTimeout(resolve, ms)); | ||
exports.sleep = sleep; | ||
const waitForApplicationOfSession = () => __awaiter(void 0, void 0, void 0, function* () { | ||
for (let attempt = 0; attempt < 5; attempt++) { | ||
if (application) | ||
return application; | ||
yield (0, exports.sleep)(300); | ||
} | ||
throw new Error('application wait attempts exceeded'); | ||
}); | ||
exports.waitForApplicationOfSession = waitForApplicationOfSession; | ||
//# sourceMappingURL=getApplicationOfSession.js.map |
@@ -5,3 +5,3 @@ { | ||
"description": "A set of types, type checks, and type guards for simpler, safer, and easier to read code.", | ||
"version": "1.1.4", | ||
"version": "1.1.5", | ||
"repository": "mhetrics/app-usage-events-react", | ||
@@ -8,0 +8,0 @@ "homepage": "https://github.com/mhetrics/app-usage-events-react", |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
157395
2376