saasco-sdk 0.1.43 → 0.1.44
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/index.cjs.js +406 -116
- package/index.esm.js +405 -116
- package/package.json +1 -1
- package/src/lib/analytics.d.ts +17 -1
- package/src/lib/integrations/facebook-pixel.d.ts +1 -1
- package/src/lib/integrations/index.d.ts +1 -0
- package/src/lib/integrations/integration-manager.d.ts +5 -11
- package/src/lib/integrations/pinterest-tag.d.ts +37 -0
- package/src/lib/integrations/tiktok-pixel.d.ts +1 -1
- package/src/lib/utils/getIntegrationLoggerLevel.d.ts +8 -0
- package/src/lib/utils/index.d.ts +1 -0
- package/src/lib/utils/logger.d.ts +9 -2
package/package.json
CHANGED
package/src/lib/analytics.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { FacebookPixelIntegrationConfig } from './integrations/facebook-pixel';
|
|
2
|
+
import { PinterestTagIntegrationConfig } from './integrations/pinterest-tag';
|
|
2
3
|
import { TikTokPixelIntegrationConfig } from './integrations/tiktok-pixel';
|
|
3
4
|
declare global {
|
|
4
5
|
interface Window {
|
|
@@ -29,8 +30,9 @@ type DoRequestResponse = {
|
|
|
29
30
|
export type IntegrationConfigBase = {
|
|
30
31
|
type: string;
|
|
31
32
|
config: Record<string, any>;
|
|
33
|
+
debug?: boolean;
|
|
32
34
|
};
|
|
33
|
-
export type IntegrationsConfig = (FacebookPixelIntegrationConfig | TikTokPixelIntegrationConfig)[];
|
|
35
|
+
export type IntegrationsConfig = (FacebookPixelIntegrationConfig | PinterestTagIntegrationConfig | TikTokPixelIntegrationConfig)[];
|
|
34
36
|
export declare class Saasco {
|
|
35
37
|
private config;
|
|
36
38
|
private lastPageViewPath;
|
|
@@ -59,6 +61,7 @@ export declare class Saasco {
|
|
|
59
61
|
};
|
|
60
62
|
enabled?: boolean;
|
|
61
63
|
debug?: boolean;
|
|
64
|
+
debugVerbose?: boolean;
|
|
62
65
|
integrations?: IntegrationsConfig;
|
|
63
66
|
});
|
|
64
67
|
init(): void;
|
|
@@ -114,5 +117,18 @@ export declare class Saasco {
|
|
|
114
117
|
* @returns
|
|
115
118
|
*/
|
|
116
119
|
private initAutoPageTracking;
|
|
120
|
+
getIntegrationsStats(): {
|
|
121
|
+
currentEnvironment: import("./integrations/integration-manager").IntegrationEnvironment;
|
|
122
|
+
integrations: {
|
|
123
|
+
name: string;
|
|
124
|
+
status: import("./integrations/integration-manager").IntegrationStatus;
|
|
125
|
+
environments: import("./integrations/integration-manager").IntegrationEnvironment[];
|
|
126
|
+
}[];
|
|
127
|
+
queueLength: number;
|
|
128
|
+
readyCount: number;
|
|
129
|
+
periodicFlushEnabled: boolean;
|
|
130
|
+
flushInterval: number;
|
|
131
|
+
context: import("./integrations/integration-manager").AnalyticsContext;
|
|
132
|
+
};
|
|
117
133
|
}
|
|
118
134
|
export {};
|
|
@@ -31,4 +31,4 @@ export type StandardFacebookEvent = (typeof standardFacebookEvents)[number];
|
|
|
31
31
|
/**
|
|
32
32
|
* Create a Facebook Pixel integration instance
|
|
33
33
|
*/
|
|
34
|
-
export declare function createFacebookPixelIntegration(config: FacebookPixelConfig): Integration;
|
|
34
|
+
export declare function createFacebookPixelIntegration(config: FacebookPixelConfig, debug?: boolean): Integration;
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { LogLevel } from '../utils';
|
|
1
2
|
export type EventType = 'identify' | 'track';
|
|
2
3
|
export type AnalyticsContext = {
|
|
3
4
|
distinctId?: string | null;
|
|
@@ -26,7 +27,7 @@ export type Integration = {
|
|
|
26
27
|
/**
|
|
27
28
|
* The function to initialize the integration
|
|
28
29
|
*/
|
|
29
|
-
init?: () => Promise<void> | void;
|
|
30
|
+
init?: (context?: AnalyticsContext) => Promise<void> | void;
|
|
30
31
|
/**
|
|
31
32
|
* The function to track an event
|
|
32
33
|
*/
|
|
@@ -43,9 +44,9 @@ export type IntegrationState = {
|
|
|
43
44
|
};
|
|
44
45
|
export type ManagerConfig = {
|
|
45
46
|
/**
|
|
46
|
-
* Enable
|
|
47
|
+
* Enable logger level
|
|
47
48
|
*/
|
|
48
|
-
|
|
49
|
+
loggerLevel?: LogLevel;
|
|
49
50
|
/**
|
|
50
51
|
* Max queue size, once it exceeds this number, the oldest event will be dropped
|
|
51
52
|
*/
|
|
@@ -59,14 +60,6 @@ export type ManagerConfig = {
|
|
|
59
60
|
*/
|
|
60
61
|
flushInterval?: number;
|
|
61
62
|
};
|
|
62
|
-
export declare class Logger {
|
|
63
|
-
private label;
|
|
64
|
-
private debug;
|
|
65
|
-
constructor(label?: string, debug?: boolean);
|
|
66
|
-
log(...args: unknown[]): void;
|
|
67
|
-
warn(...args: unknown[]): void;
|
|
68
|
-
error(...args: unknown[]): void;
|
|
69
|
-
}
|
|
70
63
|
export declare class IntegrationManager {
|
|
71
64
|
private context;
|
|
72
65
|
private integrations;
|
|
@@ -121,5 +114,6 @@ export declare class IntegrationManager {
|
|
|
121
114
|
readyCount: number;
|
|
122
115
|
periodicFlushEnabled: boolean;
|
|
123
116
|
flushInterval: number;
|
|
117
|
+
context: AnalyticsContext;
|
|
124
118
|
};
|
|
125
119
|
}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { IntegrationConfigBase } from '../analytics';
|
|
2
|
+
import { Integration } from './integration-manager';
|
|
3
|
+
declare global {
|
|
4
|
+
interface Window {
|
|
5
|
+
pintrk?: Pintrk;
|
|
6
|
+
_pintrk?: Pintrk;
|
|
7
|
+
}
|
|
8
|
+
interface Pintrk {
|
|
9
|
+
(...args: any[]): void;
|
|
10
|
+
queue?: any[];
|
|
11
|
+
loaded?: boolean;
|
|
12
|
+
version?: string;
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
export type PinterestEventMapping = {
|
|
16
|
+
[key: string]: StandardPinterestEvent;
|
|
17
|
+
};
|
|
18
|
+
export type PinterestTagIntegrationConfig = IntegrationConfigBase & {
|
|
19
|
+
type: 'pinterest-tag';
|
|
20
|
+
config: PinterestTagConfig;
|
|
21
|
+
};
|
|
22
|
+
export type PinterestTagConfig = {
|
|
23
|
+
tagId: string;
|
|
24
|
+
eventMapping?: PinterestEventMapping;
|
|
25
|
+
automaticConfiguration?: boolean;
|
|
26
|
+
};
|
|
27
|
+
/**
|
|
28
|
+
* Standard Pinterest events
|
|
29
|
+
* Reference: https://www.pinterest.com/_/_/help/business/article/event-code
|
|
30
|
+
*/
|
|
31
|
+
export declare const standardPinterestEvents: readonly ["checkout", "addtocart", "pagevisit", "signup", "watchvideo", "lead", "search", "viewcategory", "custom", "addpaymentinfo", "addtowishlist", "initiatecheckout", "subscribe", "viewcontent"];
|
|
32
|
+
export type StandardPinterestEvent = (typeof standardPinterestEvents)[number];
|
|
33
|
+
/**
|
|
34
|
+
* Create a Pinterest Tag integration instance
|
|
35
|
+
* Documentation: https://help.pinterest.com/en/business/article/install-the-pinterest-tag
|
|
36
|
+
*/
|
|
37
|
+
export declare function createPinterestTagIntegration(config: PinterestTagConfig, debug?: boolean): Integration;
|
|
@@ -56,4 +56,4 @@ export type StandardTikTokEvent = (typeof standardTikTokEvents)[number];
|
|
|
56
56
|
/**
|
|
57
57
|
* Create a TikTok Pixel integration instance
|
|
58
58
|
*/
|
|
59
|
-
export declare function createTikTokPixelIntegration(config: TikTokPixelConfig): Integration;
|
|
59
|
+
export declare function createTikTokPixelIntegration(config: TikTokPixelConfig, debug?: boolean): Integration;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { LogLevel } from './logger';
|
|
2
|
+
export declare const isServer: boolean;
|
|
3
|
+
/**
|
|
4
|
+
* Get the logger level for a specific integration
|
|
5
|
+
* Supports URL parameters like saasco-debug-{integration-type}=true
|
|
6
|
+
* If debug is true or URL param is true, sets level to DEBUG (3), otherwise WARN
|
|
7
|
+
*/
|
|
8
|
+
export declare function getIntegrationLoggerLevel(integrationName: string, debug?: boolean): LogLevel;
|
package/src/lib/utils/index.d.ts
CHANGED
|
@@ -1,14 +1,21 @@
|
|
|
1
|
+
export declare enum LogLevel {
|
|
2
|
+
ERROR = 0,
|
|
3
|
+
WARN = 1,
|
|
4
|
+
INFO = 2,
|
|
5
|
+
DEBUG = 3
|
|
6
|
+
}
|
|
1
7
|
export type AnalyticsLoggerConfig = {
|
|
2
|
-
|
|
8
|
+
level: LogLevel;
|
|
3
9
|
label: string;
|
|
4
10
|
};
|
|
5
11
|
export declare class AnalyticsLogger {
|
|
6
12
|
private config;
|
|
7
13
|
constructor(config: AnalyticsLoggerConfig);
|
|
14
|
+
debug(...args: any[]): void;
|
|
8
15
|
/**
|
|
9
16
|
* Log debug information
|
|
10
17
|
*/
|
|
11
|
-
|
|
18
|
+
info(...args: any[]): void;
|
|
12
19
|
/**
|
|
13
20
|
* Log warning information
|
|
14
21
|
*/
|