From 0026429ae69344eed3999703ff3b233d9862847a Mon Sep 17 00:00:00 2001 From: Russell Dempsey <1173416+SgtPooki@users.noreply.github.com> Date: Wed, 18 Jan 2023 16:41:15 -0800 Subject: [PATCH] fix: importing into starmap project --- .eslintignore | 1 + package.json | 10 ++++++++++ src/BrowserMetrics.ts | 4 +++- src/MetricsProvider.ts | 2 +- src/NodeMetrics.ts | 4 +++- src/index.ts | 4 ++++ src/types/countly.d.ts | 8 ++++---- src/types/{index.ts => index.d.ts} | 0 tsconfig.json | 5 ++++- 9 files changed, 30 insertions(+), 8 deletions(-) create mode 100644 .eslintignore rename src/types/{index.ts => index.d.ts} (100%) diff --git a/.eslintignore b/.eslintignore new file mode 100644 index 0000000..1521c8b --- /dev/null +++ b/.eslintignore @@ -0,0 +1 @@ +dist diff --git a/package.json b/package.json index 00a6109..d3975ec 100644 --- a/package.json +++ b/package.json @@ -38,6 +38,16 @@ "browser": "./dist/src/BrowserMetrics.js", "import": "./dist/src/NodeMetrics.js" }, + "./browser-vanilla": { + "types": "./dist/src/BrowserMetrics.d.ts", + "browser": "./dist/src/BrowserMetrics.js", + "import": "./dist/src/BrowserMetrics.js" + }, + "./node-vanilla": { + "types": "./dist/src/NodeMetrics.d.ts", + "node": "./dist/src/NodeMetrics.js", + "import": "./dist/src/NodeMetrics.js" + }, "./*": { "types": "./dist/src/*.d.ts", "import": "./dist/src/*.js" diff --git a/src/BrowserMetrics.ts b/src/BrowserMetrics.ts index fe30e8e..09fa2f0 100644 --- a/src/BrowserMetrics.ts +++ b/src/BrowserMetrics.ts @@ -2,8 +2,10 @@ import Countly from 'countly-sdk-web' import MetricsProvider, { MetricsProviderConstructorOptions } from './MetricsProvider.js' -export default class BrowserMetricsProvider extends MetricsProvider { +export class BrowserMetricsProvider extends MetricsProvider { constructor (args: Omit, 'metricsService'>) { super({ ...args, metricsService: Countly }) } } + +export default BrowserMetricsProvider diff --git a/src/MetricsProvider.ts b/src/MetricsProvider.ts index fe38cf2..c1d3150 100644 --- a/src/MetricsProvider.ts +++ b/src/MetricsProvider.ts @@ -10,7 +10,7 @@ export interface MetricsProviderConstructorOptions { metricsService: T } -export default class MetricsProvider { +export default class MetricsProvider { private readonly groupedFeatures: Record = this.mapAllEvents({ minimal: ['sessions', 'views', 'events'], performance: ['crashes', 'apm'], diff --git a/src/NodeMetrics.ts b/src/NodeMetrics.ts index 1fdff5c..46a71e7 100644 --- a/src/NodeMetrics.ts +++ b/src/NodeMetrics.ts @@ -2,8 +2,10 @@ import Countly from 'countly-sdk-nodejs' import MetricsProvider, { MetricsProviderConstructorOptions } from './MetricsProvider.js' -export default class NodeMetricsProvider extends MetricsProvider { +export class NodeMetricsProvider extends MetricsProvider { constructor (args: Omit, 'metricsService'>) { super({ ...args, metricsService: Countly }) } } + +export default NodeMetricsProvider diff --git a/src/index.ts b/src/index.ts index bb16aeb..43115db 100644 --- a/src/index.ts +++ b/src/index.ts @@ -1,2 +1,6 @@ export * from './components/index.js' +export * from './config.js' +export * from './BrowserMetrics.js' export * from './MetricsProvider.js' +export * from './NodeMetrics.js' +export * from './types/index.js' diff --git a/src/types/countly.d.ts b/src/types/countly.d.ts index 7d6bbca..d50df1b 100644 --- a/src/types/countly.d.ts +++ b/src/types/countly.d.ts @@ -24,10 +24,10 @@ declare module 'countly-sdk-web' { type IgnoreList = Array type CountlyEventQueueItem = [string, CountlyEventData] | [eventName: string, key: string] | [eventName: string] export interface CountlyWebSdk { - group_features: (arg0: Record) => unknown - check_consent: (consentFeature: metricFeatures | consentTypes) => boolean - add_consent: (consentFeature: consentTypes | consentTypes[]) => void - remove_consent: (consentFeature: consentTypes | consentTypes[], enforceConsentUpdate?: boolean) => void + group_features: (arg0: Record) => unknown + check_consent: (consentFeature: metricFeatures | import('./index.js').consentTypes) => boolean + add_consent: (consentFeature: import('./index.js').consentTypes | Array) => void + remove_consent: (consentFeature: import('./index.js').consentTypes | Array, enforceConsentUpdate?: boolean) => void require_consent: boolean init: (configOptions?: Partial) => void /** diff --git a/src/types/index.ts b/src/types/index.d.ts similarity index 100% rename from src/types/index.ts rename to src/types/index.d.ts diff --git a/tsconfig.json b/tsconfig.json index 8fceed5..9f8b9b3 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -6,7 +6,10 @@ "outDir": "dist", "target": "ES6", "allowSyntheticDefaultImports": true, - "moduleResolution": "NodeNext" + "moduleResolution": "NodeNext", + "typeRoots": [ + "src/types" + ], }, "include": [ "src",