Data passed via Segment API does not show up on Google Analytics - google-analytics

I am using Segment.com .NET APIs to pass data to Google Analytics. But even after 3 to 4 days The data has not appeared on Google. Nor I can see data in the Debugger section of Segment's Account Dashboard.
I wonder what is happening? Is there any special configuration to be done at Google side for the data to appear ? or is there anything else I am missing.
Following is the code used.
Analytics.Initialize("pOAM4 Some-KEY PrAC",new Config().SetAsync(false));
Analytics.Client.Identify("BillGates", new Segment.Model.Traits() {
{ "name", uname },
{ "email", uemail },
{ "friends", counter }
});
Analytics.Client.Track("BillGates", "Purchased Item", new Segment.Model.Properties() {
{ "Item", itemcounter},
{ "revenue", 39.95 },
{ "shipping", "2-day" }
});
Analytics.Client.Track("BillGates", "Logged Out", new Segment.Model.Properties() {} );
I am executing them several times.... and I expect something to appear on Google Analytics Dashboard, but its bank.
Any help from anyone who have used Segment.com APIs ?

If your data isn't getting to the Segment debugger, that means that something is probably wrong in your implementation, either API keys or improperly formatted code and I'd recommend using the logging that's built into this lib, you can use it like so.
using Segment;
Segment.Logger.Handlers += Logging_Handler;
void Logging_Handler(Level level, string message, Dict args)
{
if (args != null)
{
foreach (string key in args.Keys) {
message += String.Format(" {0}: {1},", "" + key, "" + args[key]);
}
}
Console.WriteLine(String.Format("[Analytics] [{0}] {1}", level, message));
}
The one thing that jumps out to me is that you're calling new Segment.Model.Properties() in your .Track() and new Segment.Model.Traits() in your .Identify().
I've always used new Properties() in .Track() and new Traits() in .Identify() like so
Analytics.Client.Identify("<<userId>>", new Traits() {
{ "name", "#{ user.name }" },
{ "email", "#{ user.email }" },
{ "friends", 29 }
});
Analytics.Client.Track("<<userId>>", "Purchased Item", new Properties() {
{ "revenue", 39.95 },
{ "shipping", "2-day" }
});
The code for this lib is all open-source and available on github here and the Segment docs are pretty thorough as well.
Good luck!

Related

Firebase Dynamic Link pass custom parameters to iOS and android

I have a custom function in python to build the dynamic link:
def generate_dynamic_link(link, title=None, image=None, description=None, short=True, timeout=10):
api_url = FIREBASE_DYNAMIC_LINK_API_URL
domain = DYNAMIC_LINK_DOMAIN
apn = APP_APN
isi = APP_ISI
ibi = APP_IBI
payload = {
"dynamicLinkInfo": {
"domainUriPrefix": domain,
"link": link,
"androidInfo": {
"androidPackageName": apn,
},
"iosInfo": {
"iosBundleId": ibi,
"iosAppStoreId": isi
},
"socialMetaTagInfo": {
"socialTitle": title,
"socialDescription": description,
"socialImageLink": image
}
},
"suffix": {
"option": "SHORT" if short else "UNGUESSABLE"
}
response = requests.post(api_url, json=payload, timeout=timeout)
data = response.json()
if not response.ok:
raise Exception(data)
return data['shortLink']
I want to pass two parameters to the android and ios app. How can I Do that?
Example:
?type=user&username=testuser
I wrote my first Medium article about this (it’s not a great tutorial) but it shows how to do this. You are correct with how you pass data using ?yourDataHere at the end of your link.
https://augustkimo.medium.com/simple-flutter-sharing-and-deeplinking-open-apps-from-a-url-be56613bdbe6
Then you can handle the deep links by calling the function below. Pretty much you can get the link used to open the app, then get the data from that URL/link string
//ADD THIS FUNCTION TO HANDLE DEEP LINKS
Future<Null> initUniLinks()async{
try{
Uri initialLink = await getInitialUri();
print(initialLink);
var dataFromLink = initialLink.toString().split(‘?’)[1];
print(dataFromLink);
} on PlatformException {
print('platfrom exception unilink');
}
}

Convert Discord.js v11 module to v12?

I mostly have this discord bot working. I am just having some trouble with this one module. The root of the problem is that this code was written for discord.js v11. I need to rewrite it for v12.
The original v11 module can be found here:
https://github.com/Meschdog18/disnet/blob/master/commands/broadcast.js
Here is what I have thus far:
exports.run = (client, message, args) => {
var serverlist = client.guilds.cache.size;
console.log(client.Networks)
var server = message.guild.channels.cache;
var Sender = client.Networks.get(message.guild.name);
const input = args.join(" "); //rejoins arg array into string
for (var i = 0; i < serverlist.length; i++) {
//get network id of message sender
var Recipient = client.Networks.get(serverlist[i].name);
Recipient = parseInt(Recipient);
if (Sender == Recipient) {
try {
var serv = serverlist[i].channels.cache.find(
serv => serv.name === "broadcast"
);
serv.send({
embed: {
/* author: { works but is disabled, because not sure if i like the look
name: "Disnet",
icon_url: client.user.defaultAvatarURL
},*/
color: 0x3850eb,
title: "**__BROADCAST__**",
thumbnail: {
url: message.guild.iconURL
},
fields: [{
name: "Broadcasted From ",
value: message.guild.name
}, {
name: "Message",
value: input
}
],
timestamp: new Date(),
footer: {
icon_url: message.author.avatarURL,
text: "Executed By " + message.author.username
}
}
})
} catch (error) {
console.log(error);
message.reply(
"You must create a #broadcast channel to recieve messages!"
);
break;
}
}
}
};
exports.help = {
name: "broadcast",
description: "Broadcasts message to all servers on your network",
usage: "N$broadcast <Message>"
};
exports.config = {
permLevel: "admin"
}
This module is meant to have the bot transmit a message to every server in my network of discord servers. (it does use enmap and MySQL, but this module doesn't appear to use the SQL component(s))
It is not transmitting messages to the other servers in my network, but I am not getting any errors thrown in my terminal. The bot just gives me this:
Enmap(2) [Map] {
'Discord Sports & Athletics Associations' => 'DSAAnet',
'NFL Discussion 2.0' => 'DSAAnet'
}
Which appears to be correct. (DSAAnet is the name of the network, and the other two names are names of servers in the network.)
Is this correct? What else do I need to change to make this v12 compatible?
you can see every change on this website: Updating from v11 to v12
I think you were reading this part.
Collection#filterArray
collection.filterArray() was removed entirely, as it was just a helper method for collection.filter().array() and most of the time converting a collection to an array is an unnecessary step.
No, .array() was never ever removed.
And for your question, it says .avatarURL, .iconURL, .defaultAvatarURL is now .avatarURL(), .iconURL(), .defaultAvatarURL()
That should fix the issue :)

Can't get subcollection in Firestore - Kotlin

I'm doing a little test app and I'm trying to get all products from a market.
The current database schema is:
markets:[
market1: {},
market2: {},
market3: {
name: "",
products: [
item1: {},
item2: {}
]
}
]
my code in kotlin is:
try {
db.collection("markets").document(marketId).collection("products")
.get()
.addOnCompleteListener { task ->
if (task.isSuccessful) {
var products = mutableListOf<Product>()
for (document in task.result) {
products.add(
Product(
document.id,
document.get("name").toString(),
true
)
)
}
//updateList(products)
} else {
Log.e("Getting markets", "Error getting documents.", task.exception)
}
}
}catch (e : Exception){ }
I also tried replacing the db.collection().document().collection() with:
db.collection("markets/$marketId/products")
however it stills returns 0 items, ( there are two).
Any help would be appreciated
After I tested a lot of variations I noticed that no matter what collection I entered it didn't give me any results, even with collections that worked on other activities.
so I went to application manager on the phone an clear cache and delete data, then I opened again and now is working.

How can I delete a post from a supergroup in telegram with telegram-cli?

we have a group in telegram and we have a rule says no one must leave a message in group between 23 to 7 am , I wanna delete messages comes to group between these times automatically . could anyone tell me how I can do that with telegram cli or any other telegram client?
Use new version of telegram-cli. It's not fully open source, but you can download a binary from its site. Also you can find some examples there.
I hope the following snippet in JavaScript will help you to achieve your goal.
var spawn = require('child_process').spawn;
var readline = require('readline');
// delay between restarts of the client in case of failure
const RESTARTING_DELAY = 1000;
// the main object for a process of telegram-cli
var tg;
function launchTelegram() {
tg = spawn('./telegram-cli', ['--json', '-DCR'],
{ stdio: ['ipc', 'pipe', process.stderr] });
readline.createInterface({ input: tg.stdout }).on('line', function(data) {
try {
var obj = JSON.parse(data);
} catch (err) {
if (err.name == 'SyntaxError') {
// sometimes client sends not only json, plain text process is not
// necessary, just output for easy debugging
console.log(data.toString());
} else {
throw err;
}
}
if (obj) {
processUpdate(obj);
}
});
tg.on('close', function(code) {
// sometimes telegram-cli fails due to bugs, then try to restart it
// skipping problematic messages
setTimeout(function(tg) {
tg.kill(); // the program terminates by sending double SIGINT
tg.kill();
tg.on('close', launchTelegram); // start again for updates
// as soon as it is finished
}, RESTARTING_DELAY, spawn('./telegram-cli', { stdio: 'inherit' }));
});
}
function processUpdate(upd) {
var currentHour = Date.now().getHours();
if (23 <= currentHour && currentHour < 7 &&
upd.ID='UpdateNewMessage' && upd.message_.can_be_deleted_) {
// if the message meets certain criteria, send a command to telegram-cli to
// delete it
tg.send({
'ID': 'DeleteMessages',
'chat_id_': upd.message_.chat_id_,
'message_ids_': [ upd.message_.id_ ]
});
}
}
launchTelegram(); // just launch these gizmos
We activate JSON mode passing --json key. telegram-cli appends underscore to all fields in objects. See all available methods in full schema.

Adding upvotes to reactjs and Firebase chatroom

https://github.com/kristinyim/ClassroomChat
I want to add an upvoting feature to the messages on this chatroom similar to what you have on GroupMe, but I'm new to React and built this off of a tutorial so don't know where to even begin. I'm good with webdev but am just getting started with the basics of React.js and Firebase. Thanks!
NB: There are many ways to achieve this, so the following is just a suggestion.
First you must think of how you want to store your data in the database. If you have users, messages and message-likes, you could structure it like this:
"root": {
"users": {
"$userId": {
...
"messages": {
"$messageId1": true,
"$messageId2": true,
...
}
}
},
"messages": {
"$messageId": {
"author": $userId,
"timestamp": ServerValue.TIMESTAMP
}
},
"likesToMessages": {
"$messageId": {
"$likeId": {
liker: $userId,
"message": $messageId,
"timestamp": ServerValue.TIMESTAMP
}
}
}
}
Whenever a user clicks "like" on a message, you want to write to
var messageId = ?; // The id of the message that was liked
var like = {
liker: currentUserId, // id of logged in user
message: messageId,
timestamp: firebase.database.ServerValue.TIMESTAMP
};
firebase.database.ref().child('likesToMessages').child(messageId).push(like);
Then you get a new like in the database, matching the proposed structure.
Then, when you want to read and show the count of likes for a message, you can do like this:
const Message = React.createClass({
propTypes: {
message: React.PropTypes.object,
messageId: React.PropTypes.string // you need to add this prop
}
componentWillMount() {
firebase.database.ref().child('likesToMessages').child(this.props.messageId).on('value', this.onLikesUpdated)
}
onLikesUpdated(dataSnapshot) {
var likes = snap.val();
this.setState({
likes
});
}
render() {
const {name, message} = this.props.message;
const emojifiedString = emoji.emojify(message);
return (
<p>
{name}: {emojifiedString} [{this.state.likes.length}♥]
</p>
);
}
});
Also, in your database security rules, you'd want to index by timestamp for message and like so you can quickly query the newest messages.
Also, feel free to check out a similar app I made, code in GitHub and demo on wooperate.firebaseapp.com.

Resources