@digia-engage/core 1.1.1 → 2.0.0-rc.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.
- package/README.md +134 -51
- package/android/build.gradle +2 -2
- package/android/src/main/java/com/digia/engage/rn/DigiaModule.kt +52 -8
- package/android/src/main/java/com/digia/engage/rn/DigiaSlotViewManager.kt +6 -2
- package/android/src/main/java/com/digia/engage/rn/DigiaViewManager.kt +1 -0
- package/ios/DigiaEngageModule.m +7 -1
- package/ios/DigiaHostViewManager.swift +20 -20
- package/ios/DigiaModule.swift +8 -4
- package/lib/commonjs/Digia.js +301 -3
- package/lib/commonjs/Digia.js.map +1 -1
- package/lib/commonjs/DigiaGuideController.js +59 -0
- package/lib/commonjs/DigiaGuideController.js.map +1 -0
- package/lib/commonjs/DigiaHealthReporter.js +45 -0
- package/lib/commonjs/DigiaHealthReporter.js.map +1 -0
- package/lib/commonjs/DigiaProvider.js +1079 -0
- package/lib/commonjs/DigiaProvider.js.map +1 -0
- package/lib/commonjs/DigiaSlotView.js +18 -3
- package/lib/commonjs/DigiaSlotView.js.map +1 -1
- package/lib/commonjs/NativeDigiaEngage.js +14 -8
- package/lib/commonjs/NativeDigiaEngage.js.map +1 -1
- package/lib/commonjs/actionHandler.js +316 -0
- package/lib/commonjs/actionHandler.js.map +1 -0
- package/lib/commonjs/defaultInAppBrowser.js +31 -0
- package/lib/commonjs/defaultInAppBrowser.js.map +1 -0
- package/lib/commonjs/digiaAnchorRegistry.js +32 -0
- package/lib/commonjs/digiaAnchorRegistry.js.map +1 -0
- package/lib/commonjs/index.js +7 -0
- package/lib/commonjs/index.js.map +1 -1
- package/lib/commonjs/templateTypes.js +2 -0
- package/lib/commonjs/templateTypes.js.map +1 -0
- package/lib/module/Digia.js +301 -3
- package/lib/module/Digia.js.map +1 -1
- package/lib/module/DigiaGuideController.js +53 -0
- package/lib/module/DigiaGuideController.js.map +1 -0
- package/lib/module/DigiaHealthReporter.js +38 -0
- package/lib/module/DigiaHealthReporter.js.map +1 -0
- package/lib/module/DigiaProvider.js +1072 -0
- package/lib/module/DigiaProvider.js.map +1 -0
- package/lib/module/DigiaSlotView.js +20 -5
- package/lib/module/DigiaSlotView.js.map +1 -1
- package/lib/module/NativeDigiaEngage.js +14 -8
- package/lib/module/NativeDigiaEngage.js.map +1 -1
- package/lib/module/actionHandler.js +311 -0
- package/lib/module/actionHandler.js.map +1 -0
- package/lib/module/defaultInAppBrowser.js +25 -0
- package/lib/module/defaultInAppBrowser.js.map +1 -0
- package/lib/module/digiaAnchorRegistry.js +26 -0
- package/lib/module/digiaAnchorRegistry.js.map +1 -0
- package/lib/module/index.js +1 -0
- package/lib/module/index.js.map +1 -1
- package/lib/module/templateTypes.js +2 -0
- package/lib/module/templateTypes.js.map +1 -0
- package/lib/typescript/Digia.d.ts +29 -2
- package/lib/typescript/Digia.d.ts.map +1 -1
- package/lib/typescript/DigiaGuideController.d.ts +30 -0
- package/lib/typescript/DigiaGuideController.d.ts.map +1 -0
- package/lib/typescript/DigiaHealthReporter.d.ts +24 -0
- package/lib/typescript/DigiaHealthReporter.d.ts.map +1 -0
- package/lib/typescript/DigiaProvider.d.ts +3 -0
- package/lib/typescript/DigiaProvider.d.ts.map +1 -0
- package/lib/typescript/DigiaSlotView.d.ts.map +1 -1
- package/lib/typescript/NativeDigiaEngage.d.ts +10 -6
- package/lib/typescript/NativeDigiaEngage.d.ts.map +1 -1
- package/lib/typescript/actionHandler.d.ts +20 -0
- package/lib/typescript/actionHandler.d.ts.map +1 -0
- package/lib/typescript/defaultInAppBrowser.d.ts +3 -0
- package/lib/typescript/defaultInAppBrowser.d.ts.map +1 -0
- package/lib/typescript/digiaAnchorRegistry.d.ts +15 -0
- package/lib/typescript/digiaAnchorRegistry.d.ts.map +1 -0
- package/lib/typescript/index.d.ts +1 -0
- package/lib/typescript/index.d.ts.map +1 -1
- package/lib/typescript/templateTypes.d.ts +140 -0
- package/lib/typescript/templateTypes.d.ts.map +1 -0
- package/lib/typescript/types.d.ts +140 -3
- package/lib/typescript/types.d.ts.map +1 -1
- package/package.json +11 -3
- package/src/Digia.ts +340 -3
- package/src/DigiaGuideController.ts +61 -0
- package/src/DigiaHealthReporter.ts +43 -0
- package/src/DigiaProvider.tsx +776 -0
- package/src/DigiaSlotView.tsx +26 -6
- package/src/NativeDigiaEngage.ts +28 -13
- package/src/actionHandler.ts +311 -0
- package/src/defaultInAppBrowser.ts +31 -0
- package/src/digiaAnchorRegistry.ts +27 -0
- package/src/index.ts +1 -0
- package/src/templateTypes.ts +121 -0
- package/src/types.ts +102 -5
package/src/types.ts
CHANGED
|
@@ -12,7 +12,9 @@ export interface InAppPayload {
|
|
|
12
12
|
cepContext: Record<string, unknown>;
|
|
13
13
|
}
|
|
14
14
|
|
|
15
|
-
|
|
15
|
+
export type CampaignType = 'nudge' | 'guide' | 'inline' | 'survey';
|
|
16
|
+
|
|
17
|
+
// ─── Experience events (CEP lifecycle — used by notifyEvent) ──────────────────
|
|
16
18
|
|
|
17
19
|
/** The experience became visible to the user. */
|
|
18
20
|
export interface ExperienceImpressed {
|
|
@@ -30,11 +32,35 @@ export interface ExperienceDismissed {
|
|
|
30
32
|
readonly type: 'dismissed';
|
|
31
33
|
}
|
|
32
34
|
|
|
35
|
+
/** The user completed the experience (advanced past the final step). */
|
|
36
|
+
export interface ExperienceCompleted {
|
|
37
|
+
readonly type: 'completed';
|
|
38
|
+
}
|
|
39
|
+
|
|
33
40
|
/** Discriminated union of all experience event types. */
|
|
34
41
|
export type DigiaExperienceEvent =
|
|
35
42
|
| ExperienceImpressed
|
|
36
43
|
| ExperienceClicked
|
|
37
|
-
| ExperienceDismissed
|
|
44
|
+
| ExperienceDismissed
|
|
45
|
+
| ExperienceCompleted;
|
|
46
|
+
|
|
47
|
+
// ─── Guide lifecycle events (analytics — used by track()) ────────────────────
|
|
48
|
+
|
|
49
|
+
export type DismissReason = 'user_close' | 'scrim_tap' | 'back_gesture' | 'auto_timeout';
|
|
50
|
+
|
|
51
|
+
/**
|
|
52
|
+
* Rich internal event emitted by guide overlays.
|
|
53
|
+
* Carries all context needed to build the CEP analytics property schema.
|
|
54
|
+
* Not part of the public plugin API — converted to track() calls in Digia.ts.
|
|
55
|
+
*/
|
|
56
|
+
export type GuideLifecycleEvent =
|
|
57
|
+
| { type: 'viewed'; stepIndex: number; stepTotal: number; anchorKey: string; displayStyle: 'tooltip' | 'spotlight' }
|
|
58
|
+
| { type: 'step_viewed'; stepIndex: number; stepTotal: number; anchorKey: string; displayStyle: 'tooltip' | 'spotlight' }
|
|
59
|
+
| { type: 'clicked'; stepIndex: number; stepTotal: number; anchorKey: string; displayStyle: 'tooltip' | 'spotlight'; ctaLabel: string; actionType: string; actionUrl?: string; elementId?: string }
|
|
60
|
+
| { type: 'step_clicked'; stepIndex: number; stepTotal: number; anchorKey: string; displayStyle: 'tooltip' | 'spotlight'; ctaLabel: string; actionType: string; actionUrl?: string; elementId?: string }
|
|
61
|
+
| { type: 'dismissed'; stepIndex: number; stepTotal: number; anchorKey: string; displayStyle: 'tooltip' | 'spotlight'; dismissReason: DismissReason }
|
|
62
|
+
| { type: 'step_dismissed'; stepIndex: number; stepTotal: number; anchorKey: string; displayStyle: 'tooltip' | 'spotlight'; dismissReason: DismissReason }
|
|
63
|
+
| { type: 'completed'; stepIndex: number; stepTotal: number; anchorKey: string; displayStyle: 'tooltip' | 'spotlight' };
|
|
38
64
|
|
|
39
65
|
/**
|
|
40
66
|
* Delegate passed by the Digia SDK to each registered plugin via setup().
|
|
@@ -65,18 +91,63 @@ export interface DigiaPlugin {
|
|
|
65
91
|
* analytics back to their CEP platform.
|
|
66
92
|
*/
|
|
67
93
|
notifyEvent(event: DigiaExperienceEvent, payload: InAppPayload): void;
|
|
94
|
+
/**
|
|
95
|
+
* Called by the Digia SDK to record a named analytics event with properties.
|
|
96
|
+
* Implement this to forward Digia lifecycle events (e.g. "Digia Experience Viewed")
|
|
97
|
+
* to the CEP platform's custom event API.
|
|
98
|
+
*/
|
|
99
|
+
track?(eventName: string, properties: Record<string, unknown>): void;
|
|
68
100
|
/** Called by Digia.setCurrentScreen() — do not call manually. */
|
|
69
101
|
forwardScreen(name: string): void;
|
|
70
102
|
/** Called by Digia.unregister() or when tearing down the app. */
|
|
71
103
|
teardown(): void;
|
|
72
104
|
}
|
|
73
105
|
|
|
106
|
+
// ─── Action types (public API) ────────────────────────────────────────────────
|
|
107
|
+
|
|
108
|
+
export type DigiaAction =
|
|
109
|
+
| { type: 'deep_link'; url: string; fallback_url?: string }
|
|
110
|
+
| { type: 'open_url'; url: string; presentation: 'external' | 'in_app' }
|
|
111
|
+
| { type: 'dismiss'; scope?: 'self' | 'all' }
|
|
112
|
+
| { type: 'next' }
|
|
113
|
+
| { type: 'back' };
|
|
114
|
+
|
|
115
|
+
export type ActionContext = {
|
|
116
|
+
campaign_id: string;
|
|
117
|
+
campaign_key: string;
|
|
118
|
+
campaign_type: 'nudge' | 'guide' | 'inline' | 'survey';
|
|
119
|
+
source: {
|
|
120
|
+
kind: 'button' | 'card_tap' | 'pip_small_view' | 'auto_dismiss';
|
|
121
|
+
element_id?: string;
|
|
122
|
+
button_label?: string;
|
|
123
|
+
};
|
|
124
|
+
step_index?: number;
|
|
125
|
+
step_total?: number;
|
|
126
|
+
source_node?: unknown;
|
|
127
|
+
};
|
|
128
|
+
|
|
129
|
+
export type ActionResult = boolean | Promise<boolean> | void;
|
|
130
|
+
|
|
131
|
+
export type OnAction = (action: DigiaAction, context: ActionContext) => ActionResult;
|
|
132
|
+
|
|
133
|
+
export type InAppBrowserAdapter = {
|
|
134
|
+
open: (url: string) => Promise<void>;
|
|
135
|
+
};
|
|
136
|
+
|
|
137
|
+
// ─── SDK init config ──────────────────────────────────────────────────────────
|
|
138
|
+
|
|
74
139
|
/**
|
|
75
140
|
* Configuration for initialising the Digia Engage SDK.
|
|
76
141
|
*/
|
|
77
142
|
export interface DigiaConfig {
|
|
78
|
-
/** The
|
|
79
|
-
|
|
143
|
+
/** The Engage project ID — sent as x-digia-project-id on all SDK requests. */
|
|
144
|
+
projectId: string;
|
|
145
|
+
/**
|
|
146
|
+
* Base URL for the Digia API.
|
|
147
|
+
* Defaults to the production API root, or the Engage sandbox root when
|
|
148
|
+
* `environment` is "sandbox".
|
|
149
|
+
*/
|
|
150
|
+
baseUrl?: string;
|
|
80
151
|
/**
|
|
81
152
|
* The target environment.
|
|
82
153
|
* @default 'production'
|
|
@@ -87,5 +158,31 @@ export interface DigiaConfig {
|
|
|
87
158
|
* @default 'error'
|
|
88
159
|
*/
|
|
89
160
|
logLevel?: 'none' | 'error' | 'verbose';
|
|
161
|
+
/**
|
|
162
|
+
* Optional global font family applied to all Digia-rendered text.
|
|
163
|
+
* Must match a font available to the native app — an Android system/registered
|
|
164
|
+
* family name, or an iOS bundled font's PostScript name.
|
|
165
|
+
*/
|
|
166
|
+
fontFamily?: string;
|
|
167
|
+
/**
|
|
168
|
+
* Optional override hook called for every action before the SDK runs its
|
|
169
|
+
* default behavior. Return true to suppress the default; false/void lets
|
|
170
|
+
* the SDK handle it.
|
|
171
|
+
*/
|
|
172
|
+
onAction?: OnAction;
|
|
173
|
+
/**
|
|
174
|
+
* URL / linking configuration.
|
|
175
|
+
*/
|
|
176
|
+
linking?: {
|
|
177
|
+
/**
|
|
178
|
+
* When true (default) the SDK calls Linking.openURL for URL-bearing actions.
|
|
179
|
+
* @default true
|
|
180
|
+
*/
|
|
181
|
+
routeViaSystemLinking?: boolean;
|
|
182
|
+
/**
|
|
183
|
+
* Required if any campaign uses open_url with presentation: 'in_app'.
|
|
184
|
+
* Falls back to Linking.openURL + emits inapp_browser_unavailable if absent.
|
|
185
|
+
*/
|
|
186
|
+
inAppBrowser?: InAppBrowserAdapter;
|
|
187
|
+
};
|
|
90
188
|
}
|
|
91
|
-
|