From c626cf89980a9c03f0ddd7b8270fd6a4b6a7f419 Mon Sep 17 00:00:00 2001 From: Raymond Ho Date: Tue, 12 Jun 2018 09:59:20 +1000 Subject: [PATCH 1/3] Add react-amplitude definition --- types/react-amplitude/index.d.ts | 22 +++++++++++++++++++ .../react-amplitude/react-amplitude-tests.ts | 0 types/react-amplitude/tsconfig.json | 22 +++++++++++++++++++ types/react-amplitude/tslint.json | 1 + 4 files changed, 45 insertions(+) create mode 100644 types/react-amplitude/index.d.ts create mode 100644 types/react-amplitude/react-amplitude-tests.ts create mode 100644 types/react-amplitude/tsconfig.json create mode 100644 types/react-amplitude/tslint.json diff --git a/types/react-amplitude/index.d.ts b/types/react-amplitude/index.d.ts new file mode 100644 index 0000000000..151302c198 --- /dev/null +++ b/types/react-amplitude/index.d.ts @@ -0,0 +1,22 @@ +// Type definitions for react-amplitude 0.1 +// Project: https://github.com/rorygarand/react-amplitude +// Definitions by: Raymond Ho +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +export interface AmplitudeInstance { + init(apiKey: string, userId?: string, config?: any, cb?: () => void): void; + amplitude(): void; + clearUserProperties(): void; + getSessionId(): void; + identify(idObj: any, cb: () => void): void; + isNewSession(): void; + logEvent(eventType: string, eventProperties: {}, cb: () => void): void; + logEventWithTimestamp(eventType: string, eventProperties: {}, timestamp: number, cb: () => void): void; + resetUserId(): void; + setUserId(userId: string): void; + setUserProperties(userProps: any): void; +} + +declare const Amplitude: AmplitudeInstance; + +export default Amplitude; \ No newline at end of file diff --git a/types/react-amplitude/react-amplitude-tests.ts b/types/react-amplitude/react-amplitude-tests.ts new file mode 100644 index 0000000000..e69de29bb2 diff --git a/types/react-amplitude/tsconfig.json b/types/react-amplitude/tsconfig.json new file mode 100644 index 0000000000..d1336e9c2c --- /dev/null +++ b/types/react-amplitude/tsconfig.json @@ -0,0 +1,22 @@ +{ + "compilerOptions": { + "module": "commonjs", + "lib": [ + "es6" + ], + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": [ + "index.d.ts", + "react-amplitude-tests.ts" + ] +} diff --git a/types/react-amplitude/tslint.json b/types/react-amplitude/tslint.json new file mode 100644 index 0000000000..3db14f85ea --- /dev/null +++ b/types/react-amplitude/tslint.json @@ -0,0 +1 @@ +{ "extends": "dtslint/dt.json" } From d968c600c50c1c3ca8659f49e2b53156189013cf Mon Sep 17 00:00:00 2001 From: Raymond Ho Date: Tue, 12 Jun 2018 10:21:46 +1000 Subject: [PATCH 2/3] fix lint issues --- types/react-amplitude/index.d.ts | 2 +- types/react-amplitude/react-amplitude-tests.ts | 1 + types/react-amplitude/tsconfig.json | 1 + 3 files changed, 3 insertions(+), 1 deletion(-) diff --git a/types/react-amplitude/index.d.ts b/types/react-amplitude/index.d.ts index 151302c198..c6a9ff3d2d 100644 --- a/types/react-amplitude/index.d.ts +++ b/types/react-amplitude/index.d.ts @@ -19,4 +19,4 @@ export interface AmplitudeInstance { declare const Amplitude: AmplitudeInstance; -export default Amplitude; \ No newline at end of file +export default Amplitude; diff --git a/types/react-amplitude/react-amplitude-tests.ts b/types/react-amplitude/react-amplitude-tests.ts index e69de29bb2..39084405b4 100644 --- a/types/react-amplitude/react-amplitude-tests.ts +++ b/types/react-amplitude/react-amplitude-tests.ts @@ -0,0 +1 @@ +import Amplitude from 'react-amplitude'; diff --git a/types/react-amplitude/tsconfig.json b/types/react-amplitude/tsconfig.json index d1336e9c2c..6f7a8a296e 100644 --- a/types/react-amplitude/tsconfig.json +++ b/types/react-amplitude/tsconfig.json @@ -7,6 +7,7 @@ "noImplicitAny": true, "noImplicitThis": true, "strictNullChecks": true, + "strictFunctionTypes": true, "baseUrl": "../", "typeRoots": [ "../" From 6ab9e1e26ffd5d0a8240fa6c18b8ae1492553d37 Mon Sep 17 00:00:00 2001 From: Raymond Ho Date: Wed, 13 Jun 2018 11:16:25 +1000 Subject: [PATCH 3/3] init Amp --- types/react-amplitude/react-amplitude-tests.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/types/react-amplitude/react-amplitude-tests.ts b/types/react-amplitude/react-amplitude-tests.ts index 39084405b4..f311f8491f 100644 --- a/types/react-amplitude/react-amplitude-tests.ts +++ b/types/react-amplitude/react-amplitude-tests.ts @@ -1 +1,2 @@ import Amplitude from 'react-amplitude'; +Amplitude.init('YOUR_UNIQUE_TRACKING_CODE');