@walkeros/web-destination-amplitude 4.8.1 → 4.8.2

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.mts CHANGED
@@ -7,6 +7,7 @@ import { InitOptions } from '@amplitude/engagement-browser';
7
7
 
8
8
  type BrowserOptions = Omit<Types$1.BrowserOptions, 'identify'>;
9
9
  type AmplitudeBrowserOptions = Types$1.BrowserOptions;
10
+ type AmplitudePlugin = Types$1.Plugin;
10
11
  /**
11
12
  * Destination-level settings.
12
13
  *
@@ -51,55 +52,53 @@ interface Mapping {
51
52
  reset?: Mapping$1.Value | boolean;
52
53
  }
53
54
  /**
54
- * Amplitude SDK surface — the subset of @amplitude/unified the
55
- * destination actually uses. Mirrors the real module's named exports so
56
- * tests can mock each method individually via env.amplitude.
55
+ * Amplitude SDK surface: the subset of @amplitude/unified the
56
+ * destination actually uses. Mirrors the real client's methods so tests can
57
+ * mock each one via env.amplitude. Generic over the Identify and Revenue
58
+ * instances, so the real SDK gets back the instances it created.
57
59
  */
58
- interface AmplitudeSDK {
59
- initAll: (apiKey: string, options?: Record<string, unknown>) => Promise<void>;
60
- track: (eventType: string, eventProperties?: Record<string, unknown>) => void;
61
- identify: (identify: IdentifyInstance) => void;
62
- revenue: (revenue: RevenueInstance) => void;
63
- reset: () => void;
64
- setOptOut: (optOut: boolean) => void;
65
- setUserId: (userId: string | undefined) => void;
66
- setDeviceId: (deviceId: string) => void;
67
- setSessionId: (sessionId: number) => void;
68
- setGroup: (groupType: string, groupName: string | string[]) => void;
69
- groupIdentify: (groupType: string, groupName: string, identify: IdentifyInstance) => void;
70
- flush: () => {
71
- promise: Promise<void>;
72
- };
73
- add: (plugin: unknown) => {
74
- promise: Promise<void>;
75
- };
76
- Identify: new () => IdentifyInstance;
77
- Revenue: new () => RevenueInstance;
60
+ interface AmplitudeSDK<I extends IdentifyInstance = IdentifyInstance, R extends RevenueInstance = RevenueInstance> {
61
+ /** Analytics. */
62
+ init: (apiKey: string, options?: AmplitudeBrowserOptions) => unknown;
63
+ /** One plugin: Session Replay, Experiment or Guides & Surveys. */
64
+ add: (plugin: AmplitudePlugin) => unknown;
65
+ track: (eventType: string, eventProperties?: Record<string, unknown>) => unknown;
66
+ identify: (identify: I) => unknown;
67
+ revenue: (revenue: R) => unknown;
68
+ reset: () => unknown;
69
+ setOptOut: (optOut: boolean) => unknown;
70
+ setUserId: (userId: string | undefined) => unknown;
71
+ setDeviceId: (deviceId: string) => unknown;
72
+ setSessionId: (sessionId: number) => unknown;
73
+ setGroup: (groupType: string, groupName: string | string[]) => unknown;
74
+ groupIdentify: (groupType: string, groupName: string, identify: I) => unknown;
75
+ Identify: new () => I;
76
+ Revenue: new () => R;
78
77
  }
79
- /** Chainable Identify — mirrors @amplitude/unified Identify class. */
78
+ /** Chainable Identify, as the @amplitude/unified Identify class. */
80
79
  interface IdentifyInstance {
81
- set: (property: string, value: unknown) => IdentifyInstance;
82
- setOnce: (property: string, value: unknown) => IdentifyInstance;
83
- add: (property: string, value: number) => IdentifyInstance;
84
- append: (property: string, value: unknown) => IdentifyInstance;
85
- prepend: (property: string, value: unknown) => IdentifyInstance;
86
- preInsert: (property: string, value: unknown) => IdentifyInstance;
87
- postInsert: (property: string, value: unknown) => IdentifyInstance;
88
- remove: (property: string, value: unknown) => IdentifyInstance;
89
- unset: (property: string) => IdentifyInstance;
90
- clearAll: () => IdentifyInstance;
80
+ set(property: string, value: unknown): IdentifyInstance;
81
+ setOnce(property: string, value: unknown): IdentifyInstance;
82
+ add(property: string, value: number): IdentifyInstance;
83
+ append(property: string, value: unknown): IdentifyInstance;
84
+ prepend(property: string, value: unknown): IdentifyInstance;
85
+ preInsert(property: string, value: unknown): IdentifyInstance;
86
+ postInsert(property: string, value: unknown): IdentifyInstance;
87
+ remove(property: string, value: unknown): IdentifyInstance;
88
+ unset(property: string): IdentifyInstance;
89
+ clearAll(): IdentifyInstance;
91
90
  }
92
- /** Chainable Revenue — mirrors @amplitude/unified Revenue class. */
91
+ /** Chainable Revenue, as the @amplitude/unified Revenue class. */
93
92
  interface RevenueInstance {
94
- setProductId: (id: string) => RevenueInstance;
95
- setPrice: (price: number) => RevenueInstance;
96
- setQuantity: (quantity: number) => RevenueInstance;
97
- setRevenueType: (type: string) => RevenueInstance;
98
- setCurrency: (currency: string) => RevenueInstance;
99
- setRevenue: (revenue: number) => RevenueInstance;
100
- setReceipt: (receipt: string) => RevenueInstance;
101
- setReceiptSig: (signature: string) => RevenueInstance;
102
- setEventProperties: (properties: Record<string, unknown>) => RevenueInstance;
93
+ setProductId(id: string): RevenueInstance;
94
+ setPrice(price: number): RevenueInstance;
95
+ setQuantity(quantity: number): RevenueInstance;
96
+ setRevenueType(type: string): RevenueInstance;
97
+ setCurrency(currency: string): RevenueInstance;
98
+ setRevenue(revenue: number): RevenueInstance;
99
+ setReceipt(receipt: string): RevenueInstance;
100
+ setReceiptSig(signature: string): RevenueInstance;
101
+ setEventProperties(properties: Record<string, unknown>): RevenueInstance;
103
102
  }
104
103
  /**
105
104
  * Env — optional SDK override. Production leaves this undefined and the
@@ -120,7 +119,8 @@ type Rules = Mapping$1.Rules<Rule>;
120
119
 
121
120
  type index_AmplitudeBrowserOptions = AmplitudeBrowserOptions;
122
121
  type index_AmplitudeDestination = AmplitudeDestination;
123
- type index_AmplitudeSDK = AmplitudeSDK;
122
+ type index_AmplitudePlugin = AmplitudePlugin;
123
+ type index_AmplitudeSDK<I extends IdentifyInstance = IdentifyInstance, R extends RevenueInstance = RevenueInstance> = AmplitudeSDK<I, R>;
124
124
  type index_Config = Config;
125
125
  type index_Destination = Destination;
126
126
  type index_Env = Env;
@@ -134,7 +134,7 @@ type index_RuntimeState = RuntimeState;
134
134
  type index_Settings = Settings;
135
135
  type index_Types = Types;
136
136
  declare namespace index {
137
- export type { index_AmplitudeBrowserOptions as AmplitudeBrowserOptions, index_AmplitudeDestination as AmplitudeDestination, index_AmplitudeSDK as AmplitudeSDK, index_Config as Config, index_Destination as Destination, index_Env as Env, index_IdentifyInstance as IdentifyInstance, index_InitSettings as InitSettings, index_Mapping as Mapping, index_RevenueInstance as RevenueInstance, index_Rule as Rule, index_Rules as Rules, index_RuntimeState as RuntimeState, index_Settings as Settings, index_Types as Types };
137
+ export type { index_AmplitudeBrowserOptions as AmplitudeBrowserOptions, index_AmplitudeDestination as AmplitudeDestination, index_AmplitudePlugin as AmplitudePlugin, index_AmplitudeSDK as AmplitudeSDK, index_Config as Config, index_Destination as Destination, index_Env as Env, index_IdentifyInstance as IdentifyInstance, index_InitSettings as InitSettings, index_Mapping as Mapping, index_RevenueInstance as RevenueInstance, index_Rule as Rule, index_Rules as Rules, index_RuntimeState as RuntimeState, index_Settings as Settings, index_Types as Types };
138
138
  }
139
139
 
140
140
  declare const destinationAmplitude: Destination;
package/dist/index.d.ts CHANGED
@@ -7,6 +7,7 @@ import { InitOptions } from '@amplitude/engagement-browser';
7
7
 
8
8
  type BrowserOptions = Omit<Types$1.BrowserOptions, 'identify'>;
9
9
  type AmplitudeBrowserOptions = Types$1.BrowserOptions;
10
+ type AmplitudePlugin = Types$1.Plugin;
10
11
  /**
11
12
  * Destination-level settings.
12
13
  *
@@ -51,55 +52,53 @@ interface Mapping {
51
52
  reset?: Mapping$1.Value | boolean;
52
53
  }
53
54
  /**
54
- * Amplitude SDK surface — the subset of @amplitude/unified the
55
- * destination actually uses. Mirrors the real module's named exports so
56
- * tests can mock each method individually via env.amplitude.
55
+ * Amplitude SDK surface: the subset of @amplitude/unified the
56
+ * destination actually uses. Mirrors the real client's methods so tests can
57
+ * mock each one via env.amplitude. Generic over the Identify and Revenue
58
+ * instances, so the real SDK gets back the instances it created.
57
59
  */
58
- interface AmplitudeSDK {
59
- initAll: (apiKey: string, options?: Record<string, unknown>) => Promise<void>;
60
- track: (eventType: string, eventProperties?: Record<string, unknown>) => void;
61
- identify: (identify: IdentifyInstance) => void;
62
- revenue: (revenue: RevenueInstance) => void;
63
- reset: () => void;
64
- setOptOut: (optOut: boolean) => void;
65
- setUserId: (userId: string | undefined) => void;
66
- setDeviceId: (deviceId: string) => void;
67
- setSessionId: (sessionId: number) => void;
68
- setGroup: (groupType: string, groupName: string | string[]) => void;
69
- groupIdentify: (groupType: string, groupName: string, identify: IdentifyInstance) => void;
70
- flush: () => {
71
- promise: Promise<void>;
72
- };
73
- add: (plugin: unknown) => {
74
- promise: Promise<void>;
75
- };
76
- Identify: new () => IdentifyInstance;
77
- Revenue: new () => RevenueInstance;
60
+ interface AmplitudeSDK<I extends IdentifyInstance = IdentifyInstance, R extends RevenueInstance = RevenueInstance> {
61
+ /** Analytics. */
62
+ init: (apiKey: string, options?: AmplitudeBrowserOptions) => unknown;
63
+ /** One plugin: Session Replay, Experiment or Guides & Surveys. */
64
+ add: (plugin: AmplitudePlugin) => unknown;
65
+ track: (eventType: string, eventProperties?: Record<string, unknown>) => unknown;
66
+ identify: (identify: I) => unknown;
67
+ revenue: (revenue: R) => unknown;
68
+ reset: () => unknown;
69
+ setOptOut: (optOut: boolean) => unknown;
70
+ setUserId: (userId: string | undefined) => unknown;
71
+ setDeviceId: (deviceId: string) => unknown;
72
+ setSessionId: (sessionId: number) => unknown;
73
+ setGroup: (groupType: string, groupName: string | string[]) => unknown;
74
+ groupIdentify: (groupType: string, groupName: string, identify: I) => unknown;
75
+ Identify: new () => I;
76
+ Revenue: new () => R;
78
77
  }
79
- /** Chainable Identify — mirrors @amplitude/unified Identify class. */
78
+ /** Chainable Identify, as the @amplitude/unified Identify class. */
80
79
  interface IdentifyInstance {
81
- set: (property: string, value: unknown) => IdentifyInstance;
82
- setOnce: (property: string, value: unknown) => IdentifyInstance;
83
- add: (property: string, value: number) => IdentifyInstance;
84
- append: (property: string, value: unknown) => IdentifyInstance;
85
- prepend: (property: string, value: unknown) => IdentifyInstance;
86
- preInsert: (property: string, value: unknown) => IdentifyInstance;
87
- postInsert: (property: string, value: unknown) => IdentifyInstance;
88
- remove: (property: string, value: unknown) => IdentifyInstance;
89
- unset: (property: string) => IdentifyInstance;
90
- clearAll: () => IdentifyInstance;
80
+ set(property: string, value: unknown): IdentifyInstance;
81
+ setOnce(property: string, value: unknown): IdentifyInstance;
82
+ add(property: string, value: number): IdentifyInstance;
83
+ append(property: string, value: unknown): IdentifyInstance;
84
+ prepend(property: string, value: unknown): IdentifyInstance;
85
+ preInsert(property: string, value: unknown): IdentifyInstance;
86
+ postInsert(property: string, value: unknown): IdentifyInstance;
87
+ remove(property: string, value: unknown): IdentifyInstance;
88
+ unset(property: string): IdentifyInstance;
89
+ clearAll(): IdentifyInstance;
91
90
  }
92
- /** Chainable Revenue — mirrors @amplitude/unified Revenue class. */
91
+ /** Chainable Revenue, as the @amplitude/unified Revenue class. */
93
92
  interface RevenueInstance {
94
- setProductId: (id: string) => RevenueInstance;
95
- setPrice: (price: number) => RevenueInstance;
96
- setQuantity: (quantity: number) => RevenueInstance;
97
- setRevenueType: (type: string) => RevenueInstance;
98
- setCurrency: (currency: string) => RevenueInstance;
99
- setRevenue: (revenue: number) => RevenueInstance;
100
- setReceipt: (receipt: string) => RevenueInstance;
101
- setReceiptSig: (signature: string) => RevenueInstance;
102
- setEventProperties: (properties: Record<string, unknown>) => RevenueInstance;
93
+ setProductId(id: string): RevenueInstance;
94
+ setPrice(price: number): RevenueInstance;
95
+ setQuantity(quantity: number): RevenueInstance;
96
+ setRevenueType(type: string): RevenueInstance;
97
+ setCurrency(currency: string): RevenueInstance;
98
+ setRevenue(revenue: number): RevenueInstance;
99
+ setReceipt(receipt: string): RevenueInstance;
100
+ setReceiptSig(signature: string): RevenueInstance;
101
+ setEventProperties(properties: Record<string, unknown>): RevenueInstance;
103
102
  }
104
103
  /**
105
104
  * Env — optional SDK override. Production leaves this undefined and the
@@ -120,7 +119,8 @@ type Rules = Mapping$1.Rules<Rule>;
120
119
 
121
120
  type index_AmplitudeBrowserOptions = AmplitudeBrowserOptions;
122
121
  type index_AmplitudeDestination = AmplitudeDestination;
123
- type index_AmplitudeSDK = AmplitudeSDK;
122
+ type index_AmplitudePlugin = AmplitudePlugin;
123
+ type index_AmplitudeSDK<I extends IdentifyInstance = IdentifyInstance, R extends RevenueInstance = RevenueInstance> = AmplitudeSDK<I, R>;
124
124
  type index_Config = Config;
125
125
  type index_Destination = Destination;
126
126
  type index_Env = Env;
@@ -134,7 +134,7 @@ type index_RuntimeState = RuntimeState;
134
134
  type index_Settings = Settings;
135
135
  type index_Types = Types;
136
136
  declare namespace index {
137
- export type { index_AmplitudeBrowserOptions as AmplitudeBrowserOptions, index_AmplitudeDestination as AmplitudeDestination, index_AmplitudeSDK as AmplitudeSDK, index_Config as Config, index_Destination as Destination, index_Env as Env, index_IdentifyInstance as IdentifyInstance, index_InitSettings as InitSettings, index_Mapping as Mapping, index_RevenueInstance as RevenueInstance, index_Rule as Rule, index_Rules as Rules, index_RuntimeState as RuntimeState, index_Settings as Settings, index_Types as Types };
137
+ export type { index_AmplitudeBrowserOptions as AmplitudeBrowserOptions, index_AmplitudeDestination as AmplitudeDestination, index_AmplitudePlugin as AmplitudePlugin, index_AmplitudeSDK as AmplitudeSDK, index_Config as Config, index_Destination as Destination, index_Env as Env, index_IdentifyInstance as IdentifyInstance, index_InitSettings as InitSettings, index_Mapping as Mapping, index_RevenueInstance as RevenueInstance, index_Rule as Rule, index_Rules as Rules, index_RuntimeState as RuntimeState, index_Settings as Settings, index_Types as Types };
138
138
  }
139
139
 
140
140
  declare const destinationAmplitude: Destination;