File

core/product-experience/gainsight.service.ts

Description

A service to manage the Gainsight integration. It allows to load the tag and

Index

Properties
Methods
Accessors

Constructor

constructor(appState: AppStateService, options: OptionsService, cookieBannerService: CookieBannerService, userPreferencesService: UserPreferencesService, translateService: TranslateService)
Parameters :
Name Type Optional
appState AppStateService No
options OptionsService No
cookieBannerService CookieBannerService No
userPreferencesService UserPreferencesService No
translateService TranslateService No

Methods

Async canEditProductExperienceSettings
canEditProductExperienceSettings()

Determines if the current user has the capability to modify Gainsight PX settings.

This method checks multiple conditions:

  1. Whether tracking has been disabled globally via application options.
  2. Whether Gainsight is disabled at the tenant level through custom properties.
  3. Whether a Gainsight key is available, either currently loaded or fetched asynchronously.
  4. Whether cookie preferences are defined and available for the user.
Returns : Promise<boolean>

Promise that resolves to a boolean. True indicates the user can edit product experience settings, and false otherwise.

Async getGainsightKey
getGainsightKey()
Returns : unknown
Async hashGroupName
hashGroupName(groupName: string)
Parameters :
Name Type Optional
groupName string No
Returns : unknown
identify
identify(sendPiiData: boolean, identifyData: IdentifyData)

Identifies the user/account at Gainsight.

Parameters :
Name Type Optional Description
sendPiiData boolean No

Flag for sending personally identifiable information.

identifyData IdentifyData No

Object containing identification data.

Returns : void
isCustomBranding
isCustomBranding()

Determines if custom branding is enabled based on the presence of a brand logo.

Returns : boolean
  • True if custom branding is applied, false otherwise.
isGainsightDisabledAtTenantCustomProperties
isGainsightDisabledAtTenantCustomProperties(customProperties: ICustomProperties)

Checks if Gainsight is disabled based on tenant custom properties.

Parameters :
Name Type Optional Description
customProperties ICustomProperties No
  • The custom properties of the tenant.
Returns : boolean
  • True if Gainsight is disabled, false otherwise.
Async isGainsightPreferenceDisabledInUserPreferences
isGainsightPreferenceDisabledInUserPreferences(preferenceName: string)

Checks if the specified Gainsight preference is disabled in user preferences.

Parameters :
Name Type Optional Description
preferenceName string No
  • Name of the Gainsight preference.
Returns : Promise<boolean>

A promise that resolves to true if the preference is disabled, otherwise false.

isTrackingDisabled
isTrackingDisabled()

Determines if tracking is disabled based on the application options.

Returns : boolean

true if tracking is disabled, otherwise false.

Async loadTag
loadTag(currentTenant: ICurrentTenant, sendPiiData: boolean)

Load the script tag and calls the identify function to start the tracking.

Parameters :
Name Type Optional Description
currentTenant ICurrentTenant No

The current tenant.

sendPiiData boolean No

Flag for sending personally identifiable information (PII) during identification in Gainsight.

Returns : any
setFunctionalCookie
setFunctionalCookie(value: boolean)

Sets the state of the functional cookie.

Parameters :
Name Type Optional Description
value boolean No
  • A boolean value to indicate whether the functional cookie should be enabled (true) or disabled (false).
Returns : void
setGlobalContext
setGlobalContext()

Sets the global context for Gainsight with the current application name. The global context can be utilized by Gainsight for various purposes, such as segmenting users.

Returns : void
Async shouldSendPiiData
shouldSendPiiData()

Determines whether personally identifiable information (PII) should be sent while loading a tag. The decision to activate Gainsight and send PII relies on whether the cookiePreferences option is defined in the application settings, if the functional cookie is enabled, and if the user grants permission.

Returns : Promise<boolean>
transformUserRolesToStr
transformUserRolesToStr(userRoles?: IIdentified[])
Parameters :
Name Type Optional
userRoles IIdentified[] Yes
Returns : string
translateToEnglish
translateToEnglish(textToTranslate: string)
Parameters :
Name Type Optional
textToTranslate string No
Returns : string
triggerEvent
triggerEvent(eventName: string, props?: PxEventData)

Triggers an event to be recorded by Gainsight PX. This method calls the Gainsight PX's tracking mechanism to log a specific event along with its associated properties.

Parameters :
Name Type Optional Description
eventName string No
  • Name of the event to be triggered.
props PxEventData Yes
  • Optional properties associated with the event.
Returns : void
updateUserAttribute
updateUserAttribute(name: string, value: string | Date | number | boolean)

Updates a specific user attribute in the Gainsight global scope. This method interfaces with the Gainsight global object to set a user's specific attribute with a provided value.

Parameters :
Name Type Optional Description
name string No
  • Name of the user attribute to be updated.
value string | Date | number | boolean No
  • Value to set for the specified user attribute.
Returns : void

Properties

Readonly HIDE_GAINSIGHT_BOT_STYLE_ID
Type : string
Default value : 'hide-gs-bot'
tagFunction$
Default value : new BehaviorSubject(null)

A subject that emits the tag function as soon as a new tag is set.

trackingLoaded$
Type : Subject<boolean>
Default value : new Subject()
Readonly USER_PREFERENCES_GAINSIGHT_ENGAGEMENTS_KEY
Type : string
Default value : 'gainsightBotEnabled'

The name of the key remained unchanged, but applies to all engagements.

Readonly USER_PREFERENCES_GAINSIGHT_KEY
Type : string
Default value : 'gainsightEnabled'

Gainsight is activated only when the cookie banner is present. If functional cookies are enabled, both personally identifiable information (PII) and required data are sent. Otherwise, only the required data is transmitted during the identity step execution.

Accessors

tagFunction
gettagFunction()

Returns the tag global function which can be used to identify user or add special events.

results matching ""

    No results matching ""