@mparticle/web-braze-kit 3.0.2 → 3.0.3
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/CHANGELOG.md +3 -0
- package/dist/BrazeKit.common.js +114 -5
- package/package.json +2 -2
package/CHANGELOG.md
CHANGED
package/dist/BrazeKit.common.js
CHANGED
|
@@ -305,7 +305,7 @@ window.appboy = appboy_min;
|
|
|
305
305
|
|
|
306
306
|
var name = 'Appboy',
|
|
307
307
|
moduleId = 28,
|
|
308
|
-
version = '3.0.
|
|
308
|
+
version = '3.0.3',
|
|
309
309
|
MessageType = {
|
|
310
310
|
PageView: 3,
|
|
311
311
|
PageEvent: 4,
|
|
@@ -385,10 +385,20 @@ var constructor = function() {
|
|
|
385
385
|
sanitizedProductName
|
|
386
386
|
);
|
|
387
387
|
}
|
|
388
|
+
var price = parseFloat(product.Price);
|
|
389
|
+
|
|
390
|
+
kitLogger(
|
|
391
|
+
'appboy.logPurchase',
|
|
392
|
+
sanitizedProductName,
|
|
393
|
+
price,
|
|
394
|
+
event.CurrencyCode,
|
|
395
|
+
product.Quantity,
|
|
396
|
+
sanitizedProperties
|
|
397
|
+
);
|
|
388
398
|
|
|
389
399
|
reportEvent = appboy.logPurchase(
|
|
390
400
|
sanitizedProductName,
|
|
391
|
-
|
|
401
|
+
price,
|
|
392
402
|
event.CurrencyCode,
|
|
393
403
|
product.Quantity,
|
|
394
404
|
sanitizedProperties
|
|
@@ -414,6 +424,9 @@ var constructor = function() {
|
|
|
414
424
|
}
|
|
415
425
|
sanitizedEventName = getSanitizedValueForAppboy(eventName);
|
|
416
426
|
sanitizedAttrs = getSanitizedCustomProperties(attrs);
|
|
427
|
+
|
|
428
|
+
kitLogger('appboy.logCustomEvent', sanitizedEventName, sanitizedAttrs);
|
|
429
|
+
|
|
417
430
|
var reportEvent = appboy.logCustomEvent(
|
|
418
431
|
sanitizedEventName,
|
|
419
432
|
sanitizedAttrs
|
|
@@ -430,6 +443,13 @@ var constructor = function() {
|
|
|
430
443
|
", removeUserAttribute or setUserAttribute must set 'dob' to a date"
|
|
431
444
|
);
|
|
432
445
|
} else {
|
|
446
|
+
kitLogger(
|
|
447
|
+
'appoy.getUser().setDateOfBirth',
|
|
448
|
+
value.getFullYear(),
|
|
449
|
+
value.getMonth() + 1,
|
|
450
|
+
value.getDate()
|
|
451
|
+
);
|
|
452
|
+
|
|
433
453
|
appboy
|
|
434
454
|
.getUser()
|
|
435
455
|
.setDateOfBirth(
|
|
@@ -441,6 +461,9 @@ var constructor = function() {
|
|
|
441
461
|
} else if (key === '$Age') {
|
|
442
462
|
if (typeof value === 'number') {
|
|
443
463
|
var year = new Date().getFullYear() - value;
|
|
464
|
+
|
|
465
|
+
kitLogger('appboy.getUser().setDateOfBirth', year, 1, 1);
|
|
466
|
+
|
|
444
467
|
appboy.getUser().setDateOfBirth(year, 1, 1);
|
|
445
468
|
} else {
|
|
446
469
|
return '$Age must be a number';
|
|
@@ -458,6 +481,12 @@ var constructor = function() {
|
|
|
458
481
|
}
|
|
459
482
|
var params = [];
|
|
460
483
|
params.push(value);
|
|
484
|
+
|
|
485
|
+
kitLogger(
|
|
486
|
+
'appboy.getUser().' + DefaultAttributeMethods[key],
|
|
487
|
+
params
|
|
488
|
+
);
|
|
489
|
+
|
|
461
490
|
var u = appboy.getUser();
|
|
462
491
|
//This method uses the setLastName, setFirstName, setEmail, setCountry, setHomeCity, setPhoneNumber, setAvatarImageUrl, setDateOfBirth, setGender, setEmailNotificationSubscriptionType, and setPushNotificationSubscriptionType methods
|
|
463
492
|
if (!u[DefaultAttributeMethods[key]].apply(u, params)) {
|
|
@@ -482,10 +511,17 @@ var constructor = function() {
|
|
|
482
511
|
);
|
|
483
512
|
}
|
|
484
513
|
|
|
514
|
+
kitLogger(
|
|
515
|
+
'appboy.logCustomEvent',
|
|
516
|
+
sanitizedEventName,
|
|
517
|
+
sanitizedProperties
|
|
518
|
+
);
|
|
519
|
+
|
|
485
520
|
var reportEvent = appboy.logCustomEvent(
|
|
486
521
|
sanitizedEventName,
|
|
487
522
|
sanitizedProperties
|
|
488
523
|
);
|
|
524
|
+
|
|
489
525
|
return reportEvent === true;
|
|
490
526
|
}
|
|
491
527
|
|
|
@@ -541,6 +577,13 @@ var constructor = function() {
|
|
|
541
577
|
function removeUserAttribute(key) {
|
|
542
578
|
if (!(key in DefaultAttributeMethods)) {
|
|
543
579
|
var sanitizedKey = getSanitizedValueForAppboy(key);
|
|
580
|
+
|
|
581
|
+
kitLogger(
|
|
582
|
+
'appboy.getUser().setCustomUserAttribute',
|
|
583
|
+
sanitizedKey,
|
|
584
|
+
null
|
|
585
|
+
);
|
|
586
|
+
|
|
544
587
|
appboy.getUser().setCustomUserAttribute(sanitizedKey, null);
|
|
545
588
|
} else {
|
|
546
589
|
return setDefaultAttribute(key, null);
|
|
@@ -554,6 +597,13 @@ var constructor = function() {
|
|
|
554
597
|
if (value != null && sanitizedValue == null) {
|
|
555
598
|
return 'Value did not pass validation for ' + key;
|
|
556
599
|
}
|
|
600
|
+
|
|
601
|
+
kitLogger(
|
|
602
|
+
'appboy.getUser().setCustomUserAttribute',
|
|
603
|
+
sanitizedKey,
|
|
604
|
+
sanitizedValue
|
|
605
|
+
);
|
|
606
|
+
|
|
557
607
|
appboy
|
|
558
608
|
.getUser()
|
|
559
609
|
.setCustomUserAttribute(sanitizedKey, sanitizedValue);
|
|
@@ -567,8 +617,12 @@ var constructor = function() {
|
|
|
567
617
|
// Other versions use onUserIdentified, which is called after setUserIdentity from core SDK
|
|
568
618
|
if (window.mParticle.getVersion().split('.')[0] === '1') {
|
|
569
619
|
if (type == window.mParticle.IdentityType.CustomerId) {
|
|
620
|
+
kitLogger('appboy.changeUser', id);
|
|
621
|
+
|
|
570
622
|
appboy.changeUser(id);
|
|
571
623
|
} else if (type == window.mParticle.IdentityType.Email) {
|
|
624
|
+
kitLogger('appboy.getUser().setEmail', id);
|
|
625
|
+
|
|
572
626
|
appboy.getUser().setEmail(id);
|
|
573
627
|
} else {
|
|
574
628
|
return (
|
|
@@ -594,9 +648,13 @@ var constructor = function() {
|
|
|
594
648
|
];
|
|
595
649
|
}
|
|
596
650
|
|
|
651
|
+
kitLogger('appboy.changeUser', appboyUserIDType);
|
|
652
|
+
|
|
597
653
|
appboy.changeUser(appboyUserIDType);
|
|
598
654
|
|
|
599
655
|
if (userIdentities.email) {
|
|
656
|
+
kitLogger('appboy.getUser().setEmail', userIdentities.email);
|
|
657
|
+
|
|
600
658
|
appboy.getUser().setEmail(userIdentities.email);
|
|
601
659
|
}
|
|
602
660
|
}
|
|
@@ -648,11 +706,33 @@ var constructor = function() {
|
|
|
648
706
|
function openSession(forwarderSettings) {
|
|
649
707
|
appboy.openSession();
|
|
650
708
|
if (forwarderSettings.softPushCustomEventName) {
|
|
709
|
+
kitLogger(
|
|
710
|
+
'appboy.logCustomEvent',
|
|
711
|
+
forwarderSettings.softPushCustomEventName
|
|
712
|
+
);
|
|
713
|
+
|
|
651
714
|
appboy.logCustomEvent(forwarderSettings.softPushCustomEventName);
|
|
652
715
|
}
|
|
653
716
|
}
|
|
654
717
|
|
|
655
|
-
function initForwarder(
|
|
718
|
+
function initForwarder(
|
|
719
|
+
settings,
|
|
720
|
+
service,
|
|
721
|
+
testMode,
|
|
722
|
+
trackerId,
|
|
723
|
+
userAttributes,
|
|
724
|
+
userIdentities,
|
|
725
|
+
appVersion,
|
|
726
|
+
appName,
|
|
727
|
+
customFlags
|
|
728
|
+
) {
|
|
729
|
+
// check to see if there is a logger for backwards compatibility, and if not, mock one to avoid errors
|
|
730
|
+
if (!self.logger) {
|
|
731
|
+
// create a logger
|
|
732
|
+
self.logger = {
|
|
733
|
+
verbose: function() {},
|
|
734
|
+
};
|
|
735
|
+
}
|
|
656
736
|
// eslint-disable-line no-unused-vars
|
|
657
737
|
mpCustomFlags = customFlags;
|
|
658
738
|
try {
|
|
@@ -689,14 +769,14 @@ var constructor = function() {
|
|
|
689
769
|
options.baseUrl = customUrl;
|
|
690
770
|
}
|
|
691
771
|
}
|
|
692
|
-
|
|
772
|
+
|
|
693
773
|
if (mpCustomFlags && mpCustomFlags[moduleId.toString()]) {
|
|
694
774
|
var brazeFlags = mpCustomFlags[moduleId.toString()];
|
|
695
775
|
if (typeof brazeFlags.initOptions === 'function') {
|
|
696
776
|
brazeFlags.initOptions(options);
|
|
697
777
|
}
|
|
698
778
|
}
|
|
699
|
-
|
|
779
|
+
|
|
700
780
|
if (testMode !== true) {
|
|
701
781
|
appboy.initialize(forwarderSettings.apiKey, options);
|
|
702
782
|
finishAppboyInitialization(forwarderSettings);
|
|
@@ -805,6 +885,35 @@ var constructor = function() {
|
|
|
805
885
|
this.onUserIdentified = onUserIdentified;
|
|
806
886
|
this.removeUserAttribute = removeUserAttribute;
|
|
807
887
|
this.decodeClusterSetting = decodeClusterSetting;
|
|
888
|
+
|
|
889
|
+
/* An example output of this logger if we pass in a purchase event for 1 iPhone
|
|
890
|
+
with a SKU of iphoneSku that cost $999 with a product attribute of
|
|
891
|
+
color: blue would be:
|
|
892
|
+
mParticle - Braze Web Kit log:
|
|
893
|
+
appboy.logPurchase:
|
|
894
|
+
iphone,
|
|
895
|
+
999,
|
|
896
|
+
USD,
|
|
897
|
+
1,
|
|
898
|
+
{\"color\":\"blue\",\"Sku":"iphoneSKU"},\n`;
|
|
899
|
+
*/
|
|
900
|
+
function kitLogger(method) {
|
|
901
|
+
var msg = 'mParticle - Braze Web Kit log:';
|
|
902
|
+
|
|
903
|
+
var nonMethodArguments = Array.prototype.slice.call(arguments, 1);
|
|
904
|
+
msg += '\n' + method + ':\n';
|
|
905
|
+
|
|
906
|
+
nonMethodArguments.forEach(function(arg) {
|
|
907
|
+
if (isObject(arg) || Array.isArray(arg)) {
|
|
908
|
+
msg += JSON.stringify(arg);
|
|
909
|
+
} else {
|
|
910
|
+
msg += arg;
|
|
911
|
+
}
|
|
912
|
+
msg += ',\n';
|
|
913
|
+
});
|
|
914
|
+
|
|
915
|
+
self.logger.verbose(msg);
|
|
916
|
+
}
|
|
808
917
|
};
|
|
809
918
|
|
|
810
919
|
function getId() {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mparticle/web-braze-kit",
|
|
3
|
-
"version": "3.0.
|
|
3
|
+
"version": "3.0.3",
|
|
4
4
|
"author": "mParticle Developers <developers@mparticle.com> (https://www.mparticle.com)",
|
|
5
5
|
"description": "mParticle integration sdk for Braze",
|
|
6
6
|
"main": "dist/BrazeKit.common.js",
|
|
@@ -31,7 +31,7 @@
|
|
|
31
31
|
},
|
|
32
32
|
"dependencies": {
|
|
33
33
|
"@braze/web-sdk": "^3.5.0",
|
|
34
|
-
"@mparticle/web-sdk": "^2.
|
|
34
|
+
"@mparticle/web-sdk": "^2.17.0"
|
|
35
35
|
},
|
|
36
36
|
"license": "Apache-2.0"
|
|
37
37
|
}
|