From 8bcbc955e00179eecf852897bbd5ea4e283e2293 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Franti=C5=A1ek=20Spurn=C3=BD?= <43814366+SenNeonoveNoci@users.noreply.github.com> Date: Fri, 9 Aug 2019 11:04:51 +0200 Subject: [PATCH] feat(smartlook): add plugin (#3117) --- src/@ionic-native/plugins/smartlook/index.ts | 249 +++++++++++++++++++ 1 file changed, 249 insertions(+) create mode 100644 src/@ionic-native/plugins/smartlook/index.ts diff --git a/src/@ionic-native/plugins/smartlook/index.ts b/src/@ionic-native/plugins/smartlook/index.ts new file mode 100644 index 00000000..38ed72b6 --- /dev/null +++ b/src/@ionic-native/plugins/smartlook/index.ts @@ -0,0 +1,249 @@ +import { Injectable } from '@angular/core'; +import { Plugin, Cordova, IonicNativePlugin } from '@ionic-native/core'; + +export class SmartlookSetupConfig { + private smartlookAPIKey: string; + private fps: number; + + constructor(smartlookAPIKey: string, fps?: number) { + this.smartlookAPIKey = smartlookAPIKey; + this.fps = fps; + } +} + +export class SmartlookUserIdentifier { + private identifier: string; + private sessionProperties: {}; + + constructor(identifier: string, sessionProperties?: {}) { + this.identifier = identifier; + this.sessionProperties = sessionProperties; + } +} + +export class SmartlookCustomEvent { + private name: string; + private eventProperties: {}; + + constructor(name: string, eventProperties?: {}) { + this.name = name; + this.eventProperties = eventProperties; + } +} + +export class SmartlookGlobalEventProperties { + private globalEventProperties: {}; + private immutable: boolean; + + constructor(globalEventProperties: {}, immutable: boolean) { + this.globalEventProperties = globalEventProperties; + this.immutable = immutable; + } +} + +export class SmartlookGlobalEventProperty { + private key: string; + private value: string; + private immutable: boolean; + + constructor(key: string, value: string, immutable: boolean) { + this.key = key; + this.value = value; + this.immutable = immutable; + } +} + +export class SmartlookGlobalEventPropertyKey { + private key: string; + + constructor(key: string) { + this.key = key; + } +} + +/** + * @name Smartlook + * @description + * Official Smartlook SDK plugin. For more information visit (www.smartlook.com). + * + * @usage + * ```typescript + * import { Smartlook } from '@ionic-native/smartlook/ngx'; + * + * + * constructor(private smartlook: Smartlook) { } + * + * ... + * + * + * this.smartlook.setupAndStartRecording(new SmartlookSetupConfig("key")); + * + * ``` + * @classes + * SmartlookSetupConfig + * SmartlookUserIdentifier + * SmartlookCustomEvent + * SmartlookGlobalEventProperties + * SmartlookGlobalEventProperty + * SmartlookGlobalEventPropertyKey + */ +@Plugin({ + pluginName: 'Smartlook', + plugin: 'https://github.com/smartlook/cordova-smartlook.git', + pluginRef: 'cordova.plugins.SmartlookPlugin', + repo: 'https://github.com/smartlook/cordova-smartlook.git', + platforms: ['Android'] +}) +@Injectable() +export class Smartlook extends IonicNativePlugin { + + /** + * Setup and start Smartlook SDK recording. + * @param config SmartlookSetupConfig object. + * @param config.smartlookAPIKey (required) Smartlook API key (you can obtain it in your dashboard). + * @param config.fps (optional) recorded video framerate (allowed values 2-10 fps). + */ + @Cordova({ sync: true }) + setupAndStartRecording(config: SmartlookSetupConfig): void { + return; + } + + /** + * Setup/initialize Smartlook SDK. This method DOESN'T start the recording (@see start()) + * @param config SmartlookSetupConfig object. + * @param config.smartlookAPIKey (required) Smartlook API key (you can obtain it in your dashboard). + * @param config.fps (optional) recorded video framerate (allowed values 2-10 fps). + */ + @Cordova({ sync: true }) + setup(config: SmartlookSetupConfig): void { + return; + } + + /** + * Start SDK recording. + */ + @Cordova({ sync: true }) + startRecording(): void { + return; + } + + /** + * Stop SDK recording. Recording will start again when you call start(). + */ + @Cordova({ sync: true }) + stopRecording(): void { + return; + } + + /** + * Check if SDK is currently recording. + * @return {Promise} Returns a promise with isRecording boolean. + */ + @Cordova() + isRecording(): Promise { + return; + } + + /** + * When you start sensitive mode SDK records blank videos (single color) but SDK still sends analytic events. + */ + @Cordova({ sync: true }) + startFullscreenSensitiveMode(): void { + return; + } + + /** + * Stop sensitive mode -> SDK records video. + */ + @Cordova({ sync: true }) + stopFullscreenSensitiveMode(): void { + return; + } + + /** + * Check if fullscreen sensitive mode is active. + * @return {Promise} Returns a promise with isFullscreenSensitiveModeActive boolean. + */ + @Cordova() + isFullscreenSensitiveModeActive(): Promise { + return; + } + + /** + * Identify user. + * @param identifier SmartlookUserIdentifier object. + * @param identifier.idenfier (required) id that can be used to identify user and his records. + * You will see this Id in Smartlook dashboard so you can pair records with concrete user. + * @param identifier.sessionProperties (optional) custom session properties object. + */ + @Cordova({ sync: true }) + setUserIdentifier(identifier: SmartlookUserIdentifier): void { + return; + } + + /** + * Track custom event. + * @param event SmartlookCustomEvent object. + * @param event.name (required) string used to identify event. + * @param event.eventProperties (optional) event properties object. + */ + @Cordova({ sync: true }) + trackCustomEvent(event: SmartlookCustomEvent): void { + return; + } + + /** + * Track custom event. + * @param timedEvent SmartlookCustomEvent object. + * @param timedEvent.name (required) string used to identify timed event. + * @param timedEvent.eventProperties (optional) timed event properties object. These properties will + * be merged with properties of tracked event (with lower priority). + */ + @Cordova({ sync: true }) + startTimedCustomEvent(timedEvent: SmartlookCustomEvent): void { + return; + } + + /** + * Set global event properties that will be added to every tracked event. + * @param properties SmartlookGlobalEventProperties object. + * @param properties.globalEventProperties (required) global event properties object. + * @param properties.immutable (required) If set to TRUE these properties have higher priority + * than mutable ones and also they cannot be changed (only removed). + */ + @Cordova({ sync: true }) + setGlobalEventProperties(properties: SmartlookGlobalEventProperties): void { + return; + } + + /** + * Check if SDK is currently recording. + * @param property SmartlookGlobalEventProperty object. + * @param property.key global property key. + * @param property.value global property value. + * @param property.immutable (required) If set to TRUE these properties have higher priority + * than mutable ones and also they cannot be changed (only removed). + */ + @Cordova({ sync: true }) + setGlobalEventProperty(property: SmartlookGlobalEventProperty): void { + return; + } + + /** + * Remove property from global event properties. + * @param property SmartlookGlobalEventPropertyKey object. + * @param property.key global property key. + */ + @Cordova({ sync: true }) + removeGlobalEventProperty(property: SmartlookGlobalEventPropertyKey): void { + return; + } + + /** + * Remove all properties from global event properties. + */ + @Cordova({ sync: true }) + removeAllGlobalEventProperties(): void { + return; + } +}