Skip to content

Commit

Permalink
fix: importing into starmap project
Browse files Browse the repository at this point in the history
  • Loading branch information
SgtPooki committed Jan 19, 2023
1 parent ba2db2f commit 0026429
Show file tree
Hide file tree
Showing 9 changed files with 30 additions and 8 deletions.
1 change: 1 addition & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
dist
10 changes: 10 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
4 changes: 3 additions & 1 deletion src/BrowserMetrics.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,10 @@ import Countly from 'countly-sdk-web'

import MetricsProvider, { MetricsProviderConstructorOptions } from './MetricsProvider.js'

export default class BrowserMetricsProvider extends MetricsProvider<typeof Countly> {
export class BrowserMetricsProvider extends MetricsProvider<typeof Countly> {
constructor (args: Omit<MetricsProviderConstructorOptions<typeof Countly>, 'metricsService'>) {
super({ ...args, metricsService: Countly })
}
}

export default BrowserMetricsProvider
2 changes: 1 addition & 1 deletion src/MetricsProvider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ export interface MetricsProviderConstructorOptions<T> {
metricsService: T
}

export default class MetricsProvider<T extends CountlyWebSdk | CountlyNodeSdk> {
export default class MetricsProvider<T extends CountlyWebSdk & CountlyNodeSdk> {
private readonly groupedFeatures: Record<consentTypes, metricFeatures[]> = this.mapAllEvents({
minimal: ['sessions', 'views', 'events'],
performance: ['crashes', 'apm'],
Expand Down
4 changes: 3 additions & 1 deletion src/NodeMetrics.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,10 @@ import Countly from 'countly-sdk-nodejs'

import MetricsProvider, { MetricsProviderConstructorOptions } from './MetricsProvider.js'

export default class NodeMetricsProvider extends MetricsProvider<typeof Countly> {
export class NodeMetricsProvider extends MetricsProvider<typeof Countly> {
constructor (args: Omit<MetricsProviderConstructorOptions<typeof Countly>, 'metricsService'>) {
super({ ...args, metricsService: Countly })
}
}

export default NodeMetricsProvider
4 changes: 4 additions & 0 deletions src/index.ts
Original file line number Diff line number Diff line change
@@ -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'
8 changes: 4 additions & 4 deletions src/types/countly.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,10 @@ declare module 'countly-sdk-web' {
type IgnoreList = Array<string | RegExp>
type CountlyEventQueueItem = [string, CountlyEventData] | [eventName: string, key: string] | [eventName: string]
export interface CountlyWebSdk {
group_features: (arg0: Record<consentTypes, metricFeatures[]>) => 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<import('./index.js').consentTypes, metricFeatures[]>) => unknown
check_consent: (consentFeature: metricFeatures | import('./index.js').consentTypes) => boolean
add_consent: (consentFeature: import('./index.js').consentTypes | Array<import('./index.js').consentTypes>) => void
remove_consent: (consentFeature: import('./index.js').consentTypes | Array<import('./index.js').consentTypes>, enforceConsentUpdate?: boolean) => void
require_consent: boolean
init: (configOptions?: Partial<CountlyWebSdk>) => void
/**
Expand Down
File renamed without changes.
5 changes: 4 additions & 1 deletion tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,10 @@
"outDir": "dist",
"target": "ES6",
"allowSyntheticDefaultImports": true,
"moduleResolution": "NodeNext"
"moduleResolution": "NodeNext",
"typeRoots": [
"src/types"
],
},
"include": [
"src",
Expand Down

0 comments on commit 0026429

Please sign in to comment.