plugeen 0.0.4 → 0.0.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/dist/index.d.cts CHANGED
@@ -1,3 +1,42 @@
1
+ declare const ANALYTICS_EVENT_ENUM: readonly ["page_view"];
2
+ type Schemas = {
3
+ events: {
4
+ name: string;
5
+ data: Record<string, unknown> | unknown[];
6
+ };
7
+ analytics: {
8
+ event: (typeof ANALYTICS_EVENT_ENUM)[number];
9
+ url: string;
10
+ title: string;
11
+ sessionId: string;
12
+ referrer?: string;
13
+ screenWidth: number;
14
+ screenHeight: number;
15
+ };
16
+ chats: {
17
+ messages: {
18
+ _id: string;
19
+ identity: Identity;
20
+ text: string;
21
+ createdAt: Date;
22
+ }[];
23
+ };
24
+ experiments: {
25
+ experimentKey: string;
26
+ variant: string;
27
+ metric: string;
28
+ converted: boolean;
29
+ value: number;
30
+ };
31
+ fatureFlags: {
32
+ key: string;
33
+ enabled: boolean;
34
+ value?: string;
35
+ description?: string;
36
+ };
37
+ };
38
+ type PluginName = keyof Schemas;
39
+
1
40
  type Plugin = {
2
41
  identifier: "floating.chat";
3
42
  slug: string;
@@ -8,12 +47,15 @@ type Plugin = {
8
47
  slug: string;
9
48
  identifier: "analytics";
10
49
  };
11
- type Options = {
12
- baseUrl?: string;
13
- accentColor?: string;
50
+ type PlugeenOptions = {
51
+ baseUrl: string;
52
+ accentColor: string;
53
+ foregroundColor: string;
54
+ plugins: PluginName[];
14
55
  };
15
56
  type Identity = {
16
- distinctId: string;
57
+ _id: string;
58
+ id: string;
17
59
  name?: string;
18
60
  email?: string;
19
61
  metadata?: Record<string, unknown>;
@@ -24,18 +66,18 @@ declare global {
24
66
  };
25
67
  }
26
68
 
27
- declare function createSdk(apiKey: string, options?: Partial<Options>): {
69
+ declare const initBaseSdk: (apiKey: string, options: PlugeenOptions) => {
28
70
  events: {
29
71
  create: (eventName: string, data: Record<string, unknown>) => Promise<unknown>;
30
72
  };
31
73
  identities: {
32
- set: (distinctId: string, data?: Omit<Identity, "distinctId">) => Promise<unknown>;
74
+ set: (distinctId: string, data?: Omit<Identity, "_id" | "id">) => Promise<unknown>;
33
75
  };
34
76
  featureFlags: {
35
77
  get: (flagKey: string) => Promise<{
36
78
  key: string;
37
79
  enabled: boolean;
38
- value: unknown;
80
+ value?: string;
39
81
  description?: string;
40
82
  }>;
41
83
  };
@@ -70,4 +112,7 @@ declare function createSdk(apiKey: string, options?: Partial<Options>): {
70
112
  };
71
113
  };
72
114
 
73
- export { type Identity, type Options, type Plugin, createSdk };
115
+ type ModuleConfig = ReturnType<typeof initBaseSdk>;
116
+ declare function createPlugeen(apiKey: string, options?: Partial<PlugeenOptions>): ModuleConfig;
117
+
118
+ export { type Identity, type PlugeenOptions as Options, type Plugin, createPlugeen };
package/dist/index.d.ts CHANGED
@@ -1,3 +1,42 @@
1
+ declare const ANALYTICS_EVENT_ENUM: readonly ["page_view"];
2
+ type Schemas = {
3
+ events: {
4
+ name: string;
5
+ data: Record<string, unknown> | unknown[];
6
+ };
7
+ analytics: {
8
+ event: (typeof ANALYTICS_EVENT_ENUM)[number];
9
+ url: string;
10
+ title: string;
11
+ sessionId: string;
12
+ referrer?: string;
13
+ screenWidth: number;
14
+ screenHeight: number;
15
+ };
16
+ chats: {
17
+ messages: {
18
+ _id: string;
19
+ identity: Identity;
20
+ text: string;
21
+ createdAt: Date;
22
+ }[];
23
+ };
24
+ experiments: {
25
+ experimentKey: string;
26
+ variant: string;
27
+ metric: string;
28
+ converted: boolean;
29
+ value: number;
30
+ };
31
+ fatureFlags: {
32
+ key: string;
33
+ enabled: boolean;
34
+ value?: string;
35
+ description?: string;
36
+ };
37
+ };
38
+ type PluginName = keyof Schemas;
39
+
1
40
  type Plugin = {
2
41
  identifier: "floating.chat";
3
42
  slug: string;
@@ -8,12 +47,15 @@ type Plugin = {
8
47
  slug: string;
9
48
  identifier: "analytics";
10
49
  };
11
- type Options = {
12
- baseUrl?: string;
13
- accentColor?: string;
50
+ type PlugeenOptions = {
51
+ baseUrl: string;
52
+ accentColor: string;
53
+ foregroundColor: string;
54
+ plugins: PluginName[];
14
55
  };
15
56
  type Identity = {
16
- distinctId: string;
57
+ _id: string;
58
+ id: string;
17
59
  name?: string;
18
60
  email?: string;
19
61
  metadata?: Record<string, unknown>;
@@ -24,18 +66,18 @@ declare global {
24
66
  };
25
67
  }
26
68
 
27
- declare function createSdk(apiKey: string, options?: Partial<Options>): {
69
+ declare const initBaseSdk: (apiKey: string, options: PlugeenOptions) => {
28
70
  events: {
29
71
  create: (eventName: string, data: Record<string, unknown>) => Promise<unknown>;
30
72
  };
31
73
  identities: {
32
- set: (distinctId: string, data?: Omit<Identity, "distinctId">) => Promise<unknown>;
74
+ set: (distinctId: string, data?: Omit<Identity, "_id" | "id">) => Promise<unknown>;
33
75
  };
34
76
  featureFlags: {
35
77
  get: (flagKey: string) => Promise<{
36
78
  key: string;
37
79
  enabled: boolean;
38
- value: unknown;
80
+ value?: string;
39
81
  description?: string;
40
82
  }>;
41
83
  };
@@ -70,4 +112,7 @@ declare function createSdk(apiKey: string, options?: Partial<Options>): {
70
112
  };
71
113
  };
72
114
 
73
- export { type Identity, type Options, type Plugin, createSdk };
115
+ type ModuleConfig = ReturnType<typeof initBaseSdk>;
116
+ declare function createPlugeen(apiKey: string, options?: Partial<PlugeenOptions>): ModuleConfig;
117
+
118
+ export { type Identity, type PlugeenOptions as Options, type Plugin, createPlugeen };