@nu-art/analytics-shared 0.400.7
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/api-def.d.ts +28 -0
- package/api-def.js +7 -0
- package/index.d.ts +2 -0
- package/index.js +2 -0
- package/package.json +33 -0
- package/types.d.ts +49 -0
- package/types.js +1 -0
package/api-def.d.ts
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { ApiDefResolver, BodyApi } from '@nu-art/thunderstorm-shared';
|
|
2
|
+
import { TSAnalyticsEvent } from './types.js';
|
|
3
|
+
export type Analytics_SendEvent = {
|
|
4
|
+
request: {
|
|
5
|
+
event: TSAnalyticsEvent;
|
|
6
|
+
};
|
|
7
|
+
response: void;
|
|
8
|
+
};
|
|
9
|
+
export type Analytics_UpdateUser = {
|
|
10
|
+
request: {
|
|
11
|
+
mode: 'set' | 'set_once';
|
|
12
|
+
userData: {
|
|
13
|
+
userId: string;
|
|
14
|
+
firstName?: string;
|
|
15
|
+
lastName?: string;
|
|
16
|
+
displayName?: string;
|
|
17
|
+
[key: string]: any;
|
|
18
|
+
};
|
|
19
|
+
};
|
|
20
|
+
response: void;
|
|
21
|
+
};
|
|
22
|
+
export type ApiStruct_Analytics = {
|
|
23
|
+
_v1: {
|
|
24
|
+
sendEvent: BodyApi<Analytics_SendEvent['response'], Analytics_SendEvent['request']>;
|
|
25
|
+
updateUser: BodyApi<Analytics_UpdateUser['response'], Analytics_UpdateUser['request']>;
|
|
26
|
+
};
|
|
27
|
+
};
|
|
28
|
+
export declare const ApiDef_Analytics: (baseUrl?: string) => ApiDefResolver<ApiStruct_Analytics>;
|
package/api-def.js
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { HttpMethod } from '@nu-art/thunderstorm-shared';
|
|
2
|
+
export const ApiDef_Analytics = (baseUrl) => ({
|
|
3
|
+
_v1: {
|
|
4
|
+
sendEvent: { baseUrl, method: HttpMethod.POST, path: '/v1/analytics/send-event' },
|
|
5
|
+
updateUser: { baseUrl, method: HttpMethod.POST, path: '/v1/analytics/update-user' },
|
|
6
|
+
}
|
|
7
|
+
});
|
package/index.d.ts
ADDED
package/index.js
ADDED
package/package.json
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@nu-art/analytics-shared",
|
|
3
|
+
"version": "0.400.7",
|
|
4
|
+
"description": "Analytics Shared",
|
|
5
|
+
"license": "Apache-2.0",
|
|
6
|
+
"scripts": {
|
|
7
|
+
"build": "tsc"
|
|
8
|
+
},
|
|
9
|
+
"publishConfig": {
|
|
10
|
+
"directory": "dist",
|
|
11
|
+
"linkDirectory": true
|
|
12
|
+
},
|
|
13
|
+
"dependencies": {
|
|
14
|
+
"@nu-art/ts-common": "0.400.7",
|
|
15
|
+
"@nu-art/thunderstorm-shared": "0.400.7"
|
|
16
|
+
},
|
|
17
|
+
"devDependencies": {},
|
|
18
|
+
"private": false,
|
|
19
|
+
"unitConfig": {
|
|
20
|
+
"type": "typescript-lib"
|
|
21
|
+
},
|
|
22
|
+
"type": "module",
|
|
23
|
+
"exports": {
|
|
24
|
+
".": {
|
|
25
|
+
"types": "./index.d.ts",
|
|
26
|
+
"import": "./index.js"
|
|
27
|
+
},
|
|
28
|
+
"./*": {
|
|
29
|
+
"types": "./*.d.ts",
|
|
30
|
+
"import": "./*.js"
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
}
|
package/types.d.ts
ADDED
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { TypedMap, UniqueId } from '@nu-art/ts-common';
|
|
2
|
+
/**
|
|
3
|
+
* Contextual metadata describing the environment in which the event occurred.
|
|
4
|
+
* This includes device, OS, IP, app version, etc.
|
|
5
|
+
*/
|
|
6
|
+
export type TSAnalyticsEventMetadata = {
|
|
7
|
+
/** Device model or type (e.g., 'iPhone 14', 'Desktop') */
|
|
8
|
+
device?: string;
|
|
9
|
+
/** Operating system or platform (e.g., 'iOS', 'Android', 'Windows') */
|
|
10
|
+
os?: string;
|
|
11
|
+
/** IP of the device */
|
|
12
|
+
ip?: string;
|
|
13
|
+
/** Application version (e.g., '1.2.3') */
|
|
14
|
+
appVersion?: string;
|
|
15
|
+
/** Environment the event originated from */
|
|
16
|
+
env?: string;
|
|
17
|
+
/** Any additional context metadata */
|
|
18
|
+
[key: string]: any;
|
|
19
|
+
};
|
|
20
|
+
export type TSAnalyticsEvent = {
|
|
21
|
+
/**
|
|
22
|
+
* The name of the event, used to identify the type of action.
|
|
23
|
+
*/
|
|
24
|
+
key: string;
|
|
25
|
+
/**
|
|
26
|
+
* The timestamp of when the event occurred, in Unix milliseconds.
|
|
27
|
+
*/
|
|
28
|
+
timestamp: number;
|
|
29
|
+
context?: TSAnalyticsEventMetadata;
|
|
30
|
+
/**
|
|
31
|
+
* A dictionary of custom event-specific properties.
|
|
32
|
+
* These describe metadata unique to this event type.
|
|
33
|
+
*/
|
|
34
|
+
properties?: Record<string, any>;
|
|
35
|
+
/**
|
|
36
|
+
* The internal user ID associated with this event.
|
|
37
|
+
* Optional for anonymous or pre-authentication events.
|
|
38
|
+
*/
|
|
39
|
+
userId?: UniqueId;
|
|
40
|
+
/**
|
|
41
|
+
* The group or organization ID associated with the event, if applicable.
|
|
42
|
+
*/
|
|
43
|
+
groups?: TypedMap<UniqueId>;
|
|
44
|
+
/**
|
|
45
|
+
* The session ID this event is part of.
|
|
46
|
+
* Useful for session-level tracking, funnels, and behavior analysis.
|
|
47
|
+
*/
|
|
48
|
+
sessionId?: UniqueId;
|
|
49
|
+
};
|
package/types.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|