analytics icon indicating copy to clipboard operation
analytics copied to clipboard

TypeScript support for analytics-plugin-do-not-track

Open saiichihashimoto opened this issue 3 years ago • 5 comments

Similar to https://github.com/DavidWells/analytics/issues/99, there aren't types for analytics-plugin-do-not-track. I don't want to add the types to https://github.com/DefinitelyTyped/DefinitelyTyped when there's some level of typescript support in some of the projects.

saiichihashimoto avatar Jan 06 '21 00:01 saiichihashimoto

Looks like there are no options for this plugin. https://github.com/DavidWells/analytics/blob/master/packages/analytics-plugin-do-not-track/src/index.js

It just uses the browser do not track settings.

So I guess no types are needed? 😃

DavidWells avatar Jan 14 '21 05:01 DavidWells

import { Analytics } from 'analytics';
import doNotTrackPlugin from 'analytics-plugin-do-not-track';

Analytics({
  plugins: [doNotTrackPlugin()], // <<< This gets mad because `doNotTrackPlugin` has no type and `Analytics` is expecting a plugin type.
  ...
});

saiichihashimoto avatar Jan 14 '21 17:01 saiichihashimoto

Yeah so to use this library with the analytics library, it needs types.

saiichihashimoto avatar Jan 26 '21 17:01 saiichihashimoto

Not sure how to add types here for this.

Maybe this belongs in https://github.com/DefinitelyTyped/DefinitelyTyped ?

DavidWells avatar Jan 29 '21 05:01 DavidWells

Is there a way to export in the package:

declare module 'analytics-plugin-do-not-track' {
	import type { AnalyticsPlugin } from 'analytics';

	export default function doNotTrackPlugin(): AnalyticsPlugin;
}

Because that's all it is

saiichihashimoto avatar Feb 03 '21 18:02 saiichihashimoto