src/App/Entity/UsageEvent.php line 31

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use App\Utility\ReflectionHelper;
  4. use DateTime;
  5. use Doctrine\ORM\Mapping as ORM;
  6. use Exception;
  7. /**
  8. * Usage Event: track what users do in order to decide how the platform presentation or behaviour should change for them.
  9. *
  10. * While Business-, Application-, and Webrequest-Events are tracked for statistical use in the Data Warehouse, Usage
  11. * Events are collected to keep track of how a given user uses our platform, because the behaviour of a user can change
  12. * the behaviour of our software. Example: if a user has seen the recurrent job editor at least once, then stop showing
  13. * them an info box related to recurrent jobs on the Dashboard.
  14. *
  15. * The big advantage of this event format is that it is very lean in terms of storage space - for every combination
  16. * of user<->eventType, only one database row is needed; no matter how often event X is tracked for user Y,
  17. * this one row of information is sufficient to answer the questions "how often did the event occur?" and
  18. * "when was the last time the event occured?".
  19. *
  20. * @see ActivityMonitoringEvent for an extended explanation and a comparison with Activity Monitoring Events
  21. *
  22. * @ORM\Entity()
  23. *
  24. * @ORM\Table(
  25. * name="usage_events"
  26. * )
  27. */
  28. class UsageEvent
  29. {
  30. public const EVENT_TYPE_USER_HAS_SEEN_JOB_EDITOR = 0;
  31. public const EVENT_TYPE_USER_HAS_SENT_MULTIPLE_MESSAGES = 1;
  32. public const EVENT_TYPE_USER_HAS_COMPLETED_BASE_PROFILE = 2;
  33. public const EVENT_TYPE_USER_HAS_COMPLETED_EXTENDED_PROFILE = 3;
  34. public const EVENT_TYPE_USER_HAS_COMPLETED_SUBSCRIPTION = 4;
  35. public const EVENT_TYPE_USER_HAS_SEEN_SUBSCRIPTION_PAGE = 5;
  36. public const EVENT_TYPE_USER_RATES_POSITIVE = 6;
  37. public const EVENT_TYPE_USER_HAS_RATED = 7;
  38. public const EVENT_TYPE_USER_HAS_CLICKED_RATING_LINK = 8;
  39. public const EVENT_TYPE_USER_RECEIVED_FIVE_MESSAGES_EXCLUDING_JOBRADAR = 9;
  40. public const EVENT_TYPE_JOBSEEKER_HAS_USED_SEARCH_FOR_RECURRENT_JOBS = 10;
  41. public const EVENT_TYPE_JOBSEEKER_HAS_CLICKED_DETAIL_VIEW_OF_RECURRENT_JOB = 11;
  42. public const EVENT_TYPE_JOBSEEKER_HAS_CLICKED_PHONE_BUTTON = 12;
  43. public const EVENT_TYPE_USER_REACTED_TO_JOBRADAR = 13;
  44. public const EVENT_TYPE_JOBSEEKER_SENT_MESSAGE = 14;
  45. public const EVENT_TYPE_JOBOFFERER_SENT_MESSAGE = 15;
  46. public const EVENT_TYPE_JOBOFFERER_CLICKED_SHARE_RECURRENT_JOB_ICON = 16;
  47. public const EVENT_TYPE_USER_HAS_ADDED_PROFILE_PICTURE = 17;
  48. public const EVENT_TYPE_USER_SENT_CONVERSATION_MESSAGE = 18;
  49. public const EVENT_TYPE_USER_HAS_BEEN_INFORMED_ABOUT_PAYMENT_ESCALATED = 19;
  50. public const EVENT_TYPE_USER_HAS_DELETED_PROFILE_PICTURE = 20;
  51. public const EVENT_TYPE_NEW_USER_HAS_CONFIRMED_ACCOUNT = 21;
  52. public const EVENT_TYPE_JOBOFFERER_HAS_USED_SEARCH_FOR_WANTED_JOBS = 22;
  53. public const EVENT_TYPE_JOBOFFERER_HAS_CLICKED_DETAIL_VIEW_OF_WANTED_JOB = 23;
  54. public const EVENT_TYPE_JOBOFFERER_HAS_CLICKED_PHONE_BUTTON = 24;
  55. public const EVENT_TYPE_JOBSEEKER_CLICKED_SHARE_WANTED_JOB_ICON = 25;
  56. public const EVENT_TYPE_GG_USER_HAS_LOGGED_IN = 26;
  57. public const EVENT_TYPE_USER_HAS_RECEIVED_CANCELLATION_EMAIL = 27;
  58. public const EVENT_TYPE_USER_HAS_CLICKED_JOBLIFT_JOBOFFER = 28;
  59. public const EVENT_TYPE_WISAG_WAS_INFORMED_ABOUT_PREMIUM_MESSAGES = 29;
  60. public const EVENT_TYPE_USER_HAS_GOT_SELFDESCRIPTION_PROPOSAL = 30;
  61. public const EVENT_TYPE_USER_HAS_CHANGED_SELFDESCRIPTION_PROPOSAL = 31;
  62. public const EVENT_TYPE_NEW_GERMAN_PERSONNEL_BILLED_JOB = 32;
  63. public const EVENT_TYPE_EXTERNAL_PARTNER_RECURRENT_JOB_HAS_BEEN_PROLONGED = 33;
  64. public const EVENT_TYPE_USER_HAS_BEEN_INFORMED_ABOUT_RECURRENT_JOBS_BELONGING_TO_JOBOO_GMBH = 34;
  65. public const EVENT_TYPE_USER_HAS_REQUESTED_MYDAYS_VOUCHER = 35;
  66. public const EVENT_TYPE_USER_HAS_VISITED_EXTERNAL_JOBOFFER = 36;
  67. public const EVENT_TYPE_JOBSEEKER_HAS_CLICKED_PHONE_BUTTON_IN_RECURRENT_JOBS_SEARCH = 37;
  68. public const EVENT_TYPE_JOBSEEKER_HAS_CLICKED_PHONE_BUTTON_IN_RECURRENT_JOBS_SEARCH_ALL_JOBS = 38;
  69. public const EVENT_TYPE_JOBOFFERER_GOT_75_PERCENT_DISCOUNT_CODE = 39;
  70. public const EVENT_TYPE_JOBOFFERER_GOT_FREE_MONTH_CODE = 40;
  71. public const EVENT_TYPE_USER_SAW_MEMBERSHIP_MODAL = 41;
  72. public const EVENT_TYPE_USER_HAS_BEEN_SENT_GOOGLE_RATING_REQUEST = 42;
  73. public const EVENT_TYPE_USER_HAS_BEEN_INFORMED_ABOUT_SCHEDULING_STATUS_CHANGE = 43;
  74. /**
  75. * @ORM\Id
  76. *
  77. * @ORM\ManyToOne(targetEntity="App\Entity\User", cascade={"persist"})
  78. *
  79. * @ORM\JoinColumn(name="users_id", referencedColumnName="id", nullable=false, onDelete="CASCADE")
  80. */
  81. private User $user;
  82. public function setUser(User $user): void
  83. {
  84. $this->user = $user;
  85. }
  86. public function getUser(): User
  87. {
  88. return $this->user;
  89. }
  90. /**
  91. * @ORM\Id
  92. *
  93. * @ORM\Column(name="event_type", type="smallint", nullable=false)
  94. */
  95. private int $eventType;
  96. /**
  97. * @throws Exception
  98. */
  99. public function setEventType(int $eventType): void
  100. {
  101. if (!ReflectionHelper::hasConstWithValue(self::class, 'EVENT_TYPE_', $eventType)) {
  102. throw new Exception('Value ' . $eventType . ' not allowed for eventType.');
  103. }
  104. $this->eventType = $eventType;
  105. }
  106. public function getEventType(): int
  107. {
  108. return $this->eventType;
  109. }
  110. /**
  111. * @ORM\Column(name="last_occurred_at", type="datetime", nullable=false)
  112. */
  113. private DateTime $lastOccurredAt;
  114. public function getLastOccurredAt(): DateTime
  115. {
  116. return $this->lastOccurredAt;
  117. }
  118. public function setLastOccurredAt(DateTime $lastOccurredAt)
  119. {
  120. $this->lastOccurredAt = $lastOccurredAt;
  121. }
  122. /**
  123. * @ORM\Column(name="number_of_occurrences", type="integer", nullable=false)
  124. */
  125. private int $numberOfOccurrences;
  126. public function setNumberOfOccurrences(int $numberOfOccurrences): void
  127. {
  128. $this->numberOfOccurrences = $numberOfOccurrences;
  129. }
  130. public function getNumberOfOccurrences(): int
  131. {
  132. return $this->numberOfOccurrences;
  133. }
  134. }