Skip to content

Commit cf1dac0

Browse files
Merge pull request #9 from BranchMetrics/update/include-base-url
feat(1.1.0) : add support for new Branch Base URL
2 parents bbaddf2 + f0310a4 commit cf1dac0

File tree

11 files changed

+221
-345
lines changed

11 files changed

+221
-345
lines changed

.sandbox/container.js

Lines changed: 63 additions & 79 deletions
Original file line numberDiff line numberDiff line change
@@ -1,80 +1,64 @@
11
module.exports = {
2-
rules: [
3-
{
4-
name: 'Example Rule 0',
5-
events: [
6-
{
7-
modulePath: 'branch-mobile-growth/src/lib/events/domReady.js',
8-
settings: {}
9-
}
10-
],
11-
actions: [
12-
{
13-
modulePath: 'branch-mobile-growth/src/lib/actions/initializeBranch.js',
14-
}
15-
]
16-
},
17-
{
18-
name: 'Example Rule 1',
19-
events: [
20-
{
21-
modulePath: 'sandbox/click.js',
22-
settings: {}
23-
}
24-
],
25-
actions: [
26-
{
27-
modulePath: 'branch-mobile-growth/src/lib/actions/logEvent.js',
28-
settings: {
29-
"v2EventName": "ADD_TO_CART",
30-
"v2EventData": {
31-
"revenue": 21321312312
32-
},
33-
"customData": {}
34-
}
35-
}
36-
]
37-
}
38-
],
39-
dataElements: {
40-
// productId: {
41-
// // This is a simple data element type provided by the sandbox which retrieves a value
42-
// // from local storage. This data element type is provided as a convenience in case
43-
// // your extension does not have any data element types of its own.
44-
// modulePath: 'sandbox/localStorage.js',
45-
// settings: {
46-
// // The local storage item name.
47-
// name: 'productId'
48-
// }
49-
// }
50-
},
51-
extensions: {
52-
// Set up an extension configuration you would like to test. The top-level object key is the
53-
// name of your extension (as defined in your extension.json).
54-
'branch-mobile-growth': {
55-
displayName: 'Branch Experiences and Measurement',
56-
settings: {
57-
'branchKey': 'key_live_oftJ3F17S3vu6KVDTl93XjiltykwRU0e',
58-
'subscriptionStatus': false
59-
}
60-
}
61-
},
62-
property: {
63-
name: 'Sandbox Property',
64-
settings: {
65-
domains: [
66-
'192.168.0.139',
67-
'172.16.32.14',
68-
],
69-
linkDelay: 100,
70-
trackingCookieName: 'sat_track',
71-
undefinedVarsReturnEmpty: false
72-
}
73-
},
74-
buildInfo: {
75-
turbineVersion: '14.0.0',
76-
turbineBuildDate: '2016-07-01T18:10:34Z',
77-
buildDate: '2016-08-01T12:10:33Z',
78-
environment: 'development'
79-
}
80-
};
2+
"extensions": {
3+
"branch-mobile-growth": {
4+
"displayName": "Branch Experiences and Measurement",
5+
"settings": {
6+
"branchKey": "key_live_hcnegAumkH7Kv18M8AOHhfgiohpXq5tB",
7+
"subscriptionStatus": true,
8+
"branchAPIURL": "https://api.branch.io"
9+
}
10+
}
11+
},
12+
"dataElements": {},
13+
"rules": [{
14+
"name": "Load and initialize Branch SDK",
15+
"events": [{
16+
"modulePath": "sandbox/pageTop.js",
17+
"settings": {}
18+
}],
19+
"actions": [{
20+
"modulePath": "branch-mobile-growth/src/lib/actions/initializeBranch.js"
21+
}]
22+
}, {
23+
"name": "Example Rule 1",
24+
"events": [{
25+
"modulePath": "sandbox/click.js",
26+
"settings": {}
27+
}],
28+
"actions": [{
29+
"modulePath": "branch-mobile-growth/src/lib/actions/logEvent.js",
30+
"settings": {
31+
"v2EventName": "ADD_TO_CART",
32+
"v2EventCategory": "commerce",
33+
"v2EventData": {
34+
"transaction_id": "id1",
35+
"revenue": 12
36+
},
37+
"customData": {
38+
"key1": "value1"
39+
}
40+
}
41+
}]
42+
}],
43+
"property": {
44+
"name": "Sandbox property",
45+
"settings": {
46+
"id": "PR12345",
47+
"domains": ["adobe.com", "example.com"],
48+
"undefinedVarsReturnEmpty": false
49+
}
50+
},
51+
"company": {
52+
"orgId": "ABCDEFGHIJKLMNOPQRSTUVWX@AdobeOrg"
53+
},
54+
"environment": {
55+
"id": "EN00000000000000000000000000000000",
56+
"stage": "development"
57+
},
58+
"buildInfo": {
59+
"turbineVersion": "27.5.0",
60+
"turbineBuildDate": "2024-05-02T19:56:48.644Z",
61+
"buildDate": "2024-05-02T19:56:48.644Z",
62+
"environment": "development"
63+
}
64+
}

.sandbox/libSandbox.html

Lines changed: 8 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,14 @@
11
<!DOCTYPE html>
22
<html>
3-
<head lang="en">
4-
<meta charset="UTF-8">
5-
<title>Reactor Extension Library Sandbox</title>
63

7-
<script>
8-
window.Coral = window.Coral || {};
9-
Coral.options = { typeKitId: 'buj6cmr'};
10-
</script>
4+
<head lang="en">
5+
<meta charset="UTF-8">
6+
<meta name="template_version" content="2.0">
7+
<script src="launch-EN00000000000000000000000000000000.js" async></script>
8+
</head>
119

12-
<link rel="stylesheet" href="//assets.adobedtm.com/activation/reactor/coralui/3.16.0/css/coral.css">
13-
<script src="//assets.adobedtm.com/activation/reactor/coralui/3.16.0/js/libs/jquery.js"></script>
14-
<script src="//assets.adobedtm.com/activation/reactor/coralui/3.16.0/js/coral.js"></script>
10+
<body>
11+
<h1>Reactor Extension Library Sandbox</h1>
12+
</body>
1513

16-
<link href="sandbox.css" rel="stylesheet" type="text/css">
17-
<script src="container.js"></script>
18-
<script src="engine.js"></script>
19-
</head>
20-
<body class="coral--light">
21-
<a class="nav" is="coral-anchorbutton" variant="quiet" href="viewSandbox.html">Go to view sandbox</a>
22-
23-
<h1 class="coral-Heading coral-Heading--1">Reactor Extension Library Sandbox</h1>
24-
25-
Modify .sandbox/container.js and .sandbox/libSandbox.html then test the result here. Check out <a href="https://www.npmjs.com/package/@adobe/reactor-sandbox#configuring-the-sandbox" target="_blank">documentation</a> on how to generate the `.sandbox` files.
26-
27-
<script>_satellite.pageBottom();_satellite.setDebug(true);</script>
28-
</body>
2914
</html>

extension.json

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,9 @@
2020
"branchKey": {
2121
"type": "string",
2222
"minLength": 41
23+
},
24+
"branchAPIURL": {
25+
"type": "string"
2326
}
2427
},
2528
"required": [
@@ -50,17 +53,6 @@
5053
},
5154
"viewPath": "actions/autoOpen.html"
5255
},
53-
{
54-
"displayName": "SMS Link to Download App",
55-
"name": "sendsms",
56-
"libPath": "src/lib/actions/sendSMS.js",
57-
"schema": {
58-
"$schema": "http://json-schema.org/draft-04/schema#",
59-
"type": "object",
60-
"properties": {}
61-
},
62-
"viewPath": "actions/sendSMS.html"
63-
},
6456
{
6557
"displayName": "Track an Event",
6658
"name": "logevent",

package.json

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,19 @@
11
{
22
"name": "branch-extension",
3-
"version": "1.0.0",
3+
"version": "1.1.0",
44
"description": "Powerful links and solutions that help you acquire, engage, and measure across all devices, channels, and platforms.",
55
"author": {
66
"name": "Branch Metrics",
77
"url": "https://branch.io"
88
},
99
"license": "ISC",
10+
"scripts": {
11+
"sandbox": "npx @adobe/reactor-sandbox"
12+
},
1013
"devDependencies": {
11-
"@adobe/reactor-packager": "^3.0.1",
12-
"@adobe/reactor-sandbox": "^10.0.4",
13-
"@adobe/reactor-scaffold": "^2.0.0",
14-
"@adobe/reactor-turbine": "^25.1.3"
14+
"@adobe/reactor-packager": "^4.3.1",
15+
"@adobe/reactor-sandbox": "^12.5.0",
16+
"@adobe/reactor-scaffold": "^2.4.0",
17+
"@adobe/reactor-turbine": "^27.5.0"
1518
}
1619
}
Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,29 @@
11
'use strict';
2+
var logger = turbine.logger;
3+
var window = require('@adobe/reactor-window');
24
module.exports = function() {
35
var extensionSettings = turbine.getExtensionSettings();
4-
var branchBase = require('../helpers/getBranchBase.js');
6+
var branch = require('../helpers/getBranchBase.js');
57
var branchKey = extensionSettings['branchKey'] || '';
8+
var branchAPIUrl = extensionSettings['branchAPIURL'] || '';
69
if (branchKey) {
7-
branch.init(branchKey);
10+
if (branchAPIUrl) {
11+
if(window.branch){
12+
branch.setAPIUrl(branchAPIUrl);
13+
}
14+
}
15+
if(window.branch){
16+
branch.init(branchKey, function(err,data) {
17+
if (err) {
18+
logger.error("Error initializing Branch::" + err);
19+
} else {
20+
logger.debug("Branch initialized successfully");
21+
}
22+
});
23+
24+
}
25+
}
26+
else {
27+
logger.error("Branch Key not found");
828
}
929
};

src/lib/actions/sendSMS.js

Lines changed: 0 additions & 38 deletions
This file was deleted.

src/lib/helpers/getBranchBase.js

Lines changed: 19 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
'use strict';
2-
var branchBase;
32
var window = require('@adobe/reactor-window');
43
var loadScript = require('@adobe/reactor-load-script');
54

@@ -8,7 +7,14 @@ var loadScript = require('@adobe/reactor-load-script');
87
while (i < funcs.length) {
98
createCallback(branchSdk, funcs[i++]);
109
}
11-
loadScript('https://cdn.branch.io/branch-latest.min.js');
10+
loadScript('https://cdn.branch.io/branch-latest.min.js').then(
11+
function () {
12+
turbine.logger.log('Branch sdk was successfully loaded.');
13+
},
14+
function () {
15+
turbine.logger.error('Branch sdk could not be loaded.');
16+
}
17+
);
1218
root[branchStr] = branchSdk;
1319
}
1420
})(
@@ -23,33 +29,33 @@ var loadScript = require('@adobe/reactor-load-script');
2329
},
2430
[
2531
'addListener',
26-
'applyCode',
27-
'autoAppIndex',
2832
'banner',
2933
'closeBanner',
3034
'closeJourney',
31-
'creditHistory',
32-
'credits',
3335
'data',
3436
'deepview',
3537
'deepviewCta',
3638
'first',
37-
'getCode',
3839
'init',
3940
'link',
4041
'logout',
41-
'redeem',
42-
'referrals',
4342
'removeListener',
44-
'sendSMS',
4543
'setBranchViewData',
4644
'setIdentity',
4745
'track',
48-
'validateCode',
4946
'trackCommerceEvent',
50-
'logEvent'
47+
'logEvent',
48+
'disableTracking',
49+
'getBrowserFingerprintId',
50+
'lastAttributedTouchData',
51+
'setAPIResponseCallback',
52+
'qrCode',
53+
'setRequestMetaData',
54+
'setDMAParamsForEEA',
55+
'setAPIUrl',
56+
'getAPIUrl'
5157
],
5258
0
5359
);
5460

55-
module.exports = branchBase;
61+
module.exports = window.branch;

0 commit comments

Comments
 (0)