homeflowjs 0.13.62 → 0.13.63

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,4 +1,4 @@
1
- /* eslint-disable import/no-cycle */
1
+ /* eslint-disable import/no-cycle, no-undef */
2
2
  import PropertiesActionTypes from './properties.types';
3
3
  import { buildQueryString } from '../search/property-search/property-search';
4
4
  import { setSearch } from './search.actions';
@@ -115,6 +115,33 @@ export const setPagination = (payload) => ({
115
115
  payload,
116
116
  });
117
117
 
118
+ export const postPropertyView = (payload) => () => {
119
+ const domain = location.hostname;
120
+ fetch('/property_views',
121
+ {
122
+ method: 'POST',
123
+ mode: 'no-cors',
124
+ headers: { 'Content-Type': 'application/json' },
125
+ body: JSON.stringify({ property_id: payload, domain }),
126
+ });
127
+ };
128
+
129
+ export const postBulkPropertyExposureCreation = (payload) => () => {
130
+ const domain = location.hostname;
131
+ const exposuresPublicUrl = Homeflow.get('exposures_public_url');
132
+
133
+ if (!exposuresPublicUrl) return;
134
+
135
+ const { propertyIds, eventType } = payload;
136
+ fetch(`${exposuresPublicUrl}/create_many`,
137
+ {
138
+ method: 'POST',
139
+ mode: 'no-cors',
140
+ headers: { 'Content-Type': 'application/json' },
141
+ body: JSON.stringify({ property_ids: propertyIds, domain, event_type: eventType }),
142
+ });
143
+ };
144
+
118
145
  export const loadNext = () => (dispatch, getState) => {
119
146
  dispatch(setLoading({ properties: true }));
120
147
  // set page on search to page + 1
@@ -126,6 +153,13 @@ export const loadNext = () => (dispatch, getState) => {
126
153
  .then((response) => response.json())
127
154
  .then((json) => {
128
155
  if (json.properties) {
156
+ // post new property ids
157
+ dispatch(
158
+ postBulkPropertyExposureCreation({
159
+ eventType: 'SearchResult',
160
+ propertyIds: json.properties.map((property) => property.property_id),
161
+ }),
162
+ );
129
163
  // add the page number to each new property for dividing properties into per-page divs
130
164
  const addedProperties = json.properties.map((property) => (
131
165
  { ...property, resultPage: newSearch.page }
@@ -12,7 +12,12 @@ import bookingCalendar from '../booking-calendar/booking-calendar';
12
12
  import { setThemePreferences, setThemeSettings, setAuthenticityToken } from '../actions/app.actions';
13
13
  import { fetchUser } from '../actions/user.actions';
14
14
  import {
15
- setProperties, setPagination, setProperty, setPropertyLinksAsync,
15
+ setProperties,
16
+ setPagination,
17
+ setProperty,
18
+ setPropertyLinksAsync,
19
+ postPropertyView,
20
+ postBulkPropertyExposureCreation,
16
21
  } from '../actions/properties.actions';
17
22
  import {
18
23
  setSearch, setInitialSearch, setSearchField, setPlace,
@@ -98,9 +103,21 @@ const hfInitialize = () => {
98
103
 
99
104
  const pageRoute = Homeflow.get('page_route');
100
105
 
101
- // if we're on the property show page, set next and previous links
106
+ // if we're on the property show page: 1. set next and previous links, 2. post property view
102
107
  if (pageRoute === 'properties#show') {
108
+ const propertyId = Homeflow.get('property')?.property_id;
103
109
  store.dispatch(setPropertyLinksAsync());
110
+ store.dispatch(postPropertyView(propertyId));
111
+ }
112
+
113
+ if (pageRoute === 'properties#index') {
114
+ const propertyIds = Homeflow.get('properties')?.map((property) => property.property_id);
115
+ store.dispatch(
116
+ postBulkPropertyExposureCreation({
117
+ eventType: 'SearchResult',
118
+ propertyIds,
119
+ }),
120
+ );
104
121
  }
105
122
 
106
123
  // setting articles, pagination and topics on articles index page
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "homeflowjs",
3
- "version": "0.13.62",
3
+ "version": "0.13.63",
4
4
  "sideEffects": [
5
5
  "modal/**/*",
6
6
  "user/default-profile/**/*",