1.0.1 • Published 8 months ago

insider-ionic-plugin v1.0.1

Weekly downloads
-
License
MIT
Repository
github
Last release
8 months ago

insider-ionic-plugin

Integration with Insider platform products. Bridge plugin with native Insider SDK's.

Install

npm install insider-ionic-plugin
npx cap sync

Setup

Insider SDK has some native requirements to run, so please follow the Dependencies and setup modules from native SDK's.

Android

  1. Setup the project following the instructions in the Insider's Academy
  2. Add the following dependencies in android/app/build.gradle file
dependencies {
  // ... all your projects other dependencies
  implementation 'com.useinsider:insider:14.2.4-nh'
  implementation 'com.useinsider:insiderhybrid:1.1.5'
}

iOS

  1. Setup the project following the instructions in the Insider's Academy

Push Notifications

For this sdk push notification's config, click here

Insider Capacitor SDK Modules

Initialization

await initialize({partnerId: "insider", appGroup: "group.com.insider.capacitor.demotest"}); 

User

Usage example:

// User object attributes
await setName({ name: `insider` });
await setSurname({ surname: `capacitor-sdk` });
await setAge({ age: 25 });
await setGender({ gender: "female" });
await setBirthday({ birthday: "1996-06-25" }); //Data should be set in (YYYY-MM-DD) format.

await setFacebookID({ facebookId: "facebookId" });
await setTwitterID({ twitterId: "twitterId" });
await setLanguage({ language: "pt" });
await setLocale({ locale: "pt_BR" });

// Optins
await setEmailOptin({ emailOptIn: true });
await setSMSOptin({ smsOptin: true });
await setLocationOptin({ locationOptin: true });
await setPushOptin({ pushOptIn: true });

// Custom User Attributes
await setCustomAttributeWithBoolean({
  key: "boolean_parameter",
  value: false,
});
await setCustomAttributeWithDouble({
  key: "double_parameter",
  value: 20.5,
});
await setCustomAttributeWithInt({
  key: "int_parameter",
  value: 25,
});
await setCustomAttributeWithString({
  key: "string_parameter",
  value: "caaqui",
});
await setCustomAttributeWithArray({
  key: "array_parameter",
  value: ["capacitor", "insider", "ionic"],
});

await setCustomAttributeWithDate({
  key: "date_parameter",
  value: new Date().toISOString(),
});

// Identifiers
await setPhoneAsIdentifier({ phone: "+5511941231111" });
await setEmailIdentifier({ email: `mobile@insider.com` });
await setUserIdAsIdentifier({ uuid: id });
await login(); // Always call LOGIN after set all the identifiers needed. 

await logout();

Product/Track Revenue

   const product = new InsiderProduct(
      "productId",
      "name",
      ["category1"],
      "http://www.insider.com",
      100.0,
      "BRL"
    );
product  
      .setColor("red")
      .setGroupcode("groupcode")
      .setQuantity(1)
      .setStock(10)
      .setPromotionDiscount(0.1)
      .setPromotionName("promotionName")
      .setShippingCost(10.0)
      .setSize("size")
      .setVoucherDiscount(0.2)
      .setSalePrice(90.0);
      .addParameterWithArray("array_parameter", [
        "insider",
        "ionic",
        "capacitor",
      ])
      //custom product parameters
      .addParameterWithBoolean("boolean_parameter", false)
      .addParameterWithDate("date_parameter", new Date().toISOString())
      .addParameterWithDouble("double_parameter", 20.5)
      .addParameterWithInt("int_parameter", 25)
      .addParameterWithString("string_parameter", "caaqui")
    

    await itemAddedToCart({ product: product });
    await itemRemovedFromCart({ productId: "productId" });
    await itemPurchased({ product: product, saleId: "saleId" });
    await cartCleared();

Events

// Events
var event = new InsiderEvent("my_custom_event")
  .addParameterWithBoolean("boolean_parameter", false)
  .addParameterWithDouble("double_parameter", 20.5)
  .addParameterWithInt("int_parameter", 25)
  .addParameterWithString("string_parameter", "insider")
  .addParameterWithArray("array_parameter", [
    "insider",
    "ionic",
    "capacitor",
  ])
  .addParameterWithDate("date_parameter", new Date().toISOString());

await build({
  event: event,
});//Always call build to send event data. If you dont call build, event will not be sent.


// Page View Events

await visitHomePage();
await visitListingPage({taxonomy: ["category1", "category2","category3"]});
await visitProductDetailPage({ product: product });
await visitCartPage({ products: [product, product2] });

Push Notifications

Setup

API

initialize(...)

initialize(_options: { partnerId: string; appGroup?: string; quietPermission?: boolean; }) => Promise<{}>
ParamType
_options{ partnerId: string; appGroup?: string; quietPermission?: boolean; }

Returns: Promise<{}>


setPhoneAsIdentifier(...)

setPhoneAsIdentifier(_options: { phone: string; }) => Promise<{}>
ParamType
_options{ phone: string; }

Returns: Promise<{}>


setEmailIdentifier(...)

setEmailIdentifier(_options: { email: string; }) => Promise<{}>
ParamType
_options{ email: string; }

Returns: Promise<{}>


setUserIdAsIdentifier(...)

setUserIdAsIdentifier(_options: { uuid: string; }) => Promise<{}>
ParamType
_options{ uuid: string; }

Returns: Promise<{}>


visitHomePage()

visitHomePage() => Promise<{}>

Returns: Promise<{}>


visitListingPage(...)

visitListingPage(_options: { taxonomy: string[]; }) => Promise<{}>
ParamType
_options{ taxonomy: string[]; }

Returns: Promise<{}>


visitCartPage(...)

visitCartPage(_options: { products: InsiderProduct[]; }) => Promise<{}>
ParamType
_options{ products: InsiderProduct[]; }

Returns: Promise<{}>


visitProductDetailPage(...)

visitProductDetailPage(_options: { product: InsiderProduct; }) => Promise<{}>
ParamType
_options{ product: InsiderProduct; }

Returns: Promise<{}>


setGDPRConsent(...)

setGDPRConsent(_options: { consent: boolean; }) => Promise<{}>
ParamType
_options{ consent: boolean; }

Returns: Promise<{}>


setActiveForegroundPushView()

setActiveForegroundPushView() => Promise<{}>

Returns: Promise<{}>


receivedNotification(...)

receivedNotification(_options: { notification: PushNotificationSchema; }) => Promise<{}>
ParamType
_options{ notification: PushNotificationSchema; }

Returns: Promise<{}>


addListener(EventTypes.CALLBACK_NOTIFICATION_OPEN, ...)

addListener(eventName: EventTypes.CALLBACK_NOTIFICATION_OPEN, listenerFunc: (data: any) => void) => Promise<PluginListenerHandle>
ParamType
eventNameEventTypes.CALLBACK_NOTIFICATION_OPEN
listenerFunc(data: any) => void

Returns: Promise<PluginListenerHandle>


addListener(EventTypes.CALLBACK_INAPP_BUTTON_CLICK, ...)

addListener(eventName: EventTypes.CALLBACK_INAPP_BUTTON_CLICK, listenerFunc: (data: any) => void) => Promise<PluginListenerHandle>
ParamType
eventNameEventTypes.CALLBACK_INAPP_BUTTON_CLICK
listenerFunc(data: any) => void

Returns: Promise<PluginListenerHandle>


addListener(EventTypes.CALLBACK_TEMP_STORE_PURCHASE, ...)

addListener(eventName: EventTypes.CALLBACK_TEMP_STORE_PURCHASE, listenerFunc: (data: any) => void) => Promise<PluginListenerHandle>
ParamType
eventNameEventTypes.CALLBACK_TEMP_STORE_PURCHASE
listenerFunc(data: any) => void

Returns: Promise<PluginListenerHandle>


addListener(EventTypes.CALLBACK_TEMP_STORE_ADDED_TO_CART, ...)

addListener(eventName: EventTypes.CALLBACK_TEMP_STORE_ADDED_TO_CART, listenerFunc: (data: any) => void) => Promise<PluginListenerHandle>
ParamType
eventNameEventTypes.CALLBACK_TEMP_STORE_ADDED_TO_CART
listenerFunc(data: any) => void

Returns: Promise<PluginListenerHandle>


addListener(EventTypes.CALLBACK_TEMP_STORE_CUSTOM_ACTION, ...)

addListener(eventName: EventTypes.CALLBACK_TEMP_STORE_CUSTOM_ACTION, listenerFunc: (data: any) => void) => Promise<PluginListenerHandle>
ParamType
eventNameEventTypes.CALLBACK_TEMP_STORE_CUSTOM_ACTION
listenerFunc(data: any) => void

Returns: Promise<PluginListenerHandle>


addListener(EventTypes.CALLBACK_INAPP_SEEN, ...)

addListener(eventName: EventTypes.CALLBACK_INAPP_SEEN, listenerFunc: (data: any) => void) => Promise<PluginListenerHandle>
ParamType
eventNameEventTypes.CALLBACK_INAPP_SEEN
listenerFunc(data: any) => void

Returns: Promise<PluginListenerHandle>


addListener(EventTypes.CALLBACK_FOREGROUND_PUSH, ...)

addListener(eventName: EventTypes.CALLBACK_FOREGROUND_PUSH, listenerFunc: () => void) => Promise<PluginListenerHandle>
ParamType
eventNameEventTypes.CALLBACK_FOREGROUND_PUSH
listenerFunc() => void

Returns: Promise<PluginListenerHandle>


Interfaces

PushNotificationSchema

PropTypeDescriptionSince
titlestringThe notification title.1.0.0
subtitlestringThe notification subtitle.1.0.0
bodystringThe main text payload for the notification.1.0.0
idstringThe notification identifier.1.0.0
tagstringThe notification tag. Only available on Android (from push notifications).4.0.0
badgenumberThe number to display for the app icon badge.1.0.0
notificationanyIt's not being returned.1.0.0
dataanyAny additional data that was included in the push notification payload.1.0.0
click_actionstringThe action to be performed on the user opening the notification. Only available on Android.1.0.0
linkstringDeep link from the notification. Only available on Android.1.0.0
groupstringSet the group identifier for notification grouping. Only available on Android. Works like threadIdentifier on iOS.1.0.0
groupSummarybooleanDesignate this notification as the summary for an associated group. Only available on Android.1.0.0

PluginListenerHandle

PropType
remove() => Promise<void>

Enums

EventTypes

MembersValue
CALLBACK_NOTIFICATION_OPEN'notification_open'
CALLBACK_INAPP_BUTTON_CLICK'inapp_button_click'
CALLBACK_TEMP_STORE_PURCHASE'temp_store_purchase'
CALLBACK_TEMP_STORE_ADDED_TO_CART'temp_store_added_to_cart'
CALLBACK_TEMP_STORE_CUSTOM_ACTION'temp_store_custom_action'
CALLBACK_INAPP_SEEN'inapp_seen'
CALLBACK_FOREGROUND_PUSH"foreground_push"

InsiderEvent Class

Overview

The InsiderEvent class represents an internal event. It allows the addition of parameters of different types to this event.

Constructor

  • constructor(eventName: string)
    • Creates a new instance of InsiderEvent with the provided event name.

Methods

  • addParameterWithString(key: string, value: string): InsiderEvent

    • Adds a parameter with a string value.
  • addParameterWithInt(key: string, value: number): InsiderEvent

    • Adds a parameter with an integer value.
  • addParameterWithDouble(key: string, value: number): InsiderEvent
    • Adds a parameter with a double value.
  • addParameterWithBoolean(key: string, value: boolean): InsiderEvent
    • Adds a parameter with a boolean value.
  • addParameterWithDate(key: string, value: string): InsiderEvent
    • Adds a parameter with a date value.
  • addParameterWithArray(key: string, value: string[]): InsiderEvent
    • Adds a parameter with an array of strings value.

InsiderProduct Class

Overview

The InsiderProduct class represents an internal product. It allows the addition of both required and optional parameters to this product.

Constructor

  • constructor(productId: string, productName: string, taxonomy: string[], imageURL: string, price: number, currency: string)
    • Creates a new instance of InsiderProduct with the provided required parameters.

Methods

  • Methods to add parameters with different value types, similar to the InsiderEvent class.

  • Methods to set optional parameters of the product:

    • setColor(color: string): InsiderProduct
    • setVoucherName(voucherName: string): InsiderProduct
    • setVoucherDiscount(voucherDiscount: number): InsiderProduct
    • setPromotionName(promotionName: string): InsiderProduct
    • setPromotionDiscount(promotionDiscount: number): InsiderProduct
    • setGroupcode(groupcode: string): InsiderProduct
    • setSize(size: string): InsiderProduct
    • setSalePrice(salePrice: number): InsiderProduct
    • setShippingCost(shippingCost: number): InsiderProduct
    • setQuantity(quantity: number): InsiderProduct
    • setStock(stock: number): InsiderProduct
    • setSubCategory(subCategory: string): InsiderProduct
1.0.1

8 months ago

1.0.0

8 months ago

0.0.1

9 months ago