wisetrack 2.0.6 → 2.0.8
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/README.md +33 -17
- package/dist/cdn/sdk.bundle.min.js +1 -1
- package/dist/cjs/constants/constants.d.ts +1 -2
- package/dist/cjs/constants/environments.d.ts +1 -1
- package/dist/cjs/constants/resource-wrapper.d.ts +5 -0
- package/dist/cjs/core/fields/event-fields-builder.d.ts +2 -2
- package/dist/cjs/core/storage/storage-manager.d.ts +5 -0
- package/dist/cjs/core/wisetrack.d.ts +10 -8
- package/dist/cjs/core/wt-tracker.d.ts +1 -1
- package/dist/cjs/index.d.ts +4 -3
- package/dist/cjs/index.js +1 -1
- package/dist/cjs/types/event/wt-event.d.ts +72 -88
- package/dist/cjs/utils/logger.d.ts +1 -3
- package/dist/esm/constants/constants.d.ts +1 -2
- package/dist/esm/constants/environments.d.ts +1 -1
- package/dist/esm/constants/resource-wrapper.d.ts +5 -0
- package/dist/esm/core/fields/event-fields-builder.d.ts +2 -2
- package/dist/esm/core/storage/storage-manager.d.ts +5 -0
- package/dist/esm/core/wisetrack.d.ts +10 -8
- package/dist/esm/core/wt-tracker.d.ts +1 -1
- package/dist/esm/index.d.ts +4 -3
- package/dist/esm/index.js +1 -1
- package/dist/esm/types/event/wt-event.d.ts +72 -88
- package/dist/esm/utils/logger.d.ts +1 -3
- package/package.json +1 -1
|
@@ -1,109 +1,93 @@
|
|
|
1
1
|
import { RevenueCurrency } from "./revenue-currency";
|
|
2
2
|
type WTEventType = "default" | "revenue";
|
|
3
3
|
export type EventParam = string | number | boolean;
|
|
4
|
-
|
|
4
|
+
/**
|
|
5
|
+
* Represents an event that can be tracked.
|
|
6
|
+
*
|
|
7
|
+
* Use the static factory methods to create events:
|
|
8
|
+
* - `WTEvent.defaultEvent()` for default events
|
|
9
|
+
* - `WTEvent.revenueEvent()` for revenue/purchase events
|
|
10
|
+
*
|
|
11
|
+
* @example
|
|
12
|
+
* ```ts
|
|
13
|
+
* // Simple event
|
|
14
|
+
* const event1 = WTEvent.defaultEvent("signup");
|
|
15
|
+
*
|
|
16
|
+
* // Event with parameters
|
|
17
|
+
* const event2 = WTEvent.defaultEvent("signup", { method: "Google", platform: "web" });
|
|
18
|
+
*
|
|
19
|
+
* // Revenue event
|
|
20
|
+
* const purchase = WTEvent.revenueEvent("order_complete", 49.99, RevenueCurrency.USD, {
|
|
21
|
+
* item_count: 3,
|
|
22
|
+
* payment_method: "credit_card"
|
|
23
|
+
* });
|
|
24
|
+
*
|
|
25
|
+
* WiseTrack.instance.trackEvent(event1);
|
|
26
|
+
* ```
|
|
27
|
+
*/
|
|
28
|
+
export declare class WTEvent {
|
|
5
29
|
/**
|
|
6
|
-
*
|
|
30
|
+
* The type of event.
|
|
31
|
+
* @internal
|
|
32
|
+
*/
|
|
33
|
+
readonly type: WTEventType;
|
|
34
|
+
/**
|
|
35
|
+
* The name of the event.
|
|
36
|
+
*/
|
|
37
|
+
readonly name: string;
|
|
38
|
+
/**
|
|
39
|
+
* Custom key-value parameters for the event.
|
|
40
|
+
*/
|
|
41
|
+
readonly params: Record<string, EventParam>;
|
|
42
|
+
/**
|
|
43
|
+
* The revenue amount (only for revenue events).
|
|
44
|
+
*/
|
|
45
|
+
readonly amount?: number;
|
|
46
|
+
/**
|
|
47
|
+
* The currency of the revenue (only for revenue events).
|
|
48
|
+
*/
|
|
49
|
+
readonly currency?: RevenueCurrency;
|
|
50
|
+
/**
|
|
51
|
+
* Private constructor. Use static factory methods instead.
|
|
52
|
+
* @internal
|
|
53
|
+
*/
|
|
54
|
+
private constructor();
|
|
55
|
+
/**
|
|
56
|
+
* Creates a default event for tracking default user actions.
|
|
7
57
|
*
|
|
8
|
-
*
|
|
58
|
+
* @param name - The name of the event.
|
|
59
|
+
* @param params - Optional custom key-value parameters for the event.
|
|
60
|
+
* @returns A new WTEvent instance.
|
|
9
61
|
*
|
|
10
62
|
* @example
|
|
11
63
|
* ```ts
|
|
12
|
-
* const event =
|
|
13
|
-
* event.addParam("method", "Google");
|
|
64
|
+
* const event = WTEvent.defaultEvent("button_click", { button_id: "signup" });
|
|
14
65
|
* WiseTrack.instance.trackEvent(event);
|
|
15
66
|
* ```
|
|
16
67
|
*/
|
|
17
|
-
|
|
18
|
-
/**
|
|
19
|
-
* The type of event.
|
|
20
|
-
* @internal
|
|
21
|
-
*/
|
|
22
|
-
readonly type: WTEventType;
|
|
23
|
-
/**
|
|
24
|
-
* Optional custom key-value parameters for the event.
|
|
25
|
-
*/
|
|
26
|
-
params?: Record<string, EventParam>;
|
|
27
|
-
/**
|
|
28
|
-
* The name of the event.
|
|
29
|
-
*/
|
|
30
|
-
name: string;
|
|
31
|
-
/**
|
|
32
|
-
* Creates a new custom event.
|
|
33
|
-
* @param name - The name of the event.
|
|
34
|
-
*/
|
|
35
|
-
constructor(name: string);
|
|
36
|
-
/**
|
|
37
|
-
* Adds a parameter to the event with validation.
|
|
38
|
-
*
|
|
39
|
-
* @param key - The parameter key (max 50 characters, cannot be "no_parameters").
|
|
40
|
-
* @param value - The parameter value (max 50 characters).
|
|
41
|
-
* @throws {WTEventValidationError} When validation fails.
|
|
42
|
-
*
|
|
43
|
-
* @example
|
|
44
|
-
* ```ts
|
|
45
|
-
* event.addParam("category", "electronics");
|
|
46
|
-
* event.addParam("item_count", 3);
|
|
47
|
-
* event.addParam("is_premium", true);
|
|
48
|
-
* ```
|
|
49
|
-
*/
|
|
50
|
-
addParam(key: string, value: EventParam): void;
|
|
51
|
-
/**
|
|
52
|
-
* Adds multiple parameters at once with validation.
|
|
53
|
-
*
|
|
54
|
-
* @param params - Object containing key-value pairs to add.
|
|
55
|
-
* @throws {WTEventValidationError} When validation fails for any parameter.
|
|
56
|
-
*/
|
|
57
|
-
addParams(params: Record<string, EventParam>): void;
|
|
58
|
-
/** @internal */
|
|
59
|
-
toJSON(): {
|
|
60
|
-
event_type: WTEventType;
|
|
61
|
-
event_name: string;
|
|
62
|
-
partner_params: Record<string, EventParam> | undefined;
|
|
63
|
-
};
|
|
64
|
-
}
|
|
68
|
+
static defaultEvent(name: string, params?: Record<string, EventParam>): WTEvent;
|
|
65
69
|
/**
|
|
66
|
-
*
|
|
70
|
+
* Creates a revenue event for tracking purchases or monetary transactions.
|
|
67
71
|
*
|
|
68
|
-
*
|
|
72
|
+
* @param name - The name of the revenue event.
|
|
73
|
+
* @param amount - The amount of revenue.
|
|
74
|
+
* @param currency - The currency of the revenue.
|
|
75
|
+
* @param params - Optional custom key-value parameters for the event.
|
|
76
|
+
* @returns A new WTEvent instance.
|
|
69
77
|
*
|
|
70
78
|
* @example
|
|
71
79
|
* ```ts
|
|
72
|
-
* const purchase =
|
|
73
|
-
*
|
|
80
|
+
* const purchase = WTEvent.revenueEvent("purchase", 99.99, RevenueCurrency.USD, {
|
|
81
|
+
* item_count: 3
|
|
82
|
+
* });
|
|
74
83
|
* WiseTrack.instance.trackEvent(purchase);
|
|
75
84
|
* ```
|
|
76
85
|
*/
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
/**
|
|
84
|
-
* The revenue amount.
|
|
85
|
-
*/
|
|
86
|
-
amount: number;
|
|
87
|
-
/**
|
|
88
|
-
* The currency of the revenue.
|
|
89
|
-
*/
|
|
90
|
-
currency: RevenueCurrency;
|
|
91
|
-
/**
|
|
92
|
-
* Creates a new revenue event.
|
|
93
|
-
*
|
|
94
|
-
* @param name - The name of the revenue event.
|
|
95
|
-
* @param amount - The amount of revenue.
|
|
96
|
-
* @param currency - The currency of the revenue.
|
|
97
|
-
*/
|
|
98
|
-
constructor(name: string, amount: number, currency: RevenueCurrency);
|
|
99
|
-
/** @internal */
|
|
100
|
-
toJSON(): {
|
|
101
|
-
event_type: WTEventType;
|
|
102
|
-
event_name: string;
|
|
103
|
-
revenue: number;
|
|
104
|
-
currency: RevenueCurrency;
|
|
105
|
-
partner_params: Record<string, EventParam> | undefined;
|
|
106
|
-
};
|
|
107
|
-
}
|
|
86
|
+
static revenueEvent(name: string, amount: number, currency: RevenueCurrency, params?: Record<string, EventParam>): WTEvent;
|
|
87
|
+
/**
|
|
88
|
+
* Validates and sets multiple parameters.
|
|
89
|
+
* @internal
|
|
90
|
+
*/
|
|
91
|
+
private validateAndSetParams;
|
|
108
92
|
}
|
|
109
93
|
export {};
|
|
@@ -1,7 +1,5 @@
|
|
|
1
1
|
/** @internal */
|
|
2
|
-
export
|
|
3
|
-
abstract log(level: string, prefix: string, ...args: any[]): void;
|
|
4
|
-
}
|
|
2
|
+
export type WTLogEngine = (level: string, prefix: string, args: any[]) => void;
|
|
5
3
|
/**
|
|
6
4
|
* Defines the available log levels for the SDK.
|
|
7
5
|
*
|