cordova-plugin-insider 1.2.0

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.
Files changed (45) hide show
  1. package/.github/CODEOWNERS +8 -0
  2. package/.github/workflows/git-leak.yml +25 -0
  3. package/.github/workflows/insider-cordova-SDK_release.yml +61 -0
  4. package/.github/workflows/release_task_merger.yml +22 -0
  5. package/.github/workflows/release_version_setter.yml +43 -0
  6. package/README.md +104 -0
  7. package/hooks/FSUtils.js +28 -0
  8. package/hooks/after_plugin_install.js +81 -0
  9. package/hooks/before_plugin_uninstall.js +49 -0
  10. package/package.json +19 -0
  11. package/plugin.xml +91 -0
  12. package/release_version.sh +27 -0
  13. package/slack_notifier.sh +20 -0
  14. package/src/android/CDVUtils.java +120 -0
  15. package/src/android/Constants.java +41 -0
  16. package/src/android/InsiderPlugin.java +814 -0
  17. package/src/android/build-extras.gradle +38 -0
  18. package/src/android/res/values/dimens.xml +4 -0
  19. package/src/android/res/values-sw600dp/dimens.xml +3 -0
  20. package/src/android/res/values-sw720dp/dimens.xml +3 -0
  21. package/src/android/res/values-xhdpi/dimens.xml +4 -0
  22. package/src/android/res/values-xxhdpi/dimens.xml +4 -0
  23. package/src/android/res/values-xxxhdpi/dimens.xml +4 -0
  24. package/src/ios/IDFAHelper.h +7 -0
  25. package/src/ios/IDFAHelper.m +19 -0
  26. package/src/ios/InsiderPlugin.h +58 -0
  27. package/src/ios/InsiderPlugin.m +758 -0
  28. package/types/CallbackType.d.ts +7 -0
  29. package/types/ContentOptimizerDataType.d.ts +4 -0
  30. package/types/Event.d.ts +9 -0
  31. package/types/Gender.d.ts +5 -0
  32. package/types/Identifier.d.ts +7 -0
  33. package/types/InsiderPlugin.d.ts +51 -0
  34. package/types/Product.d.ts +18 -0
  35. package/types/User.d.ts +27 -0
  36. package/www/CallbackType.js +7 -0
  37. package/www/Constants.js +86 -0
  38. package/www/ContentOptimizerDataType.js +4 -0
  39. package/www/Event.js +96 -0
  40. package/www/Gender.js +5 -0
  41. package/www/Identifier.js +66 -0
  42. package/www/InsiderPlugin.js +364 -0
  43. package/www/Product.js +211 -0
  44. package/www/User.js +303 -0
  45. package/www/Utils.js +18 -0
@@ -0,0 +1,7 @@
1
+ export interface CallbackType {
2
+ NOTIFICATION_OPEN: number,
3
+ INAPP_BUTTON_CLICK: number,
4
+ TEMP_STORE_PURCHASE: number,
5
+ TEMP_STORE_ADDED_TO_CART: number,
6
+ TEMP_STORE_CUSTOM_ACTION: number,
7
+ }
@@ -0,0 +1,4 @@
1
+ export interface ContentOptimizerDataType {
2
+ CONTENT: number,
3
+ ELEMENT: number,
4
+ }
@@ -0,0 +1,9 @@
1
+ export interface Event {
2
+ addParameterWithString(key: string, value: string): Event;
3
+ addParameterWithInt(key: string, value: number): Event;
4
+ addParameterWithDouble(key: string, value: number): Event;
5
+ addParameterWithBoolean(key: string, value: boolean): Event;
6
+ addParameterWithDate(key: string, value: string): Event;
7
+ addParameterWithArray(key: string, value: object): Event;
8
+ build(): void;
9
+ }
@@ -0,0 +1,5 @@
1
+ export interface Gender {
2
+ MALE: number,
3
+ FEMALE: number,
4
+ OTHER: number,
5
+ }
@@ -0,0 +1,7 @@
1
+ export interface Identifier {
2
+ addEmail(email: string): Identifier;
3
+ addPhoneNumber(phoneNumber: string): Identifier;
4
+ addUserID(userID: string): Identifier;
5
+ addCustomIdentifier(key: string, value: string): Identifier;
6
+ getIdentifiers(): Object;
7
+ }
@@ -0,0 +1,51 @@
1
+ import { User } from './User';
2
+ import { Event } from './Event';
3
+ import { Product } from './Product';
4
+ import { Identifier } from './Identifier';
5
+ import { Gender } from './Gender';
6
+ import { CallbackType } from './CallbackType';
7
+ import { ContentOptimizerDataType } from './ContentOptimizerDataType';
8
+
9
+ interface InsiderPlugin {
10
+ init(partnerName: string, appGroup: string, handleNotificationCallback: Function): void;
11
+ initWithCustomEndpoint(partnerName: string, appGroup: string, endpoint: string, handleNotificationCallback: Function): void;
12
+ tagEvent(eventName: string): Event;
13
+ getCurrentUser(): User;
14
+ createNewProduct(productId: string, name: string, taxonomy: object, imageURL: string, price: number, currency: string): Product
15
+ itemPurchased(uniqueSaleID: string, product: object): void;
16
+ itemAddedToCart(product: object): void;
17
+ itemRemovedFromCart(productID: string): void;
18
+ cartCleared(): void;
19
+ getMessageCenterData(limit: number, startDate: Date, endDate: Date): Promise <any>;
20
+ getSmartRecommendation(recommendationID: number, locale: string, currency: string): Promise <any>;
21
+ getSmartRecommendationWithProduct(product: object, recommendationID: number, locale: string): Promise <any>;
22
+ clickSmartRecommendationProduct(product: object, recommendationID: number);
23
+ getContentStringWithName(variableName: string, defaultValue: any, contentOptimizerDataType: number): Promise <any>;
24
+ getContentBoolWithName(variableName: string, defaultValue: boolean, contentOptimizerDataType: number): Promise <any>;
25
+ getContentIntWithName(variableName: string, defaultValue: number, contentOptimizerDataType: number): Promise <any>;
26
+ visitHomePage(): void;
27
+ visitListingPage(taxonomy: object): void;
28
+ visitProductDetailPage(product: object): void;
29
+ visitCartPage(products: object): void;
30
+ startTrackingGeofence(): void;
31
+ setGDPRConsent(gdprConsent: boolean): void;
32
+ enableIDFACollection(idfaCollection: boolean): void;
33
+ removeInapp(): void;
34
+ registerWithQuietPermission(booleanValue: boolean): void;
35
+ setHybridPushToken(token: string): void;
36
+ enableLocationCollection(locationCollection: boolean): void;
37
+ enableIpCollection(ipCollection: boolean): void;
38
+ enableCarrierCollection(carrierCollection: boolean): void;
39
+ signUpConfirmation(): void;
40
+ setActiveForegroundPushView(): void;
41
+ setForegroundPushCallback(): void;
42
+ handleNotification(userInfo: object): void;
43
+
44
+ gender: Gender;
45
+ callbackType: CallbackType;
46
+ contentOptimizerDataType: ContentOptimizerDataType;
47
+ identifier(): Identifier;
48
+ }
49
+
50
+ declare const Insider: InsiderPlugin;
51
+ export default Insider;
@@ -0,0 +1,18 @@
1
+ export interface Product {
2
+ setColor(color: string):Product;
3
+ setVoucherName(voucherName: string):Product;
4
+ setPromotionName(color: string):Product;
5
+ setSize(size: string):Product;
6
+ setSalePrice(salePrice: number):Product;
7
+ setShippingCost(shippingCost: number):Product;
8
+ setVoucherDiscount(voucherDiscount: number):Product;
9
+ setPromotionDiscount(promotionDiscount: number):Product;
10
+ setStock(setStock: number):Product;
11
+ setQuantity(quantity: number):Product;
12
+ setCustomAttributeWithString(key: string, value: string):Product;
13
+ setCustomAttributeWithInt(key: string, value: number):Product;
14
+ setCustomAttributeWithBoolean(key: string, value: boolean):Product;
15
+ setCustomAttributeWithDouble(key: string, value: number):Product;
16
+ setCustomAttributeWithDate(key: string, value: Date):Product;
17
+ setCustomAttributeWithArray(key: string, value: object):Product;
18
+ }
@@ -0,0 +1,27 @@
1
+ export interface User {
2
+ setGender(gender: number): User;
3
+ setBirthday(birthday: Date): User;
4
+ setName(name: string): User;
5
+ setSurname(surname: string): User;
6
+ setAge(age: number): User;
7
+ setEmail(email: string): User;
8
+ setPhoneNumber(phone: string): User;
9
+ setLanguage(language: string): User;
10
+ setLocale(locale: string): User;
11
+ setFacebookID(facebookID: string): User;
12
+ setTwitterID(twitterID: string): User;
13
+ setEmailOptin(emailOptIn: boolean): User;
14
+ setSMSOptin(smsOptIn: boolean): User;
15
+ setPushOptin(pushOptIn: boolean): User;
16
+ setLocationOptin(locationOptIn: boolean): User;
17
+ setWhatsappOptin(whatsappOptin: boolean): User;
18
+ login(identifiers:object, insiderIDResult: Function): void;
19
+ logout(): void;
20
+ setCustomAttributeWithString(key: string, value: string): User;
21
+ setCustomAttributeWithInt(key: string, value: number): User;
22
+ setCustomAttributeWithDouble(key: string, value: number): User;
23
+ setCustomAttributeWithBoolean(key: string, value: boolean): User;
24
+ setCustomAttributeWithDate(key: string, value: string): User;
25
+ setCustomAttributeWithArray(key: string, value: object): User;
26
+ unsetCustomAttribute(key: string): User;
27
+ }
@@ -0,0 +1,7 @@
1
+ module.exports = {
2
+ NOTIFICATION_OPEN: 0,
3
+ INAPP_BUTTON_CLICK: 1,
4
+ TEMP_STORE_PURCHASE: 2,
5
+ TEMP_STORE_ADDED_TO_CART: 3,
6
+ TEMP_STORE_CUSTOM_ACTION: 4,
7
+ };
@@ -0,0 +1,86 @@
1
+ module.exports = {
2
+ // Main Class Name
3
+ CLASS: 'InsiderPlugin',
4
+ // User
5
+ SET_GENDER: 'setGender',
6
+ SET_BIRTDAY: 'setBirthday',
7
+ SET_NAME: 'setName',
8
+ SET_SURNAME: 'setSurname',
9
+ SET_AGE: 'setAge',
10
+ SET_EMAIL: 'setEmail',
11
+ SET_PHONE_NUMBER: 'setPhoneNumber',
12
+ SET_LANGUAGE: 'setLanguage',
13
+ SET_LOCALE: 'setLocale',
14
+ SET_FACEBOOK_ID: 'setFacebookID',
15
+ SET_TWITTER_ID: 'setTwitterID',
16
+ SET_EMAIL_OPTIN: 'setEmailOptin',
17
+ SET_SMS_OPTIN: 'setSMSOptin',
18
+ SET_PUSH_OPTIN: 'setPushOptin',
19
+ SET_LOCATION_OPTIN: 'setLocationOptin',
20
+ SET_WHATSAPP_OPTIN: 'setWhatsappOptin',
21
+ LOGIN: 'login',
22
+ LOGOUT: 'logout',
23
+ SET_CUSTOM_ATTRIBUTE_WITH_STRING: 'setCustomAttributeWithString',
24
+ SET_CUSTOM_ATTRIBUTE_WITH_INT: 'setCustomAttributeWithInt',
25
+ SET_CUSTOM_ATTRIBUTE_WITH_DOUBLE: 'setCustomAttributeWithDouble',
26
+ SET_CUSTOM_ATTRIBUTE_WITH_BOOLEAN: 'setCustomAttributeWithBoolean',
27
+ SET_CUSTOM_ATTRIBUTE_WITH_DATE: 'setCustomAttributeWithDate',
28
+ SET_CUSTOM_ATTRIBUTE_WITH_ARRAY: 'setCustomAttributeWithArray',
29
+ UNSET_CUSTOM_ATTRIBUTE: 'unsetCustomAttribute',
30
+ // User Identifier
31
+ ADD_EMAIL: 'addEmail',
32
+ ADD_PHONE_NUMBER: 'addPhoneNumber',
33
+ ADD_USER_ID: 'addUserID',
34
+ // Insider Functions
35
+ INIT_WITH_CUSTOM_ENDPOINT: 'initWithCustomEndpoint',
36
+ INIT_WITH_LAUNCH_OPTIONS: 'initWithLaunchOptions',
37
+ INIT: 'init',
38
+ ITEM_PURCHASED: 'itemPurchased',
39
+ ITEM_ADDED_TO_CART: 'itemAddedToCart',
40
+ ITEM_REMOVED_FROM_CART: 'itemRemovedFromCart',
41
+ CART_CLEARED: 'cartCleared',
42
+ GET_MESSAGE_CENTER_DATA: 'getMessageCenterData',
43
+ GET_SMART_RECOMMENDATION: 'getSmartRecommendation',
44
+ GET_SMART_RECOMMENDATION_WITH_PRODUCT: 'getSmartRecommendationWithProduct',
45
+ CLICK_SMART_RECOMMENDATION_PRODUCT: 'clickSmartRecommendationProduct',
46
+ GET_CONTENT_STRING_WITH_NAME: 'getContentStringWithName',
47
+ GET_CONTENT_BOOL_WITH_NAME: 'getContentBoolWithName',
48
+ GET_CONTENT_INT_WITH_NAME: 'getContentIntWithName',
49
+ VISIT_HOME_PAGE: 'visitHomePage',
50
+ VISIT_LISTING_PAGE: 'visitListingPage',
51
+ VISIT_PRODUCT_DETAIL_PAGE: 'visitProductDetailPage',
52
+ VISIT_CART_PAGE: 'visitCartPage',
53
+ START_TRACKING_GEOFENCE: 'startTrackingGeofence',
54
+ SET_GDPR_CONSENT: 'setGDPRConsent',
55
+ REMOVE_IN_APP: 'removeInapp',
56
+ REGISTER_WITH_QUIET_PERMISSION: 'registerWithQuietPermission',
57
+ SET_HYBRID_PUSH_TOKEN: 'setHybridPushToken',
58
+ ENABLE_IDFA_COLLECTION: 'enableIDFACollection',
59
+ ENABLE_LOCATION_COLLECTION: 'enableLocationCollection',
60
+ ENABLE_IP_COLLECTION: 'enableIpCollection',
61
+ ENABLE_CARRIER_COLLECTION: 'enableCarrierCollection',
62
+ SIGN_UP_CONFIRMATION: 'signUpConfirmation',
63
+ SET_ACTIVE_FOREGROUND_PUSH_VIEW: 'setActiveForegroundPushView',
64
+ SET_FOREGROUND_PUSH_CALLBACK: 'setForegroundPushCallback',
65
+ HANDLE_NOTIFICATION: 'handleNotification',
66
+ // Event
67
+ TAG_EVENT: 'tagEvent',
68
+ // Product Attribute
69
+ SALE_PRICE: 'sale_price',
70
+ STOCK: 'stock',
71
+ COLOR: 'color',
72
+ SIZE: 'size',
73
+ QUANTITY: 'quantity',
74
+ SHIPPING_COST: 'shipping_cost',
75
+ VOUCHER_NAME: 'voucher_name',
76
+ VOUCHER_DISCOUNT: 'voucher_discount',
77
+ PROMOTION_NAME: 'promotion_name',
78
+ PROMOTION_DISCOUNT: 'promotion_discount',
79
+ // Error
80
+ PUT_ERROR_LOG: 'putErrorLog',
81
+ // Platform
82
+ ANDROID: 'android',
83
+ IOS: 'ios',
84
+ // SDK Version
85
+ SDK_VERSION: 'CDV-1.2.0',
86
+ };
@@ -0,0 +1,4 @@
1
+ module.exports = {
2
+ CONTENT: 0,
3
+ ELEMENT: 1,
4
+ };
package/www/Event.js ADDED
@@ -0,0 +1,96 @@
1
+ "use strict";
2
+
3
+ const Utils = require("./Utils");
4
+ const InsiderConstants = require("./Constants");
5
+
6
+ class Event {
7
+ name = '';
8
+ parameters = {};
9
+
10
+ constructor(name) {
11
+ this.name = name;
12
+ }
13
+
14
+ addParameterWithString(key, value) {
15
+ if (key === null || value === null || Utils.isEmpty(key) || Utils.isEmpty(value)){ Utils.showWarning(this.constructor.name + '-addParameterWithString key or value'); return this;}
16
+
17
+ try {
18
+ this.parameters[key] = value;
19
+
20
+ return this;
21
+ } catch (error) {
22
+ Utils.asyncExec(InsiderConstants.CLASS, InsiderConstants.PUT_ERROR_LOG, [Utils.generateJSONErrorString(error)]);
23
+ }
24
+ }
25
+
26
+ addParameterWithInt(key, value) {
27
+ if (key === null || value === null || Utils.isEmpty(key) || Utils.isEmpty(value)){ Utils.showWarning(this.constructor.name + '-addParameterWithInt key or value'); return this;}
28
+
29
+ try {
30
+ this.parameters[key] = value;
31
+
32
+ return this;
33
+ } catch (error) {
34
+ Utils.asyncExec(InsiderConstants.CLASS, InsiderConstants.PUT_ERROR_LOG, [Utils.generateJSONErrorString(error)]);
35
+ }
36
+ }
37
+
38
+ addParameterWithDouble(key, value) {
39
+ if (key === null || value === null || Utils.isEmpty(key) || Utils.isEmpty(value)){ Utils.showWarning(this.constructor.name + '-addParameterWithDouble key or value'); return this;}
40
+
41
+ try {
42
+ this.parameters[key] = value;
43
+
44
+ return this;
45
+ } catch (error) {
46
+ Utils.asyncExec(InsiderConstants.CLASS, InsiderConstants.PUT_ERROR_LOG, [Utils.generateJSONErrorString(error)]);
47
+ }
48
+ }
49
+
50
+ addParameterWithBoolean(key, value) {
51
+ if (key === null || value === null || Utils.isEmpty(key)|| Utils.isEmpty(value)){ Utils.showWarning(this.constructor.name + '-addParameterWithBoolean key or value'); return this;}
52
+
53
+ try {
54
+ this.parameters[key] = value;
55
+
56
+ return this;
57
+ } catch (error) {
58
+ Utils.asyncExec(InsiderConstants.CLASS, InsiderConstants.PUT_ERROR_LOG, [Utils.generateJSONErrorString(error)]);
59
+ }
60
+ }
61
+
62
+ addParameterWithDate(key, value) {
63
+ if (key === null || value === null || Utils.isEmpty(key) || Utils.isEmpty(value)){ Utils.showWarning(this.constructor.name + '-addParameterWithDate key or value'); return this;}
64
+
65
+ try {
66
+
67
+ this.parameters[key] = value.toISOString();
68
+
69
+ return this;
70
+ } catch (error) {
71
+ Utils.asyncExec(InsiderConstants.CLASS, InsiderConstants.PUT_ERROR_LOG, [Utils.generateJSONErrorString(error)]);
72
+ }
73
+ }
74
+
75
+ addParameterWithArray(key, value) {
76
+ if (key === null || value === null || Utils.isEmpty(key) || Utils.isEmpty(value)){ Utils.showWarning(this.constructor.name + '-addParameterWithArray key or value'); return this;}
77
+
78
+ try {
79
+ this.parameters[key] = value;
80
+
81
+ return this;
82
+ } catch (error) {
83
+ Utils.asyncExec(InsiderConstants.CLASS, InsiderConstants.PUT_ERROR_LOG, [Utils.generateJSONErrorString(error)]);
84
+ }
85
+ }
86
+
87
+ build() {
88
+ try {
89
+ Utils.asyncExec(InsiderConstants.CLASS, InsiderConstants.TAG_EVENT, [this.name, this.parameters]);
90
+ } catch (error) {
91
+ Utils.asyncExec(InsiderConstants.CLASS, InsiderConstants.PUT_ERROR_LOG, [Utils.generateJSONErrorString(error)]);
92
+ }
93
+ }
94
+ }
95
+
96
+ module.exports = Event;
package/www/Gender.js ADDED
@@ -0,0 +1,5 @@
1
+ module.exports = {
2
+ MALE: 0,
3
+ FEMALE: 1,
4
+ OTHER: 2,
5
+ };
@@ -0,0 +1,66 @@
1
+ "use strict";
2
+
3
+ const Utils = require("./Utils");
4
+ const InsiderConstants = require("./Constants");
5
+
6
+ class Identifier {
7
+ identifiers = {};
8
+
9
+ constructor() {
10
+ this.identifiers = {};
11
+ }
12
+
13
+ addEmail(email) {
14
+ if (email === null || Utils.isEmpty(email)){ Utils.showWarning(this.constructor.name + '-email'); return this;}
15
+
16
+ try {
17
+ this.identifiers[InsiderConstants.ADD_EMAIL] = email;
18
+ } catch (error) {
19
+ Utils.asyncExec(InsiderCordovaPlugin, InsiderConstants.PUT_ERROR_LOG, [Utils.generateJSONErrorString(error)]);
20
+ }
21
+
22
+ return this;
23
+ }
24
+
25
+ addPhoneNumber(phoneNumber) {
26
+ if (phoneNumber === null || Utils.isEmpty(phoneNumber)){ Utils.showWarning(this.constructor.name + '-phoneNumber'); return this;}
27
+
28
+ try {
29
+ this.identifiers[InsiderConstants.ADD_PHONE_NUMBER] = phoneNumber;
30
+ } catch (error) {
31
+ Utils.asyncExec(InsiderCordovaPlugin, InsiderConstants.PUT_ERROR_LOG, [Utils.generateJSONErrorString(error)]);
32
+ }
33
+
34
+ return this;
35
+ }
36
+
37
+ addUserID(userID) {
38
+ if (userID === null || Utils.isEmpty(userID)){ Utils.showWarning(this.constructor.name + '-userID'); return this;}
39
+
40
+ try {
41
+ this.identifiers[InsiderConstants.ADD_USER_ID] = userID;
42
+ } catch (error) {
43
+ Utils.asyncExec(InsiderCordovaPlugin, InsiderConstants.PUT_ERROR_LOG, [Utils.generateJSONErrorString(error)]);
44
+ }
45
+
46
+ return this;
47
+ }
48
+
49
+ addCustomIdentifier(key, value) {
50
+ if (key === null || value === null || Utils.isEmpty(key)){ Utils.showWarning(this.constructor.name + '-addCustomIdentifier key or value'); return this;}
51
+
52
+ try {
53
+ this.identifiers[key] = value;
54
+ } catch (error) {
55
+ Utils.asyncExec(InsiderCordovaPlugin, InsiderConstants.PUT_ERROR_LOG, [Utils.generateJSONErrorString(error)]);
56
+ }
57
+
58
+ return this;
59
+ }
60
+
61
+ getIdentifiers() {
62
+ return this.identifiers;
63
+ }
64
+ }
65
+
66
+ module.exports = Identifier;