@amplitude/analytics-types 0.1.0

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 (70) hide show
  1. package/README.md +1 -0
  2. package/lib/amplitude-promise.d.ts +4 -0
  3. package/lib/amplitude-promise.d.ts.map +1 -0
  4. package/lib/amplitude-promise.js +2 -0
  5. package/lib/amplitude-promise.js.map +1 -0
  6. package/lib/base-event.d.ts +52 -0
  7. package/lib/base-event.d.ts.map +1 -0
  8. package/lib/base-event.js +2 -0
  9. package/lib/base-event.js.map +1 -0
  10. package/lib/config.d.ts +68 -0
  11. package/lib/config.d.ts.map +1 -0
  12. package/lib/config.js +8 -0
  13. package/lib/config.js.map +1 -0
  14. package/lib/destination-context.d.ts +9 -0
  15. package/lib/destination-context.d.ts.map +1 -0
  16. package/lib/destination-context.js +2 -0
  17. package/lib/destination-context.js.map +1 -0
  18. package/lib/event-callback.d.ts +3 -0
  19. package/lib/event-callback.d.ts.map +1 -0
  20. package/lib/event-callback.js +2 -0
  21. package/lib/event-callback.js.map +1 -0
  22. package/lib/event.d.ts +105 -0
  23. package/lib/event.d.ts.map +1 -0
  24. package/lib/event.js +38 -0
  25. package/lib/event.js.map +1 -0
  26. package/lib/index.d.ts +16 -0
  27. package/lib/index.d.ts.map +1 -0
  28. package/lib/index.js +17 -0
  29. package/lib/index.js.map +1 -0
  30. package/lib/logger.d.ts +14 -0
  31. package/lib/logger.d.ts.map +1 -0
  32. package/lib/logger.js +10 -0
  33. package/lib/logger.js.map +1 -0
  34. package/lib/payload.d.ts +10 -0
  35. package/lib/payload.d.ts.map +1 -0
  36. package/lib/payload.js +2 -0
  37. package/lib/payload.js.map +1 -0
  38. package/lib/plan.d.ts +12 -0
  39. package/lib/plan.d.ts.map +1 -0
  40. package/lib/plan.js +2 -0
  41. package/lib/plan.js.map +1 -0
  42. package/lib/plugin.d.ts +28 -0
  43. package/lib/plugin.d.ts.map +1 -0
  44. package/lib/plugin.js +9 -0
  45. package/lib/plugin.js.map +1 -0
  46. package/lib/response.d.ts +84 -0
  47. package/lib/response.d.ts.map +1 -0
  48. package/lib/response.js +2 -0
  49. package/lib/response.js.map +1 -0
  50. package/lib/result.d.ts +7 -0
  51. package/lib/result.d.ts.map +1 -0
  52. package/lib/result.js +2 -0
  53. package/lib/result.js.map +1 -0
  54. package/lib/status.d.ts +22 -0
  55. package/lib/status.d.ts.map +1 -0
  56. package/lib/status.js +25 -0
  57. package/lib/status.js.map +1 -0
  58. package/lib/storage.d.ts +21 -0
  59. package/lib/storage.d.ts.map +1 -0
  60. package/lib/storage.js +2 -0
  61. package/lib/storage.js.map +1 -0
  62. package/lib/transport.d.ts +11 -0
  63. package/lib/transport.d.ts.map +1 -0
  64. package/lib/transport.js +9 -0
  65. package/lib/transport.js.map +1 -0
  66. package/lib/utm.d.ts +8 -0
  67. package/lib/utm.d.ts.map +1 -0
  68. package/lib/utm.js +2 -0
  69. package/lib/utm.js.map +1 -0
  70. package/package.json +34 -0
package/README.md ADDED
@@ -0,0 +1 @@
1
+ # @amplitude/analytics-types
@@ -0,0 +1,4 @@
1
+ export interface AmplitudeReturn<T> {
2
+ promise: Promise<T>;
3
+ }
4
+ //# sourceMappingURL=amplitude-promise.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"amplitude-promise.d.ts","sourceRoot":"","sources":["../src/amplitude-promise.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,eAAe,CAAC,CAAC;IAChC,OAAO,EAAE,OAAO,CAAC,CAAC,CAAC,CAAC;CACrB"}
@@ -0,0 +1,2 @@
1
+ Object.defineProperty(exports, "__esModule", { value: true });
2
+ //# sourceMappingURL=amplitude-promise.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"amplitude-promise.js","sourceRoot":"","sources":["../src/amplitude-promise.ts"],"names":[],"mappings":"","sourcesContent":["export interface AmplitudeReturn<T> {\n promise: Promise<T>;\n}\n"]}
@@ -0,0 +1,52 @@
1
+ import { Plan } from './plan';
2
+ export interface BaseEvent extends EventOptions {
3
+ event_type: string;
4
+ event_properties?: {
5
+ [key: string]: any;
6
+ };
7
+ user_properties?: {
8
+ [key: string]: any;
9
+ };
10
+ groups?: {
11
+ [key: string]: any;
12
+ };
13
+ }
14
+ export interface EventOptions {
15
+ user_id?: string;
16
+ device_id?: string;
17
+ time?: number;
18
+ location_lat?: number;
19
+ location_lng?: number;
20
+ app_version?: string;
21
+ version_name?: string;
22
+ library?: string;
23
+ platform?: string;
24
+ os_name?: string;
25
+ os_version?: string;
26
+ device_brand?: string;
27
+ device_manufacturer?: string;
28
+ device_model?: string;
29
+ carrier?: string;
30
+ country?: string;
31
+ region?: string;
32
+ city?: string;
33
+ dma?: string;
34
+ idfa?: string;
35
+ idfv?: string;
36
+ adid?: string;
37
+ android_id?: string;
38
+ language?: string;
39
+ ip?: string;
40
+ uuid?: string;
41
+ price?: number;
42
+ quantity?: number;
43
+ revenue?: number;
44
+ productId?: string;
45
+ revenueType?: string;
46
+ event_id?: number;
47
+ session_id?: number;
48
+ insert_id?: string;
49
+ plan?: Plan;
50
+ partner_id?: string;
51
+ }
52
+ //# sourceMappingURL=base-event.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"base-event.d.ts","sourceRoot":"","sources":["../src/base-event.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,QAAQ,CAAC;AAE9B,MAAM,WAAW,SAAU,SAAQ,YAAY;IAC7C,UAAU,EAAE,MAAM,CAAC;IACnB,gBAAgB,CAAC,EAAE;QAAE,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,CAAA;KAAE,CAAC;IAC1C,eAAe,CAAC,EAAE;QAAE,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,CAAA;KAAE,CAAC;IACzC,MAAM,CAAC,EAAE;QAAE,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,CAAA;KAAE,CAAC;CACjC;AAED,MAAM,WAAW,YAAY;IAC3B,OAAO,C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AAE,IAAI,CAAC;IACZ,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB"}
@@ -0,0 +1,2 @@
1
+ Object.defineProperty(exports, "__esModule", { value: true });
2
+ //# sourceMappingURL=base-event.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"base-event.js","sourceRoot":"","sources":["../src/base-event.ts"],"names":[],"mappings":"","sourcesContent":["import { Plan } from './plan';\n\nexport interface BaseEvent extends EventOptions {\n event_type: string;\n event_properties?: { [key: string]: any };\n user_properties?: { [key: string]: any };\n groups?: { [key: string]: any };\n}\n\nexport interface EventOptions {\n user_id?: string;\n device_id?: string;\n time?: number;\n location_lat?: number;\n location_lng?: number;\n app_version?: string;\n version_name?: string;\n library?: string;\n platform?: string;\n os_name?: string;\n os_version?: string;\n device_brand?: string;\n device_manufacturer?: string;\n device_model?: string;\n carrier?: string;\n country?: string;\n region?: string;\n city?: string;\n dma?: string;\n idfa?: string;\n idfv?: string;\n adid?: string;\n android_id?: string;\n language?: string;\n ip?: string;\n uuid?: string;\n price?: number;\n quantity?: number;\n revenue?: number;\n productId?: string;\n revenueType?: string;\n event_id?: number;\n session_id?: number;\n insert_id?: string;\n plan?: Plan;\n partner_id?: string;\n}\n"]}
@@ -0,0 +1,68 @@
1
+ import { LogLevel, Logger } from './logger';
2
+ import { Storage, UserSession } from './storage';
3
+ import { Event } from './event';
4
+ import { Transport, TransportType } from './transport';
5
+ import { Plugin } from './plugin';
6
+ export declare enum ServerZone {
7
+ US = "US",
8
+ EU = "EU"
9
+ }
10
+ export interface Config {
11
+ appVersion?: string;
12
+ apiKey: string;
13
+ userId?: string;
14
+ deviceId?: string;
15
+ sessionId?: number;
16
+ flushIntervalMillis: number;
17
+ flushMaxRetries: number;
18
+ flushQueueSize: number;
19
+ logLevel: LogLevel;
20
+ loggerProvider: Logger;
21
+ optOut: boolean;
22
+ saveEvents: boolean;
23
+ serverUrl: string | undefined;
24
+ serverZone: ServerZone;
25
+ storageProvider: Storage<Event[]>;
26
+ transportProvider: Transport;
27
+ partnerId?: string;
28
+ plugins: Plugin[];
29
+ useBatch: boolean;
30
+ }
31
+ export interface BrowserConfig extends Config {
32
+ cookieExpiration: number;
33
+ cookieSameSite: string;
34
+ cookieSecure: boolean;
35
+ cookieStorage: Storage<UserSession>;
36
+ disableCookies: boolean;
37
+ domain: string;
38
+ includeGclid: boolean;
39
+ includeFbclid: boolean;
40
+ includeReferrer: boolean;
41
+ includeUtm: boolean;
42
+ sessionTimeout: number;
43
+ trackingOptions: TrackingOptions;
44
+ }
45
+ export declare type InitOptions<T extends Config> = Partial<Config> & Omit<T, keyof Config> & {
46
+ apiKey: string;
47
+ transportProvider: Transport;
48
+ storageProvider: Storage<Event[]>;
49
+ };
50
+ export declare type TrackingOptions = {
51
+ city?: boolean;
52
+ country?: boolean;
53
+ carrier?: boolean;
54
+ deviceManufacturer?: boolean;
55
+ deviceModel?: boolean;
56
+ dma?: boolean;
57
+ ipAddress?: boolean;
58
+ language?: boolean;
59
+ osName?: boolean;
60
+ osVersion?: boolean;
61
+ platform?: boolean;
62
+ region?: boolean;
63
+ versionName?: boolean;
64
+ };
65
+ export declare type BrowserOptions = Omit<Partial<BrowserConfig & {
66
+ transport: TransportType;
67
+ }>, 'apiKey' | 'userId' | 'plugins'>;
68
+ //# sourceMappingURL=config.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAC5C,OAAO,EAAE,OAAO,EAAE,WAAW,EAAE,MAAM,WAAW,CAAC;AAEjD,OAAO,EAAE,KAAK,EAAE,MAAM,SAAS,CAAC;AAChC,OAAO,EAAE,SAAS,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AACvD,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAElC,oBAAY,UAAU;IACpB,EAAE,OAAO;IACT,EAAE,OAAO;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GAAG;IACtB,MAAM,EAAE,MAAM,CAAC;IACf,iBAAiB,EAAE,SAAS,CAAC;IAC7B,eAAe,EAAE,OAAO,CAAC,KAAK,EAAE,CAAC,CAAC;CACnC,CAAC;AAER,oBAAY,eAAe,GAAG;IAC5B,IAAI,CAAC,EAAE,OAAO,CAAC;IACf,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,kBAAkB,CAAC,EAAE,OAAO,CAAC;IAC7B,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,GAAG,CAAC,EAAE,OAAO,CAAC;IACd,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,WAAW,CAAC,EAAE,OAAO,CAAC;CACvB,CAAC;AAEF,oBAAY,cAAc,GAAG,IAAI,CAC/B,OAAO,CACL,aAAa,GAAG;IACd,SAAS,EAAE,aAAa,CAAC;CAC1B,CACF,EACD,QAAQ,GAAG,QAAQ,GAAG,SAAS,CAChC,CAAC"}
package/lib/config.js ADDED
@@ -0,0 +1,8 @@
1
+ Object.defineProperty(exports, "__esModule", { value: true });
2
+ exports.ServerZone = void 0;
3
+ var ServerZone;
4
+ (function (ServerZone) {
5
+ ServerZone["US"] = "US";
6
+ ServerZone["EU"] = "EU";
7
+ })(ServerZone = exports.ServerZone || (exports.ServerZone = {}));
8
+ //# sourceMappingURL=config.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"config.js","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":";;AAOA,IAAY,UAGX;AAHD,WAAY,UAAU;IACpB,uBAAS,CAAA;IACT,uBAAS,CAAA;AACX,CAAC,EAHW,UAAU,GAAV,kBAAU,KAAV,kBAAU,QAGrB","sourcesContent":["import { LogLevel, Logger } from './logger';\nimport { Storage, UserSession } from './storage';\n\nimport { Event } from './event';\nimport { Transport, TransportType } from './transport';\nimport { Plugin } from './plugin';\n\nexport enum ServerZone {\n US = 'US',\n EU = 'EU',\n}\n\nexport interface Config {\n appVersion?: string;\n apiKey: string;\n userId?: string;\n deviceId?: string;\n sessionId?: number;\n flushIntervalMillis: number;\n flushMaxRetries: number;\n flushQueueSize: number;\n logLevel: LogLevel;\n loggerProvider: Logger;\n optOut: boolean;\n saveEvents: boolean;\n serverUrl: string | undefined;\n serverZone: ServerZone;\n storageProvider: Storage<Event[]>;\n transportProvider: Transport;\n partnerId?: string;\n plugins: Plugin[];\n useBatch: boolean;\n}\n\nexport interface BrowserConfig extends Config {\n cookieExpiration: number;\n cookieSameSite: string;\n cookieSecure: boolean;\n cookieStorage: Storage<UserSession>;\n disableCookies: boolean;\n domain: string;\n includeGclid: boolean;\n includeFbclid: boolean;\n includeReferrer: boolean;\n includeUtm: boolean;\n sessionTimeout: number;\n trackingOptions: TrackingOptions;\n}\n\nexport type InitOptions<T extends Config> =\n | Partial<Config> &\n Omit<T, keyof Config> & {\n apiKey: string;\n transportProvider: Transport;\n storageProvider: Storage<Event[]>;\n };\n\nexport type TrackingOptions = {\n city?: boolean;\n country?: boolean;\n carrier?: boolean;\n deviceManufacturer?: boolean;\n deviceModel?: boolean;\n dma?: boolean;\n ipAddress?: boolean;\n language?: boolean;\n osName?: boolean;\n osVersion?: boolean;\n platform?: boolean;\n region?: boolean;\n versionName?: boolean;\n};\n\nexport type BrowserOptions = Omit<\n Partial<\n BrowserConfig & {\n transport: TransportType;\n }\n >,\n 'apiKey' | 'userId' | 'plugins'\n>;\n"]}
@@ -0,0 +1,9 @@
1
+ import { Event } from './event';
2
+ import { EventCallback } from './event-callback';
3
+ export interface DestinationContext {
4
+ event: Event;
5
+ attempts: number;
6
+ callback: EventCallback;
7
+ delay: number;
8
+ }
9
+ //# sourceMappingURL=destination-context.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"destination-context.d.ts","sourceRoot":"","sources":["../src/destination-context.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,SAAS,CAAC;AAChC,OAAO,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AAEjD,MAAM,WAAW,kBAAkB;IACjC,KAAK,EAAE,KAAK,CAAC;IACb,QAAQ,EAAE,MAAM,CAAC;IACjB,QAAQ,EAAE,aAAa,CAAC;IACxB,KAAK,EAAE,MAAM,CAAC;CACf"}
@@ -0,0 +1,2 @@
1
+ Object.defineProperty(exports, "__esModule", { value: true });
2
+ //# sourceMappingURL=destination-context.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"destination-context.js","sourceRoot":"","sources":["../src/destination-context.ts"],"names":[],"mappings":"","sourcesContent":["import { Event } from './event';\nimport { EventCallback } from './event-callback';\n\nexport interface DestinationContext {\n event: Event;\n attempts: number;\n callback: EventCallback;\n delay: number;\n}\n"]}
@@ -0,0 +1,3 @@
1
+ import { Result } from './result';
2
+ export declare type EventCallback = (result: Result) => void;
3
+ //# sourceMappingURL=event-callback.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"event-callback.d.ts","sourceRoot":"","sources":["../src/event-callback.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAElC,oBAAY,aAAa,GAAG,CAAC,MAAM,EAAE,MAAM,KAAK,IAAI,CAAC"}
@@ -0,0 +1,2 @@
1
+ Object.defineProperty(exports, "__esModule", { value: true });
2
+ //# sourceMappingURL=event-callback.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"event-callback.js","sourceRoot":"","sources":["../src/event-callback.ts"],"names":[],"mappings":"","sourcesContent":["import { Result } from './result';\n\nexport type EventCallback = (result: Result) => void;\n"]}
package/lib/event.d.ts ADDED
@@ -0,0 +1,105 @@
1
+ import { BaseEvent } from './base-event';
2
+ export interface Identify {
3
+ getUserProperties(): IdentifyUserProperties;
4
+ set(property: string, value: ValidPropertyType): Identify;
5
+ setOnce(property: string, value: ValidPropertyType): Identify;
6
+ append(property: string, value: ValidPropertyType): Identify;
7
+ prepend(property: string, value: ValidPropertyType): Identify;
8
+ postInsert(property: string, value: ValidPropertyType): Identify;
9
+ preInsert(property: string, value: ValidPropertyType): Identify;
10
+ remove(property: string, value: ValidPropertyType): Identify;
11
+ add(property: string, value: number): Identify;
12
+ unset(property: string): Identify;
13
+ clearAll(): Identify;
14
+ }
15
+ export declare enum IdentifyOperation {
16
+ SET = "$set",
17
+ SET_ONCE = "$setOnce",
18
+ ADD = "$add",
19
+ APPEND = "$append",
20
+ PREPEND = "$prepend",
21
+ REMOVE = "$remove",
22
+ PREINSERT = "$preInsert",
23
+ POSTINSERT = "$postInsert",
24
+ UNSET = "$unset",
25
+ CLEAR_ALL = "$clearAll"
26
+ }
27
+ export declare type ValidPropertyType = number | string | boolean | Array<string | number> | {
28
+ [key: string]: ValidPropertyType;
29
+ };
30
+ interface BaseOperationConfig {
31
+ [key: string]: ValidPropertyType;
32
+ }
33
+ export interface IdentifyUserProperties {
34
+ [IdentifyOperation.ADD]?: {
35
+ [key: string]: number;
36
+ };
37
+ [IdentifyOperation.UNSET]?: BaseOperationConfig;
38
+ [IdentifyOperation.CLEAR_ALL]?: any;
39
+ [IdentifyOperation.SET]?: BaseOperationConfig;
40
+ [IdentifyOperation.SET_ONCE]?: BaseOperationConfig;
41
+ [IdentifyOperation.APPEND]?: BaseOperationConfig;
42
+ [IdentifyOperation.PREPEND]?: BaseOperationConfig;
43
+ [IdentifyOperation.POSTINSERT]?: BaseOperationConfig;
44
+ [IdentifyOperation.PREINSERT]?: BaseOperationConfig;
45
+ [IdentifyOperation.REMOVE]?: BaseOperationConfig;
46
+ }
47
+ export interface Revenue {
48
+ getEventProperties(): RevenueEventProperties;
49
+ setProductId(productId: string): Revenue;
50
+ setQuantity(quantity: number): Revenue;
51
+ setPrice(price: number): Revenue;
52
+ setRevenueType(revenueType: string): Revenue;
53
+ setEventProperties(properties: {
54
+ [key: string]: any;
55
+ }): Revenue;
56
+ setRevenue(revenue: number): Revenue;
57
+ }
58
+ export declare enum RevenueProperty {
59
+ REVENUE_PRODUCT_ID = "$productId",
60
+ REVENUE_QUANTITY = "$quantity",
61
+ REVENUE_PRICE = "$price",
62
+ REVENUE_TYPE = "$revenueType",
63
+ REVENUE = "$revenue"
64
+ }
65
+ export interface RevenueEventProperties {
66
+ [RevenueProperty.REVENUE_PRODUCT_ID]?: string;
67
+ [RevenueProperty.REVENUE_QUANTITY]?: number;
68
+ [RevenueProperty.REVENUE_PRICE]?: number;
69
+ [RevenueProperty.REVENUE_TYPE]?: string;
70
+ [RevenueProperty.REVENUE_TYPE]?: string;
71
+ [RevenueProperty.REVENUE]?: number;
72
+ }
73
+ /**
74
+ * Strings that have special meaning when used as an event's type
75
+ * and have different specifications.
76
+ */
77
+ export declare enum SpecialEventType {
78
+ IDENTIFY = "$identify",
79
+ GROUP_IDENTIFY = "$groupidentify",
80
+ REVENUE = "revenue_amount"
81
+ }
82
+ export interface TrackEvent extends BaseEvent {
83
+ event_type: Exclude<string, SpecialEventType>;
84
+ }
85
+ export interface IdentifyEvent extends BaseEvent {
86
+ event_type: SpecialEventType.IDENTIFY;
87
+ user_properties: IdentifyUserProperties | {
88
+ [key in Exclude<string, IdentifyOperation>]: any;
89
+ };
90
+ }
91
+ export interface GroupIdentifyEvent extends BaseEvent {
92
+ event_type: SpecialEventType.GROUP_IDENTIFY;
93
+ group_properties: IdentifyUserProperties | {
94
+ [key in Exclude<string, IdentifyOperation>]: any;
95
+ };
96
+ }
97
+ export interface RevenueEvent extends BaseEvent {
98
+ event_type: SpecialEventType.REVENUE;
99
+ event_properties: RevenueEventProperties | {
100
+ [key: string]: any;
101
+ };
102
+ }
103
+ export declare type Event = TrackEvent | IdentifyEvent | GroupIdentifyEvent | RevenueEvent;
104
+ export {};
105
+ //# sourceMappingURL=event.d.ts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C,GAAG,GAAG;KACjD,CAAC;CACP;AAED,MAAM,WAAW,YAAa,SAAQ,SAAS;IAC7C,UAAU,EAAE,gBAAgB,CAAC,OAAO,CAAC;IACrC,gBAAgB,EACZ,sBAAsB,GACtB;QACE,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,CAAC;KACpB,CAAC;CACP;AAED,oBAAY,KAAK,GAAG,UAAU,GAAG,aAAa,GAAG,kBAAkB,GAAG,YAAY,CAAC"}
package/lib/event.js ADDED
@@ -0,0 +1,38 @@
1
+ Object.defineProperty(exports, "__esModule", { value: true });
2
+ exports.SpecialEventType = exports.RevenueProperty = exports.IdentifyOperation = void 0;
3
+ var IdentifyOperation;
4
+ (function (IdentifyOperation) {
5
+ // Base Operations to set values
6
+ IdentifyOperation["SET"] = "$set";
7
+ IdentifyOperation["SET_ONCE"] = "$setOnce";
8
+ // Operations around modifying existing values
9
+ IdentifyOperation["ADD"] = "$add";
10
+ IdentifyOperation["APPEND"] = "$append";
11
+ IdentifyOperation["PREPEND"] = "$prepend";
12
+ IdentifyOperation["REMOVE"] = "$remove";
13
+ // Operations around appending values *if* they aren't present
14
+ IdentifyOperation["PREINSERT"] = "$preInsert";
15
+ IdentifyOperation["POSTINSERT"] = "$postInsert";
16
+ // Operations around removing properties/values
17
+ IdentifyOperation["UNSET"] = "$unset";
18
+ IdentifyOperation["CLEAR_ALL"] = "$clearAll";
19
+ })(IdentifyOperation = exports.IdentifyOperation || (exports.IdentifyOperation = {}));
20
+ var RevenueProperty;
21
+ (function (RevenueProperty) {
22
+ RevenueProperty["REVENUE_PRODUCT_ID"] = "$productId";
23
+ RevenueProperty["REVENUE_QUANTITY"] = "$quantity";
24
+ RevenueProperty["REVENUE_PRICE"] = "$price";
25
+ RevenueProperty["REVENUE_TYPE"] = "$revenueType";
26
+ RevenueProperty["REVENUE"] = "$revenue";
27
+ })(RevenueProperty = exports.RevenueProperty || (exports.RevenueProperty = {}));
28
+ /**
29
+ * Strings that have special meaning when used as an event's type
30
+ * and have different specifications.
31
+ */
32
+ var SpecialEventType;
33
+ (function (SpecialEventType) {
34
+ SpecialEventType["IDENTIFY"] = "$identify";
35
+ SpecialEventType["GROUP_IDENTIFY"] = "$groupidentify";
36
+ SpecialEventType["REVENUE"] = "revenue_amount";
37
+ })(SpecialEventType = exports.SpecialEventType || (exports.SpecialEventType = {}));
38
+ //# sourceMappingURL=event.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"event.js","sourceRoot":"","sources":["../src/event.ts"],"names":[],"mappings":";;AAgBA,IAAY,iBAkBX;AAlBD,WAAY,iBAAiB;IAC3B,gCAAgC;IAChC,iCAAY,CAAA;IACZ,0CAAqB,CAAA;IAErB,8CAA8C;IAC9C,iCAAY,CAAA;IACZ,uCAAkB,CAAA;IAClB,yCAAoB,CAAA;IACpB,uCAAkB,CAAA;IAElB,8DAA8D;IAC9D,6CAAwB,CAAA;IACxB,+CAA0B,CAAA;IAE1B,+CAA+C;IAC/C,qCAAgB,CAAA;IAChB,4CAAuB,CAAA;AACzB,CAAC,EAlBW,iBAAiB,GAAjB,yBAAiB,KAAjB,yBAAiB,QAkB5B;AA0CD,IAAY,eAMX;AAND,WAAY,eAAe;IACzB,oDAAiC,CAAA;IACjC,iDAA8B,CAAA;IAC9B,2CAAwB,CAAA;IACxB,gDAA6B,CAAA;IAC7B,uCAAoB,CAAA;AACtB,CAAC,EANW,eAAe,GAAf,uBAAe,KAAf,uBAAe,QAM1B;AAWD;;;GAGG;AACH,IAAY,gBAIX;AAJD,WAAY,gBAAgB;IAC1B,0CAAsB,CAAA;IACtB,qDAAiC,CAAA;IACjC,8CAA0B,CAAA;AAC5B,CAAC,EAJW,gBAAgB,GAAhB,wBAAgB,KAAhB,wBAAgB,QAI3B","sourcesContent":["import { BaseEvent } from './base-event';\n\nexport interface Identify {\n getUserProperties(): IdentifyUserProperties;\n set(property: string, value: ValidPropertyType): Identify;\n setOnce(property: string, value: ValidPropertyType): Identify;\n append(property: string, value: ValidPropertyType): Identify;\n prepend(property: string, value: ValidPropertyType): Identify;\n postInsert(property: string, value: ValidPropertyType): Identify;\n preInsert(property: string, value: ValidPropertyType): Identify;\n remove(property: string, value: ValidPropertyType): Identify;\n add(property: string, value: number): Identify;\n unset(property: string): Identify;\n clearAll(): Identify;\n}\n\nexport enum IdentifyOperation {\n // Base Operations to set values\n SET = '$set',\n SET_ONCE = '$setOnce',\n\n // Operations around modifying existing values\n ADD = '$add',\n APPEND = '$append',\n PREPEND = '$prepend',\n REMOVE = '$remove',\n\n // Operations around appending values *if* they aren't present\n PREINSERT = '$preInsert',\n POSTINSERT = '$postInsert',\n\n // Operations around removing properties/values\n UNSET = '$unset',\n CLEAR_ALL = '$clearAll',\n}\n\nexport type ValidPropertyType =\n | number\n | string\n | boolean\n | Array<string | number>\n | { [key: string]: ValidPropertyType };\n\ninterface BaseOperationConfig {\n [key: string]: ValidPropertyType;\n}\n\nexport interface IdentifyUserProperties {\n // Add operations can only take numbers\n [IdentifyOperation.ADD]?: { [key: string]: number };\n\n // This reads the keys of the passed object, but the values are not used\n [IdentifyOperation.UNSET]?: BaseOperationConfig;\n // This option does not read the key as it unsets all user properties\n [IdentifyOperation.CLEAR_ALL]?: any;\n\n // These operations can take numbers, strings, or arrays of both.\n [IdentifyOperation.SET]?: BaseOperationConfig;\n [IdentifyOperation.SET_ONCE]?: BaseOperationConfig;\n [IdentifyOperation.APPEND]?: BaseOperationConfig;\n [IdentifyOperation.PREPEND]?: BaseOperationConfig;\n [IdentifyOperation.POSTINSERT]?: BaseOperationConfig;\n [IdentifyOperation.PREINSERT]?: BaseOperationConfig;\n [IdentifyOperation.REMOVE]?: BaseOperationConfig;\n}\n\nexport interface Revenue {\n getEventProperties(): RevenueEventProperties;\n setProductId(productId: string): Revenue;\n setQuantity(quantity: number): Revenue;\n setPrice(price: number): Revenue;\n setRevenueType(revenueType: string): Revenue;\n setEventProperties(properties: { [key: string]: any }): Revenue;\n setRevenue(revenue: number): Revenue;\n}\n\nexport enum RevenueProperty {\n REVENUE_PRODUCT_ID = '$productId',\n REVENUE_QUANTITY = '$quantity',\n REVENUE_PRICE = '$price',\n REVENUE_TYPE = '$revenueType',\n REVENUE = '$revenue',\n}\n\nexport interface RevenueEventProperties {\n [RevenueProperty.REVENUE_PRODUCT_ID]?: string;\n [RevenueProperty.REVENUE_QUANTITY]?: number;\n [RevenueProperty.REVENUE_PRICE]?: number;\n [RevenueProperty.REVENUE_TYPE]?: string;\n [RevenueProperty.REVENUE_TYPE]?: string;\n [RevenueProperty.REVENUE]?: number;\n}\n\n/**\n * Strings that have special meaning when used as an event's type\n * and have different specifications.\n */\nexport enum SpecialEventType {\n IDENTIFY = '$identify',\n GROUP_IDENTIFY = '$groupidentify',\n REVENUE = 'revenue_amount',\n}\n\nexport interface TrackEvent extends BaseEvent {\n event_type: Exclude<string, SpecialEventType>;\n}\n\nexport interface IdentifyEvent extends BaseEvent {\n event_type: SpecialEventType.IDENTIFY;\n user_properties:\n | IdentifyUserProperties\n | {\n [key in Exclude<string, IdentifyOperation>]: any;\n };\n}\n\nexport interface GroupIdentifyEvent extends BaseEvent {\n event_type: SpecialEventType.GROUP_IDENTIFY;\n group_properties:\n | IdentifyUserProperties\n | {\n [key in Exclude<string, IdentifyOperation>]: any;\n };\n}\n\nexport interface RevenueEvent extends BaseEvent {\n event_type: SpecialEventType.REVENUE;\n event_properties:\n | RevenueEventProperties\n | {\n [key: string]: any;\n };\n}\n\nexport type Event = TrackEvent | IdentifyEvent | GroupIdentifyEvent | RevenueEvent;\n"]}
package/lib/index.d.ts ADDED
@@ -0,0 +1,16 @@
1
+ export { AmplitudeReturn } from './amplitude-promise';
2
+ export { BaseEvent, EventOptions } from './base-event';
3
+ export { BrowserConfig, BrowserOptions, Config, InitOptions, TrackingOptions, ServerZone } from './config';
4
+ export { DestinationContext } from './destination-context';
5
+ export { Event, TrackEvent, IdentifyEvent, GroupIdentifyEvent, SpecialEventType, IdentifyOperation, IdentifyUserProperties, ValidPropertyType, Identify, Revenue, RevenueEvent, RevenueProperty, RevenueEventProperties, } from './event';
6
+ export { EventCallback } from './event-callback';
7
+ export { Logger, LogLevel } from './logger';
8
+ export { Payload } from './payload';
9
+ export { Plugin, BeforePlugin, EnrichmentPlugin, DestinationPlugin, PluginType } from './plugin';
10
+ export { Result } from './result';
11
+ export { Response, SuccessResponse, InvalidResponse, PayloadTooLargeResponse, RateLimitResponse } from './response';
12
+ export { Status } from './status';
13
+ export { CookieStorageOptions, Storage, UserSession } from './storage';
14
+ export { Transport, TransportType } from './transport';
15
+ export { UTMData } from './utm';
16
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AACtD,OAAO,EAAE,SAAS,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AACvD,OAAO,EAAE,aAAa,EAAE,cAAc,EAAE,MAAM,EAAE,WAAW,EAAE,eAAe,EAAE,UAAU,EAAE,MAAM,UAAU,CAAC;AAC3G,OAAO,EAAE,kBAAkB,EAAE,MAAM,uBAAuB,CAAC;AAC3D,OAAO,EACL,KAAK,EACL,UAAU,EACV,aAAa,EACb,kBAAkB,EAClB,gBAAgB,EAChB,iBAAiB,EACjB,sBAAsB,EACtB,iBAAiB,EACjB,QAAQ,EACR,OAAO,EACP,YAAY,EACZ,eAAe,EACf,sBAAsB,GACvB,MAAM,SAAS,CAAC;AACjB,OAAO,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AACjD,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,UAAU,CAAC;AAC5C,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,MAAM,EAAE,YAAY,EAAE,gBAAgB,EAAE,iBAAiB,EAAE,UAAU,EAAE,MAAM,UAAU,CAAC;AACjG,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAClC,OAAO,EAAE,QAAQ,EAAE,eAAe,EAAE,eAAe,EAAE,uBAAuB,EAAE,iBAAiB,EAAE,MAAM,YAAY,CAAC;AACpH,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAClC,OAAO,EAAE,oBAAoB,EAAE,OAAO,EAAE,WAAW,EAAE,MAAM,WAAW,CAAC;AACvE,OAAO,EAAE,SAAS,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AACvD,OAAO,EAAE,OAAO,EAAE,MAAM,OAAO,CAAC"}
package/lib/index.js ADDED
@@ -0,0 +1,17 @@
1
+ Object.defineProperty(exports, "__esModule", { value: true });
2
+ exports.TransportType = exports.Status = exports.PluginType = exports.LogLevel = exports.RevenueProperty = exports.IdentifyOperation = exports.SpecialEventType = exports.ServerZone = void 0;
3
+ var config_1 = require("./config");
4
+ Object.defineProperty(exports, "ServerZone", { enumerable: true, get: function () { return config_1.ServerZone; } });
5
+ var event_1 = require("./event");
6
+ Object.defineProperty(exports, "SpecialEventType", { enumerable: true, get: function () { return event_1.SpecialEventType; } });
7
+ Object.defineProperty(exports, "IdentifyOperation", { enumerable: true, get: function () { return event_1.IdentifyOperation; } });
8
+ Object.defineProperty(exports, "RevenueProperty", { enumerable: true, get: function () { return event_1.RevenueProperty; } });
9
+ var logger_1 = require("./logger");
10
+ Object.defineProperty(exports, "LogLevel", { enumerable: true, get: function () { return logger_1.LogLevel; } });
11
+ var plugin_1 = require("./plugin");
12
+ Object.defineProperty(exports, "PluginType", { enumerable: true, get: function () { return plugin_1.PluginType; } });
13
+ var status_1 = require("./status");
14
+ Object.defineProperty(exports, "Status", { enumerable: true, get: function () { return status_1.Status; } });
15
+ var transport_1 = require("./transport");
16
+ Object.defineProperty(exports, "TransportType", { enumerable: true, get: function () { return transport_1.TransportType; } });
17
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;AAEA,mCAA2G;AAA7B,oGAAA,UAAU,OAAA;AAExF,iCAciB;AATf,yGAAA,gBAAgB,OAAA;AAChB,0GAAA,iBAAiB,OAAA;AAMjB,wGAAA,eAAe,OAAA;AAIjB,mCAA4C;AAA3B,kGAAA,QAAQ,OAAA;AAEzB,mCAAiG;AAA7B,oGAAA,UAAU,OAAA;AAG9E,mCAAkC;AAAzB,gGAAA,MAAM,OAAA;AAEf,yCAAuD;AAAnC,0GAAA,aAAa,OAAA","sourcesContent":["export { AmplitudeReturn } from './amplitude-promise';\nexport { BaseEvent, EventOptions } from './base-event';\nexport { BrowserConfig, BrowserOptions, Config, InitOptions, TrackingOptions, ServerZone } from './config';\nexport { DestinationContext } from './destination-context';\nexport {\n Event,\n TrackEvent,\n IdentifyEvent,\n GroupIdentifyEvent,\n SpecialEventType,\n IdentifyOperation,\n IdentifyUserProperties,\n ValidPropertyType,\n Identify,\n Revenue,\n RevenueEvent,\n RevenueProperty,\n RevenueEventProperties,\n} from './event';\nexport { EventCallback } from './event-callback';\nexport { Logger, LogLevel } from './logger';\nexport { Payload } from './payload';\nexport { Plugin, BeforePlugin, EnrichmentPlugin, DestinationPlugin, PluginType } from './plugin';\nexport { Result } from './result';\nexport { Response, SuccessResponse, InvalidResponse, PayloadTooLargeResponse, RateLimitResponse } from './response';\nexport { Status } from './status';\nexport { CookieStorageOptions, Storage, UserSession } from './storage';\nexport { Transport, TransportType } from './transport';\nexport { UTMData } from './utm';\n"]}
@@ -0,0 +1,14 @@
1
+ export interface Logger {
2
+ disable(): void;
3
+ enable(logLevel: LogLevel): void;
4
+ log(...args: any[]): void;
5
+ warn(...args: any[]): void;
6
+ error(...args: any[]): void;
7
+ }
8
+ export declare enum LogLevel {
9
+ None = 0,
10
+ Error = 1,
11
+ Warn = 2,
12
+ Verbose = 3
13
+ }
14
+ //# sourceMappingURL=logger.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"logger.d.ts","sourceRoot":"","sources":["../src/logger.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,MAAM;IACrB,OAAO,IAAI,IAAI,CAAC;IAChB,MAAM,CAAC,QAAQ,EAAE,QAAQ,GAAG,IAAI,CAAC;IACjC,GAAG,CAAC,GAAG,IAAI,EAAE,GAAG,EAAE,GAAG,IAAI,CAAC;IAC1B,IAAI,CAAC,GAAG,IAAI,EAAE,GAAG,EAAE,GAAG,IAAI,CAAC;IAC3B,KAAK,CAAC,GAAG,IAAI,EAAE,GAAG,EAAE,GAAG,IAAI,CAAC;CAC7B;AAED,oBAAY,QAAQ;IAClB,IAAI,IAAI;IACR,KAAK,IAAI;IACT,IAAI,IAAI;IACR,OAAO,IAAI;CACZ"}
package/lib/logger.js ADDED
@@ -0,0 +1,10 @@
1
+ Object.defineProperty(exports, "__esModule", { value: true });
2
+ exports.LogLevel = void 0;
3
+ var LogLevel;
4
+ (function (LogLevel) {
5
+ LogLevel[LogLevel["None"] = 0] = "None";
6
+ LogLevel[LogLevel["Error"] = 1] = "Error";
7
+ LogLevel[LogLevel["Warn"] = 2] = "Warn";
8
+ LogLevel[LogLevel["Verbose"] = 3] = "Verbose";
9
+ })(LogLevel = exports.LogLevel || (exports.LogLevel = {}));
10
+ //# sourceMappingURL=logger.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"logger.js","sourceRoot":"","sources":["../src/logger.ts"],"names":[],"mappings":";;AAQA,IAAY,QAKX;AALD,WAAY,QAAQ;IAClB,uCAAQ,CAAA;IACR,yCAAS,CAAA;IACT,uCAAQ,CAAA;IACR,6CAAW,CAAA;AACb,CAAC,EALW,QAAQ,GAAR,gBAAQ,KAAR,gBAAQ,QAKnB","sourcesContent":["export interface Logger {\n disable(): void;\n enable(logLevel: LogLevel): void;\n log(...args: any[]): void;\n warn(...args: any[]): void;\n error(...args: any[]): void;\n}\n\nexport enum LogLevel {\n None = 0,\n Error = 1,\n Warn = 2,\n Verbose = 3,\n}\n"]}
@@ -0,0 +1,10 @@
1
+ import { Event } from './event';
2
+ export interface PayloadOptions {
3
+ min_id_length?: number;
4
+ }
5
+ export interface Payload {
6
+ api_key: string;
7
+ events: readonly Event[];
8
+ options?: PayloadOptions;
9
+ }
10
+ //# sourceMappingURL=payload.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"payload.d.ts","sourceRoot":"","sources":["../src/payload.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,SAAS,CAAC;AAEhC,MAAM,WAAW,cAAc;IAC7B,aAAa,CAAC,EAAE,MAAM,CAAC;CACxB;AAED,MAAM,WAAW,OAAO;IACtB,OAAO,EAAE,MAAM,CAAC;IAChB,MAAM,EAAE,SAAS,KAAK,EAAE,CAAC;IACzB,OAAO,CAAC,EAAE,cAAc,CAAC;CAC1B"}
package/lib/payload.js ADDED
@@ -0,0 +1,2 @@
1
+ Object.defineProperty(exports, "__esModule", { value: true });
2
+ //# sourceMappingURL=payload.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"payload.js","sourceRoot":"","sources":["../src/payload.ts"],"names":[],"mappings":"","sourcesContent":["import { Event } from './event';\n\nexport interface PayloadOptions {\n min_id_length?: number;\n}\n\nexport interface Payload {\n api_key: string;\n events: readonly Event[];\n options?: PayloadOptions;\n}\n"]}
package/lib/plan.d.ts ADDED
@@ -0,0 +1,12 @@
1
+ /**
2
+ * Tracking plan
3
+ */
4
+ export interface Plan {
5
+ /** The tracking plan branch name e.g. "main" */
6
+ branch?: string;
7
+ /** The tracking plan source e.g. "web" */
8
+ source?: string;
9
+ /** The tracking plan version e.g. "1", "15" */
10
+ version?: string;
11
+ }
12
+ //# sourceMappingURL=plan.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"plan.d.ts","sourceRoot":"","sources":["../src/plan.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,MAAM,WAAW,IAAI;IACnB,gDAAgD;IAChD,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,0CAA0C;IAC1C,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,+CAA+C;IAC/C,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB"}
package/lib/plan.js ADDED
@@ -0,0 +1,2 @@
1
+ Object.defineProperty(exports, "__esModule", { value: true });
2
+ //# sourceMappingURL=plan.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"plan.js","sourceRoot":"","sources":["../src/plan.ts"],"names":[],"mappings":"","sourcesContent":["/**\n * Tracking plan\n */\nexport interface Plan {\n /** The tracking plan branch name e.g. \"main\" */\n branch?: string;\n /** The tracking plan source e.g. \"web\" */\n source?: string;\n /** The tracking plan version e.g. \"1\", \"15\" */\n version?: string;\n}\n"]}
@@ -0,0 +1,28 @@
1
+ import { Event } from './event';
2
+ import { Config } from './config';
3
+ import { Result } from './result';
4
+ export declare enum PluginType {
5
+ BEFORE = "before",
6
+ ENRICHMENT = "enrichment",
7
+ DESTINATION = "destination"
8
+ }
9
+ export interface BeforePlugin {
10
+ name: string;
11
+ type: PluginType.BEFORE;
12
+ setup(config: Config): Promise<undefined>;
13
+ execute(context: Event): Promise<Event>;
14
+ }
15
+ export interface EnrichmentPlugin {
16
+ name: string;
17
+ type: PluginType.ENRICHMENT;
18
+ setup(config: Config): Promise<undefined>;
19
+ execute(context: Event): Promise<Event>;
20
+ }
21
+ export interface DestinationPlugin {
22
+ name: string;
23
+ type: PluginType.DESTINATION;
24
+ setup(config: Config): Promise<undefined>;
25
+ execute(context: Event): Promise<Result>;
26
+ }
27
+ export declare type Plugin = BeforePlugin | EnrichmentPlugin | DestinationPlugin;
28
+ //# sourceMappingURL=plugin.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"plugin.d.ts","sourceRoot":"","sources":["../src/plugin.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,SAAS,CAAC;AAChC,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAClC,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAElC,oBAAY,UAAU;IACpB,MAAM,WAAW;IACjB,UAAU,eAAe;IACzB,WAAW,gBAAgB;CAC5B;AAED,MAAM,WAAW,YAAY;IAC3B,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,UAAU,CAAC,MAAM,CAAC;IACxB,KAAK,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,SAAS,CAAC,CAAC;IAC1C,OAAO,CAAC,OAAO,EAAE,KAAK,GAAG,OAAO,CAAC,KAAK,CAAC,CAAC;CACzC;AAED,MAAM,WAAW,gBAAgB;IAC/B,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,UAAU,CAAC,UAAU,CAAC;IAC5B,KAAK,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,SAAS,CAAC,CAAC;IAC1C,OAAO,CAAC,OAAO,EAAE,KAAK,GAAG,OAAO,CAAC,KAAK,CAAC,CAAC;CACzC;AAED,MAAM,WAAW,iBAAiB;IAChC,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,UAAU,CAAC,WAAW,CAAC;IAC7B,KAAK,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,SAAS,CAAC,CAAC;IAC1C,OAAO,CAAC,OAAO,EAAE,KAAK,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC;CAC1C;AAED,oBAAY,MAAM,GAAG,YAAY,GAAG,gBAAgB,GAAG,iBAAiB,CAAC"}
package/lib/plugin.js ADDED
@@ -0,0 +1,9 @@
1
+ Object.defineProperty(exports, "__esModule", { value: true });
2
+ exports.PluginType = void 0;
3
+ var PluginType;
4
+ (function (PluginType) {
5
+ PluginType["BEFORE"] = "before";
6
+ PluginType["ENRICHMENT"] = "enrichment";
7
+ PluginType["DESTINATION"] = "destination";
8
+ })(PluginType = exports.PluginType || (exports.PluginType = {}));
9
+ //# sourceMappingURL=plugin.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"plugin.js","sourceRoot":"","sources":["../src/plugin.ts"],"names":[],"mappings":";;AAIA,IAAY,UAIX;AAJD,WAAY,UAAU;IACpB,+BAAiB,CAAA;IACjB,uCAAyB,CAAA;IACzB,yCAA2B,CAAA;AAC7B,CAAC,EAJW,UAAU,GAAV,kBAAU,KAAV,kBAAU,QAIrB","sourcesContent":["import { Event } from './event';\nimport { Config } from './config';\nimport { Result } from './result';\n\nexport enum PluginType {\n BEFORE = 'before',\n ENRICHMENT = 'enrichment',\n DESTINATION = 'destination',\n}\n\nexport interface BeforePlugin {\n name: string;\n type: PluginType.BEFORE;\n setup(config: Config): Promise<undefined>;\n execute(context: Event): Promise<Event>;\n}\n\nexport interface EnrichmentPlugin {\n name: string;\n type: PluginType.ENRICHMENT;\n setup(config: Config): Promise<undefined>;\n execute(context: Event): Promise<Event>;\n}\n\nexport interface DestinationPlugin {\n name: string;\n type: PluginType.DESTINATION;\n setup(config: Config): Promise<undefined>;\n execute(context: Event): Promise<Result>;\n}\n\nexport type Plugin = BeforePlugin | EnrichmentPlugin | DestinationPlugin;\n"]}
@@ -0,0 +1,84 @@
1
+ /// <reference types="node" />
2
+ import { Status } from './status';
3
+ export interface SuccessBody {
4
+ eventsIngested: number;
5
+ payloadSizeBytes: number;
6
+ serverUploadTime: number;
7
+ }
8
+ export interface InvalidRequestBody {
9
+ error: string;
10
+ missingField: string;
11
+ eventsWithInvalidFields: {
12
+ [eventField: string]: number[];
13
+ };
14
+ eventsWithMissingFields: {
15
+ [eventField: string]: number[];
16
+ };
17
+ epsThreshold: 0;
18
+ exceededDailyQuotaDevices: {
19
+ [deviceId: string]: number;
20
+ };
21
+ silencedDevices: string[];
22
+ silencedEvents: number[];
23
+ throttledDevices: {
24
+ [deviceId: string]: number;
25
+ };
26
+ throttledEvents: number[];
27
+ }
28
+ export interface PayloadTooLargeBody {
29
+ error: string;
30
+ }
31
+ export interface RateLimitBody {
32
+ error: string;
33
+ epsThreshold: number;
34
+ throttledDevices: {
35
+ [deviceId: string]: number;
36
+ };
37
+ throttledUsers: {
38
+ [userId: string]: number;
39
+ };
40
+ exceededDailyQuotaDevices: {
41
+ [deviceId: string]: number;
42
+ };
43
+ exceededDailyQuotaUsers: {
44
+ [userId: string]: number;
45
+ };
46
+ throttledEvents: number[];
47
+ }
48
+ export declare type StatusWithResponseBody = Status.Invalid | Status.PayloadTooLarge | Status.RateLimit | Status.Success;
49
+ export declare type ResponseBody = SuccessBody | InvalidRequestBody | PayloadTooLargeBody | RateLimitBody;
50
+ export interface SuccessResponse {
51
+ status: Status.Success;
52
+ statusCode: number;
53
+ body: SuccessBody;
54
+ }
55
+ export interface InvalidResponse {
56
+ status: Status.Invalid;
57
+ statusCode: number;
58
+ body: InvalidRequestBody;
59
+ }
60
+ export interface PayloadTooLargeResponse {
61
+ status: Status.PayloadTooLarge;
62
+ statusCode: number;
63
+ body: PayloadTooLargeBody;
64
+ }
65
+ export interface RateLimitResponse {
66
+ status: Status.RateLimit;
67
+ statusCode: number;
68
+ body: RateLimitBody;
69
+ }
70
+ export interface TimeoutResponse {
71
+ status: Status.Timeout;
72
+ statusCode: number;
73
+ }
74
+ export interface SystemErrorResponse {
75
+ status: Status.SystemError;
76
+ statusCode: 0;
77
+ error: NodeJS.ErrnoException;
78
+ }
79
+ export interface OtherReponse {
80
+ status: Exclude<Status, StatusWithResponseBody>;
81
+ statusCode: number;
82
+ }
83
+ export declare type Response = SuccessResponse | InvalidResponse | PayloadTooLargeResponse | RateLimitResponse | TimeoutResponse | SystemErrorResponse | OtherReponse;
84
+ //# sourceMappingURL=response.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"response.d.ts","sourceRoot":"","sources":["../src/response.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAElC,MAAM,WAAW,WAAW;IAC1B,cAAc,EAAE,MAAM,CAAC;IACvB,gBAAgB,EAAE,MAAM,CAAC;IACzB,gBAAgB,EAAE,MAAM,CAAC;CAC1B;AAED,MAAM,WAAW,kBAAkB;IAC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BAAmB,GAAG,aAAa,CAAC;AAElG,MAAM,WAAW,eAAe;IAC9B,MAAM,EAAE,MAAM,CAAC,OAAO,CAAC;IACvB,UAAU,EAAE,MAAM,CAAC;IACnB,IAAI,EAAE,WAAW,CAAC;CACnB;AAED,MAAM,WAAW,eAAe;IAC9B,MAAM,EAAE,MAAM,CAAC,OAAO,CAAC;IACvB,UAAU,EAAE,MAAM,CAAC;IACnB,IAAI,EAAE,kBAAkB,CAAC;CAC1B;AAED,MAAM,WAAW,uBAAuB;IACtC,MAAM,EAAE,MAAM,CAAC,eAAe,CAAC;IAC/B,UAAU,EAAE,MAAM,CAAC;IACnB,IAAI,EAAE,mBAAmB,CAAC;CAC3B;AAED,MAAM,WAAW,iBAAiB;IAChC,MAAM,EAAE,MAAM,CAAC,SAAS,CAAC;IACzB,UAAU,EAAE,MAAM,CAAC;IACnB,IAAI,EAAE,aAAa,CAAC;CACrB;AAED,MAAM,WAAW,eAAe;IAC9B,MAAM,EAAE,MAAM,CAAC,OAAO,CAAC;IACvB,UAAU,EAAE,MAAM,CAAC;CACpB;AAED,MAAM,WAAW,mBAAmB;IAClC,MAAM,EAAE,MAAM,CAAC,WAAW,CAAC;IAC3B,UAAU,EAAE,CAAC,CAAC;IACd,KAAK,EAAE,MAAM,CAAC,cAAc,CAAC;CAC9B;AAED,MAAM,WAAW,YAAY;IAC3B,MAAM,EAAE,OAAO,CAAC,MAAM,EAAE,sBAAsB,CAAC,CAAC;IAChD,UAAU,EAAE,MAAM,CAAC;CACpB;AAED,oBAAY,QAAQ,GAChB,eAAe,GACf,eAAe,GACf,uBAAuB,GACvB,iBAAiB,GACjB,eAAe,GACf,mBAAmB,GACnB,YAAY,CAAC"}
@@ -0,0 +1,2 @@
1
+ Object.defineProperty(exports, "__esModule", { value: true });
2
+ //# sourceMappingURL=response.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"response.js","sourceRoot":"","sources":["../src/response.ts"],"names":[],"mappings":"","sourcesContent":["import { Status } from './status';\n\nexport interface SuccessBody {\n eventsIngested: number;\n payloadSizeBytes: number;\n serverUploadTime: number;\n}\n\nexport interface InvalidRequestBody {\n error: string;\n missingField: string;\n eventsWithInvalidFields: { [eventField: string]: number[] };\n eventsWithMissingFields: { [eventField: string]: number[] };\n epsThreshold: 0;\n exceededDailyQuotaDevices: { [deviceId: string]: number };\n silencedDevices: string[];\n silencedEvents: number[];\n throttledDevices: { [deviceId: string]: number };\n throttledEvents: number[];\n}\nexport interface PayloadTooLargeBody {\n error: string;\n}\nexport interface RateLimitBody {\n error: string;\n epsThreshold: number;\n throttledDevices: { [deviceId: string]: number };\n throttledUsers: { [userId: string]: number };\n exceededDailyQuotaDevices: { [deviceId: string]: number };\n exceededDailyQuotaUsers: { [userId: string]: number };\n throttledEvents: number[];\n}\n\nexport type StatusWithResponseBody = Status.Invalid | Status.PayloadTooLarge | Status.RateLimit | Status.Success;\n\nexport type ResponseBody = SuccessBody | InvalidRequestBody | PayloadTooLargeBody | RateLimitBody;\n\nexport interface SuccessResponse {\n status: Status.Success;\n statusCode: number;\n body: SuccessBody;\n}\n\nexport interface InvalidResponse {\n status: Status.Invalid;\n statusCode: number;\n body: InvalidRequestBody;\n}\n\nexport interface PayloadTooLargeResponse {\n status: Status.PayloadTooLarge;\n statusCode: number;\n body: PayloadTooLargeBody;\n}\n\nexport interface RateLimitResponse {\n status: Status.RateLimit;\n statusCode: number;\n body: RateLimitBody;\n}\n\nexport interface TimeoutResponse {\n status: Status.Timeout;\n statusCode: number;\n}\n\nexport interface SystemErrorResponse {\n status: Status.SystemError;\n statusCode: 0;\n error: NodeJS.ErrnoException;\n}\n\nexport interface OtherReponse {\n status: Exclude<Status, StatusWithResponseBody>;\n statusCode: number;\n}\n\nexport type Response =\n | SuccessResponse\n | InvalidResponse\n | PayloadTooLargeResponse\n | RateLimitResponse\n | TimeoutResponse\n | SystemErrorResponse\n | OtherReponse;\n"]}
@@ -0,0 +1,7 @@
1
+ import { Event } from './event';
2
+ export interface Result {
3
+ event: Event;
4
+ code: number;
5
+ message: string;
6
+ }
7
+ //# sourceMappingURL=result.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"result.d.ts","sourceRoot":"","sources":["../src/result.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,SAAS,CAAC;AAEhC,MAAM,WAAW,MAAM;IACrB,KAAK,EAAE,KAAK,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,CAAC;CACjB"}
package/lib/result.js ADDED
@@ -0,0 +1,2 @@
1
+ Object.defineProperty(exports, "__esModule", { value: true });
2
+ //# sourceMappingURL=result.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"result.js","sourceRoot":"","sources":["../src/result.ts"],"names":[],"mappings":"","sourcesContent":["import { Event } from './event';\n\nexport interface Result {\n event: Event;\n code: number;\n message: string;\n}\n"]}
@@ -0,0 +1,22 @@
1
+ /** The status of an event. */
2
+ export declare enum Status {
3
+ /** The status could not be determined. */
4
+ Unknown = "unknown",
5
+ /** The event was skipped due to configuration or callbacks. */
6
+ Skipped = "skipped",
7
+ /** The event was sent successfully. */
8
+ Success = "success",
9
+ /** A user or device in the payload is currently rate limited and should try again later. */
10
+ RateLimit = "rate_limit",
11
+ /** The sent payload was too large to be processed. */
12
+ PayloadTooLarge = "payload_too_large",
13
+ /** The event could not be processed. */
14
+ Invalid = "invalid",
15
+ /** A server-side error ocurred during submission. */
16
+ Failed = "failed",
17
+ /** a server or client side error occuring when a request takes too long and is cancelled */
18
+ Timeout = "Timeout",
19
+ /** NodeJS runtime environment error.. E.g. disconnected from network */
20
+ SystemError = "SystemError"
21
+ }
22
+ //# sourceMappingURL=status.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"status.d.ts","sourceRoot":"","sources":["../src/status.ts"],"names":[],"mappings":"AAAA,8BAA8B;AAC9B,oBAAY,MAAM;IAChB,0CAA0C;IAC1C,OAAO,YAAY;IACnB,+DAA+D;IAC/D,OAAO,YAAY;IACnB,uCAAuC;IACvC,OAAO,YAAY;IACnB,4FAA4F;IAC5F,SAAS,eAAe;IACxB,sDAAsD;IACtD,eAAe,sBAAsB;IACrC,wCAAwC;IACxC,OAAO,YAAY;IACnB,qDAAqD;IACrD,MAAM,WAAW;IACjB,4FAA4F;IAC5F,OAAO,YAAY;IACnB,wEAAwE;IACxE,WAAW,gBAAgB;CAC5B"}
package/lib/status.js ADDED
@@ -0,0 +1,25 @@
1
+ Object.defineProperty(exports, "__esModule", { value: true });
2
+ exports.Status = void 0;
3
+ /** The status of an event. */
4
+ var Status;
5
+ (function (Status) {
6
+ /** The status could not be determined. */
7
+ Status["Unknown"] = "unknown";
8
+ /** The event was skipped due to configuration or callbacks. */
9
+ Status["Skipped"] = "skipped";
10
+ /** The event was sent successfully. */
11
+ Status["Success"] = "success";
12
+ /** A user or device in the payload is currently rate limited and should try again later. */
13
+ Status["RateLimit"] = "rate_limit";
14
+ /** The sent payload was too large to be processed. */
15
+ Status["PayloadTooLarge"] = "payload_too_large";
16
+ /** The event could not be processed. */
17
+ Status["Invalid"] = "invalid";
18
+ /** A server-side error ocurred during submission. */
19
+ Status["Failed"] = "failed";
20
+ /** a server or client side error occuring when a request takes too long and is cancelled */
21
+ Status["Timeout"] = "Timeout";
22
+ /** NodeJS runtime environment error.. E.g. disconnected from network */
23
+ Status["SystemError"] = "SystemError";
24
+ })(Status = exports.Status || (exports.Status = {}));
25
+ //# sourceMappingURL=status.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"status.js","sourceRoot":"","sources":["../src/status.ts"],"names":[],"mappings":";;AAAA,8BAA8B;AAC9B,IAAY,MAmBX;AAnBD,WAAY,MAAM;IAChB,0CAA0C;IAC1C,6BAAmB,CAAA;IACnB,+DAA+D;IAC/D,6BAAmB,CAAA;IACnB,uCAAuC;IACvC,6BAAmB,CAAA;IACnB,4FAA4F;IAC5F,kCAAwB,CAAA;IACxB,sDAAsD;IACtD,+CAAqC,CAAA;IACrC,wCAAwC;IACxC,6BAAmB,CAAA;IACnB,qDAAqD;IACrD,2BAAiB,CAAA;IACjB,4FAA4F;IAC5F,6BAAmB,CAAA;IACnB,wEAAwE;IACxE,qCAA2B,CAAA;AAC7B,CAAC,EAnBW,MAAM,GAAN,cAAM,KAAN,cAAM,QAmBjB","sourcesContent":["/** The status of an event. */\nexport enum Status {\n /** The status could not be determined. */\n Unknown = 'unknown',\n /** The event was skipped due to configuration or callbacks. */\n Skipped = 'skipped',\n /** The event was sent successfully. */\n Success = 'success',\n /** A user or device in the payload is currently rate limited and should try again later. */\n RateLimit = 'rate_limit',\n /** The sent payload was too large to be processed. */\n PayloadTooLarge = 'payload_too_large',\n /** The event could not be processed. */\n Invalid = 'invalid',\n /** A server-side error ocurred during submission. */\n Failed = 'failed',\n /** a server or client side error occuring when a request takes too long and is cancelled */\n Timeout = 'Timeout',\n /** NodeJS runtime environment error.. E.g. disconnected from network */\n SystemError = 'SystemError',\n}\n"]}
@@ -0,0 +1,21 @@
1
+ export interface UserSession {
2
+ userId?: string;
3
+ deviceId?: string;
4
+ sessionId?: number;
5
+ lastEventTime?: number;
6
+ optOut: boolean;
7
+ }
8
+ export interface Storage<T> {
9
+ isEnabled(): boolean;
10
+ get(key: string): T | undefined;
11
+ set(key: string, value: T): void;
12
+ remove(key: string): void;
13
+ reset(): void;
14
+ }
15
+ export interface CookieStorageOptions {
16
+ domain?: string;
17
+ expirationDays?: number;
18
+ sameSite?: string;
19
+ secure?: boolean;
20
+ }
21
+ //# sourceMappingURL=storage.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"storage.d.ts","sourceRoot":"","sources":["../src/storage.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,WAAW;IAC1B,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,MAAM,EAAE,OAAO,CAAC;CACjB;AAED,MAAM,WAAW,OAAO,CAAC,CAAC;IACxB,SAAS,IAAI,OAAO,CAAC;IACrB,GAAG,CAAC,GAAG,EAAE,MAAM,GAAG,CAAC,GAAG,SAAS,CAAC;IAChC,GAAG,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,CAAC,GAAG,IAAI,CAAC;IACjC,MAAM,CAAC,GAAG,EAAE,MAAM,GAAG,IAAI,CAAC;IAC1B,KAAK,IAAI,IAAI,CAAC;CACf;AAED,MAAM,WAAW,oBAAoB;IACnC,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,MAAM,CAAC,EAAE,OAAO,CAAC;CAClB"}
package/lib/storage.js ADDED
@@ -0,0 +1,2 @@
1
+ Object.defineProperty(exports, "__esModule", { value: true });
2
+ //# sourceMappingURL=storage.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"storage.js","sourceRoot":"","sources":["../src/storage.ts"],"names":[],"mappings":"","sourcesContent":["export interface UserSession {\n userId?: string;\n deviceId?: string;\n sessionId?: number;\n lastEventTime?: number;\n optOut: boolean;\n}\n\nexport interface Storage<T> {\n isEnabled(): boolean;\n get(key: string): T | undefined;\n set(key: string, value: T): void;\n remove(key: string): void;\n reset(): void;\n}\n\nexport interface CookieStorageOptions {\n domain?: string;\n expirationDays?: number;\n sameSite?: string;\n secure?: boolean;\n}\n"]}
@@ -0,0 +1,11 @@
1
+ import { Payload } from './payload';
2
+ import { Response } from './response';
3
+ export interface Transport {
4
+ send(serverUrl: string, payload: Payload): Promise<Response | null>;
5
+ }
6
+ export declare enum TransportType {
7
+ XHR = "xhr",
8
+ SendBeacon = "beacon",
9
+ Fetch = "fetch"
10
+ }
11
+ //# sourceMappingURL=transport.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"transport.d.ts","sourceRoot":"","sources":["../src/transport.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAEtC,MAAM,WAAW,SAAS;IACxB,IAAI,CAAC,SAAS,EAAE,MAAM,EAAE,OAAO,EAAE,OAAO,GAAG,OAAO,CAAC,QAAQ,GAAG,IAAI,CAAC,CAAC;CACrE;AAED,oBAAY,aAAa;IACvB,GAAG,QAAQ;IACX,UAAU,WAAW;IACrB,KAAK,UAAU;CAChB"}
@@ -0,0 +1,9 @@
1
+ Object.defineProperty(exports, "__esModule", { value: true });
2
+ exports.TransportType = void 0;
3
+ var TransportType;
4
+ (function (TransportType) {
5
+ TransportType["XHR"] = "xhr";
6
+ TransportType["SendBeacon"] = "beacon";
7
+ TransportType["Fetch"] = "fetch";
8
+ })(TransportType = exports.TransportType || (exports.TransportType = {}));
9
+ //# sourceMappingURL=transport.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"transport.js","sourceRoot":"","sources":["../src/transport.ts"],"names":[],"mappings":";;AAOA,IAAY,aAIX;AAJD,WAAY,aAAa;IACvB,4BAAW,CAAA;IACX,sCAAqB,CAAA;IACrB,gCAAe,CAAA;AACjB,CAAC,EAJW,aAAa,GAAb,qBAAa,KAAb,qBAAa,QAIxB","sourcesContent":["import { Payload } from './payload';\nimport { Response } from './response';\n\nexport interface Transport {\n send(serverUrl: string, payload: Payload): Promise<Response | null>;\n}\n\nexport enum TransportType {\n XHR = 'xhr',\n SendBeacon = 'beacon',\n Fetch = 'fetch',\n}\n"]}
package/lib/utm.d.ts ADDED
@@ -0,0 +1,8 @@
1
+ export interface UTMData {
2
+ utm_source?: string;
3
+ utm_medium?: string;
4
+ utm_campaign?: string;
5
+ utm_term?: string;
6
+ utm_content?: string;
7
+ }
8
+ //# sourceMappingURL=utm.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"utm.d.ts","sourceRoot":"","sources":["../src/utm.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,OAAO;IACtB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB"}
package/lib/utm.js ADDED
@@ -0,0 +1,2 @@
1
+ Object.defineProperty(exports, "__esModule", { value: true });
2
+ //# sourceMappingURL=utm.js.map
package/lib/utm.js.map ADDED
@@ -0,0 +1 @@
1
+ {"version":3,"file":"utm.js","sourceRoot":"","sources":["../src/utm.ts"],"names":[],"mappings":"","sourcesContent":["export interface UTMData {\n utm_source?: string;\n utm_medium?: string;\n utm_campaign?: string;\n utm_term?: string;\n utm_content?: string;\n}\n"]}
package/package.json ADDED
@@ -0,0 +1,34 @@
1
+ {
2
+ "name": "@amplitude/analytics-types",
3
+ "version": "0.1.0",
4
+ "description": "",
5
+ "author": "Amplitude Inc",
6
+ "homepage": "https://github.com/amplitude/Amplitude-TypeScript",
7
+ "license": "MIT",
8
+ "main": "lib/index.js",
9
+ "module": "lib/index.js",
10
+ "types": "lib/index.d.ts",
11
+ "publishConfig": {
12
+ "access": "public"
13
+ },
14
+ "repository": {
15
+ "type": "git",
16
+ "url": "git+https://github.com/amplitude/Amplitude-TypeScript.git"
17
+ },
18
+ "scripts": {
19
+ "build": "tsc -p ./tsconfig.json",
20
+ "fix": "yarn fix:eslint & yarn fix:prettier",
21
+ "fix:eslint": "eslint '{src,test}/**/*.ts' --fix",
22
+ "fix:prettier": "prettier --write \"{src,test}/**/*.ts\"",
23
+ "lint": "yarn lint:eslint & yarn lint:prettier",
24
+ "lint:eslint": "eslint '{src,test}/**/*.ts'",
25
+ "lint:prettier": "prettier --check \"{src,test}/**/*.ts\""
26
+ },
27
+ "bugs": {
28
+ "url": "https://github.com/amplitude/Amplitude-TypeScript/issues"
29
+ },
30
+ "files": [
31
+ "lib"
32
+ ],
33
+ "gitHead": "e7d36d91aab1483b3d686f7f5570c6334c27ab23"
34
+ }