private updateUserVars()

in src/shippers/fullstory/src/fullstory_shipper.ts [262:296]


  private updateUserVars({
    userId,
    isElasticCloudUser,
    cloudIsElasticStaffOwned,
    cloudTrialEndDate,
  }: FullStoryUserVars) {
    // Call it only when the userId changes
    if (userId && userId !== this.lastUserId) {
      this.initContext.logger.debug(`Calling FS.identify with userId ${userId}`);
      // We need to call the API for every new userId (restarting the session).
      this.fullStoryApi('setIdentity', { uid: userId });
      this.lastUserId = userId;

      // When delayed startup is enabled, we need to manually start capturing after identifying the user.
      if (this.delayedStartup && this.optedIn) {
        this.fullStoryApi('start');
      }
    }

    // User-level context
    if (typeof isElasticCloudUser === 'boolean' || typeof cloudIsElasticStaffOwned === 'boolean' || cloudTrialEndDate) {
      const userVars = {
        isElasticCloudUser,
        cloudIsElasticStaffOwned,
        cloudTrialEndDate,
      };
      this.initContext.logger.debug(() => `Calling FS.setProperties/user with ${JSON.stringify(userVars)}`);
      const { properties, schema } = getPropertiesAndSchema(userVars);
      this.fullStoryApi('setProperties', {
        type: 'user',
        properties,
        schema,
      });
    }
  }