-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
f6eddac
commit 8fcff10
Showing
3 changed files
with
39 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export * from "./registerTelemetry"; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
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}`); | ||
}, | ||
}; | ||
/* *** */ | ||
|
||
let isRegistered = false; | ||
|
||
function registerTelemetry(map: maptilersdk.Map) { | ||
if (isRegistered === true) { | ||
return; | ||
} | ||
|
||
map.telemetry.registerModule(packagejson.name, packagejson.version); | ||
|
||
isRegistered = true; | ||
} | ||
|
||
export { registerTelemetry }; |