Skip to content

Commit

Permalink
feat: create ably with asset-tracking-js agent
Browse files Browse the repository at this point in the history
  • Loading branch information
owenpearson committed Mar 24, 2023
1 parent 46a8ac6 commit cbd7f12
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
13 changes: 13 additions & 0 deletions src/lib/Subscriber.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,16 @@ import * as Ably from 'ably';
import { Resolution, SubscriberOptions } from '../types';
import Asset from './Asset';
import Logger from './utils/Logger';
import { version } from '../../package.json';

declare module 'ably' {
// eslint-disable-next-line @typescript-eslint/no-namespace
export namespace Types {
export interface ClientOptions {
agents?: Record<string, string>;
}
}
}

class Subscriber {
ablyOptions: Ably.Types.ClientOptions;
Expand All @@ -12,6 +22,9 @@ class Subscriber {
constructor(options: SubscriberOptions) {
this.logger = new Logger(options.loggerOptions);
this.ablyOptions = options.ablyOptions;
this.ablyOptions.agents = {
'ably-asset-tracking-js': version,
};
this.assets = new Map();
this.client = new Ably.Realtime.Promise(this.ablyOptions);
}
Expand Down
3 changes: 2 additions & 1 deletion tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
"strict": true,
"esModuleInterop": true,
"skipLibCheck": true,
"forceConsistentCasingInFileNames": true
"forceConsistentCasingInFileNames": true,
"resolveJsonModule": true
}
}

0 comments on commit cbd7f12

Please sign in to comment.