@segment/analytics.js-integration-appboy
Advanced tools
Comparing version 1.7.1 to 1.8.0
116
lib/index.js
@@ -17,3 +17,3 @@ 'use strict'; | ||
var Appboy = module.exports = integration('Appboy') | ||
var Appboy = (module.exports = integration('Appboy') | ||
.global('appboy') | ||
@@ -37,6 +37,11 @@ .option('apiKey', '') | ||
.option('version', 1) | ||
.tag('v1', '<script src="https://js.appboycdn.com/web-sdk/1.6/appboy.min.js">') | ||
.tag('v2', '<script src="https://js.appboycdn.com/web-sdk/2.1/appboy.min.js">'); | ||
.tag( | ||
'v1', | ||
'<script src="https://js.appboycdn.com/web-sdk/1.6/appboy.min.js">' | ||
) | ||
.tag( | ||
'v2', | ||
'<script src="https://js.appboycdn.com/web-sdk/2.2/appboy.min.js">' | ||
)); | ||
Appboy.prototype.initialize = function() { | ||
@@ -49,7 +54,8 @@ var options = this.options; | ||
var regex = new RegExp('^(http|https)://', 'i'); | ||
customEndpoint = (regex.test(endpoint) ? endpoint : 'https://' + endpoint) + '/api/v3'; | ||
customEndpoint = | ||
(regex.test(endpoint) ? endpoint : 'https://' + endpoint) + '/api/v3'; | ||
} else if (options.datacenter === 'eu') { | ||
customEndpoint = 'https://sdk.fra-01.braze.eu/api/v3'; | ||
} | ||
if (Number(options.version) === 2) { | ||
@@ -78,3 +84,3 @@ this.initializeV2(customEndpoint); | ||
/* eslint-enable */ | ||
// this is used to test this.loaded | ||
@@ -86,8 +92,9 @@ this._shim = window.appboy.initialize; | ||
var datacenterMappings = { | ||
us: 'https://sdk.iad-01.braze.com', | ||
us: 'https://sdk.iad-01.braze.com', | ||
us02: 'https://sdk.iad-02.braze.com', | ||
us03: 'https://sdk.iad-03.braze.com', | ||
eu: 'https://sdk.fra-01.braze.eu' | ||
eu: 'https://sdk.fra-01.braze.eu' | ||
}; | ||
if (options.safariWebsitePushId) config.safariWebsitePushId = options.safariWebsitePushId; | ||
if (options.safariWebsitePushId) | ||
config.safariWebsitePushId = options.safariWebsitePushId; | ||
if (options.enableHtmlInAppMessages) config.enableHtmlInAppMessages = true; | ||
@@ -99,5 +106,8 @@ | ||
var regex = new RegExp('^(http|https)://', 'i'); | ||
config.baseUrl = (regex.test(endpoint) ? endpoint : 'https://' + endpoint) + '/api/v3'; | ||
config.baseUrl = | ||
(regex.test(endpoint) ? endpoint : 'https://' + endpoint) + '/api/v3'; | ||
} else { | ||
config.baseUrl = (datacenterMappings[options.datacenter] || 'https://sdk.iad-01.braze.com') + '/api/v3'; | ||
config.baseUrl = | ||
(datacenterMappings[options.datacenter] || | ||
'https://sdk.iad-01.braze.com') + '/api/v3'; | ||
} | ||
@@ -110,3 +120,4 @@ | ||
if (options.automaticallyDisplayMessages) window.appboy.display.automaticallyShowNewInAppMessages(); | ||
if (options.automaticallyDisplayMessages) | ||
window.appboy.display.automaticallyShowNewInAppMessages(); | ||
if (userId) window.appboy.changeUser(userId); | ||
@@ -118,3 +129,3 @@ | ||
}; | ||
/** | ||
@@ -129,3 +140,3 @@ * Initialize v2. | ||
var userId = this.analytics.user().id(); | ||
/* eslint-disable */ | ||
@@ -150,6 +161,8 @@ +function (a, p, P, b, y) { | ||
localization: options.localization, | ||
minimumIntervalBetweenTriggerActionsInSeconds: Number(options.minimumIntervalBetweenTriggerActionsInSeconds) || 30, | ||
minimumIntervalBetweenTriggerActionsInSeconds: | ||
Number(options.minimumIntervalBetweenTriggerActionsInSeconds) || 30, | ||
openInAppMessagesInNewTab: options.openInAppMessagesInNewTab, | ||
openNewsFeedCardsInNewTab: options.openNewsFeedCardsInNewTab, | ||
requireExplicitInAppMessageDismissal: options.requireExplicitInAppMessageDismissal, | ||
requireExplicitInAppMessageDismissal: | ||
options.requireExplicitInAppMessageDismissal, | ||
sessionTimeoutInSeconds: Number(options.sessionTimeoutInSeconds) || 30 | ||
@@ -159,9 +172,10 @@ }; | ||
if (customEndpoint) config.baseUrl = customEndpoint; | ||
this.initializeTester(options.apiKey, config); | ||
window.appboy.initialize(options.apiKey, config); | ||
if (options.automaticallyDisplayMessages) window.appboy.display.automaticallyShowNewInAppMessages(); | ||
if (options.automaticallyDisplayMessages) | ||
window.appboy.display.automaticallyShowNewInAppMessages(); | ||
if (userId) window.appboy.changeUser(userId); | ||
window.appboy.openSession(); | ||
@@ -219,3 +233,9 @@ | ||
if (birthday) { | ||
window.appboy.getUser().setDateOfBirth(birthday.getUTCFullYear(), birthday.getUTCMonth() + 1, birthday.getUTCDate()); | ||
window.appboy | ||
.getUser() | ||
.setDateOfBirth( | ||
birthday.getUTCFullYear(), | ||
birthday.getUTCMonth() + 1, | ||
birthday.getUTCDate() | ||
); | ||
} | ||
@@ -226,3 +246,26 @@ | ||
// https://www.appboy.com/documentation/Platform_Wide/#reserved-keys | ||
var reserved = ['avatar', 'address', 'birthday', 'email', 'id', 'firstName', 'gender', 'lastName', 'phone', 'facebook', 'twitter', 'first_name', 'last_name', 'dob', 'external_id', 'country', 'home_city', 'bio', 'gender', 'phone', 'email_subscribe', 'push_subscribe']; | ||
var reserved = [ | ||
'avatar', | ||
'address', | ||
'birthday', | ||
'email', | ||
'id', | ||
'firstName', | ||
'gender', | ||
'lastName', | ||
'phone', | ||
'facebook', | ||
'twitter', | ||
'first_name', | ||
'last_name', | ||
'dob', | ||
'external_id', | ||
'country', | ||
'home_city', | ||
'bio', | ||
'gender', | ||
'phone', | ||
'email_subscribe', | ||
'push_subscribe' | ||
]; | ||
each(function(key) { | ||
@@ -269,3 +312,10 @@ delete traits[key]; | ||
// https://www.appboy.com/documentation/Platform_Wide/#reserved-keys | ||
var reserved = ['time', 'product_id', 'quantity', 'event_name', 'price', 'currency']; | ||
var reserved = [ | ||
'time', | ||
'product_id', | ||
'quantity', | ||
'event_name', | ||
'price', | ||
'currency' | ||
]; | ||
each(function(key) { | ||
@@ -313,3 +363,2 @@ delete properties[key]; | ||
Appboy.prototype.orderCompleted = function(track) { | ||
@@ -333,3 +382,9 @@ var userId = track.userId(); | ||
var quantity = track.quantity(); | ||
window.appboy.logPurchase(productId, price, currencyCode, quantity, purchaseProperties); | ||
window.appboy.logPurchase( | ||
productId, | ||
price, | ||
currencyCode, | ||
quantity, | ||
purchaseProperties | ||
); | ||
}, products); | ||
@@ -358,5 +413,8 @@ }; | ||
if (femaleGenders.indexOf(gender.toLowerCase()) > -1) return window.appboy.ab.User.Genders.FEMALE; | ||
if (maleGenders.indexOf(gender.toLowerCase()) > -1) return window.appboy.ab.User.Genders.MALE; | ||
if (otherGenders.indexOf(gender.toLowerCase()) > -1) return window.appboy.ab.User.Genders.OTHER; | ||
if (femaleGenders.indexOf(gender.toLowerCase()) > -1) | ||
return window.appboy.ab.User.Genders.FEMALE; | ||
if (maleGenders.indexOf(gender.toLowerCase()) > -1) | ||
return window.appboy.ab.User.Genders.MALE; | ||
if (otherGenders.indexOf(gender.toLowerCase()) > -1) | ||
return window.appboy.ab.User.Genders.OTHER; | ||
} |
{ | ||
"name": "@segment/analytics.js-integration-appboy", | ||
"description": "The Appboy analytics.js integration.", | ||
"version": "1.7.1", | ||
"version": "1.8.0", | ||
"keywords": [ | ||
@@ -15,12 +15,12 @@ "analytics.js", | ||
}, | ||
"author": "Segment \u003cfriends@segment.com\u003e", | ||
"license": "SEE LICENSE IN LICENSE", | ||
"homepage": "https://github.com/segmentio/analytics.js-integrations/blob/master/integrations/appboy#readme", | ||
"bugs": { | ||
"url": "https://github.com/segmentio/analytics.js-integrations/issues" | ||
}, | ||
"repository": { | ||
"type": "git", | ||
"url": "git+https://github.com/segment-integrations/analytics.js-integration-appboy.git" | ||
"url": "git+https://github.com/segmentio/analytics.js-integrations.git" | ||
}, | ||
"author": "Segment <friends@segment.com>", | ||
"license": "SEE LICENSE IN LICENSE", | ||
"bugs": { | ||
"url": "https://github.com/segment-integrations/analytics.js-integration-appboy/issues" | ||
}, | ||
"homepage": "https://github.com/segment-integrations/analytics.js-integration-appboy#readme", | ||
"dependencies": { | ||
@@ -27,0 +27,0 @@ "@ndhoule/clone": "^1.0.0", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
No License Found
License(Experimental) License information could not be found.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Environment variable access
Supply chain riskPackage accesses environment variables, which may be a sign of credential stuffing or data theft.
Found 3 instances in 1 package
2
36757
6
1
795
2