@adobe/react-native-aepmessaging 7.1.1 → 7.2.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 +61 -2
- package/android/src/main/java/com/adobe/marketing/mobile/reactnative/messaging/RCTAEPMessagingConstants.java +19 -0
- package/android/src/main/java/com/adobe/marketing/mobile/reactnative/messaging/RCTAEPMessagingModule.java +152 -18
- package/android/src/main/java/com/adobe/marketing/mobile/reactnative/messaging/RCTAEPMessagingUtil.java +1 -1
- package/dist/Messaging.d.ts +17 -0
- package/dist/Messaging.js +34 -7
- package/dist/Messaging.js.map +1 -1
- package/dist/index.d.ts +5 -4
- package/dist/index.js +11 -1
- package/dist/index.js.map +1 -1
- package/dist/models/ContentCard.d.ts +6 -1
- package/dist/models/ContentCard.js +9 -0
- package/dist/models/ContentCard.js.map +1 -1
- package/dist/models/HTMLProposition.d.ts +6 -2
- package/dist/models/HTMLProposition.js +9 -0
- package/dist/models/HTMLProposition.js.map +1 -1
- package/dist/models/JSONProposition.d.ts +12 -0
- package/dist/models/{JSONPropositionItem.js → JSONProposition.js} +10 -1
- package/dist/models/JSONProposition.js.map +1 -0
- package/dist/models/Message.d.ts +14 -0
- package/dist/models/Message.js +51 -1
- package/dist/models/Message.js.map +1 -1
- package/dist/models/MessagingProposition.d.ts +10 -3
- package/dist/models/MessagingProposition.js +45 -0
- package/dist/models/MessagingProposition.js.map +1 -1
- package/dist/models/MessagingPropositionItem.d.ts +3 -2
- package/dist/models/PropositionItem.d.ts +83 -0
- package/dist/models/PropositionItem.js +78 -0
- package/dist/models/PropositionItem.js.map +1 -0
- package/ios/src/RCTAEPMessaging.mm +32 -0
- package/ios/src/RCTAEPMessaging.swift +150 -45
- package/ios/src/RCTAEPMessagingConstants.swift +5 -1
- package/ios/src/RCTAEPMessagingDataBridge.swift +19 -0
- package/package.json +2 -2
- package/src/Messaging.ts +46 -13
- package/src/index.ts +13 -5
- package/src/models/ContentCard.ts +12 -1
- package/src/models/HTMLProposition.ts +15 -6
- package/src/models/{JSONPropositionItem.ts → JSONProposition.ts} +15 -6
- package/src/models/Message.ts +61 -2
- package/src/models/MessagingProposition.ts +45 -3
- package/src/models/MessagingPropositionItem.ts +6 -2
- package/src/models/PropositionItem.ts +135 -0
- package/tutorials/In-App Messaging.md +67 -0
- package/dist/models/JSONPropositionItem.d.ts +0 -8
- package/dist/models/JSONPropositionItem.js.map +0 -1
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { PersonalizationSchema } from './PersonalizationSchema';
|
|
2
|
+
import { PropositionItem, PropositionItemData } from './PropositionItem';
|
|
3
|
+
export interface JSONPropositionData extends PropositionItemData {
|
|
4
|
+
data: {
|
|
5
|
+
content: any;
|
|
6
|
+
};
|
|
7
|
+
schema: PersonalizationSchema.JSON_CONTENT;
|
|
8
|
+
}
|
|
9
|
+
export declare class JSONPropositionItem extends PropositionItem {
|
|
10
|
+
data: JSONPropositionData['data'];
|
|
11
|
+
constructor(jsonData: JSONPropositionData);
|
|
12
|
+
}
|
|
@@ -11,4 +11,13 @@
|
|
|
11
11
|
language governing permissions and limitations under the License.
|
|
12
12
|
*/
|
|
13
13
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
14
|
-
|
|
14
|
+
exports.JSONPropositionItem = void 0;
|
|
15
|
+
const PropositionItem_1 = require("./PropositionItem");
|
|
16
|
+
class JSONPropositionItem extends PropositionItem_1.PropositionItem {
|
|
17
|
+
constructor(jsonData) {
|
|
18
|
+
super(jsonData);
|
|
19
|
+
this.data = jsonData.data;
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
exports.JSONPropositionItem = JSONPropositionItem;
|
|
23
|
+
//# sourceMappingURL=JSONProposition.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"JSONProposition.js","sourceRoot":"","sources":["../../src/models/JSONProposition.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;EAUE;;;AAGF,uDAAyE;AASzE,MAAa,mBAAoB,SAAQ,iCAAe;IAGvD,YAAY,QAA6B;QACxC,KAAK,CAAC,QAAQ,CAAC,CAAC;QAChB,IAAI,CAAC,IAAI,GAAG,QAAQ,CAAC,IAAI,CAAC;IAC3B,CAAC;CACD;AAPD,kDAOC"}
|
package/dist/models/Message.d.ts
CHANGED
|
@@ -35,5 +35,19 @@ declare class Message {
|
|
|
35
35
|
* Failure to call this function leads to memory leaks.
|
|
36
36
|
*/
|
|
37
37
|
clear(): void;
|
|
38
|
+
/**
|
|
39
|
+
* Adds a handler for named JavaScript messages sent from the message's WebView.
|
|
40
|
+
* The parameter passed to handler will contain the body of the message passed from the WebView's JavaScript.
|
|
41
|
+
* @param {string} handlerName: The name of the message that should be handled by the handler
|
|
42
|
+
* @param {function} handler: The method or closure to be called with the body of the message created in the Message's JavaScript
|
|
43
|
+
*/
|
|
44
|
+
handleJavascriptMessage(handlerName: string, handler: (content: string) => void): void;
|
|
45
|
+
/**
|
|
46
|
+
* @internal - For internal use only.
|
|
47
|
+
* Clears all the javascript message handlers for the message.
|
|
48
|
+
* This function must be called if the callbacks registered in handleJavascriptMessage are no longer needed.
|
|
49
|
+
* Failure to call this function may lead to memory leaks.
|
|
50
|
+
*/
|
|
51
|
+
_clearJavascriptMessageHandlers(): void;
|
|
38
52
|
}
|
|
39
53
|
export default Message;
|
package/dist/models/Message.js
CHANGED
|
@@ -13,6 +13,17 @@ governing permissions and limitations under the License.
|
|
|
13
13
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
14
14
|
const react_native_1 = require("react-native");
|
|
15
15
|
const RCTAEPMessaging = react_native_1.NativeModules.AEPMessaging;
|
|
16
|
+
// Registery to store inAppMessage callbacks for each message in Message.handleJavascriptMessage
|
|
17
|
+
// Record - {messageId : {handlerName : callback}}
|
|
18
|
+
const jsMessageHandlers = {};
|
|
19
|
+
const handleJSMessageEventEmitter = new react_native_1.NativeEventEmitter(RCTAEPMessaging);
|
|
20
|
+
// invokes the callback registered in Message.handleJavascriptMessage with the content received from the inAppMessage webview
|
|
21
|
+
handleJSMessageEventEmitter.addListener('onJavascriptMessage', (event) => {
|
|
22
|
+
const { messageId, handlerName, content } = event;
|
|
23
|
+
if (jsMessageHandlers[messageId] && jsMessageHandlers[messageId][handlerName]) {
|
|
24
|
+
jsMessageHandlers[messageId][handlerName](content);
|
|
25
|
+
}
|
|
26
|
+
});
|
|
16
27
|
class Message {
|
|
17
28
|
constructor({ id, autoTrack = false }) {
|
|
18
29
|
this.id = id;
|
|
@@ -41,7 +52,14 @@ class Message {
|
|
|
41
52
|
* of the autoTrack setting.
|
|
42
53
|
*/
|
|
43
54
|
dismiss(suppressAutoTrack) {
|
|
44
|
-
|
|
55
|
+
// iOS message.dismiss() accepts a boolean parameter to suppress autoTrack
|
|
56
|
+
// but on android side, message.dismiss() does not accept any parameters
|
|
57
|
+
if (react_native_1.Platform.OS === 'android') {
|
|
58
|
+
RCTAEPMessaging.dismiss(this.id);
|
|
59
|
+
}
|
|
60
|
+
if (react_native_1.Platform.OS === 'ios') {
|
|
61
|
+
RCTAEPMessaging.dismiss(this.id, suppressAutoTrack ? true : false);
|
|
62
|
+
}
|
|
45
63
|
}
|
|
46
64
|
/**
|
|
47
65
|
* Generates an Edge Event for the provided interaction and eventType.
|
|
@@ -59,6 +77,38 @@ class Message {
|
|
|
59
77
|
clear() {
|
|
60
78
|
RCTAEPMessaging.clear(this.id);
|
|
61
79
|
}
|
|
80
|
+
/**
|
|
81
|
+
* Adds a handler for named JavaScript messages sent from the message's WebView.
|
|
82
|
+
* The parameter passed to handler will contain the body of the message passed from the WebView's JavaScript.
|
|
83
|
+
* @param {string} handlerName: The name of the message that should be handled by the handler
|
|
84
|
+
* @param {function} handler: The method or closure to be called with the body of the message created in the Message's JavaScript
|
|
85
|
+
*/
|
|
86
|
+
handleJavascriptMessage(handlerName, handler) {
|
|
87
|
+
// Validate parameters
|
|
88
|
+
if (!handlerName) {
|
|
89
|
+
console.warn('[AEP Messaging] handleJavascriptMessage: handlerName is required');
|
|
90
|
+
return;
|
|
91
|
+
}
|
|
92
|
+
if (typeof handler !== 'function') {
|
|
93
|
+
console.warn('[AEP Messaging] handleJavascriptMessage: handler must be a function');
|
|
94
|
+
return;
|
|
95
|
+
}
|
|
96
|
+
// cache the callback
|
|
97
|
+
if (!jsMessageHandlers[this.id]) {
|
|
98
|
+
jsMessageHandlers[this.id] = {};
|
|
99
|
+
}
|
|
100
|
+
jsMessageHandlers[this.id][handlerName] = handler;
|
|
101
|
+
RCTAEPMessaging.handleJavascriptMessage(this.id, handlerName);
|
|
102
|
+
}
|
|
103
|
+
/**
|
|
104
|
+
* @internal - For internal use only.
|
|
105
|
+
* Clears all the javascript message handlers for the message.
|
|
106
|
+
* This function must be called if the callbacks registered in handleJavascriptMessage are no longer needed.
|
|
107
|
+
* Failure to call this function may lead to memory leaks.
|
|
108
|
+
*/
|
|
109
|
+
_clearJavascriptMessageHandlers() {
|
|
110
|
+
delete jsMessageHandlers[this.id];
|
|
111
|
+
}
|
|
62
112
|
}
|
|
63
113
|
exports.default = Message;
|
|
64
114
|
//# sourceMappingURL=Message.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Message.js","sourceRoot":"","sources":["../../src/models/Message.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;EAUE;;AAEF,+
|
|
1
|
+
{"version":3,"file":"Message.js","sourceRoot":"","sources":["../../src/models/Message.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;EAUE;;AAEF,+CAA2E;AAE3E,MAAM,eAAe,GAAG,4BAAa,CAAC,YAAY,CAAC;AAEnD,gGAAgG;AAChG,kDAAkD;AAClD,MAAM,iBAAiB,GAA8D,EAAE,CAAC;AACxF,MAAM,2BAA2B,GAAG,IAAI,iCAAkB,CAAC,eAAe,CAAC,CAAC;AAE5E,6HAA6H;AAC7H,2BAA2B,CAAC,WAAW,CAAC,qBAAqB,EAAE,CAAC,KAAK,EAAE,EAAE;IACvE,MAAM,EAAC,SAAS,EAA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H,eAAe,CAAC,KAAK,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;IACjC,CAAC;IAED;;;;;OAKG;IACH,uBAAuB,CAAC,WAAmB,EAAE,OAAkC;QAC7E,sBAAsB;QACtB,IAAI,CAAC,WAAW,EAAE;YAChB,OAAO,CAAC,IAAI,CAAC,kEAAkE,CAAC,CAAC;YACjF,OAAO;SACR;QAED,IAAI,OAAO,OAAO,KAAK,UAAU,EAAE;YACjC,OAAO,CAAC,IAAI,CAAC,qEAAqE,CAAC,CAAC;YACpF,OAAO;SACR;QAED,qBAAqB;QACrB,IAAI,CAAC,iBAAiB,CAAC,IAAI,CAAC,EAAE,CAAC,EAAE;YAC/B,iBAAiB,CAAC,IAAI,CAAC,EAAE,CAAC,GAAG,EAAE,CAAC;SACjC;QACD,iBAAiB,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC,WAAW,CAAC,GAAG,OAAO,CAAC;QAClD,eAAe,CAAC,uBAAuB,CAAC,IAAI,CAAC,EAAE,EAAE,WAAW,CAAC,CAAC;IAChE,CAAC;IAED;;;;;OAKG;IACH,+BAA+B;QAC7B,OAAO,iBAAiB,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;IACpC,CAAC;CACF;AAED,kBAAe,OAAO,CAAC"}
|
|
@@ -1,8 +1,15 @@
|
|
|
1
|
-
import { MessagingPropositionItem } from './MessagingPropositionItem';
|
|
2
1
|
import { ScopeDetails } from './ScopeDetails';
|
|
3
|
-
|
|
2
|
+
import { PropositionItem } from './PropositionItem';
|
|
3
|
+
export declare class MessageProposition {
|
|
4
4
|
id: string;
|
|
5
5
|
scope: string;
|
|
6
6
|
scopeDetails: ScopeDetails;
|
|
7
|
-
items:
|
|
7
|
+
items: PropositionItem[];
|
|
8
|
+
constructor(raw: {
|
|
9
|
+
id: string;
|
|
10
|
+
scope: string;
|
|
11
|
+
scopeDetails: ScopeDetails;
|
|
12
|
+
items?: any[];
|
|
13
|
+
});
|
|
8
14
|
}
|
|
15
|
+
export { MessageProposition as MessagingProposition };
|
|
@@ -11,4 +11,49 @@
|
|
|
11
11
|
language governing permissions and limitations under the License.
|
|
12
12
|
*/
|
|
13
13
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
14
|
+
exports.MessagingProposition = exports.MessageProposition = void 0;
|
|
15
|
+
const PersonalizationSchema_1 = require("./PersonalizationSchema");
|
|
16
|
+
const ContentCard_1 = require("./ContentCard");
|
|
17
|
+
const HTMLProposition_1 = require("./HTMLProposition");
|
|
18
|
+
const JSONProposition_1 = require("./JSONProposition");
|
|
19
|
+
const PropositionItem_1 = require("./PropositionItem");
|
|
20
|
+
class MessageProposition {
|
|
21
|
+
constructor(raw) {
|
|
22
|
+
var _a, _b, _c, _d, _e, _f, _g;
|
|
23
|
+
this.id = (_a = raw === null || raw === void 0 ? void 0 : raw.id) !== null && _a !== void 0 ? _a : '';
|
|
24
|
+
this.scope = (_b = raw === null || raw === void 0 ? void 0 : raw.scope) !== null && _b !== void 0 ? _b : '';
|
|
25
|
+
this.scopeDetails = (_c = raw === null || raw === void 0 ? void 0 : raw.scopeDetails) !== null && _c !== void 0 ? _c : {};
|
|
26
|
+
// Mirror activity.id into activity.activityID for convenience
|
|
27
|
+
const activityIdFromScope = (_f = (_e = (_d = this.scopeDetails) === null || _d === void 0 ? void 0 : _d.activity) === null || _e === void 0 ? void 0 : _e.id) !== null && _f !== void 0 ? _f : '';
|
|
28
|
+
if ((_g = this.scopeDetails) === null || _g === void 0 ? void 0 : _g.activity) {
|
|
29
|
+
this.scopeDetails.activity.activityID = activityIdFromScope;
|
|
30
|
+
}
|
|
31
|
+
const rawItems = Array.isArray(raw === null || raw === void 0 ? void 0 : raw.items) ? raw.items : [];
|
|
32
|
+
this.items = rawItems.map((itemData) => {
|
|
33
|
+
var _a, _b, _c;
|
|
34
|
+
const activityId = (_c = (_b = (_a = this.scopeDetails) === null || _a === void 0 ? void 0 : _a.activity) === null || _b === void 0 ? void 0 : _b.id) !== null && _c !== void 0 ? _c : '';
|
|
35
|
+
let instance;
|
|
36
|
+
switch (itemData === null || itemData === void 0 ? void 0 : itemData.schema) {
|
|
37
|
+
case PersonalizationSchema_1.PersonalizationSchema.CONTENT_CARD:
|
|
38
|
+
instance = new ContentCard_1.ContentCard(itemData);
|
|
39
|
+
instance.activityID = activityId;
|
|
40
|
+
return instance;
|
|
41
|
+
case PersonalizationSchema_1.PersonalizationSchema.HTML_CONTENT:
|
|
42
|
+
instance = new HTMLProposition_1.HTMLProposition(itemData);
|
|
43
|
+
instance.activityID = activityId;
|
|
44
|
+
return instance;
|
|
45
|
+
case PersonalizationSchema_1.PersonalizationSchema.JSON_CONTENT:
|
|
46
|
+
instance = new JSONProposition_1.JSONPropositionItem(itemData);
|
|
47
|
+
instance.activityID = activityId;
|
|
48
|
+
return instance;
|
|
49
|
+
default:
|
|
50
|
+
instance = new PropositionItem_1.PropositionItem(itemData);
|
|
51
|
+
instance.activityID = activityId;
|
|
52
|
+
return instance;
|
|
53
|
+
}
|
|
54
|
+
});
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
exports.MessageProposition = MessageProposition;
|
|
58
|
+
exports.MessagingProposition = MessageProposition;
|
|
14
59
|
//# sourceMappingURL=MessagingProposition.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MessagingProposition.js","sourceRoot":"","sources":["../../src/models/MessagingProposition.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;EAUE"}
|
|
1
|
+
{"version":3,"file":"MessagingProposition.js","sourceRoot":"","sources":["../../src/models/MessagingProposition.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;EAUE;;;AAGF,mEAAgE;AAChE,+CAA4C;AAC5C,uDAAoD;AACpD,uDAAwD;AACxD,uDAAoD;AAEpD,MAAa,kBAAkB;IAM7B,YAAY,GAA6E;;QACvF,IAAI,CAAC,EAAE,GAAG,MAAA,GAAG,aAAH,GAAG,uBAAH,GAAG,CAAE,EAAE,mCAAI,EAAE,CAAC;QACxB,IAAI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AAK,6CAAqB,CAAC,YAAY;oBACrC,QAAQ,GAAG,IAAI,qCAAmB,CAAC,QAAe,CAAC,CAAC;oBACnD,QAAgB,CAAC,UAAU,GAAG,UAAU,CAAC;oBAC1C,OAAO,QAAQ,CAAC;gBAClB;oBACE,QAAQ,GAAG,IAAI,iCAAe,CAAC,QAAe,CAAC,CAAC;oBAC/C,QAAgB,CAAC,UAAU,GAAG,UAAU,CAAC;oBAC1C,OAAO,QAAQ,CAAC;aACnB;QACH,CAAC,CAAC,CAAC;IACL,CAAC;CACF;AAzCD,gDAyCC;AAE8B,kDAAoB"}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { ContentCard } from './ContentCard';
|
|
2
2
|
import { HTMLProposition } from './HTMLProposition';
|
|
3
|
-
import { JSONPropositionItem } from './
|
|
3
|
+
import { JSONPropositionItem } from './JSONProposition';
|
|
4
4
|
import { InAppMessage } from './InAppMessage';
|
|
5
|
-
|
|
5
|
+
import { PropositionItem } from './PropositionItem';
|
|
6
|
+
export type MessagingPropositionItem = ContentCard | HTMLProposition | InAppMessage | JSONPropositionItem | PropositionItem;
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
import { PersonalizationSchema } from './PersonalizationSchema';
|
|
2
|
+
import MessagingEdgeEventType from './MessagingEdgeEventType';
|
|
3
|
+
/**
|
|
4
|
+
* Base PropositionItem interface that all proposition items implement
|
|
5
|
+
*/
|
|
6
|
+
export interface PropositionItemData {
|
|
7
|
+
id: string;
|
|
8
|
+
uuid: string;
|
|
9
|
+
schema: PersonalizationSchema;
|
|
10
|
+
activityID: string;
|
|
11
|
+
data: {
|
|
12
|
+
[key: string]: any;
|
|
13
|
+
};
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* A PropositionItem represents a personalization JSON object returned by Konductor.
|
|
17
|
+
* This is the base class that provides tracking functionality for all proposition items
|
|
18
|
+
* including ContentCards, InApp messages, and code-based experiences.
|
|
19
|
+
*
|
|
20
|
+
* This mirrors the native Android PropositionItem class functionality.
|
|
21
|
+
*/
|
|
22
|
+
export declare class PropositionItem {
|
|
23
|
+
id: string;
|
|
24
|
+
uuid: string;
|
|
25
|
+
activityID: string;
|
|
26
|
+
schema: PersonalizationSchema;
|
|
27
|
+
data: {
|
|
28
|
+
[key: string]: any;
|
|
29
|
+
};
|
|
30
|
+
constructor(propositionItemData: PropositionItemData);
|
|
31
|
+
/**
|
|
32
|
+
* Gets the PropositionItem identifier.
|
|
33
|
+
*
|
|
34
|
+
* @returns {string} The PropositionItem identifier
|
|
35
|
+
*/
|
|
36
|
+
getItemId(): string;
|
|
37
|
+
/**
|
|
38
|
+
* Gets the PropositionItem content schema.
|
|
39
|
+
*
|
|
40
|
+
* @returns {PersonalizationSchema} The PropositionItem content schema
|
|
41
|
+
*/
|
|
42
|
+
getSchema(): PersonalizationSchema;
|
|
43
|
+
/**
|
|
44
|
+
* Gets the PropositionItem data.
|
|
45
|
+
*
|
|
46
|
+
* @returns {object} The PropositionItem data
|
|
47
|
+
*/
|
|
48
|
+
getItemData(): {
|
|
49
|
+
[key: string]: any;
|
|
50
|
+
};
|
|
51
|
+
/**
|
|
52
|
+
* Tracks interaction with this proposition item.
|
|
53
|
+
* This is the core tracking method that all proposition items use.
|
|
54
|
+
*
|
|
55
|
+
* @param {MessagingEdgeEventType} eventType - The MessagingEdgeEventType specifying event type for the interaction
|
|
56
|
+
*
|
|
57
|
+
* @example
|
|
58
|
+
* propositionItem.track(MessagingEdgeEventType.DISPLAY);
|
|
59
|
+
*/
|
|
60
|
+
track(eventType: MessagingEdgeEventType): void;
|
|
61
|
+
/**
|
|
62
|
+
* Tracks interaction with this proposition item.
|
|
63
|
+
*
|
|
64
|
+
* @param {string | null} interaction - String describing the interaction
|
|
65
|
+
* @param {MessagingEdgeEventType} eventType - The MessagingEdgeEventType specifying event type for the interaction
|
|
66
|
+
* @param {string[] | null} tokens - Array containing the sub-item tokens for recording interaction
|
|
67
|
+
*
|
|
68
|
+
* @example
|
|
69
|
+
* // Track display
|
|
70
|
+
* propositionItem.track(null, MessagingEdgeEventType.DISPLAY, null);
|
|
71
|
+
*
|
|
72
|
+
* // Track interaction
|
|
73
|
+
* propositionItem.track("button_clicked", MessagingEdgeEventType.INTERACT, null);
|
|
74
|
+
*
|
|
75
|
+
* // Track with tokens
|
|
76
|
+
* propositionItem.track("click", MessagingEdgeEventType.INTERACT, ["token1", "token2"]);
|
|
77
|
+
*/
|
|
78
|
+
track(interaction: string | null, eventType: MessagingEdgeEventType, tokens: string[] | null): void;
|
|
79
|
+
/**
|
|
80
|
+
* Internal method that performs the actual tracking
|
|
81
|
+
*/
|
|
82
|
+
private trackWithDetails;
|
|
83
|
+
}
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/*
|
|
3
|
+
Copyright 2025 Adobe. All rights reserved.
|
|
4
|
+
This file is licensed to you under the Apache License, Version 2.0 (the
|
|
5
|
+
"License"); you may not use this file except in compliance with the License.
|
|
6
|
+
You may obtain a copy of the License at
|
|
7
|
+
http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law
|
|
8
|
+
or agreed to in writing, software distributed under the License is
|
|
9
|
+
distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS OF
|
|
10
|
+
ANY KIND, either express or implied. See the License for the specific
|
|
11
|
+
language governing permissions and limitations under the License.
|
|
12
|
+
*/
|
|
13
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
14
|
+
exports.PropositionItem = void 0;
|
|
15
|
+
const react_native_1 = require("react-native");
|
|
16
|
+
const RCTAEPMessaging = react_native_1.NativeModules.AEPMessaging;
|
|
17
|
+
/**
|
|
18
|
+
* A PropositionItem represents a personalization JSON object returned by Konductor.
|
|
19
|
+
* This is the base class that provides tracking functionality for all proposition items
|
|
20
|
+
* including ContentCards, InApp messages, and code-based experiences.
|
|
21
|
+
*
|
|
22
|
+
* This mirrors the native Android PropositionItem class functionality.
|
|
23
|
+
*/
|
|
24
|
+
class PropositionItem {
|
|
25
|
+
constructor(propositionItemData) {
|
|
26
|
+
this.id = propositionItemData.id;
|
|
27
|
+
this.schema = propositionItemData.schema;
|
|
28
|
+
this.data = propositionItemData.data;
|
|
29
|
+
this.uuid = propositionItemData.uuid;
|
|
30
|
+
this.activityID = propositionItemData.activityID;
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* Gets the PropositionItem identifier.
|
|
34
|
+
*
|
|
35
|
+
* @returns {string} The PropositionItem identifier
|
|
36
|
+
*/
|
|
37
|
+
getItemId() {
|
|
38
|
+
return this.id;
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* Gets the PropositionItem content schema.
|
|
42
|
+
*
|
|
43
|
+
* @returns {PersonalizationSchema} The PropositionItem content schema
|
|
44
|
+
*/
|
|
45
|
+
getSchema() {
|
|
46
|
+
return this.schema;
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* Gets the PropositionItem data.
|
|
50
|
+
*
|
|
51
|
+
* @returns {object} The PropositionItem data
|
|
52
|
+
*/
|
|
53
|
+
getItemData() {
|
|
54
|
+
return this.data;
|
|
55
|
+
}
|
|
56
|
+
// Implementation
|
|
57
|
+
track(interactionOrEventType, eventType, tokens) {
|
|
58
|
+
// Handle overloaded method signatures
|
|
59
|
+
if (typeof interactionOrEventType === 'number' && eventType === undefined) {
|
|
60
|
+
// First overload: track(eventType)
|
|
61
|
+
this.trackWithDetails(null, interactionOrEventType, null);
|
|
62
|
+
}
|
|
63
|
+
else if (typeof interactionOrEventType === 'string' || interactionOrEventType === null) {
|
|
64
|
+
// Second overload: track(interaction, eventType, tokens)
|
|
65
|
+
this.trackWithDetails(interactionOrEventType, eventType, tokens || null);
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
/**
|
|
69
|
+
* Internal method that performs the actual tracking
|
|
70
|
+
*/
|
|
71
|
+
trackWithDetails(interaction, eventType, tokens) {
|
|
72
|
+
var _a;
|
|
73
|
+
const nativeIdentifier = (_a = this.activityID) !== null && _a !== void 0 ? _a : null;
|
|
74
|
+
RCTAEPMessaging.trackPropositionItem(nativeIdentifier, interaction, eventType, tokens);
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
exports.PropositionItem = PropositionItem;
|
|
78
|
+
//# sourceMappingURL=PropositionItem.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"PropositionItem.js","sourceRoot":"","sources":["../../src/models/PropositionItem.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;EAUE;;;AAEF,+CAA6C;AAI7C,MAAM,eAAe,GAAG,4BAAa,CAAC,YAAY,CAAC;AAenD;;;;;;GAMG;AACH,MAAa,eAAe;IAO1B,YAAY,mBAAwC;QAClD,IAAI,CAAC,EAAE,GAAG,mBAAmB,CAAC,EAAE,CAAC;QACjC,IAAI,CAAC,MAAM,GAAG,mBAAmB,CAAC,MAAM,CAAC;QACzC,IAAI,CAAC,IAAI,GAAG,mBAAmB,CAAC,IAAI,CAAC;QACrC,IAAI,CAAC,IAAI,GAAG,mBAAmB,CAAC,IAAI,CAAC;QACrC,IAAI,CAAC,UAAU,GAAG,mBAAmB,CAAC,UAAU,CAAC;IACnD,CAAC;IAED;;;;OAIG;IACH,SAAS;QACP,OAAO,IAAI,CAAC,EAAE,CAAC;IACjB,CAAC;IAED;;;;OAIG;IACH,SAAS;QACP,OAAO,IAAI,CAAC,MAAM,CAAC;IACrB,CAAC;IAED;;;;OAIG;IACH,WAAW;QACT,OAAO,IAAI,CAAC,IAAI,CAAC;IACnB,CAAC;IAgCD,iBAAiB;IACjB,KAAK,CACH,sBAA8D,EAC9D,SAAkC,EAClC,MAAwB;QAExB,sCAAsC;QACtC,IAAI,OAAO,sBAAsB,KAAK,QAAQ,IAAI,SAAS,KAAK,SAAS,EAAE;YACzE,mCAAmC;YACnC,IAAI,CAAC,gBAAgB,CAAC,IAAI,EAAE,sBAAsB,EAAE,IAAI,CAAC,CAAC;SAC3D;aAAM,IAAI,OAAO,sBAAsB,KAAK,QAAQ,IAAI,sBAAsB,KAAK,IAAI,EAAE;YACxF,yDAAyD;YACzD,IAAI,CAAC,gBAAgB,CAAC,sBAAsB,EAAE,SAAU,EAAE,MAAM,IAAI,IAAI,CAAC,CAAC;SAC3E;IACH,CAAC;IAED;;OAEG;IACK,gBAAgB,CAAC,WAA0B,EAAE,SAAiC,EAAE,MAAuB;;QAC7G,MAAM,gBAAgB,GAAG,MAAA,IAAI,CAAC,UAAU,mCAAI,IAAI,CAAC;QACjD,eAAe,CAAC,oBAAoB,CAAC,gBAAgB,EAAE,WAAW,EAAE,SAAS,EAAE,MAAM,CAAC,CAAC;IACzF,CAAC;CAEF;AAhGD,0CAgGC"}
|
|
@@ -55,4 +55,36 @@ RCT_EXTERN_METHOD(trackContentCardInteraction
|
|
|
55
55
|
: (NSDictionary *)propositionMap contentCardMap
|
|
56
56
|
: (NSDictionary *)contentCardMap);
|
|
57
57
|
|
|
58
|
+
|
|
59
|
+
RCT_EXTERN_METHOD(handleJavascriptMessage
|
|
60
|
+
: (NSString *)messageId handlerName
|
|
61
|
+
: (NSString *)handlerName)
|
|
62
|
+
|
|
63
|
+
RCT_EXTERN_METHOD(trackPropositionItem
|
|
64
|
+
: (NSString *)uuid interaction
|
|
65
|
+
: (NSString * _Nullable)interaction eventType
|
|
66
|
+
: (NSInteger)eventType tokens
|
|
67
|
+
: (NSArray<NSString *> * _Nullable)tokens withResolver
|
|
68
|
+
: (RCTPromiseResolveBlock)resolve withRejecter
|
|
69
|
+
: (RCTPromiseRejectBlock)reject);
|
|
70
|
+
|
|
71
|
+
RCT_EXTERN_METHOD(setAutoTrack
|
|
72
|
+
: (NSString *)messageId autoTrack
|
|
73
|
+
: (BOOL)autoTrack);
|
|
74
|
+
|
|
75
|
+
RCT_EXTERN_METHOD(show
|
|
76
|
+
: (NSString *)messageId);
|
|
77
|
+
|
|
78
|
+
RCT_EXTERN_METHOD(dismiss
|
|
79
|
+
: (NSString *)messageId suppressAutoTrack
|
|
80
|
+
: (BOOL)suppressAutoTrack);
|
|
81
|
+
|
|
82
|
+
RCT_EXTERN_METHOD(track
|
|
83
|
+
: (NSString *)messageId interaction
|
|
84
|
+
: (NSString *)interaction eventType
|
|
85
|
+
: (NSInteger)eventType);
|
|
86
|
+
|
|
87
|
+
RCT_EXTERN_METHOD(clear
|
|
88
|
+
: (NSString *)messageId);
|
|
89
|
+
|
|
58
90
|
@end
|