From cbd7f12c7e8b07b61f7aa00fc3ae25f022553f35 Mon Sep 17 00:00:00 2001 From: Owen Pearson Date: Wed, 22 Mar 2023 17:24:53 +0000 Subject: [PATCH] feat: create ably with asset-tracking-js agent --- src/lib/Subscriber.ts | 13 +++++++++++++ tsconfig.json | 3 ++- 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/src/lib/Subscriber.ts b/src/lib/Subscriber.ts index e414e89..194bb9c 100644 --- a/src/lib/Subscriber.ts +++ b/src/lib/Subscriber.ts @@ -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; + } + } +} class Subscriber { ablyOptions: Ably.Types.ClientOptions; @@ -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); } diff --git a/tsconfig.json b/tsconfig.json index d996b02..d7ebafe 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -6,6 +6,7 @@ "strict": true, "esModuleInterop": true, "skipLibCheck": true, - "forceConsistentCasingInFileNames": true + "forceConsistentCasingInFileNames": true, + "resolveJsonModule": true } }