mytart 0.6.4 → 0.6.6
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 +69 -3
- package/dist/index.d.mts +64 -17
- package/dist/index.d.ts +64 -17
- package/dist/index.js +167 -69
- package/dist/index.mjs +167 -69
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -271,7 +271,7 @@ When enabled:
|
|
|
271
271
|
|
|
272
272
|
- The official `https://www.clarity.ms/tag/{projectId}` script is loaded once on the first `track()`, `identify()`, or `page()` call
|
|
273
273
|
- `track()` fires `clarity('event', eventName)` and sets each property as a custom tag via `clarity('set', key, value)`
|
|
274
|
-
- `identify()` calls `clarity('identify', userId)` with
|
|
274
|
+
- `identify()` calls `clarity('identify', userId, sessionId, undefined, friendlyName)` with session ID as the native `custom-session-id` parameter, and sets remaining traits as custom tags
|
|
275
275
|
- `page()` fires a `PageView` event and sets `pageUrl`, `pageName`, and `referrer` as custom tags
|
|
276
276
|
- SSR-safe: silently succeeds when `window` is undefined
|
|
277
277
|
|
|
@@ -372,6 +372,63 @@ Returns `null` when `crossProviderLinking` is disabled.
|
|
|
372
372
|
- **User properties take precedence.** If you pass a property with the same `xpl_*` key, your value wins.
|
|
373
373
|
- **Consent.** This feature reads existing URL parameters and cookies — it does not set new cookies or tracking identifiers. Each provider's own consent mechanism remains authoritative.
|
|
374
374
|
|
|
375
|
+
## State Management
|
|
376
|
+
|
|
377
|
+
Mytart maintains a central state (`userId`, `anonymousId`, `sessionId`) that all providers can access. This enables consistent user identification across all analytics calls without manually passing IDs to every method.
|
|
378
|
+
|
|
379
|
+
### How it works
|
|
380
|
+
|
|
381
|
+
1. **Initial state** is set from `defaultUserId`, `defaultAnonymousId`, and `defaultSessionId` in the config
|
|
382
|
+
2. **`identify()` updates state** — when you call `identify({ userId: 'abc' })`, the state is updated BEFORE dispatching to providers, ensuring all providers receive the updated userId
|
|
383
|
+
3. **All methods use state** — `track()`, `page()`, and `identify()` all receive the current state values (user-provided values override state defaults)
|
|
384
|
+
|
|
385
|
+
### State methods
|
|
386
|
+
|
|
387
|
+
```typescript
|
|
388
|
+
const analytics = new Mytart({
|
|
389
|
+
defaultUserId: 'default-user',
|
|
390
|
+
defaultAnonymousId: 'anon-123',
|
|
391
|
+
defaultSessionId: 'session-abc',
|
|
392
|
+
providers: [{ provider: 'segment', writeKey: 'YOUR_KEY', enabled: true }],
|
|
393
|
+
});
|
|
394
|
+
|
|
395
|
+
// Get current state
|
|
396
|
+
const state = analytics.getState();
|
|
397
|
+
// { userId: 'default-user', anonymousId: 'anon-123', sessionId: 'session-abc' }
|
|
398
|
+
|
|
399
|
+
// Set individual IDs
|
|
400
|
+
analytics.setUserId('user-456');
|
|
401
|
+
analytics.setAnonymousId('anon-789');
|
|
402
|
+
analytics.setSessionId('session-xyz');
|
|
403
|
+
|
|
404
|
+
// Clear userId (e.g., on logout)
|
|
405
|
+
analytics.clearUserId();
|
|
406
|
+
|
|
407
|
+
// Clear session only (e.g., when session expires)
|
|
408
|
+
analytics.clearSessionId();
|
|
409
|
+
|
|
410
|
+
// Clear all state
|
|
411
|
+
analytics.clearState();
|
|
412
|
+
|
|
413
|
+
// identify() also updates state
|
|
414
|
+
await analytics.identify({ userId: 'user-789', traits: { email: 'alice@example.com' } });
|
|
415
|
+
// State is now: { userId: 'user-789', ... }
|
|
416
|
+
```
|
|
417
|
+
|
|
418
|
+
### How state flows to providers
|
|
419
|
+
|
|
420
|
+
All providers receive the current state in their `track()`, `identify()`, and `page()` calls. Each provider maps state to its API correctly:
|
|
421
|
+
|
|
422
|
+
- **GA4** — `user_id` and `session_id` in Measurement Protocol and gtag.js event params
|
|
423
|
+
- **Segment** — `userId`, `anonymousId`, `sessionId` in track/identify/page
|
|
424
|
+
- **Amplitude** — `user_id`, `device_id`, `session_id` in events
|
|
425
|
+
- **PostHog** — `distinct_id` and `$session_id` in properties
|
|
426
|
+
- **Mixpanel** — `distinct_id` and `$session_id` in events
|
|
427
|
+
- **Meta Pixel (server)** — `external_id` in user_data, `xpl_anonymous_id` and `xpl_session_id` in custom_data
|
|
428
|
+
- **Meta Pixel (browser)** — `xpl_session_id` in event properties
|
|
429
|
+
- **Clarity** — `userId` passed to `clarity('identify', userId, sessionId, undefined, friendlyName)`, `sessionId` also set as custom tag
|
|
430
|
+
- **Plausible** — does not support user identification (privacy-first, by design)
|
|
431
|
+
|
|
375
432
|
## API Reference
|
|
376
433
|
|
|
377
434
|
### `new Mytart(config: MytartConfig)`
|
|
@@ -494,12 +551,14 @@ All types are exported:
|
|
|
494
551
|
|
|
495
552
|
```typescript
|
|
496
553
|
import type {
|
|
497
|
-
MytartConfig, BaseProviderConfig, ProviderConfig, TrackOptions, IdentifyOptions, PageOptions,
|
|
554
|
+
MytartConfig, MytartState, BaseProviderConfig, ProviderConfig, TrackOptions, IdentifyOptions, PageOptions,
|
|
498
555
|
TrackResult, MytartError, EventContext, ProviderName, GoogleAnalyticsAppType,
|
|
499
556
|
GoogleAnalyticsConfig, ConsentSettings, ConsentState, MixpanelConfig, SegmentConfig,
|
|
500
557
|
AmplitudeConfig, PlausibleConfig, PostHogConfig, MetaPixelConfig, MetaPixelAppType,
|
|
501
558
|
MetaPixelAdvancedMatching, ClarityConfig,
|
|
502
559
|
} from 'mytart';
|
|
560
|
+
|
|
561
|
+
import type { MytartLike } from 'mytart'; // interface for custom providers
|
|
503
562
|
```
|
|
504
563
|
|
|
505
564
|
## Custom Providers
|
|
@@ -507,12 +566,19 @@ import type {
|
|
|
507
566
|
Extend `BaseProvider` to create your own:
|
|
508
567
|
|
|
509
568
|
```typescript
|
|
510
|
-
import { BaseProvider, TrackOptions, IdentifyOptions, PageOptions, TrackResult } from 'mytart';
|
|
569
|
+
import { BaseProvider, MytartLike, TrackOptions, IdentifyOptions, PageOptions, TrackResult } from 'mytart';
|
|
511
570
|
|
|
512
571
|
export class MyProvider extends BaseProvider {
|
|
513
572
|
readonly name = 'my-provider';
|
|
514
573
|
|
|
574
|
+
constructor(config: MyProviderConfig, mytart: MytartLike) {
|
|
575
|
+
super(mytart);
|
|
576
|
+
// Store config, set up HTTP client, etc.
|
|
577
|
+
}
|
|
578
|
+
|
|
515
579
|
async track(options: TrackOptions): Promise<TrackResult> {
|
|
580
|
+
// Access central state via this.mytart.getState()
|
|
581
|
+
const state = this.mytart.getState();
|
|
516
582
|
// your HTTP call here
|
|
517
583
|
return this.buildSuccess(200);
|
|
518
584
|
}
|
package/dist/index.d.mts
CHANGED
|
@@ -542,6 +542,16 @@ interface MytartConfig {
|
|
|
542
542
|
*/
|
|
543
543
|
crossProviderLinking?: boolean;
|
|
544
544
|
}
|
|
545
|
+
/**
|
|
546
|
+
* Central state managed by Mytart that can be accessed by all providers.
|
|
547
|
+
* This enables providers to share state (userId, anonymousId, sessionId)
|
|
548
|
+
* without coupling to each other.
|
|
549
|
+
*/
|
|
550
|
+
interface MytartState {
|
|
551
|
+
userId: string | undefined;
|
|
552
|
+
anonymousId: string | undefined;
|
|
553
|
+
sessionId: string | undefined;
|
|
554
|
+
}
|
|
545
555
|
interface EventContext {
|
|
546
556
|
ip?: string;
|
|
547
557
|
userAgent?: string;
|
|
@@ -626,6 +636,7 @@ declare class Mytart {
|
|
|
626
636
|
private readonly config;
|
|
627
637
|
private readonly capturedIds;
|
|
628
638
|
private readonly linkingProperties;
|
|
639
|
+
private state;
|
|
629
640
|
constructor(config: MytartConfig);
|
|
630
641
|
/**
|
|
631
642
|
* Returns `true` when `ignoreBots` is enabled and the given (or detected)
|
|
@@ -653,10 +664,50 @@ declare class Mytart {
|
|
|
653
664
|
* time, or `null` when `crossProviderLinking` is disabled.
|
|
654
665
|
*/
|
|
655
666
|
getCapturedIds(): CapturedIds | null;
|
|
667
|
+
/**
|
|
668
|
+
* Get the current state.
|
|
669
|
+
*/
|
|
670
|
+
getState(): MytartState;
|
|
671
|
+
/**
|
|
672
|
+
* Set userId in state. Use this when a user logs in.
|
|
673
|
+
*/
|
|
674
|
+
setUserId(userId: string): void;
|
|
675
|
+
/**
|
|
676
|
+
* Set anonymousId in state. Use this to identify anonymous users.
|
|
677
|
+
*/
|
|
678
|
+
setAnonymousId(anonymousId: string): void;
|
|
679
|
+
/**
|
|
680
|
+
* Set sessionId in state. Use this when a new session starts.
|
|
681
|
+
*/
|
|
682
|
+
setSessionId(sessionId: string): void;
|
|
683
|
+
/**
|
|
684
|
+
* Clear userId (e.g., on logout).
|
|
685
|
+
*/
|
|
686
|
+
clearUserId(): void;
|
|
687
|
+
/**
|
|
688
|
+
* Clear all state (userId, anonymousId, sessionId).
|
|
689
|
+
* Use this to reset state entirely.
|
|
690
|
+
*/
|
|
691
|
+
clearState(): void;
|
|
692
|
+
/**
|
|
693
|
+
* Clear sessionId only (e.g., when session expires).
|
|
694
|
+
*/
|
|
695
|
+
clearSessionId(): void;
|
|
656
696
|
}
|
|
657
697
|
|
|
698
|
+
interface MytartLike {
|
|
699
|
+
getState(): MytartState;
|
|
700
|
+
setUserId(userId: string): void;
|
|
701
|
+
setAnonymousId(anonymousId: string): void;
|
|
702
|
+
setSessionId(sessionId: string): void;
|
|
703
|
+
clearUserId(): void;
|
|
704
|
+
clearSessionId(): void;
|
|
705
|
+
clearState(): void;
|
|
706
|
+
}
|
|
658
707
|
declare abstract class BaseProvider {
|
|
659
708
|
abstract readonly name: string;
|
|
709
|
+
protected readonly mytart: MytartLike;
|
|
710
|
+
constructor(mytart: MytartLike);
|
|
660
711
|
abstract track(options: TrackOptions): Promise<TrackResult>;
|
|
661
712
|
abstract identify(options: IdentifyOptions): Promise<TrackResult>;
|
|
662
713
|
abstract page(options: PageOptions): Promise<TrackResult>;
|
|
@@ -683,7 +734,7 @@ declare class GoogleAnalyticsProvider extends BaseProvider {
|
|
|
683
734
|
private readonly endpoint;
|
|
684
735
|
private readonly isBrowser;
|
|
685
736
|
private gtagReady;
|
|
686
|
-
constructor(config: GoogleAnalyticsConfig);
|
|
737
|
+
constructor(config: GoogleAnalyticsConfig, mytart: MytartLike);
|
|
687
738
|
/**
|
|
688
739
|
* Initializes the gtag.js snippet exactly as Google's official documentation
|
|
689
740
|
* specifies. This mirrors the standard snippet:
|
|
@@ -738,11 +789,11 @@ declare class MixpanelProvider extends BaseProvider {
|
|
|
738
789
|
readonly name = "mixpanel";
|
|
739
790
|
private readonly config;
|
|
740
791
|
private readonly http;
|
|
741
|
-
constructor(config: MixpanelConfig);
|
|
792
|
+
constructor(config: MixpanelConfig, mytart: MytartLike);
|
|
742
793
|
private encodeData;
|
|
743
|
-
track({ event, properties, userId, anonymousId, timestamp }: TrackOptions): Promise<TrackResult>;
|
|
744
|
-
identify({ userId, traits }: IdentifyOptions): Promise<TrackResult>;
|
|
745
|
-
page({ name, url, userId, anonymousId, properties }: PageOptions): Promise<TrackResult>;
|
|
794
|
+
track({ event, properties, userId, anonymousId, sessionId, timestamp }: TrackOptions): Promise<TrackResult>;
|
|
795
|
+
identify({ userId, traits, sessionId }: IdentifyOptions): Promise<TrackResult>;
|
|
796
|
+
page({ name, url, userId, anonymousId, sessionId, properties }: PageOptions): Promise<TrackResult>;
|
|
746
797
|
}
|
|
747
798
|
|
|
748
799
|
declare class SegmentProvider extends BaseProvider {
|
|
@@ -750,7 +801,7 @@ declare class SegmentProvider extends BaseProvider {
|
|
|
750
801
|
private readonly config;
|
|
751
802
|
private readonly http;
|
|
752
803
|
private readonly baseUrl;
|
|
753
|
-
constructor(config: SegmentConfig);
|
|
804
|
+
constructor(config: SegmentConfig, mytart: MytartLike);
|
|
754
805
|
private getAuth;
|
|
755
806
|
track({ event, properties, userId, anonymousId, sessionId, timestamp, context }: TrackOptions): Promise<TrackResult>;
|
|
756
807
|
identify({ userId, traits, anonymousId, sessionId, timestamp }: IdentifyOptions): Promise<TrackResult>;
|
|
@@ -762,7 +813,7 @@ declare class AmplitudeProvider extends BaseProvider {
|
|
|
762
813
|
private readonly config;
|
|
763
814
|
private readonly http;
|
|
764
815
|
private readonly endpoint;
|
|
765
|
-
constructor(config: AmplitudeConfig);
|
|
816
|
+
constructor(config: AmplitudeConfig, mytart: MytartLike);
|
|
766
817
|
track({ event, properties, userId, anonymousId, sessionId, timestamp }: TrackOptions): Promise<TrackResult>;
|
|
767
818
|
identify({ userId, traits, anonymousId, sessionId }: IdentifyOptions): Promise<TrackResult>;
|
|
768
819
|
page({ name, url, userId, anonymousId, sessionId, properties }: PageOptions): Promise<TrackResult>;
|
|
@@ -773,11 +824,11 @@ declare class PlausibleProvider extends BaseProvider {
|
|
|
773
824
|
private readonly config;
|
|
774
825
|
private readonly http;
|
|
775
826
|
private readonly endpoint;
|
|
776
|
-
constructor(config: PlausibleConfig);
|
|
827
|
+
constructor(config: PlausibleConfig, mytart: MytartLike);
|
|
777
828
|
private buildHeaders;
|
|
778
829
|
track({ event, properties, context }: TrackOptions): Promise<TrackResult>;
|
|
779
830
|
identify(_options: IdentifyOptions): Promise<TrackResult>;
|
|
780
|
-
page({ name, url, properties }: PageOptions): Promise<TrackResult>;
|
|
831
|
+
page({ name, url, referrer, properties }: PageOptions): Promise<TrackResult>;
|
|
781
832
|
}
|
|
782
833
|
|
|
783
834
|
declare class PostHogProvider extends BaseProvider {
|
|
@@ -785,7 +836,7 @@ declare class PostHogProvider extends BaseProvider {
|
|
|
785
836
|
private readonly config;
|
|
786
837
|
private readonly http;
|
|
787
838
|
private readonly endpoint;
|
|
788
|
-
constructor(config: PostHogConfig);
|
|
839
|
+
constructor(config: PostHogConfig, mytart: MytartLike);
|
|
789
840
|
track({ event, properties, userId, anonymousId, sessionId, timestamp }: TrackOptions): Promise<TrackResult>;
|
|
790
841
|
identify({ userId, traits, anonymousId, sessionId }: IdentifyOptions): Promise<TrackResult>;
|
|
791
842
|
page({ name, url, userId, anonymousId, sessionId, properties }: PageOptions): Promise<TrackResult>;
|
|
@@ -811,12 +862,8 @@ declare class MetaPixelProvider extends BaseProvider {
|
|
|
811
862
|
private readonly isBrowser;
|
|
812
863
|
private readonly apiVersion;
|
|
813
864
|
private fbqReady;
|
|
814
|
-
/**
|
|
815
|
-
* Cached user data for the Conversions API. Updated by `identify()` so
|
|
816
|
-
* that subsequent `track()` and `page()` calls include user information.
|
|
817
|
-
*/
|
|
818
865
|
private cachedUserData;
|
|
819
|
-
constructor(config: MetaPixelConfig);
|
|
866
|
+
constructor(config: MetaPixelConfig, mytart: MytartLike);
|
|
820
867
|
/**
|
|
821
868
|
* Initialises the Meta Pixel snippet. This mirrors the official snippet from
|
|
822
869
|
* https://developers.facebook.com/docs/meta-pixel/get-started:
|
|
@@ -881,7 +928,7 @@ declare class ClarityProvider extends BaseProvider {
|
|
|
881
928
|
readonly name = "clarity";
|
|
882
929
|
private readonly config;
|
|
883
930
|
private clarityReady;
|
|
884
|
-
constructor(config: ClarityConfig);
|
|
931
|
+
constructor(config: ClarityConfig, mytart: MytartLike);
|
|
885
932
|
/**
|
|
886
933
|
* Injects the official Clarity tracking snippet. Mirrors:
|
|
887
934
|
*
|
|
@@ -898,4 +945,4 @@ declare class ClarityProvider extends BaseProvider {
|
|
|
898
945
|
page(options: PageOptions): Promise<TrackResult>;
|
|
899
946
|
}
|
|
900
947
|
|
|
901
|
-
export { type AmplitudeConfig, AmplitudeProvider, BaseProvider, type BaseProviderConfig, type CapturedIds, type ClarityConfig, ClarityProvider, type ConsentSettings, type ConsentState, type EventContext, type GoogleAnalyticsAppType, type GoogleAnalyticsConfig, GoogleAnalyticsProvider, type IdentifyOptions, type MetaPixelAdvancedMatching, type MetaPixelAppType, type MetaPixelConfig, MetaPixelProvider, type MixpanelConfig, MixpanelProvider, Mytart, type MytartConfig, type MytartError, type PageOptions, type PlausibleConfig, PlausibleProvider, type PostHogConfig, PostHogProvider, type ProviderConfig, type ProviderName, type SegmentConfig, SegmentProvider, type TrackOptions, type TrackResult };
|
|
948
|
+
export { type AmplitudeConfig, AmplitudeProvider, BaseProvider, type BaseProviderConfig, type CapturedIds, type ClarityConfig, ClarityProvider, type ConsentSettings, type ConsentState, type EventContext, type GoogleAnalyticsAppType, type GoogleAnalyticsConfig, GoogleAnalyticsProvider, type IdentifyOptions, type MetaPixelAdvancedMatching, type MetaPixelAppType, type MetaPixelConfig, MetaPixelProvider, type MixpanelConfig, MixpanelProvider, Mytart, type MytartConfig, type MytartError, type MytartLike, type MytartState, type PageOptions, type PlausibleConfig, PlausibleProvider, type PostHogConfig, PostHogProvider, type ProviderConfig, type ProviderName, type SegmentConfig, SegmentProvider, type TrackOptions, type TrackResult };
|
package/dist/index.d.ts
CHANGED
|
@@ -542,6 +542,16 @@ interface MytartConfig {
|
|
|
542
542
|
*/
|
|
543
543
|
crossProviderLinking?: boolean;
|
|
544
544
|
}
|
|
545
|
+
/**
|
|
546
|
+
* Central state managed by Mytart that can be accessed by all providers.
|
|
547
|
+
* This enables providers to share state (userId, anonymousId, sessionId)
|
|
548
|
+
* without coupling to each other.
|
|
549
|
+
*/
|
|
550
|
+
interface MytartState {
|
|
551
|
+
userId: string | undefined;
|
|
552
|
+
anonymousId: string | undefined;
|
|
553
|
+
sessionId: string | undefined;
|
|
554
|
+
}
|
|
545
555
|
interface EventContext {
|
|
546
556
|
ip?: string;
|
|
547
557
|
userAgent?: string;
|
|
@@ -626,6 +636,7 @@ declare class Mytart {
|
|
|
626
636
|
private readonly config;
|
|
627
637
|
private readonly capturedIds;
|
|
628
638
|
private readonly linkingProperties;
|
|
639
|
+
private state;
|
|
629
640
|
constructor(config: MytartConfig);
|
|
630
641
|
/**
|
|
631
642
|
* Returns `true` when `ignoreBots` is enabled and the given (or detected)
|
|
@@ -653,10 +664,50 @@ declare class Mytart {
|
|
|
653
664
|
* time, or `null` when `crossProviderLinking` is disabled.
|
|
654
665
|
*/
|
|
655
666
|
getCapturedIds(): CapturedIds | null;
|
|
667
|
+
/**
|
|
668
|
+
* Get the current state.
|
|
669
|
+
*/
|
|
670
|
+
getState(): MytartState;
|
|
671
|
+
/**
|
|
672
|
+
* Set userId in state. Use this when a user logs in.
|
|
673
|
+
*/
|
|
674
|
+
setUserId(userId: string): void;
|
|
675
|
+
/**
|
|
676
|
+
* Set anonymousId in state. Use this to identify anonymous users.
|
|
677
|
+
*/
|
|
678
|
+
setAnonymousId(anonymousId: string): void;
|
|
679
|
+
/**
|
|
680
|
+
* Set sessionId in state. Use this when a new session starts.
|
|
681
|
+
*/
|
|
682
|
+
setSessionId(sessionId: string): void;
|
|
683
|
+
/**
|
|
684
|
+
* Clear userId (e.g., on logout).
|
|
685
|
+
*/
|
|
686
|
+
clearUserId(): void;
|
|
687
|
+
/**
|
|
688
|
+
* Clear all state (userId, anonymousId, sessionId).
|
|
689
|
+
* Use this to reset state entirely.
|
|
690
|
+
*/
|
|
691
|
+
clearState(): void;
|
|
692
|
+
/**
|
|
693
|
+
* Clear sessionId only (e.g., when session expires).
|
|
694
|
+
*/
|
|
695
|
+
clearSessionId(): void;
|
|
656
696
|
}
|
|
657
697
|
|
|
698
|
+
interface MytartLike {
|
|
699
|
+
getState(): MytartState;
|
|
700
|
+
setUserId(userId: string): void;
|
|
701
|
+
setAnonymousId(anonymousId: string): void;
|
|
702
|
+
setSessionId(sessionId: string): void;
|
|
703
|
+
clearUserId(): void;
|
|
704
|
+
clearSessionId(): void;
|
|
705
|
+
clearState(): void;
|
|
706
|
+
}
|
|
658
707
|
declare abstract class BaseProvider {
|
|
659
708
|
abstract readonly name: string;
|
|
709
|
+
protected readonly mytart: MytartLike;
|
|
710
|
+
constructor(mytart: MytartLike);
|
|
660
711
|
abstract track(options: TrackOptions): Promise<TrackResult>;
|
|
661
712
|
abstract identify(options: IdentifyOptions): Promise<TrackResult>;
|
|
662
713
|
abstract page(options: PageOptions): Promise<TrackResult>;
|
|
@@ -683,7 +734,7 @@ declare class GoogleAnalyticsProvider extends BaseProvider {
|
|
|
683
734
|
private readonly endpoint;
|
|
684
735
|
private readonly isBrowser;
|
|
685
736
|
private gtagReady;
|
|
686
|
-
constructor(config: GoogleAnalyticsConfig);
|
|
737
|
+
constructor(config: GoogleAnalyticsConfig, mytart: MytartLike);
|
|
687
738
|
/**
|
|
688
739
|
* Initializes the gtag.js snippet exactly as Google's official documentation
|
|
689
740
|
* specifies. This mirrors the standard snippet:
|
|
@@ -738,11 +789,11 @@ declare class MixpanelProvider extends BaseProvider {
|
|
|
738
789
|
readonly name = "mixpanel";
|
|
739
790
|
private readonly config;
|
|
740
791
|
private readonly http;
|
|
741
|
-
constructor(config: MixpanelConfig);
|
|
792
|
+
constructor(config: MixpanelConfig, mytart: MytartLike);
|
|
742
793
|
private encodeData;
|
|
743
|
-
track({ event, properties, userId, anonymousId, timestamp }: TrackOptions): Promise<TrackResult>;
|
|
744
|
-
identify({ userId, traits }: IdentifyOptions): Promise<TrackResult>;
|
|
745
|
-
page({ name, url, userId, anonymousId, properties }: PageOptions): Promise<TrackResult>;
|
|
794
|
+
track({ event, properties, userId, anonymousId, sessionId, timestamp }: TrackOptions): Promise<TrackResult>;
|
|
795
|
+
identify({ userId, traits, sessionId }: IdentifyOptions): Promise<TrackResult>;
|
|
796
|
+
page({ name, url, userId, anonymousId, sessionId, properties }: PageOptions): Promise<TrackResult>;
|
|
746
797
|
}
|
|
747
798
|
|
|
748
799
|
declare class SegmentProvider extends BaseProvider {
|
|
@@ -750,7 +801,7 @@ declare class SegmentProvider extends BaseProvider {
|
|
|
750
801
|
private readonly config;
|
|
751
802
|
private readonly http;
|
|
752
803
|
private readonly baseUrl;
|
|
753
|
-
constructor(config: SegmentConfig);
|
|
804
|
+
constructor(config: SegmentConfig, mytart: MytartLike);
|
|
754
805
|
private getAuth;
|
|
755
806
|
track({ event, properties, userId, anonymousId, sessionId, timestamp, context }: TrackOptions): Promise<TrackResult>;
|
|
756
807
|
identify({ userId, traits, anonymousId, sessionId, timestamp }: IdentifyOptions): Promise<TrackResult>;
|
|
@@ -762,7 +813,7 @@ declare class AmplitudeProvider extends BaseProvider {
|
|
|
762
813
|
private readonly config;
|
|
763
814
|
private readonly http;
|
|
764
815
|
private readonly endpoint;
|
|
765
|
-
constructor(config: AmplitudeConfig);
|
|
816
|
+
constructor(config: AmplitudeConfig, mytart: MytartLike);
|
|
766
817
|
track({ event, properties, userId, anonymousId, sessionId, timestamp }: TrackOptions): Promise<TrackResult>;
|
|
767
818
|
identify({ userId, traits, anonymousId, sessionId }: IdentifyOptions): Promise<TrackResult>;
|
|
768
819
|
page({ name, url, userId, anonymousId, sessionId, properties }: PageOptions): Promise<TrackResult>;
|
|
@@ -773,11 +824,11 @@ declare class PlausibleProvider extends BaseProvider {
|
|
|
773
824
|
private readonly config;
|
|
774
825
|
private readonly http;
|
|
775
826
|
private readonly endpoint;
|
|
776
|
-
constructor(config: PlausibleConfig);
|
|
827
|
+
constructor(config: PlausibleConfig, mytart: MytartLike);
|
|
777
828
|
private buildHeaders;
|
|
778
829
|
track({ event, properties, context }: TrackOptions): Promise<TrackResult>;
|
|
779
830
|
identify(_options: IdentifyOptions): Promise<TrackResult>;
|
|
780
|
-
page({ name, url, properties }: PageOptions): Promise<TrackResult>;
|
|
831
|
+
page({ name, url, referrer, properties }: PageOptions): Promise<TrackResult>;
|
|
781
832
|
}
|
|
782
833
|
|
|
783
834
|
declare class PostHogProvider extends BaseProvider {
|
|
@@ -785,7 +836,7 @@ declare class PostHogProvider extends BaseProvider {
|
|
|
785
836
|
private readonly config;
|
|
786
837
|
private readonly http;
|
|
787
838
|
private readonly endpoint;
|
|
788
|
-
constructor(config: PostHogConfig);
|
|
839
|
+
constructor(config: PostHogConfig, mytart: MytartLike);
|
|
789
840
|
track({ event, properties, userId, anonymousId, sessionId, timestamp }: TrackOptions): Promise<TrackResult>;
|
|
790
841
|
identify({ userId, traits, anonymousId, sessionId }: IdentifyOptions): Promise<TrackResult>;
|
|
791
842
|
page({ name, url, userId, anonymousId, sessionId, properties }: PageOptions): Promise<TrackResult>;
|
|
@@ -811,12 +862,8 @@ declare class MetaPixelProvider extends BaseProvider {
|
|
|
811
862
|
private readonly isBrowser;
|
|
812
863
|
private readonly apiVersion;
|
|
813
864
|
private fbqReady;
|
|
814
|
-
/**
|
|
815
|
-
* Cached user data for the Conversions API. Updated by `identify()` so
|
|
816
|
-
* that subsequent `track()` and `page()` calls include user information.
|
|
817
|
-
*/
|
|
818
865
|
private cachedUserData;
|
|
819
|
-
constructor(config: MetaPixelConfig);
|
|
866
|
+
constructor(config: MetaPixelConfig, mytart: MytartLike);
|
|
820
867
|
/**
|
|
821
868
|
* Initialises the Meta Pixel snippet. This mirrors the official snippet from
|
|
822
869
|
* https://developers.facebook.com/docs/meta-pixel/get-started:
|
|
@@ -881,7 +928,7 @@ declare class ClarityProvider extends BaseProvider {
|
|
|
881
928
|
readonly name = "clarity";
|
|
882
929
|
private readonly config;
|
|
883
930
|
private clarityReady;
|
|
884
|
-
constructor(config: ClarityConfig);
|
|
931
|
+
constructor(config: ClarityConfig, mytart: MytartLike);
|
|
885
932
|
/**
|
|
886
933
|
* Injects the official Clarity tracking snippet. Mirrors:
|
|
887
934
|
*
|
|
@@ -898,4 +945,4 @@ declare class ClarityProvider extends BaseProvider {
|
|
|
898
945
|
page(options: PageOptions): Promise<TrackResult>;
|
|
899
946
|
}
|
|
900
947
|
|
|
901
|
-
export { type AmplitudeConfig, AmplitudeProvider, BaseProvider, type BaseProviderConfig, type CapturedIds, type ClarityConfig, ClarityProvider, type ConsentSettings, type ConsentState, type EventContext, type GoogleAnalyticsAppType, type GoogleAnalyticsConfig, GoogleAnalyticsProvider, type IdentifyOptions, type MetaPixelAdvancedMatching, type MetaPixelAppType, type MetaPixelConfig, MetaPixelProvider, type MixpanelConfig, MixpanelProvider, Mytart, type MytartConfig, type MytartError, type PageOptions, type PlausibleConfig, PlausibleProvider, type PostHogConfig, PostHogProvider, type ProviderConfig, type ProviderName, type SegmentConfig, SegmentProvider, type TrackOptions, type TrackResult };
|
|
948
|
+
export { type AmplitudeConfig, AmplitudeProvider, BaseProvider, type BaseProviderConfig, type CapturedIds, type ClarityConfig, ClarityProvider, type ConsentSettings, type ConsentState, type EventContext, type GoogleAnalyticsAppType, type GoogleAnalyticsConfig, GoogleAnalyticsProvider, type IdentifyOptions, type MetaPixelAdvancedMatching, type MetaPixelAppType, type MetaPixelConfig, MetaPixelProvider, type MixpanelConfig, MixpanelProvider, Mytart, type MytartConfig, type MytartError, type MytartLike, type MytartState, type PageOptions, type PlausibleConfig, PlausibleProvider, type PostHogConfig, PostHogProvider, type ProviderConfig, type ProviderName, type SegmentConfig, SegmentProvider, type TrackOptions, type TrackResult };
|