@dev.smartpricing/message-composer-layer 1.0.26 → 1.0.27
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.
package/app/api/brands.ts
CHANGED
|
@@ -12,6 +12,8 @@ import type { BrandCascadeData } from '@dev.smartpricing/message-composer-utils/
|
|
|
12
12
|
import { apiClient } from './client'
|
|
13
13
|
|
|
14
14
|
export type BrandWithProperties = BrandFromDb & { properties: BrandProperty[] }
|
|
15
|
+
export type BrandCreateResponse = BrandFromDb & { brand_count: number }
|
|
16
|
+
export type BrandDeleteResponse = { brand_count: number }
|
|
15
17
|
|
|
16
18
|
export const brandsApi = {
|
|
17
19
|
getAll: (options?: { sort_by?: 'created_at' | 'name'; direction?: 'asc' | 'desc' }) => {
|
|
@@ -25,7 +27,7 @@ export const brandsApi = {
|
|
|
25
27
|
getById: (id: string) => apiClient<BrandWithProperties>(`/brands/${id}`),
|
|
26
28
|
|
|
27
29
|
create: (data: BrandCreateBody) =>
|
|
28
|
-
apiClient<
|
|
30
|
+
apiClient<BrandCreateResponse>('/brands', {
|
|
29
31
|
method: 'POST',
|
|
30
32
|
body: data,
|
|
31
33
|
}),
|
|
@@ -36,7 +38,7 @@ export const brandsApi = {
|
|
|
36
38
|
body: data,
|
|
37
39
|
}),
|
|
38
40
|
|
|
39
|
-
delete: (id: string) => apiClient(`/brands/${id}`, { method: 'DELETE' }),
|
|
41
|
+
delete: (id: string) => apiClient<BrandDeleteResponse>(`/brands/${id}`, { method: 'DELETE' }),
|
|
40
42
|
|
|
41
43
|
preview: (data: {
|
|
42
44
|
message: PostEntity<EmailMessage>
|
|
@@ -15,6 +15,7 @@ import BrandStepGeneral from '~/components/Brand/Steps/BrandStepGeneral.vue'
|
|
|
15
15
|
import BrandStepVisual from '~/components/Brand/Steps/BrandStepVisual.vue'
|
|
16
16
|
import BrandStepSocials from '~/components/Brand/Steps/BrandStepSocials.vue'
|
|
17
17
|
import { useBrandQuery, useCreateBrandMutation, useUpdateBrandMutation } from '~/queries'
|
|
18
|
+
import type { BrandCreateResponse } from '~/api/brands'
|
|
18
19
|
|
|
19
20
|
defineOptions({ name: 'BrandDrawer' })
|
|
20
21
|
|
|
@@ -29,6 +30,7 @@ const emit = defineEmits<{
|
|
|
29
30
|
}>()
|
|
30
31
|
|
|
31
32
|
const { t } = useI18n()
|
|
33
|
+
const { trackEvent } = useTracking()
|
|
32
34
|
|
|
33
35
|
const isEditMode = computed(() => !!props.brandId)
|
|
34
36
|
|
|
@@ -199,8 +201,50 @@ async function handleSave() {
|
|
|
199
201
|
let result: BrandFromDb
|
|
200
202
|
if (isEditMode.value && props.brandId) {
|
|
201
203
|
result = await updateBrand({ id: props.brandId, data: payload })
|
|
204
|
+
|
|
205
|
+
const changedFields: string[] = []
|
|
206
|
+
const brand = existingBrand.value
|
|
207
|
+
if (brand) {
|
|
208
|
+
if (payload.name !== brand.name) changedFields.push('name')
|
|
209
|
+
if (payload.logo_media_id !== brand.logo_media_id) changedFields.push('logo')
|
|
210
|
+
if (JSON.stringify(payload.colors) !== JSON.stringify(brand.colors))
|
|
211
|
+
changedFields.push('colors')
|
|
212
|
+
if (
|
|
213
|
+
JSON.stringify(payload.default_email_settings) !==
|
|
214
|
+
JSON.stringify(brand.default_email_settings)
|
|
215
|
+
)
|
|
216
|
+
changedFields.push('email_settings')
|
|
217
|
+
if (
|
|
218
|
+
JSON.stringify(payload.default_button_settings) !==
|
|
219
|
+
JSON.stringify(brand.default_button_settings)
|
|
220
|
+
)
|
|
221
|
+
changedFields.push('button_settings')
|
|
222
|
+
if (JSON.stringify(payload.default_socials) !== JSON.stringify(brand.default_socials))
|
|
223
|
+
changedFields.push('socials')
|
|
224
|
+
if (
|
|
225
|
+
JSON.stringify(payload.property_ids) !==
|
|
226
|
+
JSON.stringify(brand.properties?.map((bp) => bp.property_id))
|
|
227
|
+
)
|
|
228
|
+
changedFields.push('properties')
|
|
229
|
+
}
|
|
230
|
+
|
|
231
|
+
trackEvent('brand_update', {
|
|
232
|
+
brand_id: result.id,
|
|
233
|
+
brand_name: result.name,
|
|
234
|
+
changed_fields: changedFields,
|
|
235
|
+
})
|
|
202
236
|
} else {
|
|
203
|
-
|
|
237
|
+
const createResult = (await createBrand(payload)) as BrandCreateResponse
|
|
238
|
+
result = createResult
|
|
239
|
+
|
|
240
|
+
trackEvent('brand_create', {
|
|
241
|
+
brand_id: result.id,
|
|
242
|
+
brand_name: result.name,
|
|
243
|
+
has_logo: !!payload.logo_media_id,
|
|
244
|
+
})
|
|
245
|
+
trackEvent('brand_count_changed', {
|
|
246
|
+
brand_count: createResult.brand_count,
|
|
247
|
+
})
|
|
204
248
|
}
|
|
205
249
|
|
|
206
250
|
useToast().add({
|
|
@@ -7,6 +7,7 @@ const { brand, brands } = storeToRefs(emailEditorStore)
|
|
|
7
7
|
|
|
8
8
|
const { t } = useI18n()
|
|
9
9
|
const { confirm } = useConfirm()
|
|
10
|
+
const { trackEvent } = useTracking()
|
|
10
11
|
|
|
11
12
|
// Local selection tracks USelectMenu value; reverted on cancel
|
|
12
13
|
const selectedBrand = shallowRef<BrandFromDb | undefined>(brand.value)
|
|
@@ -24,7 +25,13 @@ function handleBrandChange(newBrand: BrandFromDb) {
|
|
|
24
25
|
label: t('dialogs.email_change_brand.cancel'),
|
|
25
26
|
},
|
|
26
27
|
action: () => {
|
|
28
|
+
const previousBrandId = brand.value?.id ?? null
|
|
27
29
|
emailEditorStore.resetToBrand(newBrand)
|
|
30
|
+
trackEvent('brand_select', {
|
|
31
|
+
brand_id: newBrand.id,
|
|
32
|
+
brand_name: newBrand.name,
|
|
33
|
+
previous_brand_id: previousBrandId,
|
|
34
|
+
})
|
|
28
35
|
},
|
|
29
36
|
}).then((confirmed) => {
|
|
30
37
|
if (!confirmed) {
|
|
@@ -13,6 +13,7 @@ const emit = defineEmits<{
|
|
|
13
13
|
|
|
14
14
|
const { t } = useI18n()
|
|
15
15
|
const { confirm } = useConfirm()
|
|
16
|
+
const { trackEvent } = useTracking()
|
|
16
17
|
|
|
17
18
|
const { data: brands, isPending } = useBrandsQuery()
|
|
18
19
|
const { mutateAsync: deleteBrand } = useDeleteBrandMutation()
|
|
@@ -115,7 +116,16 @@ function askDelete(brand: BrandFromDb) {
|
|
|
115
116
|
},
|
|
116
117
|
action: async () => {
|
|
117
118
|
editingBrandId.value = undefined
|
|
118
|
-
await deleteBrand(brand.id)
|
|
119
|
+
const result = await deleteBrand(brand.id)
|
|
120
|
+
|
|
121
|
+
trackEvent('brand_delete', {
|
|
122
|
+
brand_id: brand.id,
|
|
123
|
+
brand_name: brand.name,
|
|
124
|
+
})
|
|
125
|
+
trackEvent('brand_count_changed', {
|
|
126
|
+
brand_count: result.brand_count,
|
|
127
|
+
})
|
|
128
|
+
|
|
119
129
|
emit('deleted', brand)
|
|
120
130
|
useToast().add({
|
|
121
131
|
color: 'success',
|
package/app/types/tracking.ts
CHANGED
|
@@ -58,12 +58,26 @@ export interface EmailTranslationsFiltersProperties extends EmailLanguagePropert
|
|
|
58
58
|
show_only_changes: boolean
|
|
59
59
|
}
|
|
60
60
|
|
|
61
|
+
// ── Brand shared property interfaces ──
|
|
62
|
+
|
|
63
|
+
export interface BrandBaseProperties {
|
|
64
|
+
brand_id: string
|
|
65
|
+
brand_name: string
|
|
66
|
+
}
|
|
67
|
+
|
|
61
68
|
// ── Event map ──
|
|
62
69
|
|
|
63
70
|
export interface TrackingEventMap {
|
|
64
71
|
// === Global ===
|
|
65
72
|
'Page View': { page_name: string }
|
|
66
73
|
|
|
74
|
+
// === Brand ===
|
|
75
|
+
brand_create: BrandBaseProperties & { has_logo: boolean }
|
|
76
|
+
brand_update: BrandBaseProperties & { changed_fields: string[] }
|
|
77
|
+
brand_delete: BrandBaseProperties
|
|
78
|
+
brand_select: BrandBaseProperties & { previous_brand_id: string | null }
|
|
79
|
+
brand_count_changed: { brand_count: number }
|
|
80
|
+
|
|
67
81
|
// === Table_List ===
|
|
68
82
|
change_filters: {
|
|
69
83
|
search_term: string
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dev.smartpricing/message-composer-layer",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.27",
|
|
4
4
|
"private": false,
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./nuxt.config.ts",
|
|
@@ -39,7 +39,7 @@
|
|
|
39
39
|
"vue-router": "^5.0.7",
|
|
40
40
|
"vue3-emoji-picker": "^1.1.8",
|
|
41
41
|
"zod": "^4.4.3",
|
|
42
|
-
"@dev.smartpricing/message-composer-utils": "3.1.
|
|
42
|
+
"@dev.smartpricing/message-composer-utils": "3.1.27"
|
|
43
43
|
},
|
|
44
44
|
"devDependencies": {
|
|
45
45
|
"@nuxt/eslint": "^1.15.2",
|