diff --git a/DEVELOPER.md b/DEVELOPER.md index ba6e164d6..d7b164051 100644 --- a/DEVELOPER.md +++ b/DEVELOPER.md @@ -115,11 +115,11 @@ You need to run `npm run build` in the `ionic-native` project, this will create ### Cleaning the code -You need to run `npm run lint` to analyze the code and ensure it's consistency with the repository style. Fix any errors before submitting a PR. +You need to run `npm run lint` to analyze the code and ensure its consistency with the repository style. Fix any errors before submitting a PR. ### 'Wrapping' Up -That's it! The only thing left to do is rigorously document the plugin and it's usage. Take a look at some of the other plugins for good documentation styles. +That's it! The only thing left to do is rigorously document the plugin and its usage. Take a look at some of the other plugins for good documentation styles. ## Commit Message Format @@ -218,4 +218,4 @@ Example: ```ts @CordovaFunctionOverride() someMethod(): Observable { return; } -``` \ No newline at end of file +``` diff --git a/package-lock.json b/package-lock.json index ace3d8cc7..21f9db457 100644 --- a/package-lock.json +++ b/package-lock.json @@ -60,16 +60,6 @@ "integrity": "sha512-El3+WJk2D/ppWNd2X05aiP5l2k4EwF7KwheknQZls+I26eSICoWRhRIJ56jGgw2dqNGQ5LtNajmBU2ajS28EvQ==", "dev": true }, - "JSONStream": { - "version": "1.3.1", - "resolved": "https://registry.npmjs.org/JSONStream/-/JSONStream-1.3.1.tgz", - "integrity": "sha1-cH92HgHa6eFvG8+TcDt4xwlmV5o=", - "dev": true, - "requires": { - "jsonparse": "1.3.1", - "through": "2.3.8" - } - }, "abbrev": { "version": "1.0.9", "resolved": "https://registry.npmjs.org/abbrev/-/abbrev-1.0.9.tgz", @@ -1592,8 +1582,8 @@ "integrity": "sha1-HxXOa4RPfKQUlcgZDAgzwwuLFpM=", "dev": true, "requires": { - "JSONStream": "1.3.1", "is-text-path": "1.0.1", + "JSONStream": "1.3.1", "lodash": "4.17.4", "meow": "3.7.0", "split2": "2.2.0", @@ -4781,6 +4771,16 @@ "integrity": "sha1-P02uSpH6wxX3EGL4UhzCOfE2YoA=", "dev": true }, + "JSONStream": { + "version": "1.3.1", + "resolved": "https://registry.npmjs.org/JSONStream/-/JSONStream-1.3.1.tgz", + "integrity": "sha1-cH92HgHa6eFvG8+TcDt4xwlmV5o=", + "dev": true, + "requires": { + "jsonparse": "1.3.1", + "through": "2.3.8" + } + }, "jsprim": { "version": "1.4.1", "resolved": "https://registry.npmjs.org/jsprim/-/jsprim-1.4.1.tgz", @@ -7154,6 +7154,15 @@ } } }, + "string_decoder": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-1.0.3.tgz", + "integrity": "sha512-4AH6Z5fzNNBcH+6XDMfA/BTt87skxqJlO0lAh3Dker5zThcAxG6mKz+iGu308UKoPPQ8Dcqx/4JhujzltRa+hQ==", + "dev": true, + "requires": { + "safe-buffer": "5.1.1" + } + }, "string-width": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/string-width/-/string-width-1.0.2.tgz", @@ -7165,15 +7174,6 @@ "strip-ansi": "3.0.1" } }, - "string_decoder": { - "version": "1.0.3", - "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-1.0.3.tgz", - "integrity": "sha512-4AH6Z5fzNNBcH+6XDMfA/BTt87skxqJlO0lAh3Dker5zThcAxG6mKz+iGu308UKoPPQ8Dcqx/4JhujzltRa+hQ==", - "dev": true, - "requires": { - "safe-buffer": "5.1.1" - } - }, "stringmap": { "version": "0.2.2", "resolved": "https://registry.npmjs.org/stringmap/-/stringmap-0.2.2.tgz", diff --git a/src/@ionic-native/plugins/tealium-adidentifier/index.ts b/src/@ionic-native/plugins/tealium-adidentifier/index.ts new file mode 100644 index 000000000..ead5311ed --- /dev/null +++ b/src/@ionic-native/plugins/tealium-adidentifier/index.ts @@ -0,0 +1,59 @@ +import { Plugin, Cordova, IonicNativePlugin } from '@ionic-native/core'; +import { Injectable } from '@angular/core'; + +/** + * @paid + * @name TealiumAdIdentifier + * @description + * This module depends on the [Tealium Cordova Plugin](https://github.com/tealium/cordova-plugin). Without it, this module will not do anything. + * Makes the IDFA and Google Ad Identifier available in the Tealium data layer. + * + * @usage + * ``` + * import { TealiumAdIdentifier } from '@ionic-native/tealium-adidentifier'; + * + * + * constructor(private adIdentifier: TealiumAdIdentifier) { } + * + * ... + * + * + * this.adIdentifier.setPersistent("main"); + * this.adIdentifier.setVolatile("main"); + * + * ``` + */ + +@Plugin({ + pluginName: 'TealiumAdIdentifier', + plugin: 'tealium-cordova-adidentifier', // npm package name, example: cordova-plugin-camera + pluginRef: 'window.tealiumAdIdentifier', // the variable reference to call the plugin, example: navigator.geolocation + repo: 'https://github.com/Tealium/cordova-plugin', // the github repository URL for the plugin + platforms: ['Android', 'iOS'], // Array of platforms supported, example: ['Android', 'iOS'] + install: '', // OPTIONAL install command, in case the plugin requires variables +}) + +@Injectable() +export class TealiumAdIdentifier extends IonicNativePlugin { + + /** + * This function stores the ad identifier information as persistent data + * @param instanceName {string} Your arbitrary Tealium instance name provided at init time + * @return {Promise} Returns a promise that resolves when something happens + */ + @Cordova() + setPersistent(instanceName: string): Promise { + return; + } + + /** + * This function stores the ad identifier information as volatile data + * @param instanceName {string} Your arbitrary Tealium instance name provided at init time + * @return {Promise} Returns a promise that resolves when something happens + */ + @Cordova() + setVolatile(instanceName: string): Promise { + return; + } + +} diff --git a/src/@ionic-native/plugins/tealium-installreferrer/index.ts b/src/@ionic-native/plugins/tealium-installreferrer/index.ts new file mode 100644 index 000000000..edd828a05 --- /dev/null +++ b/src/@ionic-native/plugins/tealium-installreferrer/index.ts @@ -0,0 +1,59 @@ +import { Plugin, Cordova, IonicNativePlugin } from '@ionic-native/core'; +import { Injectable } from '@angular/core'; + +/** + * @paid + * @name TealiumInstallReferrer + * @description + * This module depends on the [Tealium Cordova Plugin](https://github.com/tealium/cordova-plugin). Without it, this module will not do anything. + * Implements a Broadcast Receiver for the INSTALL_REFERRER intent. + * + * @usage + * ``` + * import { TealiumInstallReferrer } from '@ionic-native/tealium-installreferrer'; + * + * + * constructor(private installReferrer: TealiumInstallReferrer) { } + * + * + * this.installReferrer.setPersistent("main"); + * this.installReferrer.setVolatile("main"); + * + * + * + * ``` + */ + +@Plugin({ + pluginName: 'TealiumInstallReferrer', + plugin: 'tealium-cordova-installreferrer', // npm package name, example: cordova-plugin-camera + pluginRef: 'window.tealiumInstallReferrer', // the variable reference to call the plugin, example: navigator.geolocation + repo: 'https://github.com/Tealium/cordova-plugin', // the github repository URL for the plugin + platforms: ['Android'], // Array of platforms supported, example: ['Android', 'iOS'] + install: '', // OPTIONAL install command, in case the plugin requires variables +}) + +@Injectable() +export class TealiumInstallReferrer extends IonicNativePlugin { + + /** + * This function stores the install referrer information as persistent data + * @param instanceName {string} Your arbitrary Tealium instance name provided at init time + * @return {Promise} Returns a promise that resolves when something happens + */ + @Cordova() + setPersistent(instanceName: string): Promise { + return; + } + + /** + * This function stores the install referrer information as volatile data + * @param instanceName {string} Your arbitrary Tealium instance name provided at init time + * @return {Promise} Returns a promise that resolves when something happens + */ + @Cordova() + setVolatile(instanceName: string): Promise { + return; + } + +} diff --git a/src/@ionic-native/plugins/tealium/index.ts b/src/@ionic-native/plugins/tealium/index.ts new file mode 100644 index 000000000..c0daa2507 --- /dev/null +++ b/src/@ionic-native/plugins/tealium/index.ts @@ -0,0 +1,220 @@ +import { Plugin, Cordova, IonicNativePlugin } from '@ionic-native/core'; +import { Injectable } from '@angular/core'; + +export interface TealConfig { + /** + * Your Tealium account name + */ + account: string; + /** + * Your Tealium profile name + */ + profile: string; + /** + * Your Tealium environment name (dev, qa, prod) + */ + environment: string; + /** + * Arbitrary instance name string. Must be consistent for all calls to Tealium API. + */ + instance: string; + /** + * Enables ("true") or disables ("false") lifecycle reporting. Default true if omitted. + */ + isLifecycleEnabled?: string; + /** + * Not usually required. Sets a custom URL override for dispatches to UDH. + */ + collectDispatchURL?: string; + /** + * Your Tealium UDH profile. Only active if you do not have collectDispatchURL set. + */ + collectDispatchProfile?: string; + /** + * Enables ("true") or disables ("false") Crash Reporter module for Android. Default false if omitted. + */ + isCrashReporterEnabled?: string; +} + +/** + * @paid + * @name Tealium + * @description + * This plugin provides a TypeScript wrapper around the [Tealium](https://www.tealium.com) Cordova plugin for Ionic Native. + * + * For full documentation, see [https://community.tealiumiq.com/t5/Mobile-Libraries/Tealium-for-Cordova/ta-p/17618](https://community.tealiumiq.com/t5/Mobile-Libraries/Tealium-for-Cordova/ta-p/17618) + * @usage + * ``` + * import { Tealium, TealConfig } from '@ionic-native/tealium'; + * + * + * constructor(private tealium: Tealium) { } + * + * ... + * + * let tealConfig: TealConfig = { + * account: "", + * profile: "", + * environment: "", // usually "dev", "qa" or "prod" + * isLifecycleEnabled: "true", // pass "false" to disable lifecycle tracking + * isCrashReporterEnabled: "false", // pass "true" to enable crash reporter (Android only) + * instance: "{ + * this.tealium.trackView({"screen_name": "homescreen"}); + * }); + * + * ``` + * @interfaces + * TealConfig + */ + +@Plugin({ + pluginName: 'Tealium', + plugin: 'tealium-cordova-plugin', // npm package name, example: cordova-plugin-camera + pluginRef: 'window.tealium', // the variable reference to call the plugin, example: navigator.geolocation + repo: 'https://github.com/Tealium/cordova-plugin', // the github repository URL for the plugin + platforms: ['Android', 'iOS'], // Array of platforms supported, example: ['Android', 'iOS'] + install: '', // OPTIONAL install command, in case the plugin requires variables +}) + +@Injectable() +export class Tealium extends IonicNativePlugin { + + /** + * This function initializes the Tealium Cordova plugin. + * This should usually be done inside the "deviceReady" handler. + * @param config {TealConfig} + * @return {Promise} Returns a promise that resolves when something happens + */ + @Cordova() + init(config: TealConfig): Promise { + return; // We add return; here to avoid any IDE / Compiler errors + } + + /** + * This function tracks a view event in the Tealium Cordova plugin + * @param dataObject {any} The JSON data object containing your key-value pairs + * @param instanceName {string} Your arbitrary Tealium instance name provided at init time + * @return {Promise} Returns a promise that resolves when something happens + */ + @Cordova() + trackView(dataObject: any, instanceName: string): Promise { + return; + } + + /** + * This function tracks a link event in the Tealium Cordova plugin + * @param dataObject {any} The JSON data object containing your key-value pairs + * @param instanceName {string} Your arbitrary Tealium instance name provided at init time + * @return {Promise} Returns a promise that resolves when something happens + */ + @Cordova() + trackEvent(dataObject: any, instanceName: string): Promise { + return; + } + + /** + * This function tracks a custom event in the Tealium Cordova plugin + * @param eventType {string} The event type, link or view + * @param dataObject {any} The JSON data object containing your key-value pairs + * @param instanceName {string} Your arbitrary Tealium instance name provided at init time + * @return {Promise} Returns a promise that resolves when something happens + */ + @Cordova() + track(eventType: string, dataObject: any, instanceName: string): Promise { + return; + } + + /** + * This function adds data to the Tealium persistent data store + * @param keyName {string} The key name that this data will be stored under for later retrieval + * @param value {any} The value to be stored as persistent data + * @param instanceName {string} Your arbitrary Tealium instance name provided at init time + * @return {Promise} Returns a promise that resolves when something happens + */ + @Cordova() + addPersistent(keyName: string, value: string | string[] | any, instanceName: string): Promise { + return; + } + + /** + * This function adds data to the Tealium volatile data store + * @param keyName {string} The key name that this data will be stored under for later retrieval + * @param value {any} The value to be stored as volatile data + * @param instanceName {string} Your arbitrary Tealium instance name provided at init time + * @return {Promise} Returns a promise that resolves when something happens + */ + @Cordova() + addVolatile(keyName: string, value: string | string[], instanceName: string): Promise { + return; + } + + /** + * This function removes data from the Tealium volatile data store + * @param keyName {string} The key name that this data will removed from the Tealium data store + * @param instanceName {string} Your arbitrary Tealium instance name provided at init time + * @return {Promise} Returns a promise that resolves when something happens + */ + @Cordova() + removeVolatile(keyName: string, instanceName: string): Promise { + return; + } + + /** + * This function removes data from the Tealium persistent data store + * @param keyName {string} The key name that this data will removed from the Tealium data store + * @param instanceName {string} Your arbitrary Tealium instance name provided at init time + * @return {Promise} Returns a promise that resolves when something happens + */ + @Cordova() + removePersistent(keyName: string, instanceName: string): Promise { + return; + } + + /** + * This function retrieves a value from the Tealium Persistent data store + * @param keyName {string} The key name that this data will retrieved from the Tealium data store + * @param instanceName {string} Your arbitrary Tealium instance name provided at init time + * @param callback {any} A callback function that will be called when the data has been retrieved + * @return {Promise} Returns a promise that resolves when something happens + */ + @Cordova() + getPersistent(keyName: string, instanceName: string, callback: any): Promise { + return; + } +/** + * This function retrieves a value from the Tealium Volatile data store + * @param keyName {string} The key name that this data will retrieved from the Tealium data store + * @param instanceName {string} Your arbitrary Tealium instance name provided at init time + * @param callback {any} A callback function that will be called when the data has been retrieved + * @return {Promise} Returns a promise that resolves when something happens + */ + @Cordova() + getVolatile(keyName: string, instanceName: string, callback: any): Promise { + return; + } + + /** + * This function adds a remote command for later execution + * @param commandName {string} The command name for this Remote Command + * @param instanceName {string} Your arbitrary Tealium instance name provided at init time + * @param callback {any} A callback function that will be called when the data has been retrieved + * @return {Promise} Returns a promise that resolves when something happens + */ + @Cordova() + addRemoteCommand(commandName: string, instanceName: string, callback: any): Promise { + return; + } + + /** + * This function retrieves the Tealium Visitor ID + * @return {Promise} Returns a promise that resolves when something happens + */ + @Cordova() + getVisitorId(): Promise { + return; + } + +}