@kameleoon/javascript-sdk-core
Version:
Kameleoon JS SDK Core
50 lines (49 loc) • 1.85 kB
TypeScript
import { VisitType } from '../requester';
import { IKameleoonData, GeolocationInfoType, GeolocationDataType } from './types';
import { TrackingStatus } from '../types';
/**
* @class
* Geolocation - a class for creating an instance for geolocation data
* */
export declare class GeolocationData implements IKameleoonData {
status: TrackingStatus;
private country;
private region?;
private city?;
private postalCode?;
private coordinates?;
/**
* @param {GeolocationInfoType} geolocationInfo - an object containing information about geolocation of a visitor
* @example
* ```ts
* // Visitor is located at Triumph Arch in Paris, France
* const location: GeolocationDataType = {
* country: 'France',
* region: 'Île-de-France',
* city: 'Paris',
* postalCode: '75008',
* coordinates: [48.8738, 2.295]
* };
*
* const geolocation = new GeolocationData(location);
* ```
*
* */
constructor({ country, region, city, postalCode, coordinates, }: GeolocationInfoType);
get url(): string;
get data(): GeolocationDataType;
/**
* @private
* @method _fromRaw - an internal method for creating a GeolocationData instance from raw data
* @param {GeolocationDataType} data - a raw data
* @return {GeolocationData} a GeolocationData instance
* */
static _fromRaw(data: GeolocationDataType): GeolocationData;
/**
* @private
* @method _fromVisit - an internal method for creating an instance of GeolocationData class from a visit
* @param {VisitType} visit - a visit
* @returns {GeolocationData | undefined} an instance of GeolocationData class or undefined if geolocation can not be found among visits
* */
static _fromVisit(visit: VisitType): GeolocationData | undefined;
}