@holdyapp/sdk 1.5.0 → 1.9.0

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.
Files changed (49) hide show
  1. package/README.md +9 -1
  2. package/dist/changes.d.ts +16 -2
  3. package/dist/changes.d.ts.map +1 -1
  4. package/dist/core.d.ts +1 -0
  5. package/dist/core.d.ts.map +1 -1
  6. package/dist/friction.d.ts +2 -1
  7. package/dist/friction.d.ts.map +1 -1
  8. package/dist/holdy.js +25 -4
  9. package/dist/holdy.js.map +4 -4
  10. package/dist/index.cjs +540 -33
  11. package/dist/index.cjs.map +4 -4
  12. package/dist/index.mjs +540 -33
  13. package/dist/index.mjs.map +4 -4
  14. package/dist/server.cjs +3 -0
  15. package/dist/server.cjs.map +2 -2
  16. package/dist/server.mjs +3 -0
  17. package/dist/server.mjs.map +2 -2
  18. package/dist/skeleton.d.ts +52 -0
  19. package/dist/skeleton.d.ts.map +1 -0
  20. package/dist/theme.d.ts +43 -0
  21. package/dist/theme.d.ts.map +1 -0
  22. package/dist/tip-css.d.ts +9 -0
  23. package/dist/tip-css.d.ts.map +1 -0
  24. package/dist/types.d.ts +6 -0
  25. package/dist/types.d.ts.map +1 -1
  26. package/dist/web-context.d.ts +1 -0
  27. package/dist/web-context.d.ts.map +1 -1
  28. package/dist/web.d.ts +10 -1
  29. package/dist/web.d.ts.map +1 -1
  30. package/dist/web.mjs +540 -33
  31. package/dist/web.mjs.map +4 -4
  32. package/package.json +1 -1
  33. package/src/changes.dom.test.ts +221 -0
  34. package/src/changes.test.ts +38 -0
  35. package/src/changes.ts +299 -26
  36. package/src/core.test.ts +15 -0
  37. package/src/core.ts +3 -0
  38. package/src/friction.dom.test.ts +54 -0
  39. package/src/friction.test.ts +43 -0
  40. package/src/friction.ts +44 -7
  41. package/src/skeleton.test.ts +60 -0
  42. package/src/skeleton.ts +182 -0
  43. package/src/theme.test.ts +118 -0
  44. package/src/theme.ts +120 -0
  45. package/src/tip-css.ts +32 -0
  46. package/src/types.ts +6 -0
  47. package/src/web-context.test.ts +18 -0
  48. package/src/web-context.ts +8 -0
  49. package/src/web.ts +28 -3
package/src/web.ts CHANGED
@@ -14,9 +14,10 @@
14
14
  import { HoldyCore } from './core'
15
15
  import { installAutoCapture, type NavigationKind } from './auto-capture'
16
16
  import { installFrictionCapture, type FrictionCapture, type FrictionCaptureOptions } from './friction'
17
- import { buildWebContext } from './web-context'
17
+ import { installSkeletonCapture, type SkeletonCapture } from './skeleton'
18
+ import { buildWebContext, clearSessionId } from './web-context'
18
19
  import { installProductChanges, type ProductChangesHandle } from './changes'
19
- import type { HoldyOptions, Properties } from './types'
20
+ import type { HoldyOptions, Properties, TrackOverrides } from './types'
20
21
 
21
22
  const ANON_STORAGE_KEY = 'holdy_anon_id'
22
23
 
@@ -40,12 +41,20 @@ export interface HoldyWebOptions extends HoldyOptions {
40
41
  * identificada (`group()` ou `accountKey`) nada é aplicado.
41
42
  */
42
43
  productChanges?: boolean
44
+ /**
45
+ * Mandar o esqueleto da página · default true. Uma vez por (rota, estrutura)
46
+ * por aba: `$page_skeleton` com os elementos interativos (tag, role,
47
+ * data-testid, name, aria-label, tipo, posição relativa). Sem texto livre,
48
+ * sem valor de input, sem pixel.
49
+ */
50
+ skeleton?: boolean
43
51
  }
44
52
 
45
53
  export class HoldyWeb extends HoldyCore {
46
54
  private teardownAutoCapture: (() => void) | null = null
47
55
  private friction: FrictionCapture | null = null
48
56
  private changes: ProductChangesHandle | null = null
57
+ private skeleton: SkeletonCapture | null = null
49
58
 
50
59
  constructor(opts: HoldyWebOptions) {
51
60
  super('sdk_web', opts)
@@ -67,12 +76,20 @@ export class HoldyWeb extends HoldyCore {
67
76
  })
68
77
  }
69
78
 
79
+ if (opts.skeleton !== false) {
80
+ this.skeleton = installSkeletonCapture({
81
+ onSkeleton: (skeleton) => this.track('$page_skeleton', { ...skeleton }),
82
+ })
83
+ }
84
+
70
85
  if (opts.autoCapture !== false) {
71
86
  this.teardownAutoCapture = installAutoCapture({
72
87
  onNavigate: (kind: NavigationKind) => {
73
88
  this.page(undefined, { navigation: kind })
74
- this.friction?.onNavigate(typeof location !== 'undefined' ? location.pathname : '/')
89
+ const path = typeof location !== 'undefined' ? location.pathname : '/'
90
+ this.friction?.onNavigate(path)
75
91
  this.changes?.onNavigate()
92
+ this.skeleton?.onNavigate(path)
76
93
  },
77
94
  })
78
95
  }
@@ -108,6 +125,11 @@ export class HoldyWeb extends HoldyCore {
108
125
  this.changes?.onNavigate()
109
126
  }
110
127
 
128
+ override track(name: string, properties?: Properties, overrides?: TrackOverrides): void {
129
+ super.track(name, properties, overrides)
130
+ if (!name.startsWith('$')) this.changes?.onEvent(name)
131
+ }
132
+
111
133
  reset(): void {
112
134
  this.userId = null
113
135
  this.accountKey = null
@@ -116,6 +138,7 @@ export class HoldyWeb extends HoldyCore {
116
138
  } catch {
117
139
  // storage indisponível (SSR/privacy mode) — ok
118
140
  }
141
+ clearSessionId()
119
142
  this.anonymousId = resolveAnonymousId()
120
143
  this.changes?.onNavigate()
121
144
  }
@@ -128,6 +151,8 @@ export class HoldyWeb extends HoldyCore {
128
151
  this.friction = null
129
152
  this.changes?.teardown()
130
153
  this.changes = null
154
+ this.skeleton?.teardown()
155
+ this.skeleton = null
131
156
  await super.shutdown()
132
157
  }
133
158