UNPKG

@c8y/ngx-components

Version:

Angular modules for Cumulocity IoT applications

110 lines 5.15 kB
import { BehaviorSubject } from 'rxjs'; import { UserPreferencesService } from '../common/user-preferences/user-preferences.service'; import { GainsightService } from './gainsight.service'; import * as i0 from "@angular/core"; export declare class UserEngagementsService { private document; private userPreferencesService; private gainsightService; readonly USER_PREFERENCES_GAINSIGHT_ENGAGEMENTS_KEY = "gainsightBotEnabled"; readonly userEngagementsEnabled$: BehaviorSubject<boolean>; readonly HIDE_GAINSIGHT_BOT_STYLE_ID = "hide-gs-bot"; private readonly ENGAGEMENTS; constructor(document: Document, userPreferencesService: UserPreferencesService, gainsightService: GainsightService); /** * Handles user engagement settings based on various conditions. * * - Waits for the Gainsight tracking to be loaded. * - Retrieves the engagement settings. * - Updates the engagement settings based on the combined observations. * - Finally, toggles the Gainsight engagements based on the latest `userEngagementsEnabled$` value. */ handleUserEngagements(): void; /** * Updates the user's preference for Gainsight Engagements. * @param {boolean} isEnabled - The new value for the user's engagement preference. */ updateUserEngagementPreference(isEnabled: boolean): void; /** * Toggles the visibility of Gainsight Engagements based on the provided flag. * * @param isEnabled - A flag indicating whether Gainsight Engagements should be visible. */ toggleGainsightEngagements(isEnabled: boolean): void; /** * Constructs an observable that emits an array of boolean values representing * the current engagement settings. The observable combines the latest values from: * * 1. User's preferences for Gainsight engagements. * 2. A flag indicating if PII data should be sent. * 3. A flag indicating if the platform uses custom branding. * * @returns An observable emitting an array of boolean values. */ private getEngagementSettingsObservable; /** * Updates user engagement settings based on provided preferences and settings. * * Based on the received values, the method decides to: * 1. Disable user engagements if PII data should not be shared or certain branding/settings conditions are met. * 2. Update the user engagement preference if the user engagement bot setting is undefined. * * @param userEngagementBotSetting - The user's setting for the engagement bot. * @param shouldSendPiiData - Indicates whether PII data should be shared. * @param hasCustomBranding - Indicates if custom branding is applied. */ private updateUserEngagementSettings; /** * Determines whether user engagements should be disabled due to PII data settings. * * If the `shouldSendPiiData` parameter is false, this indicates that the user engagements * should be disabled to prevent sharing personally identifiable information. * * @param {boolean} shouldSendPiiData - Indicates whether PII data is allowed to be sent. * @returns {boolean} Returns true if user engagements should be disabled, otherwise false. */ private shouldDisableUserEngagementsDueToPIIData; /** * Determines if the user engagement bot setting is undefined. * * @param {boolean | undefined} userEngagementBotSetting - The setting value to check. * @returns {boolean} Returns `true` if the setting is undefined; otherwise, `false`. * * This scenario occurs when a user is new and hasn't modified the bot settings in the user details UI yet. */ private isUserEngagementBotSettingUndefined; /** * Enables the visibility of Gainsight engagements. * * This method removes the CSS styles that hide the Gainsight engagements * and updates the relevant user attribute to mark the engagements as visible. */ private showGainsightEngagements; /** * Hides the Gainsight engagements. * * This method applies CSS styles to hide the Gainsight engagements * and updates the relevant user attribute to mark the engagements as hidden. */ private hideGainsightEngagements; /** * Removes the specified CSS style from the document. * * @param {string} styleId - The ID of the CSS style element to remove. */ private removeHidingStyle; /** * Adds a new CSS style to the document. * * If the style with the specified ID already exists, the method will do nothing. * Otherwise, it creates a new `<style>` element with the given ID and content, * then appends it to the document head. * * @param {string} styleId - The ID to assign to the new style element. * @param {string} textContent - The CSS rules to be included in the style. */ private addHidingStyle; static ɵfac: i0.ɵɵFactoryDeclaration<UserEngagementsService, never>; static ɵprov: i0.ɵɵInjectableDeclaration<UserEngagementsService>; } //# sourceMappingURL=user-engagements.service.d.ts.map