@ooneex/analytics 0.0.13 → 0.0.14
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/dist/index.js +22 -1
- package/dist/index.js.map +3 -3
- package/package.json +4 -4
package/dist/index.js
CHANGED
|
@@ -1,4 +1,19 @@
|
|
|
1
1
|
// @bun
|
|
2
|
+
var __legacyDecorateClassTS = function(decorators, target, key, desc) {
|
|
3
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
|
|
5
|
+
r = Reflect.decorate(decorators, target, key, desc);
|
|
6
|
+
else
|
|
7
|
+
for (var i = decorators.length - 1;i >= 0; i--)
|
|
8
|
+
if (d = decorators[i])
|
|
9
|
+
r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
10
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
11
|
+
};
|
|
12
|
+
var __legacyMetadataTS = (k, v) => {
|
|
13
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function")
|
|
14
|
+
return Reflect.metadata(k, v);
|
|
15
|
+
};
|
|
16
|
+
|
|
2
17
|
// src/AnalyticsException.ts
|
|
3
18
|
import { Exception } from "@ooneex/exception";
|
|
4
19
|
import { HttpStatus } from "@ooneex/http-status";
|
|
@@ -49,10 +64,16 @@ class PostHogAnalytics {
|
|
|
49
64
|
this.client?.shutdown();
|
|
50
65
|
}
|
|
51
66
|
}
|
|
67
|
+
PostHogAnalytics = __legacyDecorateClassTS([
|
|
68
|
+
decorator.analytics(),
|
|
69
|
+
__legacyMetadataTS("design:paramtypes", [
|
|
70
|
+
Object
|
|
71
|
+
])
|
|
72
|
+
], PostHogAnalytics);
|
|
52
73
|
export {
|
|
53
74
|
decorator,
|
|
54
75
|
PostHogAnalytics,
|
|
55
76
|
AnalyticsException
|
|
56
77
|
};
|
|
57
78
|
|
|
58
|
-
//# debugId=
|
|
79
|
+
//# debugId=09FCEB9520FE124664756E2164756E21
|
package/dist/index.js.map
CHANGED
|
@@ -4,9 +4,9 @@
|
|
|
4
4
|
"sourcesContent": [
|
|
5
5
|
"import { Exception } from \"@ooneex/exception\";\nimport { HttpStatus } from \"@ooneex/http-status\";\n\nexport class AnalyticsException extends Exception {\n constructor(message: string, data: Record<string, unknown> = {}) {\n super(message, {\n status: HttpStatus.Code.InternalServerError,\n data,\n });\n\n this.name = \"AnalyticsException\";\n }\n}\n",
|
|
6
6
|
"import { container, EContainerScope } from \"@ooneex/container\";\nimport type { AnalyticsClassType } from \"./types\";\n\nexport const decorator = {\n analytics: (scope: EContainerScope = EContainerScope.Singleton) => {\n return (target: AnalyticsClassType): void => {\n container.add(target, scope);\n };\n },\n};\n",
|
|
7
|
-
"import { PostHog } from \"posthog-node\";\nimport { AnalyticsException } from \"./AnalyticsException\";\nimport type { IAnalytics, PostHogCaptureOptionsType } from \"./types\";\n\nexport class PostHogAnalytics<T extends PostHogCaptureOptionsType = PostHogCaptureOptionsType>\n implements IAnalytics<T>\n{\n private client: PostHog | null = null;\n\n constructor(options?: { apiKey?: string; host?: string }) {\n const apiKey = options?.apiKey || Bun.env.ANALYTICS_POSTHOG_API_KEY;\n\n if (!apiKey) {\n throw new AnalyticsException(\n \"PostHog API key is required. Please provide an API key either through the constructor options or set the ANALYTICS_POSTHOG_API_KEY environment variable.\",\n );\n }\n\n if (options?.apiKey) {\n this.client = new PostHog(apiKey, {\n host: options.host || Bun.env.ANALYTICS_POSTHOG_HOST || \"https://eu.i.posthog.com\",\n });\n }\n }\n\n public capture(options: T): void {\n this.client?.capture({\n distinctId: options.id,\n event: options.event,\n properties: {\n $set: options.properties,\n },\n timestamp: new Date(),\n ...(options.groups && { groups: options.groups }),\n });\n this.client?.shutdown();\n }\n}\n"
|
|
7
|
+
"import { PostHog } from \"posthog-node\";\nimport { AnalyticsException } from \"./AnalyticsException\";\nimport { decorator } from \"./decorators\";\nimport type { IAnalytics, PostHogCaptureOptionsType } from \"./types\";\n\n@decorator.analytics()\nexport class PostHogAnalytics<T extends PostHogCaptureOptionsType = PostHogCaptureOptionsType>\n implements IAnalytics<T>\n{\n private client: PostHog | null = null;\n\n constructor(options?: { apiKey?: string; host?: string }) {\n const apiKey = options?.apiKey || Bun.env.ANALYTICS_POSTHOG_API_KEY;\n\n if (!apiKey) {\n throw new AnalyticsException(\n \"PostHog API key is required. Please provide an API key either through the constructor options or set the ANALYTICS_POSTHOG_API_KEY environment variable.\",\n );\n }\n\n if (options?.apiKey) {\n this.client = new PostHog(apiKey, {\n host: options.host || Bun.env.ANALYTICS_POSTHOG_HOST || \"https://eu.i.posthog.com\",\n });\n }\n }\n\n public capture(options: T): void {\n this.client?.capture({\n distinctId: options.id,\n event: options.event,\n properties: {\n $set: options.properties,\n },\n timestamp: new Date(),\n ...(options.groups && { groups: options.groups }),\n });\n this.client?.shutdown();\n }\n}\n"
|
|
8
8
|
],
|
|
9
|
-
"mappings": "
|
|
10
|
-
"debugId": "
|
|
9
|
+
"mappings": ";;;;;;;;;;;;;;;;;AAAA;AACA;AAAA;AAEO,MAAM,2BAA2B,UAAU;AAAA,EAChD,WAAW,CAAC,SAAiB,OAAgC,CAAC,GAAG;AAAA,IAC/D,MAAM,SAAS;AAAA,MACb,QAAQ,WAAW,KAAK;AAAA,MACxB;AAAA,IACF,CAAC;AAAA,IAED,KAAK,OAAO;AAAA;AAEhB;;ACZA;AAGO,IAAM,YAAY;AAAA,EACvB,WAAW,CAAC,QAAyB,gBAAgB,cAAc;AAAA,IACjE,OAAO,CAAC,WAAqC;AAAA,MAC3C,UAAU,IAAI,QAAQ,KAAK;AAAA;AAAA;AAGjC;;ACTA;AAMO,MAAM,iBAEb;AAAA,EACU,SAAyB;AAAA,EAEjC,WAAW,CAAC,SAA8C;AAAA,IACxD,MAAM,SAAS,SAAS,UAAU,IAAI,IAAI;AAAA,IAE1C,IAAI,CAAC,QAAQ;AAAA,MACX,MAAM,IAAI,mBACR,0JACF;AAAA,IACF;AAAA,IAEA,IAAI,SAAS,QAAQ;AAAA,MACnB,KAAK,SAAS,IAAI,QAAQ,QAAQ;AAAA,QAChC,MAAM,QAAQ,QAAQ,IAAI,IAAI,0BAA0B;AAAA,MAC1D,CAAC;AAAA,IACH;AAAA;AAAA,EAGK,OAAO,CAAC,SAAkB;AAAA,IAC/B,KAAK,QAAQ,QAAQ;AAAA,MACnB,YAAY,QAAQ;AAAA,MACpB,OAAO,QAAQ;AAAA,MACf,YAAY;AAAA,QACV,MAAM,QAAQ;AAAA,MAChB;AAAA,MACA,WAAW,IAAI;AAAA,SACX,QAAQ,UAAU,EAAE,QAAQ,QAAQ,OAAO;AAAA,IACjD,CAAC;AAAA,IACD,KAAK,QAAQ,SAAS;AAAA;AAE1B;AAjCa,mBAAN;AAAA,EADN,UAAU,UAAU;AAAA,EACd;AAAA;AAAA;AAAA,GAAM;",
|
|
10
|
+
"debugId": "09FCEB9520FE124664756E2164756E21",
|
|
11
11
|
"names": []
|
|
12
12
|
}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ooneex/analytics",
|
|
3
3
|
"description": "Analytics and event tracking integration with PostHog for user behavior insights and product analytics",
|
|
4
|
-
"version": "0.0.
|
|
4
|
+
"version": "0.0.14",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"files": [
|
|
7
7
|
"dist",
|
|
@@ -28,9 +28,9 @@
|
|
|
28
28
|
"npm:publish": "bun publish --tolerate-republish --access public"
|
|
29
29
|
},
|
|
30
30
|
"dependencies": {
|
|
31
|
-
"@ooneex/container": "0.0.
|
|
32
|
-
"@ooneex/exception": "0.0.
|
|
33
|
-
"@ooneex/http-status": "0.0.
|
|
31
|
+
"@ooneex/container": "0.0.14",
|
|
32
|
+
"@ooneex/exception": "0.0.13",
|
|
33
|
+
"@ooneex/http-status": "0.0.13",
|
|
34
34
|
"posthog-node": "^5.11.0"
|
|
35
35
|
},
|
|
36
36
|
"keywords": [
|