@visitor-analytics-sdk/plugins 1.0.0 → 1.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +47 -0
- package/dist/index.d.ts +2 -1
- package/dist/index.js +2 -4
- package/package.json +23 -3
package/README.md
ADDED
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
# @visitor-analytics-sdk/plugins
|
|
2
|
+
|
|
3
|
+
Plugin manager for the visitor-analytics SDK — install/uninstall lifecycle, collector registration, and event bus integration.
|
|
4
|
+
|
|
5
|
+
```bash
|
|
6
|
+
npm install @visitor-analytics-sdk/plugins
|
|
7
|
+
```
|
|
8
|
+
|
|
9
|
+
## Usage
|
|
10
|
+
|
|
11
|
+
```ts
|
|
12
|
+
import { PluginManager } from "@visitor-analytics-sdk/plugins";
|
|
13
|
+
import { EventBus } from "@visitor-analytics-sdk/utils";
|
|
14
|
+
|
|
15
|
+
const eventBus = new EventBus();
|
|
16
|
+
const pluginManager = new PluginManager(eventBus);
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
## Writing a plugin
|
|
20
|
+
|
|
21
|
+
```ts
|
|
22
|
+
import type { Plugin, PluginContext } from "@visitor-analytics-sdk/core";
|
|
23
|
+
|
|
24
|
+
class MyPlugin implements Plugin {
|
|
25
|
+
readonly name = "my-plugin";
|
|
26
|
+
readonly version = "1.0.0";
|
|
27
|
+
readonly description = "Adds custom data to analytics";
|
|
28
|
+
|
|
29
|
+
install(ctx: PluginContext): void {
|
|
30
|
+
ctx.addCollector({
|
|
31
|
+
name: "my-collector",
|
|
32
|
+
category: "custom",
|
|
33
|
+
version: "1.0.0",
|
|
34
|
+
enabled: true,
|
|
35
|
+
collect: async () => ({ /* custom data */ }),
|
|
36
|
+
});
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
uninstall(ctx: PluginContext): void {
|
|
40
|
+
ctx.removeCollector("my-collector");
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
## License
|
|
46
|
+
|
|
47
|
+
MIT
|
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { Plugin, PluginContext, Collector } from '@visitor-analytics-sdk/core';
|
|
2
|
+
import { EventBus } from '@visitor-analytics-sdk/utils';
|
|
2
3
|
|
|
3
4
|
declare class PluginManager {
|
|
4
5
|
private readonly installedPlugins;
|
package/dist/index.js
CHANGED
package/package.json
CHANGED
|
@@ -1,10 +1,29 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@visitor-analytics-sdk/plugins",
|
|
3
|
-
"
|
|
3
|
+
"description": "Plugin manager for the visitor-analytics SDK — install/uninstall lifecycle, collector registration, and event bus integration.",
|
|
4
|
+
"license": "MIT",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"visitor-analytics",
|
|
7
|
+
"plugins",
|
|
8
|
+
"plugin-system",
|
|
9
|
+
"extensibility"
|
|
10
|
+
],
|
|
11
|
+
"repository": {
|
|
12
|
+
"type": "git",
|
|
13
|
+
"url": "git+https://github.com/instax-dutta/visitor-analytics.git"
|
|
14
|
+
},
|
|
15
|
+
"homepage": "https://github.com/instax-dutta/visitor-analytics#readme",
|
|
16
|
+
"bugs": {
|
|
17
|
+
"url": "https://github.com/instax-dutta/visitor-analytics/issues"
|
|
18
|
+
},
|
|
19
|
+
"version": "1.0.1",
|
|
4
20
|
"type": "module",
|
|
5
21
|
"main": "dist/index.js",
|
|
6
22
|
"module": "dist/index.js",
|
|
7
23
|
"types": "dist/index.d.ts",
|
|
24
|
+
"publishConfig": {
|
|
25
|
+
"access": "public"
|
|
26
|
+
},
|
|
8
27
|
"exports": {
|
|
9
28
|
".": {
|
|
10
29
|
"import": "./dist/index.js",
|
|
@@ -15,10 +34,11 @@
|
|
|
15
34
|
"dist"
|
|
16
35
|
],
|
|
17
36
|
"dependencies": {
|
|
18
|
-
"@visitor-analytics-sdk/
|
|
37
|
+
"@visitor-analytics-sdk/utils": "1.0.1",
|
|
38
|
+
"@visitor-analytics-sdk/core": "1.0.1"
|
|
19
39
|
},
|
|
20
40
|
"scripts": {
|
|
21
|
-
"build": "tsup src/index.ts --format esm --dts",
|
|
41
|
+
"build": "tsup src/index.ts --format esm --dts --treeshake",
|
|
22
42
|
"typecheck": "tsc --noEmit"
|
|
23
43
|
}
|
|
24
44
|
}
|