ainamika-sdk 1.2.7 → 1.2.9

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/dist/sdk.d.ts CHANGED
@@ -202,6 +202,7 @@ declare class AInamikaSDKPro {
202
202
  private generateSessionId;
203
203
  private getPageContext;
204
204
  private getCommonEventData;
205
+ private sendSessionStartEvent;
205
206
  private getUserId;
206
207
  identifyUser(authenticatedUserId: string, userProperties?: Record<string, any>): void;
207
208
  /**
@@ -233,21 +234,71 @@ declare class AInamikaSDKPro {
233
234
  private setupDynamicDomTracking;
234
235
  private computeDomHash;
235
236
  /**
236
- * Generates a stable fingerprint for an element based on stable attributes.
237
- * This fingerprint is used to ensure consistent event naming across all users.
237
+ * Generates a stable fingerprint for an element that remains consistent
238
+ * across page loads and different users viewing the same element.
239
+ *
240
+ * IMPORTANT: This fingerprint is designed to be i18n-safe and user-agnostic.
241
+ * It does NOT use textContent, aria-label, or other user/locale-specific attributes.
238
242
  *
239
243
  * Priority order for fingerprint generation:
240
- * 1. data-testid, data-track, data-analytics (explicit tracking attributes)
241
- * 2. id (if unique and stable)
244
+ * 1. All data-* attributes (generalized, not just specific ones)
245
+ * 2. id (if stable, not dynamically generated)
242
246
  * 3. name attribute (for form elements)
243
- * 4. aria-label (accessibility attribute)
244
- * 5. Combination of tag + text + stable parent context
247
+ * 4. className (filtered to exclude hashed/dynamic classes)
248
+ * 5. onclick function signature (if inline)
249
+ * 6. href path (for links, without query params)
250
+ * 7. tag + type + role (semantic HTML)
251
+ * 8. Structural aria attributes (aria-controls, aria-haspopup, etc.)
252
+ * 9. Parent chain (structural context using tags and stable classes)
245
253
  */
246
254
  private generateElementFingerprint;
255
+ /**
256
+ * Extracts all data-* attributes from an element, sorted for consistency.
257
+ * Returns array like ["action=checkout", "component=cart", "id=123"]
258
+ */
259
+ private extractDataAttributes;
260
+ /**
261
+ * Checks if a data attribute likely contains dynamic/user-specific values
262
+ */
263
+ private isDynamicDataAttribute;
264
+ /**
265
+ * Checks if an ID appears to be dynamically generated
266
+ */
267
+ private isDynamicId;
268
+ /**
269
+ * Extracts stable class names, filtering out hashed/dynamic ones
270
+ */
271
+ private extractStableClasses;
272
+ /**
273
+ * Determines if a class name is stable (not hashed/dynamic)
274
+ */
275
+ private isStableClassName;
276
+ /**
277
+ * Extracts function signature from onclick attribute
278
+ */
279
+ private extractOnclickSignature;
280
+ /**
281
+ * Extracts path from href, removing query params and normalizing
282
+ */
283
+ private extractHrefPath;
284
+ /**
285
+ * Extracts structural aria attributes (not aria-label which contains text)
286
+ */
287
+ private extractStructuralAriaAttributes;
288
+ /**
289
+ * Builds a structural parent chain signature using tags and stable classes
290
+ */
291
+ private buildParentChainSignature;
247
292
  /**
248
293
  * Simple hash function for fingerprinting (MD5-like, but faster)
249
294
  */
250
295
  private hashString;
296
+ /**
297
+ * Detects if an element has a click handler attached via any framework.
298
+ * Works with React, Vue, Angular, Svelte, and vanilla JS.
299
+ * Also checks cursor: pointer as a universal fallback.
300
+ */
301
+ private hasFrameworkClickHandler;
251
302
  private readonly MAX_CACHED_CONFIGS;
252
303
  private getLastKnownConfig;
253
304
  private setLastKnownConfig;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ainamika-sdk",
3
- "version": "1.2.7",
3
+ "version": "1.2.9",
4
4
  "description": "AI-powered analytics SDK with Web Vitals, engagement tracking, error monitoring, and real-time insights for web applications",
5
5
  "main": "dist/ainamika-sdk.js",
6
6
  "types": "dist/sdk.d.ts",