fk-platform-sdk 1.0.47 → 1.1.0-beta.2

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.
@@ -1,6 +1,10 @@
1
1
  import { AnalyticsEvent } from "./interfaces/AnalyticsEvent";
2
2
  import { EventValidator } from "./EventValidator";
3
3
  import { Person } from "./Person";
4
+ export interface PageMetaInfo {
5
+ mk?: string;
6
+ mv?: string;
7
+ }
4
8
  export declare class Search implements AnalyticsEvent {
5
9
  type: string;
6
10
  private fromLocation;
@@ -43,3 +47,16 @@ export declare class OrderConfirmation implements AnalyticsEvent {
43
47
  constructor(orderAmount: number, paymentMethod: string);
44
48
  getValidator(): EventValidator;
45
49
  }
50
+ export declare class PageViewEvent implements AnalyticsEvent {
51
+ type: string;
52
+ private readonly en;
53
+ private t;
54
+ private ib;
55
+ private rt?;
56
+ private he?;
57
+ private mt?;
58
+ private ver?;
59
+ private cat?;
60
+ constructor(isBack: boolean, timestamp: number, responseType?: string, hyperlocalEligible?: boolean, pageMetaInfo?: PageMetaInfo, vertical?: string, category?: string);
61
+ getValidator(): EventValidator;
62
+ }
@@ -124,3 +124,25 @@ var OrderConfirmation = /** @class */ (function () {
124
124
  return OrderConfirmation;
125
125
  }());
126
126
  exports.OrderConfirmation = OrderConfirmation;
127
+ var PageViewEvent = /** @class */ (function () {
128
+ function PageViewEvent(isBack, timestamp, responseType, hyperlocalEligible, pageMetaInfo, vertical, category) {
129
+ this.type = "Travel.PageViewEvent";
130
+ this.en = "PV";
131
+ this.t = timestamp;
132
+ this.ib = isBack;
133
+ this.rt = responseType;
134
+ this.he = hyperlocalEligible;
135
+ this.mt = pageMetaInfo;
136
+ this.ver = vertical;
137
+ this.cat = category;
138
+ }
139
+ PageViewEvent.prototype.getValidator = function () {
140
+ var invalidValues = Validator_1.validate(metadataMap, this, "PageViewEvent");
141
+ return new EventValidator_1.EventValidator(invalidValues);
142
+ };
143
+ __decorate([
144
+ decorators_1.Positive(metadataMap, "PageViewEvent")
145
+ ], PageViewEvent.prototype, "t", void 0);
146
+ return PageViewEvent;
147
+ }());
148
+ exports.PageViewEvent = PageViewEvent;
@@ -1,4 +1,5 @@
1
1
  import { Bill, Cab, FoodDelivery, Recharge, Ticket, Travel, Healthcare, Nft } from "../";
2
+ import { PageMetaInfo } from "../Travel";
2
3
  import { FoodDish } from "../FoodDish";
3
4
  import { Person } from "../Person";
4
5
  export interface AnalyticsHelper {
@@ -46,6 +47,7 @@ export interface TravelAnalyticsHelper {
46
47
  proceedToPayEvent: (amountToPay: number, offerAmount: number, bookingCharge: number, vasCharge: number) => Travel.ProceedToPay;
47
48
  customerDetails: (email: string, phoneNumber: string, travellers: Person[]) => Travel.CustomerDetails;
48
49
  orderConfirmation: (amountToPay: number, paymentMethod: string) => Travel.OrderConfirmation;
50
+ pageView: (isBack: boolean, timestamp: number, responseType?: string, hyperlocalEligible?: boolean, pageMetaInfo?: PageMetaInfo, vertical?: string, category?: string) => Travel.PageViewEvent;
49
51
  }
50
52
  export interface NFTAnalyticsHelper {
51
53
  wallet: (stage: string, session_id: string) => Nft.Wallet;
@@ -11,9 +11,17 @@ export interface ErrorInfo {
11
11
  stackTrace: string;
12
12
  statusCode: number;
13
13
  }
14
+ export interface PartialNavigationContext {
15
+ pageName: string;
16
+ pageType: string;
17
+ prevPageName?: string;
18
+ prevPageType?: string;
19
+ findingMethod?: string;
20
+ }
14
21
  export interface AnalyticsModule {
15
22
  pushEvent: (event: AnalyticsEvent) => void;
16
23
  forceFlushEvents: () => void;
17
24
  logPerformanceMetrics: (eventInfo: EventInfo) => void;
18
25
  logPageError: (errorInfo: ErrorInfo) => void;
26
+ ultraTrackEvent: (event: AnalyticsEvent, partialNavigationContext?: PartialNavigationContext, trackImmediately?: boolean) => void;
19
27
  }
@@ -1,11 +1,12 @@
1
1
  import { NativeModule, NativeModuleManager } from "../managers/NativeModuleHelper";
2
2
  import { NativeModuleCallbackManager } from "../managers/NativeModuleCallbackManager";
3
3
  import { AnalyticsEvent } from "../analytics/interfaces/AnalyticsEvent";
4
- import { AnalyticsModule, EventInfo, ErrorInfo } from "../analytics/interfaces/AnalyticsModule";
4
+ import { AnalyticsModule, EventInfo, ErrorInfo, PartialNavigationContext } from "../analytics/interfaces/AnalyticsModule";
5
5
  export declare class AnalyticsModuleImpl extends NativeModule<NativeModuleManager> implements AnalyticsModule {
6
6
  constructor(nativeModuleCallbackManager: NativeModuleCallbackManager);
7
7
  pushEvent(event: AnalyticsEvent): void;
8
8
  forceFlushEvents(): void;
9
9
  logPerformanceMetrics(eventInfo: EventInfo): void;
10
10
  logPageError(errorInfo: ErrorInfo): void;
11
+ ultraTrackEvent(event: AnalyticsEvent, partialNavigationContext?: PartialNavigationContext, trackImmediately?: boolean): void;
11
12
  }
@@ -69,6 +69,29 @@ var AnalyticsModuleImpl = /** @class */ (function (_super) {
69
69
  });
70
70
  });
71
71
  };
72
+ AnalyticsModuleImpl.prototype.ultraTrackEvent = function (event, partialNavigationContext, trackImmediately) {
73
+ var _this = this;
74
+ this.nativeModuleCallbackManager.executeOnBridge(function (requestId) {
75
+ var type = event.type;
76
+ var eventValidator = event.getValidator();
77
+ if (eventValidator.isValid()) {
78
+ _this.postMessage({
79
+ methodName: "ultraTrackEvent",
80
+ event: JSON.stringify(event),
81
+ partialNavigationContext: partialNavigationContext ? JSON.stringify(partialNavigationContext) : null,
82
+ trackImmediately: trackImmediately || false,
83
+ });
84
+ }
85
+ else {
86
+ _this.postMessage({
87
+ methodName: "onEventValidationError",
88
+ requestId: requestId,
89
+ type: type,
90
+ error: eventValidator.getErrorMessage(),
91
+ });
92
+ }
93
+ });
94
+ };
72
95
  return AnalyticsModuleImpl;
73
96
  }(NativeModuleHelper_1.NativeModule));
74
97
  exports.AnalyticsModuleImpl = AnalyticsModuleImpl;
@@ -146,6 +146,9 @@ var SetupHelper = /** @class */ (function () {
146
146
  orderConfirmation: function (amountToPay, paymentMethod) {
147
147
  return new analytics_1.Travel.OrderConfirmation(amountToPay, paymentMethod);
148
148
  },
149
+ pageView: function (isBack, timestamp, responseType, hyperlocalEligible, pageMetaInfo, vertical, category) {
150
+ return new analytics_1.Travel.PageViewEvent(isBack, timestamp, responseType, hyperlocalEligible, pageMetaInfo, vertical, category);
151
+ },
149
152
  };
150
153
  };
151
154
  SetupHelper.getBillObject = function () {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "fk-platform-sdk",
3
- "version": "1.0.47",
3
+ "version": "1.1.0-beta.2",
4
4
  "description": "SDK to enable external experience integration within flipkart app.",
5
5
  "main": "dist/index.js",
6
6
  "typings": "dist/index.d.ts",
@@ -1 +0,0 @@
1
- export {};
@@ -1,49 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- var NativeModuleCallbackManager_1 = require("../managers/NativeModuleCallbackManager");
4
- var NavigationModuleImpl_1 = require("../modules/NavigationModuleImpl");
5
- var LAST_WINDOW_LOCATION = "";
6
- var pushStateOriginal = history.pushState;
7
- var replaceStateOriginal = history.replaceState;
8
- var nativeCallbackManager = new NativeModuleCallbackManager_1.NativeModuleCallbackManager();
9
- var nativeModule = new NavigationModuleImpl_1.NavigationModuleImpl(nativeCallbackManager);
10
- function trySettingUpLocationChangeEvents() {
11
- history.pushState = function (data, title, url) {
12
- var args = [];
13
- for (var _i = 3; _i < arguments.length; _i++) {
14
- args[_i - 3] = arguments[_i];
15
- }
16
- notfiyLocationChange(url, false);
17
- pushStateOriginal.call.apply(pushStateOriginal, [history, data, title, url].concat(args));
18
- };
19
- history.replaceState = function (data, title, url) {
20
- var args = [];
21
- for (var _i = 3; _i < arguments.length; _i++) {
22
- args[_i - 3] = arguments[_i];
23
- }
24
- notfiyLocationChange(url, false);
25
- replaceStateOriginal.call.apply(replaceStateOriginal, [history, data, title, url].concat(args));
26
- };
27
- window.addEventListener("popstate", function (event) {
28
- if (event.state) {
29
- notfiyLocationChange(window.location.href, true);
30
- }
31
- });
32
- }
33
- function startsWith(searchString, stringVal) {
34
- return stringVal.substring(0, searchString.length) === searchString;
35
- }
36
- function notfiyLocationChange(url, isBackNavigation) {
37
- if (url) {
38
- if (url !== LAST_WINDOW_LOCATION) {
39
- LAST_WINDOW_LOCATION = url;
40
- if (typeof url === "string") {
41
- if (!startsWith("http", url)) {
42
- url = location.protocol + "//" + window.location.hostname + url;
43
- }
44
- nativeModule.notifyPageLocationChange(url, !!isBackNavigation);
45
- }
46
- }
47
- }
48
- }
49
- trySettingUpLocationChangeEvents();