Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 1 addition & 19 deletions package-lock.json

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

3 changes: 1 addition & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,6 @@
"webpack-cli": "^5.1.4"
},
"dependencies": {
"buffer": "^6.0.3",
"nanoid": "^5.1.5"
"buffer": "^6.0.3"
}
}
6 changes: 3 additions & 3 deletions src/AnamClient.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { nanoid } from 'nanoid';
import { ClientError, ErrorCode } from './lib/ClientError';
import { generateCorrelationId } from './lib/correlationId';
import {
ClientMetricMeasurement,
DEFAULT_ANAM_API_VERSION,
Expand Down Expand Up @@ -276,7 +276,7 @@ export default class AnamClient {
throw new Error('Already streaming');
}
// generate a new ID here to track the attempt
const attemptCorrelationId = nanoid();
const attemptCorrelationId = generateCorrelationId();
setMetricsContext({
attemptCorrelationId,
sessionId: null, // reset sessionId
Expand Down Expand Up @@ -342,7 +342,7 @@ export default class AnamClient {
userProvidedAudioStream?: MediaStream,
): Promise<void> {
// generate a new ID here to track the attempt
const attemptCorrelationId = nanoid();
const attemptCorrelationId = generateCorrelationId();
setMetricsContext({
attemptCorrelationId,
sessionId: null, // reset sessionId
Expand Down
9 changes: 9 additions & 0 deletions src/lib/correlationId.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
export function generateCorrelationId() {
// Try native crypto.randomUUID() first (supported in modern browsers)
if (typeof crypto !== 'undefined' && crypto.randomUUID) {
return crypto.randomUUID();
}

// Fallback for older environments and older react native
return Date.now().toString(36) + Math.random().toString(36).substr(2, 9);
}