@sharadtech/infralytiqs-sdk 1.0.1 → 1.0.3

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 (69) hide show
  1. package/buildScripts/Jenkinsfile.deploy +241 -125
  2. package/clients/publicis/arc/README.md +212 -0
  3. package/clients/publicis/arc/package-lock.json +808 -0
  4. package/clients/publicis/arc/package.json +23 -0
  5. package/clients/publicis/arc/rollup.config.mjs +28 -0
  6. package/clients/publicis/arc/src/index.js +2900 -0
  7. package/clients/publicis/atl/README.md +203 -0
  8. package/clients/publicis/atl/package-lock.json +808 -0
  9. package/clients/publicis/atl/package.json +23 -0
  10. package/clients/publicis/atl/rollup.config.mjs +28 -0
  11. package/clients/publicis/atl/src/index.js +2902 -0
  12. package/clients/publicis/colab/README.md +213 -0
  13. package/clients/publicis/colab/package-lock.json +808 -0
  14. package/clients/publicis/colab/package.json +23 -0
  15. package/clients/publicis/colab/rollup.config.mjs +28 -0
  16. package/clients/publicis/colab/src/index.js +2901 -0
  17. package/clients/publicis/fnacdarty/README.md +210 -0
  18. package/clients/publicis/fnacdarty/package-lock.json +808 -0
  19. package/clients/publicis/fnacdarty/package.json +23 -0
  20. package/clients/publicis/fnacdarty/rollup.config.mjs +28 -0
  21. package/clients/publicis/fnacdarty/src/index.js +2900 -0
  22. package/clients/publicis/garnier/README.md +206 -0
  23. package/clients/publicis/garnier/package-lock.json +808 -0
  24. package/clients/publicis/garnier/package.json +23 -0
  25. package/clients/publicis/garnier/rollup.config.mjs +28 -0
  26. package/clients/publicis/garnier/src/index.js +2894 -0
  27. package/clients/publicis/pmigtr/README.md +212 -0
  28. package/clients/publicis/pmigtr/package-lock.json +808 -0
  29. package/clients/publicis/pmigtr/package.json +23 -0
  30. package/clients/publicis/pmigtr/rollup.config.mjs +28 -0
  31. package/clients/publicis/pmigtr/src/index.js +2903 -0
  32. package/clients/publicis/ps/README.md +105 -5
  33. package/clients/publicis/ps/package-lock.json +2 -2
  34. package/clients/publicis/ps/package.json +1 -1
  35. package/clients/publicis/ps/src/index.js +2473 -70
  36. package/clients/publicis/px/README.md +209 -0
  37. package/clients/publicis/px/package-lock.json +808 -0
  38. package/clients/publicis/px/package.json +23 -0
  39. package/clients/publicis/px/rollup.config.mjs +28 -0
  40. package/clients/publicis/px/src/index.js +2899 -0
  41. package/clients/publicis/pxp/README.md +212 -0
  42. package/clients/publicis/pxp/package-lock.json +808 -0
  43. package/clients/publicis/pxp/package.json +23 -0
  44. package/clients/publicis/pxp/rollup.config.mjs +28 -0
  45. package/clients/publicis/pxp/src/index.js +2900 -0
  46. package/clients/publicis/razorfish/README.md +210 -0
  47. package/clients/publicis/razorfish/package-lock.json +808 -0
  48. package/clients/publicis/razorfish/package.json +23 -0
  49. package/clients/publicis/razorfish/rollup.config.mjs +28 -0
  50. package/clients/publicis/razorfish/src/index.js +2900 -0
  51. package/clients/publicis/stellantis/README.md +208 -0
  52. package/clients/publicis/stellantis/package-lock.json +808 -0
  53. package/clients/publicis/stellantis/package.json +23 -0
  54. package/clients/publicis/stellantis/rollup.config.mjs +28 -0
  55. package/clients/publicis/stellantis/src/index.js +2895 -0
  56. package/clients/publicis/visa/README.md +208 -0
  57. package/clients/publicis/visa/package-lock.json +808 -0
  58. package/clients/publicis/visa/package.json +23 -0
  59. package/clients/publicis/visa/rollup.config.mjs +28 -0
  60. package/clients/publicis/visa/src/index.js +2894 -0
  61. package/dist/infralytiqs.js +272 -3
  62. package/dist/infralytiqs.min.js +2 -2
  63. package/package.json +1 -1
  64. package/src/envConfig.ts +1 -1
  65. package/src/index.ts +31 -0
  66. package/src/remoteConfig.ts +164 -0
  67. package/src/token.ts +79 -0
  68. package/src/tracker.ts +30 -0
  69. package/src/types.ts +10 -2
package/src/token.ts ADDED
@@ -0,0 +1,79 @@
1
+ /**
2
+ * Infralytiqs token sync.
3
+ *
4
+ * The host page (e.g. the AEM Infralytiqs.html HTL fragment) renders the
5
+ * tenant's current Infralytiqs token id into a global:
6
+ *
7
+ * <script>window.IL_TOKEN = "....";</script>
8
+ *
9
+ * On SDK load we copy that value into sessionStorage so the rest of the page
10
+ * (and any embedded Infralytiqs widgets — e.g. the "Infralytiqs SDK" report
11
+ * snippet) can read a single, tab-scoped source of truth. The token is
12
+ * tab-scoped on purpose: it lives only for the current session/tab, mirroring
13
+ * how the host page re-emits a fresh `window.IL_TOKEN` on every render.
14
+ *
15
+ * Update semantics: if a token is already stored and the markup provides a
16
+ * different (non-empty) value, the stored token is replaced with the markup
17
+ * value so the freshest server-issued token always wins.
18
+ */
19
+
20
+ import { ENV } from './envConfig';
21
+
22
+ /** sessionStorage key holding the Infralytiqs token id. */
23
+ export const TOKEN_STORAGE_KEY = `${ENV.STORAGE_PREFIX}token`;
24
+
25
+ interface WindowWithToken extends Window {
26
+ IL_TOKEN?: unknown;
27
+ }
28
+
29
+ /**
30
+ * Reads `window.IL_TOKEN` and stores it in sessionStorage, updating the
31
+ * stored value when the markup token differs from what is already cached.
32
+ *
33
+ * @returns the token value now held in sessionStorage, or `null` when no
34
+ * valid token is available.
35
+ */
36
+ export function syncToken(): string | null {
37
+ if (typeof window === 'undefined') {
38
+ return null;
39
+ }
40
+
41
+ const w = window as WindowWithToken;
42
+ const markupToken = typeof w.IL_TOKEN === 'string' ? w.IL_TOKEN.trim() : '';
43
+
44
+ let stored: string | null = null;
45
+ try {
46
+ stored = sessionStorage.getItem(TOKEN_STORAGE_KEY);
47
+ } catch {
48
+ // sessionStorage unavailable (e.g. privacy mode) — nothing we can do.
49
+ return markupToken || null;
50
+ }
51
+
52
+ // No usable markup token: keep whatever is already stored (if anything).
53
+ if (!markupToken) {
54
+ return stored;
55
+ }
56
+
57
+ // Store on first sight or whenever the markup token has changed.
58
+ if (stored !== markupToken) {
59
+ try {
60
+ sessionStorage.setItem(TOKEN_STORAGE_KEY, markupToken);
61
+ } catch {
62
+ /* storage write failed — return the markup value regardless */
63
+ }
64
+ }
65
+
66
+ return markupToken;
67
+ }
68
+
69
+ /**
70
+ * @returns the Infralytiqs token id currently held in sessionStorage, or
71
+ * `null` if none is stored / storage is unavailable.
72
+ */
73
+ export function getStoredToken(): string | null {
74
+ try {
75
+ return sessionStorage.getItem(TOKEN_STORAGE_KEY);
76
+ } catch {
77
+ return null;
78
+ }
79
+ }
package/src/tracker.ts CHANGED
@@ -6,6 +6,7 @@ import { getUtmParams } from './utm';
6
6
  import { sendViaFetch, sendViaBeacon, TransportConfig } from './transport';
7
7
  import { installAutoCapture } from './autocapture';
8
8
  import { requestLocation, getCachedCoords } from './location';
9
+ import { fetchRemoteClientConfig } from './remoteConfig';
9
10
 
10
11
  /**
11
12
  * Pre-init buffer entry for a `track()` call that arrived before the SDK
@@ -146,6 +147,35 @@ export class InfralytiqsTracker {
146
147
  requestLocation(this.config.debug).catch(() => { /* never throws */ });
147
148
  }
148
149
 
150
+ // Fire-and-forget remote tenant configuration. The server's ClickHouse
151
+ // module configuration (Infralytiqs Settings → Data Sources) carries
152
+ // browser-safe behaviour flags — today "Capture Precise Visitor
153
+ // Location". When the fetch succeeds the remote flag is authoritative:
154
+ // • remote true → enable captureLocation and kick off the (consented)
155
+ // geolocation prompt, even if init() left it off.
156
+ // • remote false → disable captureLocation so subsequent events stop
157
+ // attaching cached coords.
158
+ // When the fetch fails for any reason (no token, endpoint not deployed
159
+ // yet, expired token, network down) it resolves null and the local
160
+ // init() config stays in effect — tracking is never disrupted.
161
+ fetchRemoteClientConfig(
162
+ this.config.serverUrl,
163
+ this.config.tenantId,
164
+ this.config.siteId,
165
+ this.config.dbName,
166
+ this.config.debug,
167
+ ).then((remote) => {
168
+ if (!remote) return;
169
+ if (remote.preciseVisitorLocation && !this.config.captureLocation) {
170
+ this.config.captureLocation = true;
171
+ this.log('Remote config enabled precise visitor location');
172
+ requestLocation(this.config.debug).catch(() => { /* never throws */ });
173
+ } else if (!remote.preciseVisitorLocation && this.config.captureLocation) {
174
+ this.config.captureLocation = false;
175
+ this.log('Remote config disabled precise visitor location');
176
+ }
177
+ }).catch(() => { /* never throws */ });
178
+
149
179
  // Drain anything that arrived during the async bootstrap window.
150
180
  if (this.preInitBuffer.length > 0) {
151
181
  const buffered = this.preInitBuffer.splice(0);
package/src/types.ts CHANGED
@@ -84,8 +84,16 @@ export interface InfralytiqsConfig {
84
84
  * Coords are cached in `localStorage` for 7 days; denials are cached for
85
85
  * 24 hours so we don't re-prompt on every page load.
86
86
  *
87
- * Default: `false`. Configured per-domain in the Domain admin UI and
88
- * delivered to the SDK via `/system/client/config?domainKey=…`.
87
+ * Default: `false`.
88
+ *
89
+ * Remote override: after `init()`, the SDK fetches the tenant's remote
90
+ * client configuration from
91
+ * `GET /il/analytics/:tenant_id/:site_id/client-config` (authenticated
92
+ * via `window.IL_TOKEN`). The "Capture Precise Visitor Location"
93
+ * checkbox on the tenant's ClickHouse server configuration (Infralytiqs
94
+ * Settings → Data Sources) is authoritative when that fetch succeeds —
95
+ * it can turn this flag on or off at runtime. When the fetch fails for
96
+ * any reason, the value passed here stays in effect.
89
97
  */
90
98
  captureLocation?: boolean;
91
99
  }