-
Notifications
You must be signed in to change notification settings - Fork 85
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
separating modules from RudderClient
- Loading branch information
1 parent
6a4eba5
commit 2fd5e00
Showing
5 changed files
with
222 additions
and
204 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
//Application class | ||
class RudderApp { | ||
constructor() { | ||
this.rl_build = "1.0.0"; | ||
this.rl_name = "RudderLabs JavaScript SDK"; | ||
this.rl_namespace = "com.rudderlabs.javascript"; | ||
this.rl_version = "1.0.0"; | ||
} | ||
} | ||
module.exports = { | ||
RudderApp: RudderApp | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
//Context class | ||
var RudderApp = require("./utils.RudderApp.js"); | ||
var RudderLibraryInfo = require("./utils.RudderInfo.js").RudderLibraryInfo; | ||
var RudderOSInfo = require("./utils.RudderInfo.js").RudderOSInfo; | ||
var RudderScreenInfo = require("./utils.RudderInfo.js").RudderScreenInfo; | ||
class RudderContext { | ||
constructor() { | ||
this.rl_app = new RudderApp(); | ||
this.rl_traits = null; | ||
this.rl_library = new RudderLibraryInfo(); | ||
//this.rl_os = null; | ||
var os = new RudderOSInfo(); | ||
os.rl_version = ""; //skipping version for simplicity now | ||
var screen = new RudderScreenInfo(); | ||
|
||
//Depending on environment within which the code is executing, screen | ||
//dimensions can be set | ||
//User agent and locale can be retrieved only for browser | ||
//For server-side integration, same needs to be set by calling program | ||
if (typeof window === "undefined") { | ||
//server-side integration | ||
screen.rl_width = 0; | ||
screen.rl_height = 0; | ||
screen.rl_density = 0; | ||
os.rl_version = ""; | ||
os.rl_name = ""; | ||
this.rl_user_agent = null; | ||
this.rl_locale = null; | ||
} else { | ||
//running within browser | ||
screen.rl_width = window.width; | ||
screen.rl_height = window.height; | ||
screen.rl_density = window.devicePixelRatio; | ||
this.rl_user_agent = navigator.userAgent; | ||
//property name differs based on browser version | ||
this.rl_locale = navigator.language || navigator.browserLanguage; | ||
} | ||
|
||
this.screen = screen; | ||
this.rl_device = null; | ||
this.rl_network = null; | ||
} | ||
} | ||
module.exports = { | ||
RudderContext: RudderContext | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
//Library information class | ||
class RudderLibraryInfo { | ||
constructor() { | ||
this.rl_name = "RudderLabs JavaScript SDK"; | ||
this.rl_version = "1.0.0"; | ||
} | ||
} | ||
//Operating System information class | ||
class RudderOSInfo { | ||
constructor() { | ||
this.rl_name = ""; | ||
this.rl_version = ""; | ||
} | ||
} | ||
//Screen information class | ||
class RudderScreenInfo { | ||
constructor() { | ||
this.rl_density = 0; | ||
this.rl_width = 0; | ||
this.rl_height = 0; | ||
} | ||
} | ||
//Device information class | ||
class RudderDeviceInfo { | ||
constructor() { | ||
this.rl_id = ""; | ||
this.rl_manufacturer = ""; | ||
this.rl_model = ""; | ||
this.rl_name = ""; | ||
} | ||
} | ||
//Carrier information | ||
class RudderNetwork { | ||
constructor() { | ||
this.rl_carrier = ""; | ||
} | ||
} | ||
module.exports = { | ||
RudderLibraryInfo: RudderLibraryInfo, | ||
RudderOSInfo: RudderOSInfo, | ||
RudderScreenInfo: RudderScreenInfo, | ||
RudderDeviceInfo: RudderDeviceInfo, | ||
RudderNetwork: RudderNetwork | ||
}; |
Oops, something went wrong.