fleek-track-analytics 0.0.7 → 0.0.8

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "fleek-track-analytics",
3
- "version": "0.0.7",
3
+ "version": "0.0.8",
4
4
  "main": "./dist/index.js",
5
5
  "types": "./dist/index.d.ts",
6
6
  "repository": {
@@ -14,7 +14,7 @@
14
14
  "lint": "eslint --ignore-path .gitignore src/**/*.ts",
15
15
  "format": "prettier --ignore-path .gitignore --write \"**/*.+(js|ts|json)\"",
16
16
  "test": "jest --passWithNoTests",
17
- "build": "tsc",
17
+ "build": "rm -rf dist && tsc",
18
18
  "prepublish": "lint && build"
19
19
  },
20
20
  "dependencies": {
package/tsconfig.json CHANGED
@@ -25,11 +25,11 @@
25
25
  "experimentalDecorators": true,
26
26
  "resolveJsonModule": true,
27
27
  "baseUrl": "./",
28
- "rootDir": "src",
28
+ "rootDir": ".",
29
29
  "paths": {
30
30
  "src/*": ["./src/*"]
31
31
  }
32
32
  },
33
- "exclude": ["node_modules"],
33
+ "exclude": ["node_modules", "dist"],
34
34
  "include": ["./src/**/*.ts"]
35
35
  }
@@ -1,2 +0,0 @@
1
- import { tAPP, tPLATFORM } from '../types';
2
- export declare const lazyLoadTool: (platform: tPLATFORM, app: tAPP) => Promise<import("../types").IAnalyticsWrapper | null>;
@@ -1,59 +0,0 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
- Object.defineProperty(o, "default", { enumerable: true, value: v });
15
- }) : function(o, v) {
16
- o["default"] = v;
17
- });
18
- var __importStar = (this && this.__importStar) || function (mod) {
19
- if (mod && mod.__esModule) return mod;
20
- var result = {};
21
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
- __setModuleDefault(result, mod);
23
- return result;
24
- };
25
- Object.defineProperty(exports, "__esModule", { value: true });
26
- exports.lazyLoadTool = void 0;
27
- const getAnalyticsToolWrapper = async (platform) => {
28
- try {
29
- if (platform === 'REACT_NATIVE') {
30
- return (await Promise.resolve().then(() => __importStar(require('./react-native-segment')))).reactNativeSegment;
31
- }
32
- if (platform === 'NODE' || platform === 'WEB') {
33
- return (await Promise.resolve().then(() => __importStar(require('./web-segment')))).webSegment;
34
- }
35
- return null;
36
- }
37
- catch (e) {
38
- console.log(e);
39
- throw new Error(JSON.stringify(e));
40
- }
41
- };
42
- const ERROR_MESSAGES = {
43
- TOOL_INIT_FAILED_AT_LAZY_LOAD: 'TOOL_INIT_FAILED_AT_LAZY_LOAD',
44
- };
45
- const lazyLoadTool = async (platform, app) => {
46
- let tool = null;
47
- try {
48
- const toolWrapper = await getAnalyticsToolWrapper(platform);
49
- if (toolWrapper) {
50
- tool = await Promise.resolve(toolWrapper(app));
51
- }
52
- }
53
- catch (e) {
54
- console.error(ERROR_MESSAGES.TOOL_INIT_FAILED_AT_LAZY_LOAD, { platform, app });
55
- }
56
- return tool;
57
- };
58
- exports.lazyLoadTool = lazyLoadTool;
59
- //# sourceMappingURL=lazy-load-tool.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"lazy-load-tool.js","sourceRoot":"","sources":["../../src/analytics-tool/lazy-load-tool.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAGA,MAAM,uBAAuB,GAAG,KAAK,EAAE,QAAmB,EAAE,EAAE;IAC5D,IAAI,CAAC;QACH,IAAI,QAAQ,KAAK,cAAc,EAAE,CAAC;YAChC,OAAO,CAAC,wDAAa,wBAAwB,GAAC,CAAC,CAAC,kBAAkB,CAAC;QACrE,CAAC;QACD,IAAI,QAAQ,KAAK,MAAM,IAAI,QAAQ,KAAK,KAAK,EAAE,CAAC;YAC9C,OAAO,CAAC,wDAAa,eAAe,GAAC,CAAC,CAAC,UAAU,CAAC;QACpD,CAAC;QAED,OAAO,IAAI,CAAC;IACd,CAAC;IAAC,OAAO,CAAC,EAAE,CAAC;QACX,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;QACf,MAAM,IAAI,KAAK,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,CAAC;IACrC,CAAC;AACH,CAAC,CAAC;AAEF,MAAM,cAAc,GAAG;IACrB,6BAA6B,EAAE,+BAA+B;CAC/D,CAAC;AAEK,MAAM,YAAY,GAAG,KAAK,EAAE,QAAmB,EAAE,GAAS,EAAE,EAAE;IACnE,IAAI,IAAI,GAAG,IAAI,CAAC;IAChB,IAAI,CAAC;QACH,MAAM,WAAW,GAA+B,MAAM,uBAAuB,CAAC,QAAQ,CAAC,CAAC;QACxF,IAAI,WAAW,EAAE,CAAC;YAChB,IAAI,GAAG,MAAM,OAAO,CAAC,OAAO,CAAC,WAAW,CAAC,GAAG,CAAC,CAAC,CAAC;QACjD,CAAC;IACH,CAAC;IAAC,OAAO,CAAC,EAAE,CAAC;QACX,OAAO,CAAC,KAAK,CAAC,cAAc,CAAC,6BAA6B,EAAE,EAAE,QAAQ,EAAE,GAAG,EAAE,CAAC,CAAC;IACjF,CAAC;IAED,OAAO,IAAI,CAAC;AACd,CAAC,CAAC;AAZW,QAAA,YAAY,gBAYvB"}
@@ -1,2 +0,0 @@
1
- import { tToolWraperFunction } from './types';
2
- export declare const reactNativeSegment: tToolWraperFunction;
@@ -1,25 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.reactNativeSegment = void 0;
4
- const analytics_react_native_1 = require("@segment/analytics-react-native");
5
- const getSegmentKey_1 = require("./utils/getSegmentKey");
6
- const reactNativeSegment = (APP) => {
7
- const segmentKey = (0, getSegmentKey_1.getSegmentKey)(APP);
8
- const client = (0, analytics_react_native_1.createClient)({
9
- writeKey: segmentKey,
10
- trackAppLifecycleEvents: true,
11
- });
12
- const { track, screen, identify } = client;
13
- const trackWrapper = (eventName, eventParams) => {
14
- const data = eventParams;
15
- track(eventName, data);
16
- };
17
- return {
18
- track: trackWrapper,
19
- screen,
20
- identify,
21
- type: 'RN_SEGMENT',
22
- };
23
- };
24
- exports.reactNativeSegment = reactNativeSegment;
25
- //# sourceMappingURL=react-native-segment.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"react-native-segment.js","sourceRoot":"","sources":["../../src/analytics-tool/react-native-segment.ts"],"names":[],"mappings":";;;AAAA,4EAA+D;AAC/D,yDAAsD;AAI/C,MAAM,kBAAkB,GAAwB,CAAC,GAAS,EAAE,EAAE;IACnE,MAAM,UAAU,GAAG,IAAA,6BAAa,EAAC,GAAG,CAAC,CAAC;IACtC,MAAM,MAAM,GAAG,IAAA,qCAAY,EAAC;QAC1B,QAAQ,EAAE,UAAU;QACpB,uBAAuB,EAAE,IAAI;KAC9B,CAAC,CAAC;IAEH,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,QAAQ,EAAE,GAAG,MAAM,CAAC;IAE3C,MAAM,YAAY,GAAW,CAAC,SAAS,EAAE,WAAW,EAAE,EAAE;QAEtD,MAAM,IAAI,GAAG,WAA2C,CAAC;QAEzD,KAAK,CAAC,SAAS,EAAE,IAAI,CAAC,CAAC;IACzB,CAAC,CAAC;IAEF,OAAO;QACL,KAAK,EAAE,YAAY;QACnB,MAAM;QACN,QAAQ;QACR,IAAI,EAAE,YAAY;KACnB,CAAC;AACJ,CAAC,CAAC;AAtBW,QAAA,kBAAkB,sBAsB7B"}
@@ -1,2 +0,0 @@
1
- import { IAnalyticsWrapper, tAPP } from '../types';
2
- export type tToolWraperFunction = (APP: tAPP) => IAnalyticsWrapper;
@@ -1,3 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- //# sourceMappingURL=types.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/analytics-tool/types.ts"],"names":[],"mappings":""}
@@ -1,3 +0,0 @@
1
- import { tAPP } from '../../types';
2
- export declare const getSegmentKey: (APP: tAPP) => string;
3
- export declare const SEGMENT_KEY_NOT_FOUND = "SEGMENT_KEY_NOT_FOUND";
@@ -1,7 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.SEGMENT_KEY_NOT_FOUND = exports.getSegmentKey = void 0;
4
- const getSegmentKey = (APP) => process.env[`SEGMENT_PROJECT_KEY_${APP}`] || exports.SEGMENT_KEY_NOT_FOUND;
5
- exports.getSegmentKey = getSegmentKey;
6
- exports.SEGMENT_KEY_NOT_FOUND = 'SEGMENT_KEY_NOT_FOUND';
7
- //# sourceMappingURL=getSegmentKey.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"getSegmentKey.js","sourceRoot":"","sources":["../../../src/analytics-tool/utils/getSegmentKey.ts"],"names":[],"mappings":";;;AAEO,MAAM,aAAa,GAAG,CAAC,GAAS,EAAE,EAAE,CAAC,OAAO,CAAC,GAAG,CAAC,uBAAuB,GAAG,EAAE,CAAC,IAAI,6BAAqB,CAAC;AAAlG,QAAA,aAAa,iBAAqF;AAClG,QAAA,qBAAqB,GAAG,uBAAuB,CAAC"}
@@ -1,2 +0,0 @@
1
- import { tToolWraperFunction } from './types';
2
- export declare const webSegment: tToolWraperFunction;
@@ -1,18 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.webSegment = void 0;
4
- const getSegmentKey_1 = require("./utils/getSegmentKey");
5
- const analytics_next_1 = require("@segment/analytics-next");
6
- const webSegment = (APP) => {
7
- const segmentKey = (0, getSegmentKey_1.getSegmentKey)(APP);
8
- const client = analytics_next_1.AnalyticsBrowser.load({ writeKey: segmentKey });
9
- const { track, page, identify } = client;
10
- return {
11
- track,
12
- screen: page,
13
- identify,
14
- type: 'WEB_SEGMENT',
15
- };
16
- };
17
- exports.webSegment = webSegment;
18
- //# sourceMappingURL=web-segment.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"web-segment.js","sourceRoot":"","sources":["../../src/analytics-tool/web-segment.ts"],"names":[],"mappings":";;;AAAA,yDAAsD;AACtD,4DAA2D;AAIpD,MAAM,UAAU,GAAwB,CAAC,GAAS,EAAE,EAAE;IAC3D,MAAM,UAAU,GAAG,IAAA,6BAAa,EAAC,GAAG,CAAC,CAAC;IACtC,MAAM,MAAM,GAAG,iCAAgB,CAAC,IAAI,CAAC,EAAE,QAAQ,EAAE,UAAU,EAAE,CAAC,CAAC;IAC/D,MAAM,EAAE,KAAK,EAAE,IAAI,EAAE,QAAQ,EAAE,GAAG,MAAM,CAAC;IAEzC,OAAO;QACL,KAAK;QACL,MAAM,EAAE,IAAI;QACZ,QAAQ;QACR,IAAI,EAAE,aAAa;KACpB,CAAC;AACJ,CAAC,CAAC;AAXW,QAAA,UAAU,cAWrB"}
@@ -1,25 +0,0 @@
1
- export declare enum EVENT_NAMES {
2
- ADD_TO_CART = "ADD_TO_CART"
3
- }
4
- export interface ProductCartEventData {
5
- value: number;
6
- valueCurrencyCode: string;
7
- vendor: string;
8
- productCategoryL2: Array<string>;
9
- productCategoryL1: Array<string>;
10
- productGenderCategory: Array<string>;
11
- productType: string;
12
- price: number;
13
- priceCurrencyCode: string;
14
- brand: Array<string>;
15
- collectionName: Array<string>;
16
- quantity: number;
17
- productId: string;
18
- url: string;
19
- failureReason: string;
20
- productName: string;
21
- grade: string;
22
- }
23
- export interface EVENT_MAP {
24
- [EVENT_NAMES.ADD_TO_CART]: ProductCartEventData;
25
- }
@@ -1,8 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.EVENT_NAMES = void 0;
4
- var EVENT_NAMES;
5
- (function (EVENT_NAMES) {
6
- EVENT_NAMES["ADD_TO_CART"] = "ADD_TO_CART";
7
- })(EVENT_NAMES || (exports.EVENT_NAMES = EVENT_NAMES = {}));
8
- //# sourceMappingURL=event-map.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"event-map.js","sourceRoot":"","sources":["../../src/event-map/event-map.ts"],"names":[],"mappings":";;;AAAA,IAAY,WAEX;AAFD,WAAY,WAAW;IACrB,0CAA2B,CAAA;AAC7B,CAAC,EAFW,WAAW,2BAAX,WAAW,QAEtB"}
package/dist/index.d.ts DELETED
@@ -1 +0,0 @@
1
- export { init as trackAnalyticsInit } from './init/init';
package/dist/index.js DELETED
@@ -1,6 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.trackAnalyticsInit = void 0;
4
- var init_1 = require("./init/init");
5
- Object.defineProperty(exports, "trackAnalyticsInit", { enumerable: true, get: function () { return init_1.init; } });
6
- //# sourceMappingURL=index.js.map
package/dist/index.js.map DELETED
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;AAAA,oCAAyD;AAAhD,0GAAA,IAAI,OAAsB"}
@@ -1,2 +0,0 @@
1
- import { trackAnalyticsInit } from '../types';
2
- export declare const init: trackAnalyticsInit;
package/dist/init/init.js DELETED
@@ -1,26 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.init = void 0;
4
- const lazy_load_tool_1 = require("../analytics-tool/lazy-load-tool");
5
- const failedAnalyticsReurn = {
6
- track: () => { },
7
- identify: () => { },
8
- screen: () => { },
9
- type: 'FAILED_INIT',
10
- };
11
- const init = async (params) => {
12
- console.log(params);
13
- try {
14
- const analyticsWrapper = await (0, lazy_load_tool_1.lazyLoadTool)(params.platform, params.App);
15
- if (!analyticsWrapper) {
16
- console.log('ANALYTICS_WRAPPER_NULL');
17
- }
18
- return analyticsWrapper || failedAnalyticsReurn;
19
- }
20
- catch (e) {
21
- console.log('MAIN_INIT_FAILED', JSON.stringify(e));
22
- return failedAnalyticsReurn;
23
- }
24
- };
25
- exports.init = init;
26
- //# sourceMappingURL=init.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"init.js","sourceRoot":"","sources":["../../src/init/init.ts"],"names":[],"mappings":";;;AAAA,qEAAgE;AAGhE,MAAM,oBAAoB,GAAsB;IAC9C,KAAK,EAAE,GAAG,EAAE,GAAE,CAAC;IACf,QAAQ,EAAE,GAAG,EAAE,GAAE,CAAC;IAClB,MAAM,EAAE,GAAG,EAAE,GAAE,CAAC;IAChB,IAAI,EAAE,aAAa;CACpB,CAAC;AAEK,MAAM,IAAI,GAAuB,KAAK,EAAE,MAAM,EAAE,EAAE;IACvD,OAAO,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC;IAGpB,IAAI,CAAC;QACH,MAAM,gBAAgB,GAAG,MAAM,IAAA,6BAAY,EAAC,MAAM,CAAC,QAAQ,EAAE,MAAM,CAAC,GAAG,CAAC,CAAC;QACzE,IAAI,CAAC,gBAAgB,EAAE,CAAC;YACtB,OAAO,CAAC,GAAG,CAAC,wBAAwB,CAAC,CAAC;QACxC,CAAC;QACD,OAAO,gBAAgB,IAAI,oBAAoB,CAAC;IAClD,CAAC;IAAC,OAAO,CAAC,EAAE,CAAC;QACX,OAAO,CAAC,GAAG,CAAC,kBAAkB,EAAE,IAAI,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,CAAC;QACnD,OAAO,oBAAoB,CAAC;IAC9B,CAAC;AACH,CAAC,CAAC;AAdW,QAAA,IAAI,QAcf"}
@@ -1 +0,0 @@
1
- export {};
@@ -1,18 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const init_1 = require("./init");
4
- describe('init', () => {
5
- test('it returns object of type AnalyticsWrapper', async () => {
6
- expect.assertions(3);
7
- const output = await (0, init_1.init)({
8
- platform: 'REACT_NATIVE',
9
- App: 'CONSUMER_WEB',
10
- segment: true,
11
- pixel: true,
12
- });
13
- expect(output).toHaveProperty('track');
14
- expect(output).toHaveProperty('identify');
15
- expect(output).toHaveProperty('screen');
16
- });
17
- });
18
- //# sourceMappingURL=init.test.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"init.test.js","sourceRoot":"","sources":["../../src/init/init.test.ts"],"names":[],"mappings":";;AAAA,iCAA8B;AAE9B,QAAQ,CAAC,MAAM,EAAE,GAAG,EAAE;IACpB,IAAI,CAAC,4CAA4C,EAAE,KAAK,IAAI,EAAE;QAC5D,MAAM,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC;QACrB,MAAM,MAAM,GAAG,MAAM,IAAA,WAAI,EAAC;YACxB,QAAQ,EAAE,cAAc;YACxB,GAAG,EAAE,cAAc;YACnB,OAAO,EAAE,IAAI;YACb,KAAK,EAAE,IAAI;SACZ,CAAC,CAAC;QACH,MAAM,CAAC,MAAM,CAAC,CAAC,cAAc,CAAC,OAAO,CAAC,CAAC;QACvC,MAAM,CAAC,MAAM,CAAC,CAAC,cAAc,CAAC,UAAU,CAAC,CAAC;QAC1C,MAAM,CAAC,MAAM,CAAC,CAAC,cAAc,CAAC,QAAQ,CAAC,CAAC;IAC1C,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
package/dist/types.d.ts DELETED
@@ -1,27 +0,0 @@
1
- import { EVENT_MAP, EVENT_NAMES } from './event-map/event-map';
2
- export type tTrack = <T extends EVENT_NAMES>(eventName: T, eventParams: EVENT_MAP[T]) => void;
3
- export type JsonList = Array<JsonValue>;
4
- export type JsonValue = boolean | number | string | null | JsonList | JsonMap | undefined;
5
- export interface JsonMap {
6
- [key: string]: JsonValue;
7
- [index: number]: JsonValue;
8
- }
9
- type tWebScreen = (category?: string, name?: string, properties?: Record<string, unknown>, options?: Record<string, unknown>, callback?: () => void) => void;
10
- type tRNScreen = (name: string, properties?: JsonMap) => void;
11
- export type tScreen = tWebScreen | tRNScreen;
12
- export type tPLATFORM = 'REACT_NATIVE' | 'WEB' | 'NODE';
13
- export type tAPP = 'VENDOR_APP' | 'CONSUMER_APP' | 'CONSUMER_WEB';
14
- export interface AnalyticsInit {
15
- platform: tPLATFORM;
16
- App: tAPP;
17
- segment: boolean;
18
- pixel: boolean;
19
- }
20
- export interface IAnalyticsWrapper {
21
- track: tTrack;
22
- identify: () => void;
23
- screen: tScreen;
24
- type: string;
25
- }
26
- type tInit = (params: AnalyticsInit) => Promise<IAnalyticsWrapper>;
27
- export { tInit as trackAnalyticsInit };
package/dist/types.js DELETED
@@ -1,3 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- //# sourceMappingURL=types.js.map
package/dist/types.js.map DELETED
@@ -1 +0,0 @@
1
- {"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":""}