@growth-rail/core 1.0.0
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 +114 -0
- package/dist/index.d.ts +114 -0
- package/dist/index.js +876 -0
- package/dist/index.js.map +1 -0
- package/dist/index.mjs +848 -0
- package/dist/index.mjs.map +1 -0
- package/package.json +40 -0
package/dist/index.d.mts
ADDED
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
type GrowthRailOptions = {
|
|
2
|
+
apiKey: string;
|
|
3
|
+
cookieDomain?: string;
|
|
4
|
+
autoPageTrack?: boolean;
|
|
5
|
+
};
|
|
6
|
+
type AppUserType = {
|
|
7
|
+
attributes: Record<string, unknown>;
|
|
8
|
+
firstSeenAt: string;
|
|
9
|
+
lastSeenAt: string | null;
|
|
10
|
+
uniqueId: string;
|
|
11
|
+
referralCode: string;
|
|
12
|
+
referralLink: string;
|
|
13
|
+
referrerExperience: ReferrerExperience;
|
|
14
|
+
};
|
|
15
|
+
type AppUserTypeWithId = AppUserType & {
|
|
16
|
+
id: string;
|
|
17
|
+
};
|
|
18
|
+
type ReferralLink = {
|
|
19
|
+
referralCode: string;
|
|
20
|
+
referralLink: string;
|
|
21
|
+
};
|
|
22
|
+
type EventPayload = {
|
|
23
|
+
event: string;
|
|
24
|
+
userId?: string;
|
|
25
|
+
properties?: Record<string, any>;
|
|
26
|
+
timestamp: string;
|
|
27
|
+
};
|
|
28
|
+
type TrackReferralResponse = {
|
|
29
|
+
referralTrackingId: string;
|
|
30
|
+
promotionalText: string;
|
|
31
|
+
};
|
|
32
|
+
type TriggerButtonPosition = 'bottom-right' | 'bottom-left' | 'top-right' | 'top-left';
|
|
33
|
+
type ReferrerTriggerButton = {
|
|
34
|
+
show: boolean;
|
|
35
|
+
position: TriggerButtonPosition;
|
|
36
|
+
type: 'floating' | 'edge';
|
|
37
|
+
};
|
|
38
|
+
type ReferrerModalOptions = {
|
|
39
|
+
title: string;
|
|
40
|
+
description: string;
|
|
41
|
+
type: 'modal' | 'drawer';
|
|
42
|
+
theme: {
|
|
43
|
+
primaryColor: string;
|
|
44
|
+
tintColor: string;
|
|
45
|
+
backgroundColor: string;
|
|
46
|
+
};
|
|
47
|
+
};
|
|
48
|
+
interface ReferrerExperience {
|
|
49
|
+
trigger: ReferrerTriggerButton;
|
|
50
|
+
modal: ReferrerModalOptions;
|
|
51
|
+
}
|
|
52
|
+
interface NewUserExperience {
|
|
53
|
+
banner: {
|
|
54
|
+
show: boolean;
|
|
55
|
+
position: 'center-top' | 'center-bottom' | 'left-top' | 'left-bottom' | 'right-top' | 'right-bottom';
|
|
56
|
+
text: string;
|
|
57
|
+
};
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
declare class GrowthRail {
|
|
61
|
+
private static api;
|
|
62
|
+
private static storage;
|
|
63
|
+
private static options;
|
|
64
|
+
private static currentUser;
|
|
65
|
+
private static initialized;
|
|
66
|
+
private static referralModal;
|
|
67
|
+
private static floatingButton;
|
|
68
|
+
private static experience;
|
|
69
|
+
private static userReadyPromise;
|
|
70
|
+
private static userReadyResolver;
|
|
71
|
+
private constructor();
|
|
72
|
+
static init(options: GrowthRailOptions): void;
|
|
73
|
+
static isInitialized(): boolean;
|
|
74
|
+
private static ensureInitialized;
|
|
75
|
+
private static loadReferrerExperience;
|
|
76
|
+
private static createReferralModal;
|
|
77
|
+
private static autoTrackReferral;
|
|
78
|
+
static initAppUser(clientProvidedId: string): Promise<AppUserType>;
|
|
79
|
+
static trackReferral(referralCode: string, rewardEventName?: string): Promise<TrackReferralResponse>;
|
|
80
|
+
static trackRewardEvent(eventName?: string): Promise<void>;
|
|
81
|
+
static getReferralLink(): string;
|
|
82
|
+
static getReferralCode(): string | undefined;
|
|
83
|
+
static getUserId(): string | undefined;
|
|
84
|
+
static isUserReady(): boolean;
|
|
85
|
+
static ensureUserReady(): Promise<AppUserType>;
|
|
86
|
+
static showReferralDashboard(options?: Partial<ReferrerModalOptions>): Promise<void>;
|
|
87
|
+
private static createPromotionalBanner;
|
|
88
|
+
static createTriggerButton(options: Partial<ReferrerTriggerButton>): void;
|
|
89
|
+
static destroyTriggerButton(): void;
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
interface ReferralModalDependencies {
|
|
93
|
+
isUserReady: () => boolean;
|
|
94
|
+
getReferralLink: () => string;
|
|
95
|
+
}
|
|
96
|
+
declare class ReferralModal {
|
|
97
|
+
private referrerExperience;
|
|
98
|
+
private deps;
|
|
99
|
+
private host;
|
|
100
|
+
private shadow;
|
|
101
|
+
private overlay;
|
|
102
|
+
private content;
|
|
103
|
+
constructor(deps: ReferralModalDependencies, referrerExperience: ReferrerExperience);
|
|
104
|
+
show(options?: Partial<ReferrerModalOptions>, container?: HTMLElement): void;
|
|
105
|
+
hide(): void;
|
|
106
|
+
private createDom;
|
|
107
|
+
private getTheme;
|
|
108
|
+
private renderInternalContent;
|
|
109
|
+
private renderLinkView;
|
|
110
|
+
private renderSocialShare;
|
|
111
|
+
private bindEvents;
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
export { type AppUserType, type AppUserTypeWithId, type EventPayload, GrowthRail, type GrowthRailOptions, type NewUserExperience, type ReferralLink, ReferralModal, type ReferralModalDependencies, type ReferrerExperience, type ReferrerModalOptions, type ReferrerTriggerButton, type TrackReferralResponse, type TriggerButtonPosition };
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
type GrowthRailOptions = {
|
|
2
|
+
apiKey: string;
|
|
3
|
+
cookieDomain?: string;
|
|
4
|
+
autoPageTrack?: boolean;
|
|
5
|
+
};
|
|
6
|
+
type AppUserType = {
|
|
7
|
+
attributes: Record<string, unknown>;
|
|
8
|
+
firstSeenAt: string;
|
|
9
|
+
lastSeenAt: string | null;
|
|
10
|
+
uniqueId: string;
|
|
11
|
+
referralCode: string;
|
|
12
|
+
referralLink: string;
|
|
13
|
+
referrerExperience: ReferrerExperience;
|
|
14
|
+
};
|
|
15
|
+
type AppUserTypeWithId = AppUserType & {
|
|
16
|
+
id: string;
|
|
17
|
+
};
|
|
18
|
+
type ReferralLink = {
|
|
19
|
+
referralCode: string;
|
|
20
|
+
referralLink: string;
|
|
21
|
+
};
|
|
22
|
+
type EventPayload = {
|
|
23
|
+
event: string;
|
|
24
|
+
userId?: string;
|
|
25
|
+
properties?: Record<string, any>;
|
|
26
|
+
timestamp: string;
|
|
27
|
+
};
|
|
28
|
+
type TrackReferralResponse = {
|
|
29
|
+
referralTrackingId: string;
|
|
30
|
+
promotionalText: string;
|
|
31
|
+
};
|
|
32
|
+
type TriggerButtonPosition = 'bottom-right' | 'bottom-left' | 'top-right' | 'top-left';
|
|
33
|
+
type ReferrerTriggerButton = {
|
|
34
|
+
show: boolean;
|
|
35
|
+
position: TriggerButtonPosition;
|
|
36
|
+
type: 'floating' | 'edge';
|
|
37
|
+
};
|
|
38
|
+
type ReferrerModalOptions = {
|
|
39
|
+
title: string;
|
|
40
|
+
description: string;
|
|
41
|
+
type: 'modal' | 'drawer';
|
|
42
|
+
theme: {
|
|
43
|
+
primaryColor: string;
|
|
44
|
+
tintColor: string;
|
|
45
|
+
backgroundColor: string;
|
|
46
|
+
};
|
|
47
|
+
};
|
|
48
|
+
interface ReferrerExperience {
|
|
49
|
+
trigger: ReferrerTriggerButton;
|
|
50
|
+
modal: ReferrerModalOptions;
|
|
51
|
+
}
|
|
52
|
+
interface NewUserExperience {
|
|
53
|
+
banner: {
|
|
54
|
+
show: boolean;
|
|
55
|
+
position: 'center-top' | 'center-bottom' | 'left-top' | 'left-bottom' | 'right-top' | 'right-bottom';
|
|
56
|
+
text: string;
|
|
57
|
+
};
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
declare class GrowthRail {
|
|
61
|
+
private static api;
|
|
62
|
+
private static storage;
|
|
63
|
+
private static options;
|
|
64
|
+
private static currentUser;
|
|
65
|
+
private static initialized;
|
|
66
|
+
private static referralModal;
|
|
67
|
+
private static floatingButton;
|
|
68
|
+
private static experience;
|
|
69
|
+
private static userReadyPromise;
|
|
70
|
+
private static userReadyResolver;
|
|
71
|
+
private constructor();
|
|
72
|
+
static init(options: GrowthRailOptions): void;
|
|
73
|
+
static isInitialized(): boolean;
|
|
74
|
+
private static ensureInitialized;
|
|
75
|
+
private static loadReferrerExperience;
|
|
76
|
+
private static createReferralModal;
|
|
77
|
+
private static autoTrackReferral;
|
|
78
|
+
static initAppUser(clientProvidedId: string): Promise<AppUserType>;
|
|
79
|
+
static trackReferral(referralCode: string, rewardEventName?: string): Promise<TrackReferralResponse>;
|
|
80
|
+
static trackRewardEvent(eventName?: string): Promise<void>;
|
|
81
|
+
static getReferralLink(): string;
|
|
82
|
+
static getReferralCode(): string | undefined;
|
|
83
|
+
static getUserId(): string | undefined;
|
|
84
|
+
static isUserReady(): boolean;
|
|
85
|
+
static ensureUserReady(): Promise<AppUserType>;
|
|
86
|
+
static showReferralDashboard(options?: Partial<ReferrerModalOptions>): Promise<void>;
|
|
87
|
+
private static createPromotionalBanner;
|
|
88
|
+
static createTriggerButton(options: Partial<ReferrerTriggerButton>): void;
|
|
89
|
+
static destroyTriggerButton(): void;
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
interface ReferralModalDependencies {
|
|
93
|
+
isUserReady: () => boolean;
|
|
94
|
+
getReferralLink: () => string;
|
|
95
|
+
}
|
|
96
|
+
declare class ReferralModal {
|
|
97
|
+
private referrerExperience;
|
|
98
|
+
private deps;
|
|
99
|
+
private host;
|
|
100
|
+
private shadow;
|
|
101
|
+
private overlay;
|
|
102
|
+
private content;
|
|
103
|
+
constructor(deps: ReferralModalDependencies, referrerExperience: ReferrerExperience);
|
|
104
|
+
show(options?: Partial<ReferrerModalOptions>, container?: HTMLElement): void;
|
|
105
|
+
hide(): void;
|
|
106
|
+
private createDom;
|
|
107
|
+
private getTheme;
|
|
108
|
+
private renderInternalContent;
|
|
109
|
+
private renderLinkView;
|
|
110
|
+
private renderSocialShare;
|
|
111
|
+
private bindEvents;
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
export { type AppUserType, type AppUserTypeWithId, type EventPayload, GrowthRail, type GrowthRailOptions, type NewUserExperience, type ReferralLink, ReferralModal, type ReferralModalDependencies, type ReferrerExperience, type ReferrerModalOptions, type ReferrerTriggerButton, type TrackReferralResponse, type TriggerButtonPosition };
|