@dev.smartpricing/message-composer-layer 5.0.3 → 5.0.4

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/README.md CHANGED
@@ -53,7 +53,7 @@ The layer is published on the private Smartpricing npm registry together with `@
53
53
 
54
54
  See "Organization and WABA" below for what `organization_id` and `metaWabaId` do.
55
55
 
56
- 4. Tracking is opt-in: set `composer.tracking: true` in the host's `app.config.ts` to have the layer post its events to `POST /tracking/event`.
56
+ 4. Tracking is opt-in: set `composer.tracking: true` in the host's `app.config.ts` to have the layer post its events to `POST /tracking/event`. Page views are the host's to track: the layer sends none.
57
57
 
58
58
  The layer's pages are mounted at root (`/`, `/template/...`, `/preview/...`, `/brands`, `/images`). Remap them with `pages:extend` if the host already owns those routes. The Automation pages (`/automations/...`) are mounted too and answer 404 until the Host turns them on: see "Automation pages" below.
59
59
 
@@ -1,9 +1,11 @@
1
1
  import { apiClient } from './client'
2
2
 
3
3
  export const trackingApi = {
4
+ /** No error toast: tracking is not something the user did. */
4
5
  event: (eventName: string, organizationId: string, properties?: Record<string, unknown>) =>
5
6
  apiClient<{ success: boolean }>('/tracking/event', {
6
7
  method: 'POST',
7
8
  body: { eventName, properties, organization_id: organizationId },
8
- }),
9
+ _skipErrorToast: true,
10
+ } as Record<string, unknown>),
9
11
  }
@@ -28,8 +28,16 @@ export function useTracking(
28
28
  const payload = { ...getDefaultProperties(), ...properties }
29
29
  try {
30
30
  // The tracking route needs an Organization: an event fired while it is
31
- // still being resolved (the first page view) waits instead of being lost.
32
- const organization = await until(organizationId).toBeTruthy()
31
+ // still being resolved waits instead of being lost. Without one (the
32
+ // user reaches none, or the lookup failed) it is dropped, not left waiting.
33
+ await until(
34
+ () =>
35
+ !!organizationId.value ||
36
+ effectiveOrganization.status === 'none' ||
37
+ effectiveOrganization.status === 'failed',
38
+ ).toBe(true)
39
+ const organization = organizationId.value
40
+ if (!organization) return
33
41
  const { trackingApi } = await import('@/api/tracking')
34
42
  await trackingApi.event(eventName, organization, payload)
35
43
  } catch {
@@ -39,9 +47,5 @@ export function useTracking(
39
47
  }
40
48
  }
41
49
 
42
- function trackPageView(pageName: string): void {
43
- trackEvent('Page View', { page_name: pageName })
44
- }
45
-
46
- return { trackEvent, trackPageView }
50
+ return { trackEvent }
47
51
  }
@@ -73,9 +73,6 @@ export interface BrandBaseProperties {
73
73
  // ── Event map ──
74
74
 
75
75
  export interface TrackingEventMap {
76
- // === Global ===
77
- 'Page View': { page_name: string }
78
-
79
76
  // === Automation_list ===
80
77
  'automation_list.delete': { automation_name: string; automation_id: string }
81
78
  'automation_list.duplicate': { automation_name: string; automation_id: string }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dev.smartpricing/message-composer-layer",
3
- "version": "5.0.3",
3
+ "version": "5.0.4",
4
4
  "private": false,
5
5
  "type": "module",
6
6
  "main": "./nuxt.config.ts",
@@ -35,7 +35,7 @@
35
35
  "vue-router": "^5.0.7",
36
36
  "vue3-emoji-picker": "^1.1.8",
37
37
  "zod": "^4.4.3",
38
- "@dev.smartpricing/message-composer-utils": "5.0.3"
38
+ "@dev.smartpricing/message-composer-utils": "5.0.4"
39
39
  },
40
40
  "devDependencies": {
41
41
  "@dev.smartpricing/platform-layer": "^0.0.23",
@@ -1,12 +0,0 @@
1
- export default defineNuxtPlugin(() => {
2
- const appConfig = useAppConfig()
3
- if (!appConfig.composer?.tracking) return
4
-
5
- const { trackPageView } = useTracking()
6
- const router = useRouter()
7
-
8
- router.afterEach((to) => {
9
- const pageName = (to.name as string) || to.path
10
- trackPageView(pageName)
11
- })
12
- })