From f574f4aa1344774ef08caf8c9e2f994c4e7fa30e Mon Sep 17 00:00:00 2001 From: Enzo Volkmann Date: Fri, 13 Sep 2019 17:51:07 +0200 Subject: [PATCH] Added type definitions for "ineum" (#38275) * Added type definitions for "ineum" ineum is the global object used by the Instana Website Monitoring API (https://docs.instana.io/products/website_monitoring/api/) to collect different kinds of information from websites/apps. * Added tests and fixed header lint issue * Fixed test file and added minimum TS version * Merged definitions with same signature, added dummy version number * Made userName and userEmail optional * Removed unnecessary type reference --- types/ineum/index.d.ts | 17 +++++++++++++++++ types/ineum/ineum-tests.ts | 33 +++++++++++++++++++++++++++++++++ types/ineum/tsconfig.json | 23 +++++++++++++++++++++++ types/ineum/tslint.json | 1 + 4 files changed, 74 insertions(+) create mode 100644 types/ineum/index.d.ts create mode 100644 types/ineum/ineum-tests.ts create mode 100644 types/ineum/tsconfig.json create mode 100644 types/ineum/tslint.json diff --git a/types/ineum/index.d.ts b/types/ineum/index.d.ts new file mode 100644 index 0000000000..f7b21259cb --- /dev/null +++ b/types/ineum/index.d.ts @@ -0,0 +1,17 @@ +// Type definitions for non-npm package ineum-browser 1.0 +// Project: https://docs.instana.io/products/website_monitoring/api/ +// Definitions by: Enzo Volkmann +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// TypeScript Version: 3.2 + +// Website Monitoring API from Instana (status: 2019-09-10) + +declare function ineum(command: 'key' | 'reportingUrl' | 'page' | 'traceId', value: string): void; +declare function ineum(command: 'user', userId: string, userName?: string, userEmail?: string): void; +declare function ineum(command: 'meta', key: string, value: string): void; +declare function ineum(command: 'autoClearResourceTimings' | 'wrapEventHandlers' | 'wrapTimers', enable: boolean): void; +declare function ineum(command: 'getPageLoadId'): string | undefined; +declare function ineum(command: 'reportError', error: string, opts?: { + componentStack: string +}): void; +declare function ineum(command: 'ignoreUrls' | 'ignoreErrorMessages' | 'whitelistedOrigins', values: RegExp[]): void; diff --git a/types/ineum/ineum-tests.ts b/types/ineum/ineum-tests.ts new file mode 100644 index 0000000000..b67339003e --- /dev/null +++ b/types/ineum/ineum-tests.ts @@ -0,0 +1,33 @@ +// $ExpectType void +ineum("key", "key"); +// $ExpectType void +ineum("reportingUrl", "reportingUrl"); +// $ExpectType void +ineum("page", "pageName"); +// $ExpectType void +ineum("user", "userId", "userName", "userEmail"); +// $ExpectType void +ineum("meta", "key", "value"); +// $ExpectType void +ineum("traceId", "traceId"); +// $ExpectType void +ineum("ignoreUrls", [/regex/]); +// $ExpectType void +ineum("autoClearResourceTimings", true); +// $ExpectType void +ineum("reportError", "error"); +// $ExpectType void +ineum("reportError", "error", { + componentStack: "stack" +}); +// $ExpectType void +ineum("ignoreErrorMessages", [/regex/]); +// $ExpectType void +ineum("wrapEventHandlers", true); +// $ExpectType void +ineum("wrapTimers", true); +// $ExpectType void +ineum("whitelistedOrigins", [/regex/]); + +// $ExpectType string | undefined +ineum("getPageLoadId"); diff --git a/types/ineum/tsconfig.json b/types/ineum/tsconfig.json new file mode 100644 index 0000000000..64d89597d1 --- /dev/null +++ b/types/ineum/tsconfig.json @@ -0,0 +1,23 @@ +{ + "compilerOptions": { + "module": "commonjs", + "lib": [ + "es6" + ], + "noImplicitAny": true, + "noImplicitThis": true, + "strictFunctionTypes": true, + "strictNullChecks": true, + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": [ + "index.d.ts", + "ineum-tests.ts" + ] +} diff --git a/types/ineum/tslint.json b/types/ineum/tslint.json new file mode 100644 index 0000000000..3db14f85ea --- /dev/null +++ b/types/ineum/tslint.json @@ -0,0 +1 @@ +{ "extends": "dtslint/dt.json" }