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
|
*
|
|
@@ -4,10 +4,9 @@ import { WTSDKEnvironment } from "./environments";
|
|
|
4
4
|
export declare const WTConstants: {
|
|
5
5
|
readonly SDK: {
|
|
6
6
|
readonly PLATFORM: "web";
|
|
7
|
-
readonly VERSION: "2.0.
|
|
7
|
+
readonly VERSION: "2.0.8";
|
|
8
8
|
};
|
|
9
9
|
readonly CONFIG: {
|
|
10
|
-
readonly BASE_URL: "https://config.wisetrack.io";
|
|
11
10
|
readonly DEFAULT_ENVIRONMENT: WTSDKEnvironment;
|
|
12
11
|
};
|
|
13
12
|
readonly DEFAULTS: {
|
|
@@ -19,7 +19,7 @@ export declare const WTSDKEnvironment: {
|
|
|
19
19
|
export type WTSDKEnvironment = (typeof WTSDKEnvironment)[keyof typeof WTSDKEnvironment];
|
|
20
20
|
/** @internal */
|
|
21
21
|
export declare const EnvironmentUtils: {
|
|
22
|
-
sdkEnvironment: WTSDKEnvironment;
|
|
22
|
+
readonly sdkEnvironment: WTSDKEnvironment;
|
|
23
23
|
readonly needResponseDetails: boolean;
|
|
24
24
|
readonly baseUrl: string;
|
|
25
25
|
};
|
|
@@ -2,7 +2,7 @@ import { WTEvent } from "../../types/event/wt-event";
|
|
|
2
2
|
import { FieldsBuilder } from "./fields-builder";
|
|
3
3
|
/** @internal */
|
|
4
4
|
export declare class EventFieldsBuilder extends FieldsBuilder {
|
|
5
|
-
event: WTEvent
|
|
6
|
-
constructor(event: WTEvent
|
|
5
|
+
event: WTEvent;
|
|
6
|
+
constructor(event: WTEvent);
|
|
7
7
|
build(): Promise<Record<string, any>>;
|
|
8
8
|
}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { WTSDKEnvironment } from "../../constants/environments";
|
|
1
2
|
import { WTInitialConfig } from "../../types/config/initial-config";
|
|
2
3
|
import { WTConfig } from "../../types/config/wt-config";
|
|
3
4
|
import { RequestRecord } from "../caching/queue-data";
|
|
@@ -43,6 +44,10 @@ declare class StorageManager {
|
|
|
43
44
|
set pendingRequestRecords(value: RequestRecord[]);
|
|
44
45
|
get eventCount(): number;
|
|
45
46
|
set eventCount(value: number);
|
|
47
|
+
get sdkEnvironment(): WTSDKEnvironment | null;
|
|
48
|
+
set sdkEnvironment(value: string);
|
|
49
|
+
get sdkVersion(): string;
|
|
50
|
+
set sdkVersion(value: string);
|
|
46
51
|
}
|
|
47
52
|
/** @internal */
|
|
48
53
|
export declare const storageManager: StorageManager;
|
|
@@ -100,20 +100,22 @@ export declare class WiseTrack {
|
|
|
100
100
|
* @example
|
|
101
101
|
* ```ts
|
|
102
102
|
* // Create a Default Event
|
|
103
|
-
* const defaultEvent = new WTEvent.
|
|
104
|
-
*
|
|
105
|
-
*
|
|
106
|
-
*
|
|
103
|
+
* const defaultEvent = new WTEvent.defaultEvent("default-event", {
|
|
104
|
+
* key1: "value1",
|
|
105
|
+
* key2: 123,
|
|
106
|
+
* key3: true
|
|
107
|
+
* });
|
|
107
108
|
* await WiseTrack.instance.trackEvent(defaultEvent);
|
|
108
109
|
*
|
|
109
110
|
* // Create a Revenue Event
|
|
110
|
-
* const revenueEvent = new WTEvent.
|
|
111
|
-
*
|
|
112
|
-
*
|
|
111
|
+
* const revenueEvent = new WTEvent.revenueEvent("revenue-event", 100, "USD", {
|
|
112
|
+
* item_id: "item123",
|
|
113
|
+
* quantity: 2
|
|
114
|
+
* });
|
|
113
115
|
* await WiseTrack.instance.trackEvent(revenueEvent);
|
|
114
116
|
* ```
|
|
115
117
|
*/
|
|
116
|
-
trackEvent(event: WTEvent
|
|
118
|
+
trackEvent(event: WTEvent): Promise<void>;
|
|
117
119
|
/** @internal */
|
|
118
120
|
private getConfig;
|
|
119
121
|
/** @internal */
|
|
@@ -8,7 +8,7 @@ declare class WTTracker {
|
|
|
8
8
|
startTracking(): Promise<void>;
|
|
9
9
|
stopTracking(): Promise<void>;
|
|
10
10
|
checkPushToken(token: string): Promise<void>;
|
|
11
|
-
trackEvent(event: WTEvent
|
|
11
|
+
trackEvent(event: WTEvent): Promise<void>;
|
|
12
12
|
private getCountryCode;
|
|
13
13
|
private createAttribution;
|
|
14
14
|
private checkFirstSession;
|
package/dist/esm/index.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
|
+
export { WTUserEnvironment } from "./constants/environments";
|
|
2
|
+
export { ResourceWrapper } from "./constants/resource-wrapper";
|
|
1
3
|
export { WiseTrack } from "./core/wisetrack";
|
|
2
4
|
export { WTInitialConfig } from "./types/config/initial-config";
|
|
3
|
-
export { WTEvent, EventParam } from "./types/event/wt-event";
|
|
4
|
-
export { WTLogEngine, WTLogger, WTLogLevel } from "./utils/logger";
|
|
5
|
-
export { WTUserEnvironment } from "./constants/environments";
|
|
6
5
|
export { RevenueCurrency } from "./types/event/revenue-currency";
|
|
6
|
+
export { EventParam, WTEvent } from "./types/event/wt-event";
|
|
7
|
+
export { WTLogger, WTLogLevel } from "./utils/logger";
|