@amplitude/analytics-types 2.0.0-beta.8 → 2.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.
@@ -1,6 +1,7 @@
1
1
  import { AmplitudeReturn } from '../amplitude-promise';
2
- import { NodeOptions } from '../config';
2
+ import { NodeConfig, NodeOptions } from '../config';
3
3
  import { CoreClient } from './core-client';
4
+ import { Plugin } from '../plugin';
4
5
  export interface NodeClient extends CoreClient {
5
6
  /**
6
7
  * Initializes the Amplitude SDK with your apiKey, optional configurations.
@@ -11,5 +12,23 @@ export interface NodeClient extends CoreClient {
11
12
  * ```
12
13
  */
13
14
  init(apiKey: string, options?: NodeOptions): AmplitudeReturn<void>;
15
+ /**
16
+ * Adds a new plugin.
17
+ *
18
+ * ```typescript
19
+ * const plugin = {
20
+ * name: 'my-plugin',
21
+ * type: 'enrichment',
22
+ * async setup(config: NodeConfig, amplitude: NodeClient) {
23
+ * return;
24
+ * },
25
+ * async execute(event: Event) {
26
+ * return event;
27
+ * },
28
+ * };
29
+ * amplitude.add(plugin);
30
+ * ```
31
+ */
32
+ add(plugin: Plugin<NodeClient, NodeConfig>): AmplitudeReturn<void>;
14
33
  }
15
34
  //# sourceMappingURL=node-client.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"node-client.d.ts","sourceRoot":"","sources":["../../../src/client/node-client.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AACvD,OAAO,EAAE,WAAW,EAAE,MAAM,WAAW,CAAC;AACxC,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAE3C,MAAM,WAAW,UAAW,SAAQ,UAAU;IAC5C;;;;;;;OAOG;IACH,IAAI,CAAC,MAAM,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,WAAW,GAAG,eAAe,CAAC,IAAI,CAAC,CAAC;CACpE"}
1
+ {"version":3,"file":"node-client.d.ts","sourceRoot":"","sources":["../../../src/client/node-client.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AACvD,OAAO,EAAE,UAAU,EAAE,WAAW,EAAE,MAAM,WAAW,CAAC;AACpD,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAC3C,OAAO,EAAE,MAAM,EAAE,MAAM,WAAW,CAAC;AAEnC,MAAM,WAAW,UAAW,SAAQ,UAAU;IAC5C;;;;;;;OAOG;IACH,IAAI,CAAC,MAAM,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,WAAW,GAAG,eAAe,CAAC,IAAI,CAAC,CAAC;IAEnE;;;;;;;;;;;;;;;;OAgBG;IACH,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,UAAU,EAAE,UAAU,CAAC,GAAG,eAAe,CAAC,IAAI,CAAC,CAAC;CACpE"}
@@ -1 +1 @@
1
- {"version":3,"file":"node-client.js","sourceRoot":"","sources":["../../../src/client/node-client.ts"],"names":[],"mappings":"","sourcesContent":["import { AmplitudeReturn } from '../amplitude-promise';\nimport { NodeOptions } from '../config';\nimport { CoreClient } from './core-client';\n\nexport interface NodeClient extends CoreClient {\n /**\n * Initializes the Amplitude SDK with your apiKey, optional configurations.\n * This method must be called before any other operations.\n *\n * ```typescript\n * await init(API_KEY, options).promise;\n * ```\n */\n init(apiKey: string, options?: NodeOptions): AmplitudeReturn<void>;\n}\n"]}
1
+ {"version":3,"file":"node-client.js","sourceRoot":"","sources":["../../../src/client/node-client.ts"],"names":[],"mappings":"","sourcesContent":["import { AmplitudeReturn } from '../amplitude-promise';\nimport { NodeConfig, NodeOptions } from '../config';\nimport { CoreClient } from './core-client';\nimport { Plugin } from '../plugin';\n\nexport interface NodeClient extends CoreClient {\n /**\n * Initializes the Amplitude SDK with your apiKey, optional configurations.\n * This method must be called before any other operations.\n *\n * ```typescript\n * await init(API_KEY, options).promise;\n * ```\n */\n init(apiKey: string, options?: NodeOptions): AmplitudeReturn<void>;\n\n /**\n * Adds a new plugin.\n *\n * ```typescript\n * const plugin = {\n * name: 'my-plugin',\n * type: 'enrichment',\n * async setup(config: NodeConfig, amplitude: NodeClient) {\n * return;\n * },\n * async execute(event: Event) {\n * return event;\n * },\n * };\n * amplitude.add(plugin);\n * ```\n */\n add(plugin: Plugin<NodeClient, NodeConfig>): AmplitudeReturn<void>;\n}\n"]}
@@ -1,7 +1,8 @@
1
1
  import { AmplitudeReturn } from '../amplitude-promise';
2
- import { BrowserOptions, ReactNativeOptions } from '../config';
2
+ import { BrowserConfig, BrowserOptions, ReactNativeConfig, ReactNativeOptions } from '../config';
3
3
  import { TransportType } from '../transport';
4
4
  import { CoreClient } from './core-client';
5
+ import { Plugin } from '../plugin';
5
6
  interface Client extends CoreClient {
6
7
  /**
7
8
  * Returns current user ID.
@@ -107,6 +108,24 @@ export interface BrowserClient extends Client {
107
108
  * ```
108
109
  */
109
110
  setTransport(transport: TransportType): void;
111
+ /**
112
+ * Adds a new plugin.
113
+ *
114
+ * ```typescript
115
+ * const plugin = {
116
+ * name: 'my-plugin',
117
+ * type: 'enrichment',
118
+ * async setup(config: BrowserConfig, amplitude: BrowserClient) {
119
+ * return;
120
+ * },
121
+ * async execute(event: Event) {
122
+ * return event;
123
+ * },
124
+ * };
125
+ * amplitude.add(plugin);
126
+ * ```
127
+ */
128
+ add(plugin: Plugin<BrowserClient, BrowserConfig>): AmplitudeReturn<void>;
110
129
  }
111
130
  export interface ReactNativeClient extends Client {
112
131
  /**
@@ -118,6 +137,24 @@ export interface ReactNativeClient extends Client {
118
137
  * ```
119
138
  */
120
139
  init(apiKey: string, userId?: string, options?: ReactNativeOptions): AmplitudeReturn<void>;
140
+ /**
141
+ * Adds a new plugin.
142
+ *
143
+ * ```typescript
144
+ * const plugin = {
145
+ * name: 'my-plugin',
146
+ * type: 'enrichment',
147
+ * async setup(config: ReactNativeConfig, amplitude: ReactNativeClient) {
148
+ * return;
149
+ * },
150
+ * async execute(event: Event) {
151
+ * return event;
152
+ * },
153
+ * };
154
+ * amplitude.add(plugin);
155
+ * ```
156
+ */
157
+ add(plugin: Plugin<ReactNativeClient, ReactNativeConfig>): AmplitudeReturn<void>;
121
158
  }
122
159
  export {};
123
160
  //# sourceMappingURL=web-client.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"web-client.d.ts","sourceRoot":"","sources":["../../../src/client/web-client.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AACvD,OAAO,EAAE,cAAc,EAAE,kBAAkB,EAAE,MAAM,WAAW,CAAC;AAC/D,OAAO,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAC7C,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAE3C,UAAU,MAAO,SAAQ,UAAU;IACjC;;;;;;OAMG;IACH,SAAS,IAAI,MAAM,GAAG,SAAS,CAAC;IAEhC;;;;;;OAMG;IACH,SAAS,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS,GAAG,IAAI,CAAC;IAE5C;;;;;;OAMG;IACH,WAAW,IAAI,MAAM,GAAG,SAAS,CAAC;IAElC;;;;;;;;OAQG;IACH,WAAW,CAAC,QAAQ,EAAE,MAAM,GAAG,IAAI,CAAC;IAEpC;;;;;;OAMG;IACH,YAAY,IAAI,MAAM,GAAG,SAAS,CAAC;IAEnC;;;;;;;OAOG;IACH,YAAY,CAAC,SAAS,EAAE,MAAM,GAAG,IAAI,CAAC;IAEtC;;;;;;;;;OASG;IACH,aAAa,IAAI,IAAI,CAAC;IAEtB;;;;;;;;;;;;;OAaG;IACH,KAAK,IAAI,IAAI,CAAC;CACf;AAED,MAAM,WAAW,aAAc,SAAQ,MAAM;IAC3C;;;;;;;OAOG;IACH,IAAI,CAAC,MAAM,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,cAAc,GAAG,eAAe,CAAC,IAAI,CAAC,CAAC;IACtE,IAAI,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE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;;;;;;;OAaG;IACH,KAAK,IAAI,IAAI,CAAC;CACf;AAED,MAAM,WAAW,aAAc,SAAQ,MAAM;IAC3C;;;;;;;OAOG;IACH,IAAI,CAAC,MAAM,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,cAAc,GAAG,eAAe,CAAC,IAAI,CAAC,CAAC;IACtE,IAAI,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,cAAc,GAAG,eAAe,CAAC,IAAI,CAAC,CAAC;IAEvF;;;;;;;;;;;;;OAaG;IACH,YAAY,CAAC,SAAS,EAAE,aAAa,GAAG,IAAI,CAAC;IAE7C;;;;;;;;;;;;;;;;OAgBG;IACH,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,aAAa,EAAE,aAAa,CAAC,GAAG,eAAe,CAAC,IAAI,CAAC,CAAC;CAC1E;AAED,MAAM,WAAW,iBAAkB,SAAQ,MAAM;IAC/C;;;;;;;OAOG;IACH,IAAI,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,kBAAkB,GAAG,eAAe,CAAC,IAAI,CAAC,CAAC;IAE3F;;;;;;;;;;;;;;;;OAgBG;IACH,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,iBAAiB,EAAE,iBAAiB,CAAC,GAAG,eAAe,CAAC,IAAI,CAAC,CAAC;CAClF"}
@@ -1 +1 @@
1
- {"version":3,"file":"web-client.js","sourceRoot":"","sources":["../../../src/client/web-client.ts"],"names":[],"mappings":"","sourcesContent":["import { AmplitudeReturn } from '../amplitude-promise';\nimport { BrowserOptions, ReactNativeOptions } from '../config';\nimport { TransportType } from '../transport';\nimport { CoreClient } from './core-client';\n\ninterface Client extends CoreClient {\n /**\n * Returns current user ID.\n *\n * ```typescript\n * const userId = getUserId();\n * ```\n */\n getUserId(): string | undefined;\n\n /**\n * Sets a new user ID.\n *\n * ```typescript\n * setUserId('userId');\n * ```\n */\n setUserId(userId: string | undefined): void;\n\n /**\n * Returns current device ID.\n *\n * ```typescript\n * const deviceId = getDeviceId();\n * ```\n */\n getDeviceId(): string | undefined;\n\n /**\n * Sets a new device ID.\n * When setting a custom device ID, make sure the value is sufficiently unique.\n * A uuid is recommended.\n *\n * ```typescript\n * setDeviceId('deviceId');\n * ```\n */\n setDeviceId(deviceId: string): void;\n\n /**\n * Returns current session ID.\n *\n * ```typescript\n * const sessionId = getSessionId();\n * ```\n */\n getSessionId(): number | undefined;\n\n /**\n * Sets a new session ID.\n * When setting a custom session ID, make sure the value is in milliseconds since epoch (Unix Timestamp).\n *\n * ```typescript\n * setSessionId(Date.now());\n * ```\n */\n setSessionId(sessionId: number): void;\n\n /**\n * Extends the current session (advanced)\n *\n * Normally sessions are extended automatically by track()'ing events. If you want to extend the session without\n * tracking and event, this will set the last user interaction to the current time.\n *\n * ```typescript\n * extendSession();\n * ```\n */\n extendSession(): void;\n\n /**\n * Anonymizes users after they log out, by:\n *\n * * setting userId to undefined\n * * setting deviceId to a new uuid value\n *\n * With an undefined userId and a completely new deviceId, the current user would appear as a brand new user in dashboard.\n *\n * ```typescript\n * import { reset } from '@amplitude/analytics-browser';\n *\n * reset();\n * ```\n */\n reset(): void;\n}\n\nexport interface BrowserClient extends Client {\n /**\n * Initializes the Amplitude SDK with your apiKey, optional configurations.\n * This method must be called before any other operations.\n *\n * ```typescript\n * await init(API_KEY, options).promise;\n * ```\n */\n init(apiKey: string, options?: BrowserOptions): AmplitudeReturn<void>;\n init(apiKey: string, userId?: string, options?: BrowserOptions): AmplitudeReturn<void>;\n\n /**\n * Sets the network transport type for events.\n *\n * ```typescript\n * // Use Fetch API\n * setTransport('fetch');\n *\n * // Use XMLHttpRequest API\n * setTransport('xhr');\n *\n * // Use navigator.sendBeacon API\n * setTransport('beacon');\n * ```\n */\n setTransport(transport: TransportType): void;\n}\n\nexport interface ReactNativeClient extends Client {\n /**\n * Initializes the Amplitude SDK with your apiKey, optional configurations.\n * This method must be called before any other operations.\n *\n * ```typescript\n * await init(API_KEY, options).promise;\n * ```\n */\n init(apiKey: string, userId?: string, options?: ReactNativeOptions): AmplitudeReturn<void>;\n}\n"]}
1
+ {"version":3,"file":"web-client.js","sourceRoot":"","sources":["../../../src/client/web-client.ts"],"names":[],"mappings":"","sourcesContent":["import { AmplitudeReturn } from '../amplitude-promise';\nimport { BrowserConfig, BrowserOptions, ReactNativeConfig, ReactNativeOptions } from '../config';\nimport { TransportType } from '../transport';\nimport { CoreClient } from './core-client';\nimport { Plugin } from '../plugin';\n\ninterface Client extends CoreClient {\n /**\n * Returns current user ID.\n *\n * ```typescript\n * const userId = getUserId();\n * ```\n */\n getUserId(): string | undefined;\n\n /**\n * Sets a new user ID.\n *\n * ```typescript\n * setUserId('userId');\n * ```\n */\n setUserId(userId: string | undefined): void;\n\n /**\n * Returns current device ID.\n *\n * ```typescript\n * const deviceId = getDeviceId();\n * ```\n */\n getDeviceId(): string | undefined;\n\n /**\n * Sets a new device ID.\n * When setting a custom device ID, make sure the value is sufficiently unique.\n * A uuid is recommended.\n *\n * ```typescript\n * setDeviceId('deviceId');\n * ```\n */\n setDeviceId(deviceId: string): void;\n\n /**\n * Returns current session ID.\n *\n * ```typescript\n * const sessionId = getSessionId();\n * ```\n */\n getSessionId(): number | undefined;\n\n /**\n * Sets a new session ID.\n * When setting a custom session ID, make sure the value is in milliseconds since epoch (Unix Timestamp).\n *\n * ```typescript\n * setSessionId(Date.now());\n * ```\n */\n setSessionId(sessionId: number): void;\n\n /**\n * Extends the current session (advanced)\n *\n * Normally sessions are extended automatically by track()'ing events. If you want to extend the session without\n * tracking and event, this will set the last user interaction to the current time.\n *\n * ```typescript\n * extendSession();\n * ```\n */\n extendSession(): void;\n\n /**\n * Anonymizes users after they log out, by:\n *\n * * setting userId to undefined\n * * setting deviceId to a new uuid value\n *\n * With an undefined userId and a completely new deviceId, the current user would appear as a brand new user in dashboard.\n *\n * ```typescript\n * import { reset } from '@amplitude/analytics-browser';\n *\n * reset();\n * ```\n */\n reset(): void;\n}\n\nexport interface BrowserClient extends Client {\n /**\n * Initializes the Amplitude SDK with your apiKey, optional configurations.\n * This method must be called before any other operations.\n *\n * ```typescript\n * await init(API_KEY, options).promise;\n * ```\n */\n init(apiKey: string, options?: BrowserOptions): AmplitudeReturn<void>;\n init(apiKey: string, userId?: string, options?: BrowserOptions): AmplitudeReturn<void>;\n\n /**\n * Sets the network transport type for events.\n *\n * ```typescript\n * // Use Fetch API\n * setTransport('fetch');\n *\n * // Use XMLHttpRequest API\n * setTransport('xhr');\n *\n * // Use navigator.sendBeacon API\n * setTransport('beacon');\n * ```\n */\n setTransport(transport: TransportType): void;\n\n /**\n * Adds a new plugin.\n *\n * ```typescript\n * const plugin = {\n * name: 'my-plugin',\n * type: 'enrichment',\n * async setup(config: BrowserConfig, amplitude: BrowserClient) {\n * return;\n * },\n * async execute(event: Event) {\n * return event;\n * },\n * };\n * amplitude.add(plugin);\n * ```\n */\n add(plugin: Plugin<BrowserClient, BrowserConfig>): AmplitudeReturn<void>;\n}\n\nexport interface ReactNativeClient extends Client {\n /**\n * Initializes the Amplitude SDK with your apiKey, optional configurations.\n * This method must be called before any other operations.\n *\n * ```typescript\n * await init(API_KEY, options).promise;\n * ```\n */\n init(apiKey: string, userId?: string, options?: ReactNativeOptions): AmplitudeReturn<void>;\n\n /**\n * Adds a new plugin.\n *\n * ```typescript\n * const plugin = {\n * name: 'my-plugin',\n * type: 'enrichment',\n * async setup(config: ReactNativeConfig, amplitude: ReactNativeClient) {\n * return;\n * },\n * async execute(event: Event) {\n * return event;\n * },\n * };\n * amplitude.add(plugin);\n * ```\n */\n add(plugin: Plugin<ReactNativeClient, ReactNativeConfig>): AmplitudeReturn<void>;\n}\n"]}
@@ -6,24 +6,24 @@ type PluginTypeBefore = 'before';
6
6
  type PluginTypeEnrichment = 'enrichment';
7
7
  type PluginTypeDestination = 'destination';
8
8
  export type PluginType = PluginTypeBefore | PluginTypeEnrichment | PluginTypeDestination;
9
- interface PluginBase<T = CoreClient> {
9
+ interface PluginBase<T = CoreClient, U = Config> {
10
10
  name?: string;
11
11
  type?: PluginType;
12
- setup?(config: Config, client: T): Promise<void>;
12
+ setup?(config: U, client: T): Promise<void>;
13
13
  }
14
- export interface BeforePlugin extends PluginBase {
14
+ export interface BeforePlugin<T = CoreClient, U = Config> extends PluginBase<T, U> {
15
15
  type: PluginTypeBefore;
16
16
  execute?(context: Event): Promise<Event | null>;
17
17
  }
18
- export interface EnrichmentPlugin extends PluginBase {
18
+ export interface EnrichmentPlugin<T = CoreClient, U = Config> extends PluginBase<T, U> {
19
19
  type?: PluginTypeEnrichment;
20
20
  execute?(context: Event): Promise<Event | null>;
21
21
  }
22
- export interface DestinationPlugin extends PluginBase {
22
+ export interface DestinationPlugin<T = CoreClient, U = Config> extends PluginBase<T, U> {
23
23
  type: PluginTypeDestination;
24
24
  execute(context: Event): Promise<Result>;
25
25
  flush?(): Promise<void>;
26
26
  }
27
- export type Plugin = BeforePlugin | EnrichmentPlugin | DestinationPlugin;
27
+ export type Plugin<T = CoreClient, U = Config> = BeforePlugin<T, U> | EnrichmentPlugin<T, U> | DestinationPlugin<T, U>;
28
28
  export {};
29
29
  //# sourceMappingURL=plugin.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"plugin.d.ts","sourceRoot":"","sources":["../../src/plugin.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,SAAS,CAAC;AAChC,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAClC,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAClC,OAAO,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;AAElD,KAAK,gBAAgB,GAAG,QAAQ,CAAC;AACjC,KAAK,oBAAoB,GAAG,YAAY,CAAC;AACzC,KAAK,qBAAqB,GAAG,aAAa,CAAC;AAC3C,MAAM,MAAM,UAAU,GAAG,gBAAgB,GAAG,oBAAoB,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CAAC,CAAC,GAAG,gBAAgB,CAAC,CAAC,EAAE,CAAC,CAAC,GAAG,iBAAiB,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"plugin.js","sourceRoot":"","sources":["../../src/plugin.ts"],"names":[],"mappings":"","sourcesContent":["import { Event } from './event';\nimport { Config } from './config';\nimport { Result } from './result';\nimport { CoreClient } from './client/core-client';\n\ntype PluginTypeBefore = 'before';\ntype PluginTypeEnrichment = 'enrichment';\ntype PluginTypeDestination = 'destination';\nexport type PluginType = PluginTypeBefore | PluginTypeEnrichment | PluginTypeDestination;\n\ninterface PluginBase<T = CoreClient> {\n name?: string;\n type?: PluginType;\n setup?(config: Config, client: T): Promise<void>;\n}\n\nexport interface BeforePlugin extends PluginBase {\n type: PluginTypeBefore;\n execute?(context: Event): Promise<Event | null>;\n}\n\nexport interface EnrichmentPlugin extends PluginBase {\n type?: PluginTypeEnrichment;\n execute?(context: Event): Promise<Event | null>;\n}\n\nexport interface DestinationPlugin extends PluginBase {\n type: PluginTypeDestination;\n execute(context: Event): Promise<Result>;\n flush?(): Promise<void>;\n}\n\nexport type Plugin = BeforePlugin | EnrichmentPlugin | DestinationPlugin;\n"]}
1
+ {"version":3,"file":"plugin.js","sourceRoot":"","sources":["../../src/plugin.ts"],"names":[],"mappings":"","sourcesContent":["import { Event } from './event';\nimport { Config } from './config';\nimport { Result } from './result';\nimport { CoreClient } from './client/core-client';\n\ntype PluginTypeBefore = 'before';\ntype PluginTypeEnrichment = 'enrichment';\ntype PluginTypeDestination = 'destination';\nexport type PluginType = PluginTypeBefore | PluginTypeEnrichment | PluginTypeDestination;\n\ninterface PluginBase<T = CoreClient, U = Config> {\n name?: string;\n type?: PluginType;\n setup?(config: U, client: T): Promise<void>;\n}\n\nexport interface BeforePlugin<T = CoreClient, U = Config> extends PluginBase<T, U> {\n type: PluginTypeBefore;\n execute?(context: Event): Promise<Event | null>;\n}\n\nexport interface EnrichmentPlugin<T = CoreClient, U = Config> extends PluginBase<T, U> {\n type?: PluginTypeEnrichment;\n execute?(context: Event): Promise<Event | null>;\n}\n\nexport interface DestinationPlugin<T = CoreClient, U = Config> extends PluginBase<T, U> {\n type: PluginTypeDestination;\n execute(context: Event): Promise<Result>;\n flush?(): Promise<void>;\n}\n\nexport type Plugin<T = CoreClient, U = Config> = BeforePlugin<T, U> | EnrichmentPlugin<T, U> | DestinationPlugin<T, U>;\n"]}
@@ -1,6 +1,7 @@
1
1
  import { AmplitudeReturn } from '../amplitude-promise';
2
- import { NodeOptions } from '../config';
2
+ import { NodeConfig, NodeOptions } from '../config';
3
3
  import { CoreClient } from './core-client';
4
+ import { Plugin } from '../plugin';
4
5
  export interface NodeClient extends CoreClient {
5
6
  /**
6
7
  * Initializes the Amplitude SDK with your apiKey, optional configurations.
@@ -11,5 +12,23 @@ export interface NodeClient extends CoreClient {
11
12
  * ```
12
13
  */
13
14
  init(apiKey: string, options?: NodeOptions): AmplitudeReturn<void>;
15
+ /**
16
+ * Adds a new plugin.
17
+ *
18
+ * ```typescript
19
+ * const plugin = {
20
+ * name: 'my-plugin',
21
+ * type: 'enrichment',
22
+ * async setup(config: NodeConfig, amplitude: NodeClient) {
23
+ * return;
24
+ * },
25
+ * async execute(event: Event) {
26
+ * return event;
27
+ * },
28
+ * };
29
+ * amplitude.add(plugin);
30
+ * ```
31
+ */
32
+ add(plugin: Plugin<NodeClient, NodeConfig>): AmplitudeReturn<void>;
14
33
  }
15
34
  //# sourceMappingURL=node-client.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"node-client.d.ts","sourceRoot":"","sources":["../../../src/client/node-client.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AACvD,OAAO,EAAE,WAAW,EAAE,MAAM,WAAW,CAAC;AACxC,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAE3C,MAAM,WAAW,UAAW,SAAQ,UAAU;IAC5C;;;;;;;OAOG;IACH,IAAI,CAAC,MAAM,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,WAAW,GAAG,eAAe,CAAC,IAAI,CAAC,CAAC;CACpE"}
1
+ {"version":3,"file":"node-client.d.ts","sourceRoot":"","sources":["../../../src/client/node-client.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AACvD,OAAO,EAAE,UAAU,EAAE,WAAW,EAAE,MAAM,WAAW,CAAC;AACpD,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAC3C,OAAO,EAAE,MAAM,EAAE,MAAM,WAAW,CAAC;AAEnC,MAAM,WAAW,UAAW,SAAQ,UAAU;IAC5C;;;;;;;OAOG;IACH,IAAI,CAAC,MAAM,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,WAAW,GAAG,eAAe,CAAC,IAAI,CAAC,CAAC;IAEnE;;;;;;;;;;;;;;;;OAgBG;IACH,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,UAAU,EAAE,UAAU,CAAC,GAAG,eAAe,CAAC,IAAI,CAAC,CAAC;CACpE"}
@@ -1 +1 @@
1
- {"version":3,"file":"node-client.js","sourceRoot":"","sources":["../../../src/client/node-client.ts"],"names":[],"mappings":"","sourcesContent":["import { AmplitudeReturn } from '../amplitude-promise';\nimport { NodeOptions } from '../config';\nimport { CoreClient } from './core-client';\n\nexport interface NodeClient extends CoreClient {\n /**\n * Initializes the Amplitude SDK with your apiKey, optional configurations.\n * This method must be called before any other operations.\n *\n * ```typescript\n * await init(API_KEY, options).promise;\n * ```\n */\n init(apiKey: string, options?: NodeOptions): AmplitudeReturn<void>;\n}\n"]}
1
+ {"version":3,"file":"node-client.js","sourceRoot":"","sources":["../../../src/client/node-client.ts"],"names":[],"mappings":"","sourcesContent":["import { AmplitudeReturn } from '../amplitude-promise';\nimport { NodeConfig, NodeOptions } from '../config';\nimport { CoreClient } from './core-client';\nimport { Plugin } from '../plugin';\n\nexport interface NodeClient extends CoreClient {\n /**\n * Initializes the Amplitude SDK with your apiKey, optional configurations.\n * This method must be called before any other operations.\n *\n * ```typescript\n * await init(API_KEY, options).promise;\n * ```\n */\n init(apiKey: string, options?: NodeOptions): AmplitudeReturn<void>;\n\n /**\n * Adds a new plugin.\n *\n * ```typescript\n * const plugin = {\n * name: 'my-plugin',\n * type: 'enrichment',\n * async setup(config: NodeConfig, amplitude: NodeClient) {\n * return;\n * },\n * async execute(event: Event) {\n * return event;\n * },\n * };\n * amplitude.add(plugin);\n * ```\n */\n add(plugin: Plugin<NodeClient, NodeConfig>): AmplitudeReturn<void>;\n}\n"]}
@@ -1,7 +1,8 @@
1
1
  import { AmplitudeReturn } from '../amplitude-promise';
2
- import { BrowserOptions, ReactNativeOptions } from '../config';
2
+ import { BrowserConfig, BrowserOptions, ReactNativeConfig, ReactNativeOptions } from '../config';
3
3
  import { TransportType } from '../transport';
4
4
  import { CoreClient } from './core-client';
5
+ import { Plugin } from '../plugin';
5
6
  interface Client extends CoreClient {
6
7
  /**
7
8
  * Returns current user ID.
@@ -107,6 +108,24 @@ export interface BrowserClient extends Client {
107
108
  * ```
108
109
  */
109
110
  setTransport(transport: TransportType): void;
111
+ /**
112
+ * Adds a new plugin.
113
+ *
114
+ * ```typescript
115
+ * const plugin = {
116
+ * name: 'my-plugin',
117
+ * type: 'enrichment',
118
+ * async setup(config: BrowserConfig, amplitude: BrowserClient) {
119
+ * return;
120
+ * },
121
+ * async execute(event: Event) {
122
+ * return event;
123
+ * },
124
+ * };
125
+ * amplitude.add(plugin);
126
+ * ```
127
+ */
128
+ add(plugin: Plugin<BrowserClient, BrowserConfig>): AmplitudeReturn<void>;
110
129
  }
111
130
  export interface ReactNativeClient extends Client {
112
131
  /**
@@ -118,6 +137,24 @@ export interface ReactNativeClient extends Client {
118
137
  * ```
119
138
  */
120
139
  init(apiKey: string, userId?: string, options?: ReactNativeOptions): AmplitudeReturn<void>;
140
+ /**
141
+ * Adds a new plugin.
142
+ *
143
+ * ```typescript
144
+ * const plugin = {
145
+ * name: 'my-plugin',
146
+ * type: 'enrichment',
147
+ * async setup(config: ReactNativeConfig, amplitude: ReactNativeClient) {
148
+ * return;
149
+ * },
150
+ * async execute(event: Event) {
151
+ * return event;
152
+ * },
153
+ * };
154
+ * amplitude.add(plugin);
155
+ * ```
156
+ */
157
+ add(plugin: Plugin<ReactNativeClient, ReactNativeConfig>): AmplitudeReturn<void>;
121
158
  }
122
159
  export {};
123
160
  //# sourceMappingURL=web-client.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"web-client.d.ts","sourceRoot":"","sources":["../../../src/client/web-client.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AACvD,OAAO,EAAE,cAAc,EAAE,kBAAkB,EAAE,MAAM,WAAW,CAAC;AAC/D,OAAO,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAC7C,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAE3C,UAAU,MAAO,SAAQ,UAAU;IACjC;;;;;;OAMG;IACH,SAAS,IAAI,MAAM,GAAG,SAAS,CAAC;IAEhC;;;;;;OAMG;IACH,SAAS,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS,GAAG,IAAI,CAAC;IAE5C;;;;;;OAMG;IACH,WAAW,IAAI,MAAM,GAAG,SAAS,CAAC;IAElC;;;;;;;;OAQG;IACH,WAAW,CAAC,QAAQ,EAAE,MAAM,GAAG,IAAI,CAAC;IAEpC;;;;;;OAMG;IACH,YAAY,IAAI,MAAM,GAAG,SAAS,CAAC;IAEnC;;;;;;;OAOG;IACH,YAAY,CAAC,SAAS,EAAE,MAAM,GAAG,IAAI,CAAC;IAEtC;;;;;;;;;OASG;IACH,aAAa,IAAI,IAAI,CAAC;IAEtB;;;;;;;;;;;;;OAaG;IACH,KAAK,IAAI,IAAI,CAAC;CACf;AAED,MAAM,WAAW,aAAc,SAAQ,MAAM;IAC3C;;;;;;;OAOG;I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AM,GAAG,SAAS,CAAC;IAEnC;;;;;;;OAOG;IACH,YAAY,CAAC,SAAS,EAAE,MAAM,GAAG,IAAI,CAAC;IAEtC;;;;;;;;;OASG;IACH,aAAa,IAAI,IAAI,CAAC;IAEtB;;;;;;;;;;;;;OAaG;IACH,KAAK,IAAI,IAAI,CAAC;CACf;AAED,MAAM,WAAW,aAAc,SAAQ,MAAM;IAC3C;;;;;;;OAOG;IACH,IAAI,CAAC,MAAM,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,cAAc,GAAG,eAAe,CAAC,IAAI,CAAC,CAAC;IACtE,IAAI,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,cAAc,GAAG,eAAe,CAAC,IAAI,CAAC,CAAC;IAEvF;;;;;;;;;;;;;OAaG;IACH,YAAY,CAAC,SAAS,EAAE,aAAa,GAAG,IAAI,CAAC;IAE7C;;;;;;;;;;;;;;;;OAgBG;IACH,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,aAAa,EAAE,aAAa,CAAC,GAAG,eAAe,CAAC,IAAI,CAAC,CAAC;CAC1E;AAED,MAAM,WAAW,iBAAkB,SAAQ,MAAM;IAC/C;;;;;;;OAOG;IACH,IAAI,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,kBAAkB,GAAG,eAAe,CAAC,IAAI,CAAC,CAAC;IAE3F;;;;;;;;;;;;;;;;OAgBG;IACH,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,iBAAiB,EAAE,iBAAiB,CAAC,GAAG,eAAe,CAAC,IAAI,CAAC,CAAC;CAClF"}
@@ -1 +1 @@
1
- {"version":3,"file":"web-client.js","sourceRoot":"","sources":["../../../src/client/web-client.ts"],"names":[],"mappings":"","sourcesContent":["import { AmplitudeReturn } from '../amplitude-promise';\nimport { BrowserOptions, ReactNativeOptions } from '../config';\nimport { TransportType } from '../transport';\nimport { CoreClient } from './core-client';\n\ninterface Client extends CoreClient {\n /**\n * Returns current user ID.\n *\n * ```typescript\n * const userId = getUserId();\n * ```\n */\n getUserId(): string | undefined;\n\n /**\n * Sets a new user ID.\n *\n * ```typescript\n * setUserId('userId');\n * ```\n */\n setUserId(userId: string | undefined): void;\n\n /**\n * Returns current device ID.\n *\n * ```typescript\n * const deviceId = getDeviceId();\n * ```\n */\n getDeviceId(): string | undefined;\n\n /**\n * Sets a new device ID.\n * When setting a custom device ID, make sure the value is sufficiently unique.\n * A uuid is recommended.\n *\n * ```typescript\n * setDeviceId('deviceId');\n * ```\n */\n setDeviceId(deviceId: string): void;\n\n /**\n * Returns current session ID.\n *\n * ```typescript\n * const sessionId = getSessionId();\n * ```\n */\n getSessionId(): number | undefined;\n\n /**\n * Sets a new session ID.\n * When setting a custom session ID, make sure the value is in milliseconds since epoch (Unix Timestamp).\n *\n * ```typescript\n * setSessionId(Date.now());\n * ```\n */\n setSessionId(sessionId: number): void;\n\n /**\n * Extends the current session (advanced)\n *\n * Normally sessions are extended automatically by track()'ing events. If you want to extend the session without\n * tracking and event, this will set the last user interaction to the current time.\n *\n * ```typescript\n * extendSession();\n * ```\n */\n extendSession(): void;\n\n /**\n * Anonymizes users after they log out, by:\n *\n * * setting userId to undefined\n * * setting deviceId to a new uuid value\n *\n * With an undefined userId and a completely new deviceId, the current user would appear as a brand new user in dashboard.\n *\n * ```typescript\n * import { reset } from '@amplitude/analytics-browser';\n *\n * reset();\n * ```\n */\n reset(): void;\n}\n\nexport interface BrowserClient extends Client {\n /**\n * Initializes the Amplitude SDK with your apiKey, optional configurations.\n * This method must be called before any other operations.\n *\n * ```typescript\n * await init(API_KEY, options).promise;\n * ```\n */\n init(apiKey: string, options?: BrowserOptions): AmplitudeReturn<void>;\n init(apiKey: string, userId?: string, options?: BrowserOptions): AmplitudeReturn<void>;\n\n /**\n * Sets the network transport type for events.\n *\n * ```typescript\n * // Use Fetch API\n * setTransport('fetch');\n *\n * // Use XMLHttpRequest API\n * setTransport('xhr');\n *\n * // Use navigator.sendBeacon API\n * setTransport('beacon');\n * ```\n */\n setTransport(transport: TransportType): void;\n}\n\nexport interface ReactNativeClient extends Client {\n /**\n * Initializes the Amplitude SDK with your apiKey, optional configurations.\n * This method must be called before any other operations.\n *\n * ```typescript\n * await init(API_KEY, options).promise;\n * ```\n */\n init(apiKey: string, userId?: string, options?: ReactNativeOptions): AmplitudeReturn<void>;\n}\n"]}
1
+ {"version":3,"file":"web-client.js","sourceRoot":"","sources":["../../../src/client/web-client.ts"],"names":[],"mappings":"","sourcesContent":["import { AmplitudeReturn } from '../amplitude-promise';\nimport { BrowserConfig, BrowserOptions, ReactNativeConfig, ReactNativeOptions } from '../config';\nimport { TransportType } from '../transport';\nimport { CoreClient } from './core-client';\nimport { Plugin } from '../plugin';\n\ninterface Client extends CoreClient {\n /**\n * Returns current user ID.\n *\n * ```typescript\n * const userId = getUserId();\n * ```\n */\n getUserId(): string | undefined;\n\n /**\n * Sets a new user ID.\n *\n * ```typescript\n * setUserId('userId');\n * ```\n */\n setUserId(userId: string | undefined): void;\n\n /**\n * Returns current device ID.\n *\n * ```typescript\n * const deviceId = getDeviceId();\n * ```\n */\n getDeviceId(): string | undefined;\n\n /**\n * Sets a new device ID.\n * When setting a custom device ID, make sure the value is sufficiently unique.\n * A uuid is recommended.\n *\n * ```typescript\n * setDeviceId('deviceId');\n * ```\n */\n setDeviceId(deviceId: string): void;\n\n /**\n * Returns current session ID.\n *\n * ```typescript\n * const sessionId = getSessionId();\n * ```\n */\n getSessionId(): number | undefined;\n\n /**\n * Sets a new session ID.\n * When setting a custom session ID, make sure the value is in milliseconds since epoch (Unix Timestamp).\n *\n * ```typescript\n * setSessionId(Date.now());\n * ```\n */\n setSessionId(sessionId: number): void;\n\n /**\n * Extends the current session (advanced)\n *\n * Normally sessions are extended automatically by track()'ing events. If you want to extend the session without\n * tracking and event, this will set the last user interaction to the current time.\n *\n * ```typescript\n * extendSession();\n * ```\n */\n extendSession(): void;\n\n /**\n * Anonymizes users after they log out, by:\n *\n * * setting userId to undefined\n * * setting deviceId to a new uuid value\n *\n * With an undefined userId and a completely new deviceId, the current user would appear as a brand new user in dashboard.\n *\n * ```typescript\n * import { reset } from '@amplitude/analytics-browser';\n *\n * reset();\n * ```\n */\n reset(): void;\n}\n\nexport interface BrowserClient extends Client {\n /**\n * Initializes the Amplitude SDK with your apiKey, optional configurations.\n * This method must be called before any other operations.\n *\n * ```typescript\n * await init(API_KEY, options).promise;\n * ```\n */\n init(apiKey: string, options?: BrowserOptions): AmplitudeReturn<void>;\n init(apiKey: string, userId?: string, options?: BrowserOptions): AmplitudeReturn<void>;\n\n /**\n * Sets the network transport type for events.\n *\n * ```typescript\n * // Use Fetch API\n * setTransport('fetch');\n *\n * // Use XMLHttpRequest API\n * setTransport('xhr');\n *\n * // Use navigator.sendBeacon API\n * setTransport('beacon');\n * ```\n */\n setTransport(transport: TransportType): void;\n\n /**\n * Adds a new plugin.\n *\n * ```typescript\n * const plugin = {\n * name: 'my-plugin',\n * type: 'enrichment',\n * async setup(config: BrowserConfig, amplitude: BrowserClient) {\n * return;\n * },\n * async execute(event: Event) {\n * return event;\n * },\n * };\n * amplitude.add(plugin);\n * ```\n */\n add(plugin: Plugin<BrowserClient, BrowserConfig>): AmplitudeReturn<void>;\n}\n\nexport interface ReactNativeClient extends Client {\n /**\n * Initializes the Amplitude SDK with your apiKey, optional configurations.\n * This method must be called before any other operations.\n *\n * ```typescript\n * await init(API_KEY, options).promise;\n * ```\n */\n init(apiKey: string, userId?: string, options?: ReactNativeOptions): AmplitudeReturn<void>;\n\n /**\n * Adds a new plugin.\n *\n * ```typescript\n * const plugin = {\n * name: 'my-plugin',\n * type: 'enrichment',\n * async setup(config: ReactNativeConfig, amplitude: ReactNativeClient) {\n * return;\n * },\n * async execute(event: Event) {\n * return event;\n * },\n * };\n * amplitude.add(plugin);\n * ```\n */\n add(plugin: Plugin<ReactNativeClient, ReactNativeConfig>): AmplitudeReturn<void>;\n}\n"]}
@@ -6,24 +6,24 @@ type PluginTypeBefore = 'before';
6
6
  type PluginTypeEnrichment = 'enrichment';
7
7
  type PluginTypeDestination = 'destination';
8
8
  export type PluginType = PluginTypeBefore | PluginTypeEnrichment | PluginTypeDestination;
9
- interface PluginBase<T = CoreClient> {
9
+ interface PluginBase<T = CoreClient, U = Config> {
10
10
  name?: string;
11
11
  type?: PluginType;
12
- setup?(config: Config, client: T): Promise<void>;
12
+ setup?(config: U, client: T): Promise<void>;
13
13
  }
14
- export interface BeforePlugin extends PluginBase {
14
+ export interface BeforePlugin<T = CoreClient, U = Config> extends PluginBase<T, U> {
15
15
  type: PluginTypeBefore;
16
16
  execute?(context: Event): Promise<Event | null>;
17
17
  }
18
- export interface EnrichmentPlugin extends PluginBase {
18
+ export interface EnrichmentPlugin<T = CoreClient, U = Config> extends PluginBase<T, U> {
19
19
  type?: PluginTypeEnrichment;
20
20
  execute?(context: Event): Promise<Event | null>;
21
21
  }
22
- export interface DestinationPlugin extends PluginBase {
22
+ export interface DestinationPlugin<T = CoreClient, U = Config> extends PluginBase<T, U> {
23
23
  type: PluginTypeDestination;
24
24
  execute(context: Event): Promise<Result>;
25
25
  flush?(): Promise<void>;
26
26
  }
27
- export type Plugin = BeforePlugin | EnrichmentPlugin | DestinationPlugin;
27
+ export type Plugin<T = CoreClient, U = Config> = BeforePlugin<T, U> | EnrichmentPlugin<T, U> | DestinationPlugin<T, U>;
28
28
  export {};
29
29
  //# sourceMappingURL=plugin.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"plugin.d.ts","sourceRoot":"","sources":["../../src/plugin.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,SAAS,CAAC;AAChC,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAClC,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAClC,OAAO,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;AAElD,KAAK,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zC,KAAK,CAAC,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;CACzB;AAED,MAAM,MAAM,MAAM,CAAC,CAAC,GAAG,UAAU,EAAE,CAAC,GAAG,MAAM,IAAI,YAAY,CAAC,CAAC,EAAE,CAAC,CAAC,GAAG,gBAAgB,CAAC,CAAC,EAAE,CAAC,CAAC,GAAG,iBAAiB,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"plugin.js","sourceRoot":"","sources":["../../src/plugin.ts"],"names":[],"mappings":"","sourcesContent":["import { Event } from './event';\nimport { Config } from './config';\nimport { Result } from './result';\nimport { CoreClient } from './client/core-client';\n\ntype PluginTypeBefore = 'before';\ntype PluginTypeEnrichment = 'enrichment';\ntype PluginTypeDestination = 'destination';\nexport type PluginType = PluginTypeBefore | PluginTypeEnrichment | PluginTypeDestination;\n\ninterface PluginBase<T = CoreClient> {\n name?: string;\n type?: PluginType;\n setup?(config: Config, client: T): Promise<void>;\n}\n\nexport interface BeforePlugin extends PluginBase {\n type: PluginTypeBefore;\n execute?(context: Event): Promise<Event | null>;\n}\n\nexport interface EnrichmentPlugin extends PluginBase {\n type?: PluginTypeEnrichment;\n execute?(context: Event): Promise<Event | null>;\n}\n\nexport interface DestinationPlugin extends PluginBase {\n type: PluginTypeDestination;\n execute(context: Event): Promise<Result>;\n flush?(): Promise<void>;\n}\n\nexport type Plugin = BeforePlugin | EnrichmentPlugin | DestinationPlugin;\n"]}
1
+ {"version":3,"file":"plugin.js","sourceRoot":"","sources":["../../src/plugin.ts"],"names":[],"mappings":"","sourcesContent":["import { Event } from './event';\nimport { Config } from './config';\nimport { Result } from './result';\nimport { CoreClient } from './client/core-client';\n\ntype PluginTypeBefore = 'before';\ntype PluginTypeEnrichment = 'enrichment';\ntype PluginTypeDestination = 'destination';\nexport type PluginType = PluginTypeBefore | PluginTypeEnrichment | PluginTypeDestination;\n\ninterface PluginBase<T = CoreClient, U = Config> {\n name?: string;\n type?: PluginType;\n setup?(config: U, client: T): Promise<void>;\n}\n\nexport interface BeforePlugin<T = CoreClient, U = Config> extends PluginBase<T, U> {\n type: PluginTypeBefore;\n execute?(context: Event): Promise<Event | null>;\n}\n\nexport interface EnrichmentPlugin<T = CoreClient, U = Config> extends PluginBase<T, U> {\n type?: PluginTypeEnrichment;\n execute?(context: Event): Promise<Event | null>;\n}\n\nexport interface DestinationPlugin<T = CoreClient, U = Config> extends PluginBase<T, U> {\n type: PluginTypeDestination;\n execute(context: Event): Promise<Result>;\n flush?(): Promise<void>;\n}\n\nexport type Plugin<T = CoreClient, U = Config> = BeforePlugin<T, U> | EnrichmentPlugin<T, U> | DestinationPlugin<T, U>;\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@amplitude/analytics-types",
3
- "version": "2.0.0-beta.8",
3
+ "version": "2.0.1",
4
4
  "description": "",
5
5
  "author": "Amplitude Inc",
6
6
  "homepage": "https://github.com/amplitude/Amplitude-TypeScript",
@@ -35,5 +35,5 @@
35
35
  "files": [
36
36
  "lib"
37
37
  ],
38
- "gitHead": "790489ad98a62bc8e8afa9ee749e113442e8beef"
38
+ "gitHead": "8999d1e1eb063c2a511b3d8c3fad25a7622ca730"
39
39
  }