@obsrviq/tracker 0.4.0 → 0.4.1

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@obsrviq/tracker",
3
- "version": "0.4.0",
3
+ "version": "0.4.1",
4
4
  "license": "MIT",
5
5
  "publishConfig": {
6
6
  "access": "public"
package/src/global.ts CHANGED
@@ -28,27 +28,34 @@ function bool(v: string | null | undefined, fallback: boolean): boolean {
28
28
  return v === 'true' || v === '1';
29
29
  }
30
30
 
31
+ /** Read `data-obsrviq-<name>`, falling back to the pre-rebrand `data-lumera-<name>`
32
+ * so old embeds (which still use the Lumera attribute names + filename) keep
33
+ * initialising. Mirrors the ingest accepting the legacy x-lumera-key header. */
34
+ function attr(el: HTMLScriptElement, name: string): string | null {
35
+ return el.getAttribute(`data-obsrviq-${name}`) ?? el.getAttribute(`data-lumera-${name}`);
36
+ }
37
+
31
38
  if (current) {
32
- const key = current.getAttribute('data-obsrviq-key');
39
+ const key = attr(current, 'key');
33
40
  if (key) {
34
41
  const cfg: ObsrviqInitConfig = {
35
42
  siteKey: key,
36
- endpoint: current.getAttribute('data-obsrviq-endpoint') || undefined,
37
- maskAllInputs: bool(current.getAttribute('data-obsrviq-mask-inputs'), true),
38
- captureNetworkBodies: bool(current.getAttribute('data-obsrviq-capture-bodies'), false),
39
- requireConsent: bool(current.getAttribute('data-obsrviq-require-consent'), false),
40
- askPermission: bool(current.getAttribute('data-obsrviq-ask-permission'), false),
41
- showRecording: bool(current.getAttribute('data-obsrviq-show-recording'), false),
42
- recordCanvas: bool(current.getAttribute('data-obsrviq-record-canvas'), false),
43
- autoStart: bool(current.getAttribute('data-obsrviq-auto-start'), true),
43
+ endpoint: attr(current, 'endpoint') || undefined,
44
+ maskAllInputs: bool(attr(current, 'mask-inputs'), true),
45
+ captureNetworkBodies: bool(attr(current, 'capture-bodies'), false),
46
+ requireConsent: bool(attr(current, 'require-consent'), false),
47
+ askPermission: bool(attr(current, 'ask-permission'), false),
48
+ showRecording: bool(attr(current, 'show-recording'), false),
49
+ recordCanvas: bool(attr(current, 'record-canvas'), false),
50
+ autoStart: bool(attr(current, 'auto-start'), true),
44
51
  };
45
- const rate = current.getAttribute('data-obsrviq-sample-rate');
52
+ const rate = attr(current, 'sample-rate');
46
53
  if (rate) cfg.sampleRate = Number(rate);
47
54
  // Identity is usually set later via Obsrviq.identify() (post-login), but can be
48
55
  // seeded here when known at load time.
49
- const userId = current.getAttribute('data-obsrviq-user-id');
56
+ const userId = attr(current, 'user-id');
50
57
  if (userId) cfg.userId = userId;
51
- const metaAttr = current.getAttribute('data-obsrviq-metadata');
58
+ const metaAttr = attr(current, 'metadata');
52
59
  if (metaAttr) {
53
60
  try {
54
61
  cfg.metadata = JSON.parse(metaAttr) as Record<string, unknown>;
@@ -61,5 +68,7 @@ if (current) {
61
68
  }
62
69
 
63
70
  window.Obsrviq = Obsrviq;
71
+ // Legacy global alias: pre-rebrand embeds call window.Lumera.identify()/track()/etc.
72
+ (window as unknown as { Lumera: typeof Obsrviq }).Lumera = Obsrviq;
64
73
 
65
74
  export { Obsrviq };