diff --git a/src/markerlayout.ts b/src/markerlayout.ts index 0ed70fb..4a2b135 100644 --- a/src/markerlayout.ts +++ b/src/markerlayout.ts @@ -3,7 +3,26 @@ import type { Map as MapSDK, MapGeoJSONFeature, } from "@maptiler/sdk"; -import { registerTelemetry } from "./telemetry"; + +import packagejson from "../package.json"; + +/** + * TODO: Remove when telemetry will be implemented + */ +declare module "@maptiler/sdk" { + interface Map { + telemetry: { + registerModule: (name: string, version: string) => void; + }; + } +} + +MapSDK.prototype.telemetry = { + registerModule: (name: string, version: string) => { + console.log(`Telemetry module registered: ${name} ${version}`); + }, +}; +/* *** */ /** * How the markers are anchored to a given point @@ -222,7 +241,7 @@ export class MarkerLayout { private maxNbFeaturesPerMarker: number = Number.POSITIVE_INFINITY; constructor(map: MapSDK, options: MarkerLayoutOptions = {}) { - registerTelemetry(map); + map.telemetry.registerModule(packagejson.name, packagejson.version); this.map = map; this.layers = options.layers ?? undefined; diff --git a/src/telemetry/index.ts b/src/telemetry/index.ts deleted file mode 100644 index ec7047f..0000000 --- a/src/telemetry/index.ts +++ /dev/null @@ -1 +0,0 @@ -export * from "./registerTelemetry"; diff --git a/src/telemetry/registerTelemetry.ts b/src/telemetry/registerTelemetry.ts deleted file mode 100644 index 5854826..0000000 --- a/src/telemetry/registerTelemetry.ts +++ /dev/null @@ -1,34 +0,0 @@ -import * as maptilersdk from "@maptiler/sdk"; -import packagejson from "../../package.json"; - -/** - * TODO: Remove when telemetry will be implemented - */ -declare module "@maptiler/sdk" { - interface Map { - telemetry: { - registerModule: (name: string, version: string) => void; - }; - } -} - -maptilersdk.Map.prototype.telemetry = { - registerModule: (name: string, version: string) => { - console.log(`Telemetry module registered: ${name} ${version}`); - }, -}; -/* *** */ - -const registeredMaps: Array = []; - -function registerTelemetry(map: maptilersdk.Map) { - if (registeredMaps.includes(map._mapId)) { - return; - } - - map.telemetry.registerModule(packagejson.name, packagejson.version); - - registeredMaps.push(map._mapId); -} - -export { registerTelemetry };