Skip to content

Commit

Permalink
Merge pull request #176 from rudderlabs/appCuesDevelop
Browse files Browse the repository at this point in the history
Appcues Web SDK
  • Loading branch information
prabrishac authored Jan 4, 2021
2 parents 2059243 + 4f4930c commit 5355040
Show file tree
Hide file tree
Showing 7 changed files with 15,834 additions and 8,100 deletions.
82 changes: 82 additions & 0 deletions integrations/Appcues/browser.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
import logger from "../../utils/logUtil";
import ScriptLoader from "../ScriptLoader";

class Appcues {
constructor(config) {
this.accountId = config.accountId;
this.apiKey = config.apiKey;
this.name = "APPCUES";
//this.sendToAllDestinations = config.sendToAll;
}

init() {
logger.debug("===in init Appcues===");
ScriptLoader(
"appcues-id",
`https://fast.appcues.com/${this.accountId}.js`
);
}

isLoaded() {
logger.debug("in appcues isLoaded");
return !!window.Appcues;
}

isReady() {
logger.debug("in appcues isReady");
// This block of code enables us to send Appcues Flow events to all the other destinations connected to the same source (we might use it in future)
// if (this.sendToAllDestinations && window.Appcues) {
// window.Appcues.on("all", function(eventName, event) {
// window.rudderanalytics.track(eventName, event, {
// integrations: {
// All: true,
// APPCUES: false
// }
// });
// });
// }
return !!window.Appcues;
}

identify(rudderElement) {
const {
traits
} = rudderElement.message.context;
const {
userId
} = rudderElement.message;
if (userId) {
window.Appcues.identify(userId, traits);
} else {
logger.error("user id is empty");
}
}

track(rudderElement) {
const eventName = rudderElement.message.event;
let {
properties
} = rudderElement.message;
if (eventName) {
window.Appcues.track(eventName, properties);
} else {
logger.error("event name is empty");
}
}

page(rudderElement) {
const {
properties,
name
} = rudderElement.message;
window.Appcues.page(name, properties);
}

// To be uncommented after adding Reset feature to our SDK
// reset() {
// window.Appcues.reset();
// }

}

export default Appcues;
3 changes: 3 additions & 0 deletions integrations/Appcues/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import Appcues from "./browser";

export default Appcues;
1 change: 1 addition & 0 deletions integrations/client_server_name.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ const clientToServerNames = {
AM: "Amplitude",
PENDO: "Pendo",
LYTICS: "Lytics",
APPCUES: "Appcues",
};

export { clientToServerNames };
2 changes: 2 additions & 0 deletions integrations/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import * as MoEngage from "./MoEngage";
import * as Amplitude from "./Amplitude";
import * as Pendo from "./Pendo";
import * as Lytics from "./Lytics";
import * as Appcues from "./Appcues";

// the key names should match the destination.name value to keep partity everywhere
// (config-plan name, native destination.name , exported integration name(this one below))
Expand Down Expand Up @@ -51,6 +52,7 @@ const integrations = {
AM: Amplitude.default,
PENDO: Pendo.default,
LYTICS: Lytics.default,
APPCUES: Appcues.default
};

export { integrations };
2 changes: 2 additions & 0 deletions integrations/integration_cname.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,8 @@ const commonNames = {
PENDO: "PENDO",
Lytics: "Lytics",
LYTICS: "Lytics",
Appcues: "APPCUES",
APPCUES: "APPCUES",
};

export { commonNames };
Loading

0 comments on commit 5355040

Please sign in to comment.