{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE DuplicateRecordFields #-}
{-# LANGUAGE NamedFieldPuns #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE RecordWildCards #-}
{-# LANGUAGE StrictData #-}
{-# LANGUAGE NoImplicitPrelude #-}
{-# OPTIONS_GHC -fno-warn-unused-imports #-}
{-# OPTIONS_GHC -fno-warn-unused-matches #-}

-- Derived from AWS service descriptions, licensed under Apache 2.0.

-- |
-- Module      : Amazonka.Rum.Types.UserDetails
-- Copyright   : (c) 2013-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
module Amazonka.Rum.Types.UserDetails where

import qualified Amazonka.Core as Core
import qualified Amazonka.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
import qualified Amazonka.Prelude as Prelude

-- | A structure that contains information about the user session that this
-- batch of events was collected from.
--
-- /See:/ 'newUserDetails' smart constructor.
data UserDetails = UserDetails'
  { -- | The session ID that the performance events are from.
    UserDetails -> Maybe Text
sessionId :: Prelude.Maybe Prelude.Text,
    -- | The ID of the user for this user session. This ID is generated by RUM
    -- and does not include any personally identifiable information about the
    -- user.
    UserDetails -> Maybe Text
userId :: Prelude.Maybe Prelude.Text
  }
  deriving (UserDetails -> UserDetails -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: UserDetails -> UserDetails -> Bool
$c/= :: UserDetails -> UserDetails -> Bool
== :: UserDetails -> UserDetails -> Bool
$c== :: UserDetails -> UserDetails -> Bool
Prelude.Eq, ReadPrec [UserDetails]
ReadPrec UserDetails
Int -> ReadS UserDetails
ReadS [UserDetails]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [UserDetails]
$creadListPrec :: ReadPrec [UserDetails]
readPrec :: ReadPrec UserDetails
$creadPrec :: ReadPrec UserDetails
readList :: ReadS [UserDetails]
$creadList :: ReadS [UserDetails]
readsPrec :: Int -> ReadS UserDetails
$creadsPrec :: Int -> ReadS UserDetails
Prelude.Read, Int -> UserDetails -> ShowS
[UserDetails] -> ShowS
UserDetails -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [UserDetails] -> ShowS
$cshowList :: [UserDetails] -> ShowS
show :: UserDetails -> String
$cshow :: UserDetails -> String
showsPrec :: Int -> UserDetails -> ShowS
$cshowsPrec :: Int -> UserDetails -> ShowS
Prelude.Show, forall x. Rep UserDetails x -> UserDetails
forall x. UserDetails -> Rep UserDetails x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep UserDetails x -> UserDetails
$cfrom :: forall x. UserDetails -> Rep UserDetails x
Prelude.Generic)

-- |
-- Create a value of 'UserDetails' with all optional fields omitted.
--
-- Use <https://hackage.haskell.org/package/generic-lens generic-lens> or <https://hackage.haskell.org/package/optics optics> to modify other optional fields.
--
-- The following record fields are available, with the corresponding lenses provided
-- for backwards compatibility:
--
-- 'sessionId', 'userDetails_sessionId' - The session ID that the performance events are from.
--
-- 'userId', 'userDetails_userId' - The ID of the user for this user session. This ID is generated by RUM
-- and does not include any personally identifiable information about the
-- user.
newUserDetails ::
  UserDetails
newUserDetails :: UserDetails
newUserDetails =
  UserDetails'
    { $sel:sessionId:UserDetails' :: Maybe Text
sessionId = forall a. Maybe a
Prelude.Nothing,
      $sel:userId:UserDetails' :: Maybe Text
userId = forall a. Maybe a
Prelude.Nothing
    }

-- | The session ID that the performance events are from.
userDetails_sessionId :: Lens.Lens' UserDetails (Prelude.Maybe Prelude.Text)
userDetails_sessionId :: Lens' UserDetails (Maybe Text)
userDetails_sessionId = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UserDetails' {Maybe Text
sessionId :: Maybe Text
$sel:sessionId:UserDetails' :: UserDetails -> Maybe Text
sessionId} -> Maybe Text
sessionId) (\s :: UserDetails
s@UserDetails' {} Maybe Text
a -> UserDetails
s {$sel:sessionId:UserDetails' :: Maybe Text
sessionId = Maybe Text
a} :: UserDetails)

-- | The ID of the user for this user session. This ID is generated by RUM
-- and does not include any personally identifiable information about the
-- user.
userDetails_userId :: Lens.Lens' UserDetails (Prelude.Maybe Prelude.Text)
userDetails_userId :: Lens' UserDetails (Maybe Text)
userDetails_userId = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UserDetails' {Maybe Text
userId :: Maybe Text
$sel:userId:UserDetails' :: UserDetails -> Maybe Text
userId} -> Maybe Text
userId) (\s :: UserDetails
s@UserDetails' {} Maybe Text
a -> UserDetails
s {$sel:userId:UserDetails' :: Maybe Text
userId = Maybe Text
a} :: UserDetails)

instance Prelude.Hashable UserDetails where
  hashWithSalt :: Int -> UserDetails -> Int
hashWithSalt Int
_salt UserDetails' {Maybe Text
userId :: Maybe Text
sessionId :: Maybe Text
$sel:userId:UserDetails' :: UserDetails -> Maybe Text
$sel:sessionId:UserDetails' :: UserDetails -> Maybe Text
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
sessionId
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
userId

instance Prelude.NFData UserDetails where
  rnf :: UserDetails -> ()
rnf UserDetails' {Maybe Text
userId :: Maybe Text
sessionId :: Maybe Text
$sel:userId:UserDetails' :: UserDetails -> Maybe Text
$sel:sessionId:UserDetails' :: UserDetails -> Maybe Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
sessionId
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
userId

instance Data.ToJSON UserDetails where
  toJSON :: UserDetails -> Value
toJSON UserDetails' {Maybe Text
userId :: Maybe Text
sessionId :: Maybe Text
$sel:userId:UserDetails' :: UserDetails -> Maybe Text
$sel:sessionId:UserDetails' :: UserDetails -> Maybe Text
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Key
"sessionId" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..=) forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Text
sessionId,
            (Key
"userId" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..=) forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Text
userId
          ]
      )